Using a Microsoft remote control in Windows

From Official Kodi Wiki
Revision as of 20:18, 5 June 2014 by NedBot (talk | contribs) (Robot: Substituting template: Name)
Jump to navigation Jump to search

This article applies to remote controls that use the Microsoft eHome device driver. If you are unsure whether your remote is an eHome remote look in the Device Manager under Human Interface Devices and see if there is a device called "Microsoft eHome Infrared Transceiver" or something similar.

EHome Remote Button IDs 1.jpg

The above example is from Windows 7. If the eHome device does not appear you aren't using the eHome driver and you should read no further. For MCE remotes see Using an MCE remote control in Windows and for general notes on remote controllers see Remote Controls.

Introduction

The simplest way to use an eHome remote with XBMC is to configure it to emulate a keyboard. The eHome driver can be configured by modifying the registry (details below). The details are rather involved, but there are various resources you can use that make it all very simple.

EliteGamer360 has written a registry config file and associated keyboard.xml and these are available from http://xbmccustomregis.sourceforge.net/.

jhsrennie has written an add-on to configure MS remotes. To install it run XBMC and go to Settings, Add-ons, Get Add-ons, XBMC.org Add-ons, Program Add-ons and select MCERemote. Once installed, you can open the add-on by selecting Programs from the home page then MCERemote. The addon includes an option to display the instructions.

Default eHome configuration

Any version of Windows from Windows XP onwards will automatically detect and install a Microsoft remote as soon as you connect it. With versions of XBMC from v10.0 Dharma onwards most of the buttons on the Microsoft remote will work immediately. The exceptions I know about are:

  • The Info button; sometimes labelled More or just i.
  • The volume buttons will control the Windows volume setting not the XBMC volume
  • The four coloured buttons (not all MS remotes have these) won't do anything
  • With Vista/Windows 7 the Live TV, Recorded TV and Guide buttons will start Windows Media Center. With Windows XP (non-Media Center Edition) these buttons won't do anything
  • The Green/Windows button will start Windows Media Center

For most people this will be fine, and in that case you don't need to do anything further. The only reason for continuing with this article is if you want to customise the Microsoft remote to change the actions of any of the buttons or to make the Info and coloured buttons work.

Useful resources

http://xbmcmce.sourceforge.net/ has various utilities to help with tweaking the button mapping. ShowKey will show you what keypresses or AppCommand messages are being sent, and KeyMapEdit is a utility for editing the keyboard.xml file.

The remainder of this article describes the gory details of configuring the Microsoft remote. This probably looks frighteningly complicated to most of us, but very few people need to read further as EliteGamer360's scripts and/or the MCERemote add-on should do everything you need. Only the curious and determined need read further.

How the MS remote works

The Microsoft remote, or more accurately the eHome device driver, keeps the button configuration in the registry value ReportMappingTable in the key:

HKEY_LOCAL_MACHINE
 \SYSTEM
  \CurrentControlSet
   \Services
    \HidIr
     \Remotes
      \745a17a0-74d3-11d0-b6fe-00a0c90f57da

This is a binary array consisting of rows of 7 bytes. Each row defines one button. The seven bytes in the row are:


Byte Action
0 button number (see below)
1 always 0
2 always 0
3 always 0
4 04 sends a keystroke; 01 results in a multimedia keypress or WM_APPCOMMAND message; 03 generates a Raw Input message
5 Key modifier or low byte of multimedia command (see below)
6 Key modifier or high byte of multimedia command (see below)

Byte 4 determines what the eHome driver will do when the button is pressed. If byte 4 is set to 03 the eHome driver will generate a "Raw Input" message and if byte 4 is 04 this will cause the button to send a keypress i.e. Windows will react as if a key had been pressed on the keyboard. If byte 4 is 01 the eHome driver will either send either a multimedia keypress or an APPCOMMAND message.

Byte 4 = 03: Raw Input messages

If byte 4 is set to 03 the eHome driver will generate a "Raw Input" message, see http://msdn.microsoft.com/en-us/library/ms645536(v=vs.85).aspx. The only raw input messages likely to be useful are:


<button>,00,00,00,03,81,00 System Power: will cause Windows to shut down
<button>,00,00,00,03,82,00 System Sleep: will cause Windows to hibernate
<button>,00,00,00,03,83,00 System Wake: will cause Windows to wake from hibernation

Byte 4 = 04: Normal keypresses

