-
Notifications
You must be signed in to change notification settings - Fork 30
Setting up the keyboard driver
Attention If using Ubuntu or Debian I would recommend using the scripts that generate the .deb packages as they do some extra clever things like set up automatically rebuilding the driver when the kernel changes.
Once the kernel driver has been compiled you should have a razerkbd.ko
inside the driver
directory, this must be moved to /lib/modules/$(shell uname -r)/kernel/drivers/usb/misc
. That directory will expand to the current USB misc directory for the active kernel.
So doing something like the following will move the driver into the correct place.
$ cp driver/razerkbd.ko /lib/modules/$(shell uname -r)/kernel/drivers/usb/misc
If you have not rebooted since installing the driver run this to activate the driver.
$ modprobe razerkbd
Running this should verify that the driver is loaded. It should look similar
$ lsmod | grep razerkbd
razerkbd 24159 0
hid 106148 3 hid_generic,razerkbd,usbhid
There should also be a folder located in /sys/bus/hid/drivers
$ ls -l /sys/bus/hid/drivers
total 0
drwxr-xr-x 2 root root 0 Nov 27 15:36 hid-generic/
drwxr-xr-x 2 root root 0 Nov 28 00:49 razerkbd/
If you've got this far the kernel driver is loaded.
You need to unbind one of the keyboard "devices" from the kernels generic-hid driver and bind it to our keyboard driver.
First things first you need to locate the correct device ID to use. If you run this it will list USB HID devices
ls -l /sys/bus/hid/devices/
lrwxrwxrwx 1 root root 0 Nov 28 00:19 0003:1532:0203.004E
lrwxrwxrwx 1 root root 0 Nov 28 00:19 0003:1532:0203.004F
lrwxrwxrwx 1 root root 0 Nov 28 00:19 0003:1532:0203.0050
lrwxrwxrwx 1 root root 0 Nov 28 22:12 0003:E0FF:0005.0004
lrwxrwxrwx 1 root root 0 Nov 28 22:12 0003:E0FF:0005.0005
The Razer BlackWidow Chromas USB ID is 1532:0203
so there are 3 options (aka 3 interfaces) you need the one that represents itself as a mouse device (that one accepts control messages). There are many ways to do this, I use udev
.
You can run lsusb -v -d 1532:0203
, this will list all USB interfaces on the device, for a keyboard there will be 2 keyboard interfaces (00 and 01) and a mouse interface (02), your looking for the mouse one (lines starting with bInterfaceProtocol
and bInterfaceNumber
are the ones of interest).
After looking at lsusb
you've found that we are after interface 02
, you can use the following udev snippet to get a device's interface number.
$ udevadm info -a /sys/bus/hid/devices/0003:1532:0203.0050 | grep bInterfaceNumber
ATTRS{bInterfaceNumber}=="02"
As you can see I passed into the path /sys/bus/hid/devices/0003:1532:0203.0050
which is the 3rd entry in the list to udev
and grepped. Your looking for the 2nd interface number (Should be that for the BlackWidow Ultimates too).
Now that we know the correct ID (0003:1532:0203.0050
) we need to unbind that from the USB HID driver thats using it and bind it to ours.
On Ubuntu the driver is hid-generic
so i'll be using that for the examples. Running ls /sys/bus/hid/drivers
will show you the drivers.
Go into the hid-generic
directory
$ cd /sys/bus/hid/drivers/hid-generic
$ ls -l
lrwxrwxrwx 1 root root 0 Nov 28 22:20 0003:1532:0203.004E
lrwxrwxrwx 1 root root 0 Nov 28 22:20 0003:1532:0203.004F
lrwxrwxrwx 1 root root 0 Nov 28 22:20 0003:1532:0203.0050
lrwxrwxrwx 1 root root 0 Nov 28 22:20 0003:E0FF:0005.0004
lrwxrwxrwx 1 root root 0 Nov 28 22:20 0003:E0FF:0005.0005
--w------- 1 root root 4.0K Nov 28 01:40 bind
lrwxrwxrwx 1 root root 0 Nov 28 22:20 module
--w------- 1 root root 4.0K Nov 28 22:20 new_id
--w------- 1 root root 4.0K Nov 28 22:20 uevent
--w------- 1 root root 4.0K Nov 28 01:40 unbind
As you can see it shows some symlinks to modules binded with this driver. Our device is binded to this so we need to unbind it. To unbind a device type
$ echo -n "0003:1532:0203.0050" > unbind
This unbinds the driver from hid-generic
. The procedure is similar to bind to our driver.
$ cd /sys/bus/hid/drivers/razerkbd
$ echo -n "0003:1532:0203.0050" > bind
Now if you run ls
you should see the driver symlink in the directory
$ ls -l
total 0
lrwxrwxrwx 1 root root 0 Nov 28 22:22 0003:1532:0203.0050
--w------- 1 root root 4.0K Nov 28 01:40 bind
lrwxrwxrwx 1 root root 0 Nov 28 22:22 module -> ../../../../module/razerkbd/
--w------- 1 root root 4.0K Nov 28 22:22 new_id
--w------- 1 root root 4.0K Nov 28 00:49 uevent
--w------- 1 root root 4.0K Nov 28 01:40 unbind
Done.
Firstly go into the driver directory
$ cd /sys/bus/hid/drivers/razerkbd/0003:1532:0203.0050
$ ls -l
total 0
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 device_type
lrwxrwxrwx 1 root root 0 Nov 28 01:40 driver
drwxr-xr-x 3 root root 0 Nov 28 01:40 hidraw/
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 macro_keys
-r--r--r-- 1 root root 4.0K Nov 28 00:45 modalias
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 mode_breath
-rw-rw-r-- 1 root root 4.0K Nov 28 01:40 mode_custom
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 mode_game
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 mode_none
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 mode_reactive
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 mode_spectrum
-rw-rw-r-- 1 root root 4.0K Nov 28 01:41 mode_static
-rw-rw-r-- 1 root root 4.0K Nov 28 01:41 mode_wave
drwxr-xr-x 2 root root 0 Nov 28 00:45 power/
-r--r--r-- 1 root root 4.0K Nov 28 22:17 report_descriptor
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 reset
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 set_brightness
-rw-rw-r-- 1 root root 4.0K Nov 28 01:40 set_key_row
lrwxrwxrwx 1 root root 0 Nov 27 23:47 subsystem
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 temp_clear_row
-rw-rw-r-- 1 root root 4.0K Nov 28 22:17 test
-rw-r--r-- 1 root root 4.0K Nov 27 23:47 uevent
Thats what the directory will look like normally. To use the driver you can now echo strings into the files and it will control the keyboard. The definition of the driver_files and what they accept should be on another page.
Example
$ echo -n "1" > mode_wave
$ cat device_type
Razer BlackWidow Chroma