Roku 2 Remote with XBMC
#1
I just got my hands on a Roku 2 gaming remote to use with XBMC. It connects with Windows using Bluetooth and its key presses are output as keyboard buttons. It shows up in the Bluetooth Devices as a keyboard labeled "BCM20730".

e - Back
4 - Home
u - Up
l - Left
r - Right
d - Down
6 - Reload
s - Okay
3 - Star
c - Rewind
a - Play/Pause
8 - Fast Forward
x - A
y - B

But the thing is, I don't want to just modify the keyboard.xml to use those keys for the common tasks as it will make using a normal keyboard a huge headache if ever need be. But as far as I can tell in order to separate one device from another in XBMC it needs a device name which I should be able to get from my xbmc.log, but it just shows keyboard when I use the remote.

I could really use some advice on how to differentiate this remote from a normal keyboard when its used within XBMC so it can have its own keymap.
Reply
#2
I don't quite get what you are saying. Because even though you set the keyboard.xml, it is really hard to see how anyone could accidentally press the buttons on the roku remote and send keyboard presses.

Personally, what I am doing is getting this remote: http://www.amazon.com/Roku-Game-Remote-m...B007B4ZDUA

And just editing the keyboard.xml to my liking, since I am using that remote to work with a seperate device that will only be used for XBMC (mk808/908/etc.)
Reply
#3
Not to sound rude, but no, you really didn't get the idea of any of what I said.

Yes, your link is exactly what I got. Yes I edited the keyboard.xml in order to use the remote within XBMC for the time being but that is not what I'd like in the long run.

Basically what I am looking to do is create an entirely new keymap xml specifically for the Roku Remote so when you have a normal keyboard plugged in the default keys that you will be use to won't be completely changed and awkward. Think about when you use a MCE Remote or Game Controller, same idea. Doing this would also have the benefit of not confusing the Roku modded keyboard.xml with any others.

Now for something completely different and for any one else that is using a Roku remote with a PC. I am not sure if this is an issue with my PC, with the series of Bluetooth Adapters (I'm up to three now because of this!), Windows, or the Roku Remote, but I just can not for the life of me get the PC to wake from sleep with this remote. While none of my Bluetooth Adapters list power options to wake the PC I have gone as far as modifying the registry to enable it and still I've come up empty handed. Other USB devices have no issue so I do not believe it is the PC and reviews of at least one of the adapters I bought mention it wakes just fine, I don't know what to do from here. If anyone has a Roku Remote that can wake their PC let me know so I can at least rule that out as a cause. I sadly do not have any other Bluetooth devices to connect, such as a keyboard, to help troubleshoot.
Reply
#4
From my understanding bluetooth connectivity is high-level protocol which need drivers on top off OS to works. So you can forget power on from remote, I doubt even wake from sleep would works since OS needs to be fully on and drivers loaded to be able to connected bluetooth device. In normal sleep state bluetooth connectivilty on host would be suspended. So you can't interact from client side.
Reply
#5
So to bring back an old thread that I still have need help with. Does anyone have any idea on how I can make this keymap specific to this device so it does not effect the default keyboard laýout? This has become more of a concern now that I can use this remote with my Tablet PC and I really don't want to mess with the keyboard too.
Reply
#6
I struggled with this for quite a while too. Everything I tried meant I had to give up something else I wanted/needed, documentation online is either skeletal or ancient, and frankly Linux isn't one of my strong points. I really would have liked to do it with udev and be done with it, but in the end I found a pretty simple fix with an edit to the xorg.conf file, and a new xkb keyboard layout file.

It's a little hackier than I would have liked, but it works! I've got all the keys mapping to what they actually do, and can even map secondary functions to each one, all while maintaining the default layouts for my USB, and logitech BT keyboards.

I'll put something together and post back some instructions this weekend if I don't have time to do it tomorrow.
Reply
#7
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).
  1. Identify device
  2. Create a static udev node
  3. Create a new xkb keyboard layout
  4. Edit xkb evdev.lst/.xml files
  5. Edit xorg.conf
  6. 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!
Reply
#8
Unfortunately I am on a Windows installed of Kodi and will not be switching as I also run games off of this machines. I'm not sure if I could do something like this on Windows but if I could I wouldn't even know where to start.
Reply
#9
Right you are. For some reason I read it like you could ALSO connect via windows. Well the good news is that it's even easier in windows. You can use Auto Hotkey to remap keys and even create macros by user/device. It's free and can be downloaded HERE. You basically create a map file with oldcode::newcode pairs, and tell the script to use it on the BCM20730. It's pretty lightweight, and doesn't require editing the registry (which is where your symbols are stored).
Reply

Logout Mark Read Team Forum Stats Members Help
Roku 2 Remote with XBMC0