If byte 4 is set to 04 then byte 5 contains modifiers like control, shift, alt, etc and byte 6 contains the key code.

The value of byte 5, the key modifier, can be:


Byte Action
0 No modifier
1 Control
2 Shift
3 Control-Shift
4 Alt
5 Control-Alt
6 Shift-Alt
7 Control-Shift-Alt
8 Windows
9 Control-Windows
a Shift-Windows
b Control-Shift-Windows
c Alt-Windows
d Control-Alt-Windows
e Shift-Alt-Windows
f Control-Shift-Alt-Windows

If you're happy with binary numbers you've probably spotted that bit 0 specifies Control, bit 1 specifies Shift, bit 2 specifies Alt and bit 3 specifies the Windows key.

The key code is not an ACSII code or a scan code. It's an arbitrary code selected by MS. You can find a list of the codes in http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf. The button numbers obey no obvious logic.

To give a specific example, suppose you want to configure the Play button to send the Media Center keyboard shortcut for "Play", the 7 bytes would be:

16,00,00,00,04,03,13


Byte Value Notes
Byte 0 16 The number of the Play button is 0x16 (see table below)
Byte 1 00 Bytes 1 to 3 are always zero
Byte 2 00
Byte 3 00
Byte 4 04 The value 0x04 means send a normal keypress
Byte 5 03 Ctrl = 2 and Shift = 1 so 3 = 2 + 1 mean ctrl-shift
Byte 6 13 0x13 is the key code for "P"

Byte 4 = 01: Multimedia key or APPCOMMAND message

The Microsoft Multimedia Keyboard and various clones have keys for functions like "Play" and "Stop". If byte 4 is set to 01 the eHome driver may generate a multimedia keyboard keypress. Alternatively, and with no onbvious logic, it may generate the Windows message WM_APPCOMMAND instead. The WM_APPCOMMAND message is used to send commands like "Play", 2Pause", "Stop", etc. See http://msdn.microsoft.com/en-us/library/ms647591(v=vs.85).aspx for details.

The multimedia keys have key codes that can be greater than 255 (0xFF) so they need two bytes to represnt them. Byte 5 is used for the low byte and byte 6 is used for the high byte, though in most cases the high byte will be zero. This means that there is no byte available to specify the key modifiers, so you cannot combine a multimedia keypress with ctrl, shift, alt, etc.

Following on from the example above, suppose you want to configure the Play button to send the Multimedia Play/Pause keypress i.e. Play then Pause the media on alternate presses. The 7 bytes would be:

16,00,00,00,01,cd,00


Byte Value Notes
Byte 0 16 The number of the Play button is 0x16 (see table below)
Byte 1 00 Bytes 1 to 3 are always zero
Byte 2 00
Byte 3 00
Byte 4 01 The value 0x01 means send a multimedia keypress
Byte 5 cd The code for the play/pause key is 0x00CD so put cd as the low byte
Byte 6 00 and 00 as the high byte

The key codes for the multimedia keys are also listed in http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf. They are the keys with the "HID usage page" set to 0C. The normal keys have the "HID usage page" set to 07.

Table of remote button codes

The following table lists all the known button numbers. Thanks to the many people who put effort into discovering these numbers.


