Using an MCE remote in XBMC
Note: this article refers to build 26407 and later. Earlier versions of XBMC did not have all the features described in this and related articles. The first offical release of XBMC with this remote support will be v10.05.
If you have one of the many cheap MCE remote controllers then just connect it to your PC and there's a fair chance it will just work. If you have the official Microsoft MCE remote controller or a full compatible then you may need a small amount of extra effort to get it working: details below.
If you're in a hurry to get your remote working jump straight to:
- Using the official MS remote with XBMC on Windows
- Using non-MS remotes with XBMC on Windows
- Using remote controllers with XBMC on Linux
However if you have the spare five minutes it will take to read this article I recommend that you take the time to do it. Once you've read this article the articles above will make more sense.
Media Center remotes are obviously designed to work with Microsoft Windows Media Center Edition (hence the "MCE" acronym) so this article concentrates on Windows. However the same remotes will usually work with Linux and possibly OSX, and much of this discussion applies to all platforms.
On Linux there is a standard method for supporting remote controllers using software called Lirc. Assuming there is a Linux driver for your remote controller you can configure Lirc to use it with XBMC. Details are in the Linux article above. Note that XBMCLive is already configured to work with the official MS remote. Sadly, on Windows the situation is a lot more confused.
1 Why there is a problem (on Windows) ...
The problem with using MCE remotes is that there is no such thing as a standard MCE remote. There is the official Microsoft remote of course, and some remotes are genuinely fully compatible with the MS remote. Unfortunately the majority of MCE remote controllers, especially the cheap ones, work in different ways. There are four different ways a remote can work on Windows.
- The remote can send an IR code like the Microsoft remote. To use
the remote an application has to link to the IR driver.
- The remote can send the Windows message WM_APPCOMMAND. This
message is used to send a multimedia application messages like "Play",
"Pause", "Stop" etc. To use this type of remote an application has to
process the WM_APPCOMMAND messages.
- The remote can simulate multimedia keypresses when you press a
button. Multimedia keys were introduced with the Microsoft multimedia
keyboard, which has extra keys for multimedia functions like "Play"
etc. To use this type of remote an application has to process the
- Finally the remote can simulate the standard MS Media Center
keyboard shortcuts. When Microsoft introduced Media Center the
specified a set of standard keyboard shortcuts to operate it. For
example control-shift-P means "Play". Many cheap MCE remotes simulate
these keyboard shortcuts e.g. when you press the Play button they
simulate the keypress control-shift-P. To use this type of remote an
application has to process the Media Center keypresses.
2 ... and how to solve it
The good news is that from build 26407 onwards XBMC has support built in for remote controllers of types 2, 3 and 4. This includes the vast majority of the cheap MCE remotes, so the basic functions like "Play" etc will work without any messing around. A lot of MCE remotes include extra keys not on the official MS remote, and to get these to do anything you will need some manual configuration. All this is covered in the article on using non-MS remotes.
Ironically the official MS remote will not work with XBMC out of the box. This is because it uses IR codes i.e. type 1 in the list above, and XBMC does not support this. The good news is that the MS remote is easily reconfigured to work as a type 4 remote instead. This is covered in the article on using the MS remote.
3 A note on Linux
to be completed
4 How it works
Actually supporting the type 2 and 3 remotes is quite easy, and version 9.11 (Camelot) of XBMC already includes partial support for these types. The only changes in the post 26407 builds just extend the WM_APPCOMMAMD processing a bit. It's handling the type 4 remotes that is hard. This is because type 4 remotes send combinations of keypresses with modifier keys like Control and Shift. The key handler in XBMC v9.11 and earlier cannot process the key modifiers so it can't process the simulated keypresses sent by the type 4 remotes. The later builds include support for key modifiers and add the Media Center keyboard shortcuts to the key mapping file.
5 If you can't wait for v10.05
The remote controller support described above will be included in XBMC version 10.05. If you can't wait that long you'll need to build the latest version of XBMC yourself. If you don't have the development tools (or skills) to compile XBMC yourself there are several people around who provide development builds. See <a href="http://forum.xbmc.org/showthread.php?t=62109"> http://forum.xbmc.org/showthread.php?t=62109</a> for example. Alternatively there is an unofficial Windows build of v9.11 with key modifier support retro-fitted at <a href="http://xbmcmce.sourceforge.net/">xbmcmce.sourceforge.net</a>.
6 Configuring the keyboard
You're into nerd (OK, "enthusiast") territory now. This section described how to manually edit the key mappings in XBMC. You will only need to do this if your remote sends non-standard keypresses, or if you want to use non-standard buttons on the remote. If you are going to do this make sure you read the article on using non-MS remotes first.
The mapping of keypresses like P to XBMC actions like Play is configured in a file called keyboard.xml. There is a copy of keyboard.xml in C:\Program Files\XBMC\system\keymaps, and the settings in this file apply to all users. In general you shouldn't edit or replace this file because any mistakes you make can be hard to undo. At the very least make a backup copy of the file before you change anything.
If you want to change the key mapping you can create a second keyboard.xml file in your userdata/keymaps folder (see below for where this folder is). XBMC combines the system keyboard.xml with your userdata keyboard.xml so you only need to add any extra keys; you don't need to duplicate all the key definitions already in the system keyboard.xml. You can also override any key definitions in the system keyboard.xml by putting the new definition in your userdata keyboard.xml.
If you use Linux then your userdata folder is $home/.xbmc/userdata so the full path to your keyboard.xml file is $home/.xbmc/userdata/keymaps/keyboard.xml.
If you use Windows the situation is a bit more complicated because it depends on whether you installed XBMC in default mode or portable mode. In portable mode the path to the file is C:\Program Files\XBMC\userdata\keymaps\keyboard.xml. In default mode the file is in your profile, in %APPDATA%\XBMC\userdata\keymaps\keyboard.xml, where APPDATA is an environment variable. In both default and portable mode, if the keymaps folder doesn't exist in your userdata folder just create it.
A side note: if you are using the 64 bit versions of Windows replace C:\Program Files\ by C:\Program Files (x86)\. If you didn't install XBMC into the Program Files folder then replace C:\Program Files\XBMC\ by whatever directory you chose at installation.
7 Modifying keyboard.xml
The keyboard.xml file is just a text file and can be edited in any text editor like Notepad in Windows or gedit in Linux. One day there will be a nice GUI app for editing keyboard.xml, but for now you need to do it by hand.
The first step is to create the keyboard.xml file in userdata\keymaps. If there isn't a keymaps folder in userdata then create one now. To get you started there is a sample keyboard.xml <a href="keyboard.xml">here</a> with key mappings for the standard Media Center keyboard shortcuts. In many cases just copying this file into userdata\keymaps will be enough to get your remote working.
If you make a mistake in the keyboard.xml XBMC will probably just ignore it and none of your extra keymappings will work. If you think this has happened look in the xbmc.log file for an error like:
ERROR: Error loading keymap: special://masterprofile/keymaps/keyboard.xml, Line 16 Error reading end tag. ERROR: Error loading keymap: special://profile/keymaps/keyboard.xml, Line 16 Error reading end tag.