Razer Naga open source Linux driver

I've written a basic kernel driver for the Razer Naga gaming mouse (can be extended for other Razer HIDs).

Basically it allows for mapping of the 12 keys to any other (single) keys from userspace.

The module is a bit dirty (and probably buggy), please feel free to improve it!

You can pull it off the GitHub repo: http://github.com/depletionmode/razer-drivers.

Once you've compiled the module you can insert it into a running kernel with 'sudo insmod hid-razer.ko'.

Before the kernel will load the module code when you plug in the device, you'll need to compile a custom version of the hid module.
You basically need to add an exception for the Naga device to hid-core.c to cause the module to load the driver instead of defaulting to the regular HID code.

I simply added (on line 1290 of Ubuntu's 3.0.0 kernel sources):

  
static const struct hid_device_id hid_have_special_driver[] = {  
    { HID_USB_DEVICE(0x1532, 0x0015) },
    .
    .
    .
}

To change the key mappings from userspace, you can change the values of key1-key12 in the sysfs driver tree:

  
$ tree /sys/bus/hid/drivers/razer/0003\:1532\:0015.0004

You need to use key values as they appear in the kernel input device header <linux/input.h>.