Button no. Button name Comments
00 0 Standard MS remote
01 1 Standard MS remote
02 2 Standard MS remote
03 3 Standard MS remote
04 4 Standard MS remote
05 5 Standard MS remote
06 6 Standard MS remote
07 7 Standard MS remote
08 8 Standard MS remote
09 9 Standard MS remote
0A Clear Standard MS remote
Logitech Harmony One
0B Enter Standard MS remote
0C Main Power Standard MS remote
Logitech Harmony One (PowerToggle)
0D Windows Standard MS remote
0E Mute Standard MS remote
This button does not work on the 360 universal remote
Logitech Harmony One
0F Info/More Standard MS remote
Logitech Harmony One (Info)
10 Volume Up Standard MS remote
This button does not work on the 360 universal remote
Logitech Harmony One
11 Volume Down Standard MS remote
This button does not work on the 360 universal remote
Logitech Harmony One
12 Channel Up Standard MS remote
13 Channel Down Standard MS remote
14 Fast Forward Standard MS remote
15 Rewind Standard MS remote
16 Play Standard MS remote
17 Record Standard MS remote
18 Pause Standard MS remote
19 Stop Standard MS remote
1A Next/Skip Standard MS remote
1B Previous/Replay Standard MS remote
1C #/Refresh Labelled with a curved arrow (meaning refresh) on the 360 universal remote.
1D */100 Labelled "100" on the 360 universal remote.
1E Up Standard MS remote
1F Down Standard MS remote
20 Left Standard MS remote
21 Right Standard MS remote
22 OK Standard MS remote
23 Back Standard MS remote
24 DVD Menu Standard MS remote
Logitech Harmony One
25 Live TV, Red (B) Red button labelled "B" on the 360 universal remote
Logitech Harmony One
26 TV Guide, Yellow (Y) Yellow button labelled "Y" on the 360 universal remote
Logitech Harmony One (Menu)
27 Zoom/Aspect Ratio Top left button on the Asrock and Mediagate remotes
28 Open/Close Only on XBox 360 universal remote
29 Discrete Power On Present on the Harmony universal remote
2A Discrete Power Off Present on the Harmony universal remote
32 Visualisation  
33 Slideshow  
34 Eject  
3B Close App  
46 My TV Logitech Harmony One
47 Music Library Present on the Asrock remote
Logitech Harmony One (MyMusic)
48 Recorded TV Standard MS remote
Logitech Harmony One
49 Picture Library Present on the Asrock remote
Logitech Harmony One (MyPictures)
4A Video Library Present on the Asrock remote
Logitech Harmony One (MyVideos)
4B DVD Angle Present on the Mediagate MG-IR02BK remote
4C DVD Audio Present on the Mediagate MG-IR02BK remote
4D Subtitles Present on the Mediagate MG-IR02BK remote
4E Print Labelled "Print" on the HP remote
4F Display Labelled "Display" on the 360 universal remote
50 Radio Present on the Asrock remote
Logitech Harmony One (MyRadio)
51 Title Labelled "Title" on the 360 universal remote
5A Teletext On some, but not all, models of the MS remote and many compatibles
5B Red teletext button On the v2 Microsoft remote
5C Green teletext button On the v2 Microsoft remote
5D Yellow teletext button On the v2 Microsoft remote
5E Blue teletext button On the v2 Microsoft remote
64 XBox button Large "X" button on the 360 universal remote
66 Green (A) Green button labelled "A" on the 360 universal remote
68 Blue (X) Blue button labelled "X" on the 360 universal remote
6C Channel Up Channel up button on the 360 universal remote. Note that the standard MS remote uses number 12 for this button.
6D Channel Down Channel down button on the 360 universal remote. Note that the standard MS remote uses number 13 for this button.
6E Play/Pause You can configure the button to send VK_MEDIA_PLAY_PAUSE using 6e,00,00,00,01,cd,00

Table of key codes

This data is taken from http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf. The data has been reproduced here just in case Microsoft ever remove the link to the tranlate.pdf file:


