XBMC and the Jaycar/Digitech XC4889 Media Center Remote E-mail
Saturday, 04 July 2009 06:37

The Microsoft Media Center remote is reported to work great with XBMC, however Microsoft no longer sells them here in Australia, so I had to find something else. One option would have been to order a Windows Media Center remote, but that would have been like giving money to the Spanish Inquisition... and besides it'd take a few days to arrive, so a quick Google lead me to my nearest Jaycar store and the Jaycar Media Center Remote Control XC4889, for about $30.

Since writing this article, I have discovered that this remote is known under several different brands, including Digitech, all of which share the model number XC4889.

The remote

Keycode map for the remote's buttonsThe blister pack contained a fancy looking remote (that chews through batteries thanks to the glowing keypad) and an IR dongle. Plugging it in revealed that the dongle masquerades as a keyboard so pressing the Stop button shows up as an Alt+S on the computer.

That sounded easy to use and it would have been, had XBMC actually been able to detect more than one key press at time. Instead XBMC simply discards any keys that are pressed after the first one, and since many of the buttons on the remote send a control code (ctrl, shift or alt) before a useful character, XBMC won't respond to most of the buttons. Yay.

I used xev and xkeycaps (in the repo) to get the data for the diagram on the right. Several buttons produced no output, (right Shutdown, MSN and MOUSE). The Cursor, OK, Mute and Volume buttons all worked out of the box. The More button sends a right mouse click, which brings up a useful menu while playing a movie in XBMC. You can press the Back button to hide the menu. Luckily, there's a bit of a kludge that can be used to get around this multi-key press problem. xmodmap can be used to disable the control keys so that XBMC will only receive the regular character key presses. Execute the following script before starting XBMC and you can now discard all the control characters off of the diagram. Play will produce a "p" character instead of Ctrl+Shift+P, for example.

#!/bin/bash
xmodmap -display :0 -e "clear control"
xmodmap -display :0 -e "clear shift"
xmodmap -display :0 -e "clear mod1"

And to re-enable the control keys:

#!/bin/bash
xmodmap -e "add control = Control_L Control_R"
xmodmap -e "add shift = Shift_L Shift_R"
xmodmap -e "add mod1 = Alt_L Meta_L"

Like any quick hack, there are side effects. Certain buttons will now be doubled up. For example the Rewind button is Ctrl+Shift+B and the Replay is Ctrl+B. By disabling the control codes, both buttons now produce a "b" keypress. This also afflicts the Forward/Skip buttons, left Shutdown/MyTV and OK/Home/Enter, but it's a small price to pay since the majority of the buttons work with no problems. Play/Pause is s special case because both buttons toggle playback and pause, so despite producing the same keypress, they will appear to be working.

Keymap.xml

Finally, I've attached my very simple, custom Keymap.xml, which is used to tell XBMC what to do when it receives a keypress. This file resides in "~\.xbmc\userdata\Keymap.xml". I've added one special key to the file which the remote doesn't produce, "n", which will close down XBMC without shutting down the computer, which is useful for tweaking the configuration of XBMC when it's running in fullscreen mode.

<keymap>
<global>
<keyboard>
<p>Play</p>
<n>Quit</n>
<q>Queue</q>
<f>FastForward</f>
<b>Rewind</b>
<left>Left</left>
<right>Right</right>
<up>Up</up>
<down>Down</down>
<pageup>PageUp</pageup>
<pagedown>PageDown</pagedown>
<return>Select</return>
<backspace>ParentDir</backspace>
<s>Stop</s>
<t>XBMC.ShutDown()</t>
<m>XBMC.ActivateWindow(Videofiles,TV Shows)</m>
<e>XBMC.ActivateWindow(Videofiles,Movies)</e>
<i>XBMC.ActivateWindow(Videofiles)</i>
<r>XBMC.EjectTray()</r>
<minus>VolumeDown</minus>
<plus>VolumeUp</plus>
<z>AspectRatio</z>
<zero></zero>
<one></one>
<two></two>
<three></three>
<four></four>
<five></five>
<six></six>
<seven></seven>
<eight></eight>
<nine></nine>
</keyboard>
</global>
</keymap>

Notes

  • Although I have an entry for "r" to eject the tray, it doesn't work. Once you put a DVD in the drive and close it, Gnome locks the drive and the machine has to be restarted or the mouse used to eject the drive from the Ubuntu desktop.
  • XMBC produces a log file, "~/.xbmc/temp/xbmc.log", which is handy for debugging the Keymap.xml as it will contain messages if there are any mistakes in the file and might help explain why some buttons on the remote stop working after you make changes to the keymap file.
blog comments powered by Disqus