Using an MCE remote control in Windows: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Jhsrennie
No edit summary
>Jhsrennie
No edit summary
Line 10: Line 10:
If you buy a cheap generic remote from eBay the chances are that it
If you buy a cheap generic remote from eBay the chances are that it
does send keypresses. In fact it probably sends the standard Media
does send keypresses. In fact it probably sends the standard Media
Centre keyboard shortcuts of the Microsoft multimedia keyboard media
Centre keyboard shortcuts or the Microsoft multimedia keyboard media
keypresses.
keypresses, in which case it will work with XBMC out of the box and
you need read no further. You only reason you need to persist with this
article is if your remote send non-MCE keystrokes, or more likely if
the remote has extra keys that you want to map to XBMC actions.


Assuming you've read [[Using a remote control with XBMC]] you will know that the essential steps are to
Assuming you've read [[Using a remote control with XBMC]] you will
know that the essential steps are to
work out what keypresses your remote control is sending and edit
work out what keypresses your remote control is sending and edit
keyboard.xml accordingly. The main part of this article describes these
keyboard.xml accordingly. The main part of this article describes these

Revision as of 16:30, 7 January 2010

See Using a remote control with XBMC for general notes on remote controllers. See Using a Microsoft remote control in Windows for using the official Microsoft remote control.

This article explains how you can make your generic MCE remote work with XBMC. Note that this is only possible if your remote sends keypresses when you press the buttons, or can be configured to send keypresses. Examples of remotes that are configurable include the Microsoft remote and the various types of Logitech harmony remotes.

If you buy a cheap generic remote from eBay the chances are that it does send keypresses. In fact it probably sends the standard Media Centre keyboard shortcuts or the Microsoft multimedia keyboard media keypresses, in which case it will work with XBMC out of the box and you need read no further. You only reason you need to persist with this article is if your remote send non-MCE keystrokes, or more likely if the remote has extra keys that you want to map to XBMC actions.

Assuming you've read Using a remote control with XBMC you will know that the essential steps are to work out what keypresses your remote control is sending and edit keyboard.xml accordingly. The main part of this article describes these steps.

Getting started

Start by grabbing a copy of mceremote.zip from http://xbmcmce.sourceforge.net/. This zip is mainly intended for configuring the official MS remote, but it contains a utility, ShowKey.exe, that is very useful for seeing what keypresses your remote is sending. Extract ShowKey.exe from the zip and save it somewhere convenient.

You will need to create a custom keyboard.xml. Rather than starting from scratch I suggest you grab this example <a href="keyboard.xml">keyboard.xml</a> and save it into your userdata folder. Not only does this file contain useful examples, but you can cut and paste the definitions in it to create new definitions. XBMC is intolerant of typing mistakes in keyboard.xml, so the less typing the better!

Finally you need to work out where you need to put your keyboard.xml file. 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.

Identifying the keypresses

This section uses a Windows app I wrote to identify keypresses. I don't have a Linux or OSX version of the app at the moment, though I might in the future rewrite it in .Net/Mono or possibly Python/QT. For Linux users the best course is to temporarily bow to Redwood and borrow a Windows PC to test on.

If you haven't already done so, connect your remote and try it with XBMC. You may be surprised how many buttons work without any special configuration. Make a note of the buttons that do nothing and decide what you want them to do.

Now run ShowKey.exe and press a button on your remote. Assuming your remote sends a keypress ShowKey will show you what the key is. For example the Play button may send the MCE shortcut ctrl-shift-P, or it may send the multimedia keypress VK_MEDIA_PLAY_PAUSE. If Showkey detects a keystroke it will display the line that needs adding to keyboard.xml. For example, for ctrl-shift-P the line will be:

<p mod="ctrl,shift">Put action here</p>

In this case you'd replace "Put action here" by Play so the line looked like:

<p mod="ctrl,shift">Play</p>

And it's as simple as that. Work through all the keys and add the corresponding lines to keyboard.xml.

Tips and tricks

If ShowKey does not show any keypress when you press a button on the remote this means your remote is not sending a keypress. If you have a cheap non-configurable remote there's not much you can do about this. With a universal remote, like the Logitech Harmony, see the manual for the remote. For the MS remote see the separate article on <a href="ms_remote.html">using the MS remote with XBMC</a>.

The green "Windows" button in the middle of the remote probably sends Windows-Alt-Enter, which is the standard Windows shortcut for launching Windows Media Center. I don't know of any way to make this key launch XBMC instead. Any suggestions gratefully received.

Remember you can test your config file by pressing keys on the keyboard as well as pressing buttons on the remote. Suppose you've added:

<p mod="ctrl,shift">Play</p>

but it isn't working. Well try pressing control-shift-P on the keyboard. If it still doesn't work there's something wrong with your config file.

If an apparently perfect keyboard.xml file stubbornly isn't working, turn on debugging in XBMC (Settings, System, Debugging and Enable debug logging), start and stop XBMC and look at the xbmc.log file in C:\Program Files\XBMC. Look for the lines:

INFO: load keymapping
INFO: Loading special://xbmc/system/keymaps/gamepad.xml
INFO: Loading special://xbmc/system/keymaps/joystick.AppleRemote.xml
INFO: Loading special://xbmc/system/keymaps/joystick.Harmony.xml
INFO: Loading special://xbmc/system/keymaps/joystick.Logitech.RumblePad.2.xml
INFO: Loading special://xbmc/system/keymaps/joystick.Microsoft.Xbox.Controller.S.xml
INFO: Loading special://xbmc/system/keymaps/joystick.WiiRemote.xml
INFO: Loading special://xbmc/system/keymaps/keyboard.xml
INFO: Loading special://xbmc/system/keymaps/remote.xml
INFO: Loading special://masterprofile/keymaps/keyboard.xml
INFO: Loading special://profile/keymaps/keyboard.xml

special://xbmc/system/keymaps/keyboard.xml is the system keyboard.xml, which should always be there, and special://profile/keymaps/keyboard.xml is your keyboard.xml. If there is no masterprofile or profile entry then XBMC isn't loading your keyboard.xml so you probably put it in the wrong place. If you look at line 7 or thereabouts of the log file you should see:

NOTICE: special://masterprofile/ is mapped to: C:\Program Files\XBMC\userdata

and this will tell you where XBMC is looking for your keyboard.xml.

Also look for any lines following the above that look like:

ERROR: Error loading keymap: special://masterprofile/keymaps/keyboard.xml, Line 14
       Error reading end tag.

This tells you if XBMC found an error in your keyboard.xml file.

A list of possible keys and actions

There is a list of all the XBMC key names that you can use in keyboard.xml <a href="list_of_keys.html">here</a>.

There is a list of all the actions that you can use in keyboard.xml <a href="list_of_actions.html">here</a>.

And finally

All this probably looks very complicated and you're wondering if it can't be made simpler. Well on my list of things to do is write a utility for managing keyboard.xml files, so no more Notepad. Until then it isn't really that complicated. I've probably made it seem so by ranting on in more detail than necessary. Anyhow if you run into any problems please post in <a href="http://forum.xbmc.org/">http://forum.xbmc.org/</a> and I'll try to answer there.