Key Code
aA 04
bB 05
cC 06
dD 07
eE 08
fF 09
gG 0A
hH 0B
iI 0C
jJ 0D
kK 0E
lL 0F
mM 10
nN 11
oO 12
pP 13
qQ 14
rR 15
sS 16
tT 17
uU 18
vV 19
wW 1A
xX 1B
yY 1C
zZ 1D
1! 1E
2@ 1F
3# 20
4$ 21
5% 22
6^ 23
7& 24
8* 25
9( 26
0) 27
Return 28
Escape 29
Backspace 2A
Tab 2B
Space 2C
-_ 2D
=+ 2E
[{ 2F
]} 30
31
Europe 1 32
;: 33
'" 34
`~ 35
,< 36
.> 37
/? 38
Caps Lock 39
F1 3A
F2 3B
F3 3C
F4 3D
F5 3E
F6 3F
F7 40
F8 41
F9 42
F10 43
F11 44
F12 45
Print Screen 46
Scroll Lock 47
Break (Ctrl-Pause) 48
Pause 48
Insert 49
Home 4A
Page Up 4B
Delete 4C
End 4D
Page Down 4E
Right Arrow 4F
Left Arrow 50
Down Arrow 51
Up Arrow 52
Num Lock 53
Keypad / 54
Keypad * 55
Keypad - 56
Keypad + 57
Keypad Enter 58
Keypad 1 End 59
Keypad 2 Down 5A
Keypad 3 PageDn 5B
Keypad 4 Left 5C
Keypad 5 5D
Keypad 6 Right 5E
Keypad 7 Home 5F
Keypad 8 Up 60
Keypad 9 PageUp 61
Keypad 0 Insert 62
Keypad . Delete 63
Europe 2 64
App 65
Keyboard Power 66
Keypad = 67
F13 68
F14 69
F15 6A
F16 6B
F17 6C
F18 6D
F19 6E
F20 6F
F21 70
F22 71
F23 72
F24 73
Keyboard Execute 74
Keyboard Help 75
Keyboard Menu 76
Keyboard Select 77
Keyboard Stop 78
Keyboard Again 79
Keyboard Undo 7A
Keyboard Cut 7B
Keyboard Copy 7C
Keyboard Paste 7D
Keyboard Find 7E
Keyboard Mute 7F
Keyboard Volume Up 80
Keyboard Volume Dn 81
Caps Lock 82
Num Lock 83
Scroll Lock 84
Keypad , Brazilian Keypad . 85
Keyboard Equal Sign 86
Keyboard Int'l 1 87
Keyboard Int'l 2 88
Keyboard Int'l 2 89
Keyboard Int'l 4 8A
Keyboard Int'l 5 8B
Keyboard Int'l 6 8C
Keyboard Int'l 7 8D
Keyboard Int'l 8 8E
Keyboard Int'l 9 8F
Keyboard Lang 1 90
Keyboard Lang 2 91
Keyboard Lang 3 92
Keyboard Lang 4 93
Keyboard Lang 5 94
Keyboard Lang 6 95
Keyboard Lang 7 96
Keyboard Lang 8 97
Keyboard Alternate 98
Erase 99
SysReq/Attention 9A
Keyboard Cancel 9B
Keyboard Clear 9C
Keyboard Prior 9D
Keyboard Return 9E
Keyboard Separator 9F
Keyboard Out A0
Keyboard Oper A1
Keyboard Clear/Again A2
Keyboard CrSel/Props A3
Keyboard ExSel A4
Left Control E0
Left Shift E1
Left Alt E2
Left GUI E3
Right Control E4
Right Shift E5
Right Alt E6
Right GUI E7

Multimedia keys

The following has been established by experiment. There is no guarantee that the behaviour will be the same on all platforms.

Windows normally responds to Multimedia keypresses by generating WM_APPCOMMAND messages, so for example the Stop command, 00B7, generates both a VK_MEDIA_STOP keypress and a WM_APPCOMMAND 13 - Stop message.


Button Code Action
Play 00B0 sends WM_APPCOMMAND 46 - play
Pause 00B1 sends WM_APPCOMMAND 47 - pause
Record 00B2 sends WM_APPCOMMAND 48 - record
Fast forward 00B3 sends WM_APPCOMMAND 49 - fast forward
Rewind 00B4 sends WM_APPCOMMAND 50 - rewind
Scan Next Track 00B5 sends keypress VK_MEDIA_NEXT_TRACK
Scan Previous Track 00B6 sends keypress VK_MEDIA_PREV_TRACK
Stop 00B7 sends keypress VK_MEDIA_STOP
Play/Pause 00CD sends keypress VK_MEDIA_PLAY_PAUSE
Mute 00E2 sends keypress VK_VOLUME_MUTE
Bass Boost 00E5 sends WM_APPCOMMAND 20 - toggle bass boost
Loudness 00E7 not known
Volume Up 00E9 sends keypress VK_VOLUME_UP
Volume Down 00EA sends keypress VK_VOLUME_DOWN
Bass Up 0152 sends WM_APPCOMMAND 21 - increase bass
Bass Down 0153 sends WM_APPCOMMAND 19 - decrease bass
Treble Up 0154 sends WM_APPCOMMAND 23 - increase treble
Treble Down 0155 sends WM_APPCOMMAND 22 - decrease treble
Media Select 0183 sends keypress VK_LAUNCH_MEDIA_SELECT
Mail 018A sends keypress VK_LAUNCH_MAIL
Calculator 0192 sends keypress VK_LAUNCH_APP2
My Computer 0194 sends keypress VK_LAUNCH_APP1
Info 0209 not known
WWW Search 0221 sends keypress VK_BROWSER_SEARCH
WWW Home 0223 sends keypress VK_BROWSER_HOME
WWW Back 0224 sends keypress VK_BROWSER_BACK
WWW Forward 0225 sends keypress VK_BROWSER_FORWARD
WWW Stop 0226 sends keypress VK_BROWSER_STOP
WWW Refresh 0227 sends keypress VK_BROWSER_REFRESH
WWW Favorites 022A sends keypress VK_BROWSER_FAVORITES