SourceForge.net Logo


mod_mce


Linux input module to use Microsoft® Remote Keyboard for Windows XP® Media Center Edition and the matching receiver as a keyboard and mouse replacement.

Technical Background

The data from the keyboard is transferred via infrared (IR) light. Therefore the infrared light is pulsed at a high frequency (usually round about 35 kHz). The receiver takes notice of that light and measures the time, it is received. It also measures the time, it does not receive infrared light. In this case, the digital information is encapsulated in the relation between on- and off-times.

IR timing parameters used

RC6 - Media Keys

First, a synchronisation pulse of 2600µs to 3300µs is sent. Following that pulse, pulses and spaces of either 350µs to 600µs, 750µs to 1000µs or 1200µs to 1600µs are used. Each of these possible length is given a logical length of 1, 2 or 3. The sync has a logical length of 6. With this information, a series of zeroes (for spaces) and ones (for pulses) can be built. Due to limitations of the receiver used, the final space is missing and should be substituded. Here is an example of the green start key pressed:

111111 00 10 10 10 01 0011 10 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 01 01 01 01 01 10 01 01 01 01 01 01 10 10 01 10

A combination of two states gives us the final digital data. Whenever a combination 01 is seen, it results in a 0; 10 results in 1. All other pairs are not allowed. Be aware of the header consisting of the sync pulse (length 6), a space of length 2 and four bits followed by the so called 'toggle bit' -- in this case consisting of 0011 (i.e. double length). The four bits in header do not carry important information for this case. They can be used to identify the data packet, since possibly other remote controls use this kind of code, which could lead into confusion.

The final decoding of our above mentioned packet (omiting the section from sync to toggle) gives us:

1000 0000 0000 1111 0000 0100 0000 1101

The most significant bit (MSB) comes first. See below for information on the content of those data packets.

RC5 - Keyboard and Mouse

Basically the same technique as for the media keys is used. We have a sync pulse of 2600µs to 3300µs and pulse lengths of 150µs to 450µs or 500µs to 750µs, which are somewhat faster than for the media keys. Here, no toggle bits or long spaces are used. Beside the content, the data for mouse and keyboard differ in length. Some information shows up the possibility that a japanese keyboard exists with different timing.

Data Payload


The information presented here is mostly derived from recording IR data and is incomplete and highly subjective.

Media Keys

The layout is as follows

Identification
C
Code Set
Identification
Pressed Button
1000
0000
0000
1111
x
xxx
0100
xxxx
xxxx

The meaning of 'Code Set' is not known to me and is always 000 for the key strokes mentioned here. The bit 'C' seems to vary from keyboard to remote control and is not clear to me.

Value
Pressed Button
0x00
0 (rc only)
0x01
1 (rc only)
0x02
2 (rc only)
0x03
3 (rc only)
0x04
4 (rc only)
0x05
5 (rc only)
0x06
6 (rc only)
0x07
7 (rc only)
0x08
8 (rc only)
0x09
9 (rc only)
0x0A
Delete (rc only)
0x0B
Enter (rc only)
0x0C
PC Power
0x0D
Green Logo Button
0x0E
Mute
0x0F
Info
0x10
Vol +
0x11
Vol -
0x12
Ch/Pg +
0x13
Ch/Pg -
0x14
Fwd
0x15
Rew
0x16
Play
0x17
Record
0x18
Pause
0x19
Stop
0x1A
Skip
0x1B
Replay
0x1C
# (rc only)
0x1D
* (rc only)
0x1E
Up
0x1F
Down
0x20
Left
0x21
Right
0x22
OK
0x23
Back
0x24
DVD Menu
0x25
Live TV
0x26
EPG
0x46
TV (keyboard only)
0x47
Music (keyboard only)
0x48
Recorded TV
0x49
Pictures (keyboard only)
0x4A
Videos (keyboard only)
0x50
Radio (keyboard only)
0x5A
Videotext (rc only)
0x5B
Red (rc only)
0x5C
Green (rc only)
0x5D
Yellow (rc only)
0x5E
Blue (rc only)
0x64
Messenger (keyboard only)

Mouse

The data layout is as follows:
Identification
unknown
ΔY
ΔX
R
L
Checksum
0
 0001
xxxx
xxxx
xxx
xxxx
xxx
xxxx
x
x
x
xxxx

The unknown bits also contain a 'code set'. The algorithm used for the checksum is not clear to me.

R is the right button flag, L is the left button flag:
Bit
Meaning
0
not pressed
1
pressed

The differences in X- and Y-direction are expressed as 7-bit signed integers in two's complement. I have not seen values less than -30 or values greater than +30. Positive X-values indicate movement to the right, positive Y-values indicate movement to the top. For completeness here the full value table (assuming the limit mentioned):

