
Cheap Raspberry Pi Media Center Remote
I got this $5 remote control to run my Raspberry Pi running the OpenElec media center (which is based on Kodi) but found that not all the keys worked as expected. I actually wanted to be able to use my Logitech Harmony 650 remote, so here I describe some of the modifications I made to get it to work to my liking.
I had a Raspberry Pi for a while before I decided to try using it as a Media Center device. I installed BerryBoot on it, which allows you to install multiple operating systems which you can then select from a menu at boot time. So I have Wheezy Raspbian installed which allows me to boot into a general purpose Linux environment, but I have it set to default boot into OpenElec which is a version of Linux specially built to efficiently run the Kodi media center software. I use it to play MP3 music files and I also set it up to allow my wife to play her workout videos (both the video and music files are on a USB connected hard drive). I already had a Logitech Harmony 650 remote that I use to control all the other devices in my entertainment center and found this article explaining how to get a cheap remote for $5 from Amazon for controlling the Raspberry Pi.
I then programmed my Harmony remote to emulate the cheap remote. It all worked fine except my wife discovered that the fastforward and rewind functions didn’t work correctly when watching videos. What happens if you press the fastforward button is the video will skip ahead 10 minutes and then start fast forwarding. Same when rewinding, the video skips back 10 minutes and then starts rewinding from there. I found a workaround for this problem, so I thought it might be helpful to anyone else who runs into it.
First of all, I used the MyHarmony software to modify the following keys on the Harmony remote as assigned to the “Chinavasion CVSB-983”. As you can see, besides fixing the fastforward and rewind buttons, I also modified a few other buttons that initially did nothing so that they would do something useful.
Harmony Key | Chinavasion key | Action |
---|---|---|
Exit | Escape | Home Screen |
Menu | Escape | Home Screen |
ChanUp | PageUp | Scroll list up |
ChanDwn | PageDn | Scroll list down |
Previous Channel | Backspace | Back one level |
Skip Forward | NextTrack | Skip ahead 30s |
Skip Backward | PrevTrack | Skip back 30s |
Info | HotKeyA | Info |
Now to get these keys to take the desired action, we also need to put a custom keyboard.xml file on the Raspberry Pi. You need to go into the OpenElec system settings and enable ssh access to the system. Then you remotely ssh into the Pi as root and create a file called keyboard.xml in the directory /storage/.kodi/userdata/keymaps with the following contents:
<?xml version="1.0" encoding="UTF-8"?> <!-- see http://www.htpcbeginner.com/configure-chinavision-cvsb983-remote-to-work-with-xbmc-and-logitech-harmony-remote-revisited/ Chinavision key sends: Fastforward : ctrl-leftctrl, ctrl-right, ctrl-leftctrl, ctrl-shift-leftshift, ctrl-shift-f Rewind : ctrl-leftctrl, ctrl-left, ctrl-leftctrl, ctrl-shift-leftshift, ctrl-shift-b A : ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-a, ctrl-alt-one, ctrl-alt-f1 B : ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-b, ctrl-alt-at, ctrl-alt-f2 C : ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-164, ctrl-alt-three, ctrl-alt-f3 D : ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-d, ctrl-alt-dollar, ctrl-alt-f4 MYPC : meta-0, meta-e DESKTOP : meta-0, meta-d FULLSCREEN : alt-leftalt, alt-return, ctrl-alt-leftctrl, ctrl-three CLOSE : alt-leftalt, alt-f4 --> <keymap> <global> <keyboard> <!-- Map Chinavision Esc key to show Home screen (then set Harmony Menu and Exit keys to the Chinavasion ESC key) --> <escape>ActivateWindow(Home)</escape> <!-- Map Chinavision A key to Info function (then set Harmony Info button to Chinavision HotKeyA). This allows us to display the current song info on top of the visualization while music is playing. --> <f1 mod="ctrl,alt">Info</f1> </keyboard> </global> <FullscreenVideo> <keyboard> <!-- Next two entries fix the fastforward and rewind commands if you are using the "Chinavasion" remote. It sends a ctrl-right or ctrl-left keypress before the actual fastforward/rewind command which causes a big skip forward/backward and then starting the fastforward/rewind. So we modify ctrl-right/left to just put up a notification and not do the skip. --> <left mod="ctrl">Notification(Keypress, Rewind, 3)</left> <right mod="ctrl">Notification(Keypress, FastForward, 3)</right> <!-- Use skip/replay buttons on Harmony 650 to skip forward/back like I'm used to when using our Verizon DVR. --> <next_track>StepForward</next_track> <prev_track>StepBack</prev_track> </keyboard> </FullscreenVideo> </keymap>
As explained in the comments included in the XML code above, the problem with the fastforward and rewind buttons is that they send multiple keypresses including one that causes the skip ahead. So I’m working around that by reassigning that keypress to just display a notification message instead of doing the skip. Instead of the notification you could also just put in “noop” (no operation), but I like having the notification because that makes it obvious that the system is using your modified keymap.
You can determine what keypresses each button on the Chinavision remote sends by going into the System menu in Kodi and enabling Debug Logging. Then press the desired buttons and the keypresses will be recorded in the log file which can be found in ~/.kodi/temp/kodi.log. I recommend alternating the keys with a known key like the Escape key to help orient you in the log file which will contain a lot of information. Write down what buttons you pressed, then look for the “OnKey” string in the kodi.log file for the keypresses (remember some buttons send multiple keypresses which is why having the Escape key in between is helpful to know when each sequence begins and ends). Here are what some of the buttons send:
Button | Keypresses |
---|---|
Fastforward | ctrl-leftctrl, ctrl-right, ctrl-leftctrl, ctrl-shift-leftshift, ctrl-shift-f |
Rewind | ctrl-leftctrl, ctrl-left, ctrl-leftctrl, ctrl-shift-leftshift, ctrl-shift-b |
HotKeyA | ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-a, ctrl-alt-one, ctrl-alt-f1 |
HotKeyB | ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-b, ctrl-alt-at, ctrl-alt-f2 |
HotKeyC | ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-164, ctrl-alt-three, ctrl-alt-f3 |
HotKeyD | ctrl-leftctrl, ctrl-alt-leftalt, ctrl-alt-d, ctrl-alt-dollar, ctrl-alt-f4 |
MYPC | meta-0, meta-e |
DESKTOP | meta-0, meta-d |
FULLSCREEN | alt-leftalt, alt-return, ctrl-alt-leftctrl, ctrl-three |
CLOSE | alt-leftalt, alt-f4 |
You really only need to worry about buttons that don’t already do what you want.