I'm not gonna get too into the W's on all of this unless somebody wants it. It doesn't look like too many people are messing with the Roku remotes, but it seems like others might benefit from unique device layouts using X. For the record I'm running Ubuntu Server 14.04 LTS (No Desktop), so I can't guarantee this method will work on any system, though I did try to make it as agnostic as I could. I'm no expert, so surely this isn't the most elegant or "correct" way of doing this, but it works, and quite well!
Not too much to it though, just 6 steps (looks a lot worse than it is).
- Identify device
- Create a static udev node
- Create a new xkb keyboard layout
- Edit xkb evdev.lst/.xml files
- Edit xorg.conf
- Restart Kodi (X)
1.) Identify device
There's lots of ways you can do this, if you already know what event* your remote is, you can skip to #2.
First thing, lets identify our BT input devices. I find this is the easiest way to get alot of basic info about input devices in a single line. Note: you can also ls other folders in /sys/class and with the -l option and get path info from the symlinks.
Code:
user:~$ ls –l /sys/class/input | grep bluetooth
lrwxrwxrwx 1 root root 0 Mar 20 11:33 event12 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:12/0005:046D:B319.0010/input/input26/event12
lrwxrwxrwx 1 root root 0 Mar 20 11:33 event13 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:13/0005:1D5A:C090.0006/input/input16/event13
You'll notice I have 2 BT devices, one is an actual keyboard, and the other is the remote. We're after the event## here. If you only have one slave input paired to your radio then you need look no further. If you, like me, have several you may have to dig a little deeper. The two middle groups of chars in this folder (from above) 0005:
1D5A:C090.0006 are your VendorID and ProductID, so that may be enough to help you identify. If not, you can use the next step to look a little deeper. Lets look at event13.
You're going to get a lot of info out of this one. You can use the arrow keys on your keyboard to scroll, and "q" to exit. It's really just the top two sections you need. Check name (ATTRS{name}) and mac address (ATTRS{uniq}) to make sure you have the right event, and then take note of your KERNEL and SUBSYSTEM.
Code:
user:~$ udevadm info –attribute-walk /dev/input/event13 | less
looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:13/0005:1D5A:C090.0006/input/input16/event13':
KERNEL=="event13"
SUBSYSTEM=="input"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:13/0005:1D5A:C090.0006/input/input16':
KERNELS=="input16"
SUBSYSTEMS=="input"
DRIVERS==""
ATTRS{name}=="BCM20730"
ATTRS{phys}=="98:58:8a:03:cf:64"
ATTRS{uniq}=="cc:6d:a0:03:5a:c9"
ATTRS{properties}=="0"
2.) Create a static udev node
Since adding/removing devices can cause your final eventID to change from boot to boot, we need to make a rule to give us a static node to point Xorg.conf to.
Create a new rule in /etc/udev/rules.d and add these 3 lines. This will identify the device upon connection, and add a symlink in your /dev directory that ALWAYS points to the correct event, using the KERNEL, SUBSYSTEM, and ATTRS{uniq} (mac address) from above.
Code:
user:~$ sudo nano /etc/udev/rules.d/15-local.rules
# local udev rules
# Roku Remote Dynamic Symlink
KERNEL==”event*”, SUBSYSTEM==”input”, ATTRS{uniq}==”cc:6d:a0:03:5a:c9”, SYMLINK+=”BTevent0”
Note: You may need to restart udev, disconnect/reconnect, or pull the batteries on your remote before the new node will appear under /dev.
3.) Create new xkb keyboard layout
Now we'll create a new keyboard layout in /usr/share/X11/xkb/symbols and add the following lines. I tried to make it look pretty, but couldn't get it to tabluate... sorry.
Code:
user:~$ sudo nano /usr/share/X11/xkb/symbols/us-roku
default partial alphanumeric_keys modifier_keys xkb_symbols "basic" {
name[Group1]="roku";
key <AE03> { [ c, C ] }; // * remap from 3 to c
key <AE04> { [ Escape, Escape ] }; // Home remap from 4 to ESC
key <AE06> { [ XF86AudioMute, XF86AudioMute ] }; // Replay remap from 6 to Mute
key <AE08> { [ XF86AudioNext, XF86AudioNext ] }; // Forward remap from 8 to Next
key <AD03> { [ BackSpace, BackSpace ] }; // Back remap from e to Back
key <AD04> { [ Right, Right ] }; // Right remap from r to Right
key <AD06> { [ Next, Next ] }; // B remap from y to Page Down
key <AD07> { [ Up, Up ] }; // Up remap from u to Up
key <AC01> { [ XF86AudioPlay, XF86AudioPause ] }; // Play/Pause remap from a to Play/Pause
key <AC02> { [ Return, Return ] }; // OK remap from s to Enter
key <AC03> { [ Down, Down ] }; // Down remap from d to Down
key <AC09> { [ Left, Left ] }; // Left remap from l to Left
key <AB02> { [ Prior, Prior ] }; // A remap from x to Page Up
key <AB03> { [ XF86AudioPrev, XF86AudioPrev ] }; // Rewind remap from c to Previous
};
Note: If you want to map other keys to your remote, you can find the possible keycodes in the /usr/share/X11/xkb/symbols/us and /usr/share/X11/xkb/symbols/inet layouts.
4.) Edit xkb evdev .lst/.xml files
Now we'll add the new model and layout info to a couple files in /usr/share/X11/xkb/rules. First, update the evdev.lst file. Add the following line right under "! model"
Code:
user:~$ sudo nano /usr/share/X11/xkb/rules/evdev.lst
roku Roku 2 XS BT Remote
and this one right under "! layout"
Code:
us-roku English (US)
Now the evdev.xml file needs 2 updates as well. Add the following <model> to the evdev.xml file right under the <modelList>.
Code:
user:~$ sudo nano /usr/share/X11/xkb/rules/evdev.xml
<model>
<configItem>
<name>roku</name>
<description>Roku 2 XS BT Remote</description>
<vendor>roku</vendor>
</configItem>
</model>
And add this one right under the <layoutList><layout> a little further down. Hint: If you're using nano, Ctrl+w will help you find it without scrolling.
Code:
<configItem>
<name>us-roku</name>
<shortDescription>RR</shortDescription>
<description>Roku 2 XS BT Remote</description>
<languageList>
<iso639Id>eng</iso639Id>
</languageList>
</configItem>
5.) Edit xorg.conf
Now we'll add the entry to our /etc/X11/xorg.conf file to tell it to use the new layout on our new static device node. Add the following line at the bottom of the "ServerLayout" section, right above "EndSection".
Code:
user:~$ sudo nano /etc/X11/xorg.conf
InputDevice “Kodi BT Remote” “CoreKeyboard”
And add these lines in among the InputDevice sections under it. (I put it under the existing keyboard catchall, but I don't think it matters where). You'll notice the Option "Device" "/dev/BTEvent0" line pointing to our new static node, and the next two assigning our new model & layout.
Code:
Section “InputDevice”
Identifier “Kodi BT Remote”
Option “Device” “/dev/BTevent0”
Option “XkbModel” “roku”
Option “XkbLayout” “us-roku”
Driver “evdev”
EndSection
6.) Restart Kodi (X)
Before you restart you may have to manually clear the cache in /var/lib/xkb. After that you can reboot, stop/start Kodi, however you prefer to restart as long as X restarts you should have a newly functional and unique Roku remote.
Code:
user:~$ sudo rm /var/lib/xkb/*.xkm
Hope it helps... enjoy!