Value
Meaning
0x00
0
0x01
1
0x02
2
0x03
3
0x04
4
0x05
5
0x06
6
0x07
7
0x08
8
0x09
9
0x0A
10
0x0B
11
0x0C
12
0x0D
13
0x0E
14
0x0F
15
0x10
16
0x11
17
0x12
18
0x13
19
0x14
20
0x15
21
0x16
22
0x17
23
0x18
24
0x19
25
0x1A
26
0x1B
27
0x1C
28
0x1D
29
0x1E
30
...
0x62
-30
0x63
-29
0x64
-28
0x65
-27
0x66
-26
0x67
-25
0x68
-24
0x69
-23
0x6A
-22
0x6B
-21
0x6C
-20
0x6D
-19
0x6E
-18
0x6F
-17
0x70
-16
0x71
-15
0x72
-14
0x73
-13
0x74
-12
0x75
-11
0x76
-10
0x77
-9
0x78
-8
0x79
-7
0x7A
-6
0x7B
-5
0x7C
-4
0x7D
-3
0x7E
-2
0x7F
-1

Keyboard

The data layout is as follows:
Identification
unknown
Code Set
unknown
Key Code
Shift Mask
0
 0100
xxx
x
xxxx
xxxx
xxxx
xxxx
xxxx
xxxx
xxxx

As in the other codes, the 'Code Set' is unknown to me.

The shift mask uses basically bits used also in USB HID. The following table shows the contents of 'Shift Mask'.

Bit
7
6
5
4
3
2
1
0
Key
Right Logo (n/a)
Right Alt
Right Shift
Right Ctrl
Left Logo
Left Alt
Left Shift
Left Ctrl
Matching Key Code
0xE7
0xE6
0xE5
0xE4
0xE3
0xE2
0xE1
0xE0

The right logo key is not existing on my keyboard. The bit is described only for completeness. This bit field enables the keyboard to also send key combinations like Ctrl + Alt + Delete, where Ctrl and Alt is stuffed into the shift mask.

The Key Codes also follow the USB HID standard and are described here only for reference. The assumption is made, that the keyboard is a US English keyboard (which mine is not). The keys have to be translated to your local character set. It is possible that some key codes are not sent by all keyboards, as well as some might be sent, which are not in this table.

Keycode
Meaning
0x00
All keys released (except those in Shift Mask)
0x04
A
0x05
B
0x06
C
0x07
D
0x08
E
0x09
F
0x0A
G
0x0B
H
0x0C
I
0x0D
J
0x0E
K
0x0F
L
0x10
M
0x11
N
0x12
O
0x13
P
0x14
Q
0x15
R
0x16
S
0x17
T
0x18
U
0x19
V
0x1A
W
0x1B
X
0x1C
Y
0x1D
Z
0x1E
1
0x1F
2
0x20
3
0x21
4
0x22
5
0x23
6
0x24
7
0x25
8
0x26
9
0x27
0
0x28

0x29
Esc
0x2A
← (backspace)
0x2B
Tab
0x2C
Space
0x2D
-
0x2E
=
0x2F
[
0x30
]
0x31
\
0x32
Non-US #
0x33
;
0x34
'
0x35
`
0x36
,
0x37
.
0x38
/
0x39
Caps Lock
0x3A
F1
0x3B
F2
0x3C
F3
0x3D
F4
0x3E
F5
0x3F
F6
0x40
F7
0x41
F8
0x42
F9
0x43
F10
0x44
F11
0x45
F12
0x46
Print Screen
0x47
Scroll Lock
0x48
Pause
0x49
Insert
0x4A
Home
0x4B
Page Up
0x4C
Delete
0x4D
End
0x4E
Page Down
0x4F

0x50

0x51

0x52

...
0x64
Non-US \
0x65
Application (=context menu)
...

Available Source Code

mod_mce

Since some new input functions are used in this project, please update your kernel. You have to enable USB and input in your kernel configuration. Building is done by executing 'make'.

mce_lircd


This is a daemon for those without the USB receiver but with a lirc-compatible receiver. This daemon relies on user input to be activated in your kernel.

lirc_mod_mce

Due to popular demand, I quickly assembled this driver which is basically a combination of mod_mce and a lirc module. This driver allows you to use the keyboard/mouse features as well as the remote control features at the same time.

lircd.conf


This config file can be used for the media keys. At the moment you can use either lirc or one of mod_mce or mce_lircd. It can be downloaded here.


Since the project is in some early stage, I unfortunately cannot give you more assistance right now.

For further information take a look at the SourceForge files page.

Contact

If you feel to contact me, please first take a look at the SourceForge page and check if the issue has been previously posted.

Last revision: 2006-09-06