rc-core support for Microsoft IR keyboard/mouse
Subsystems (2)
PATCH 1/1 rc-core support for Microsoft IR keyboard/mouse
This is a custom IR protocol decoder, for the RC-6-ish protocol used by the Microsoft Remote Keyboard.
http://www.amazon.com/Microsoft-Remote-Keyboard-Windows-ZV1-00004/dp/B000AOAAN8
Its a standard keyboard with embedded thumb stick mouse pointer and mouse buttons, along with a number of media keys. The media keys are standard RC-6, identical to the signals from the stock MCE remotes, and will be handled as such. The keyboard and mouse signals will be decoded and delivered to the system by an input device registered specifically by this driver.
Successfully tested with an mceusb-driven receiver, but this should actually work with any raw IR rc-core receiver.
This work is inspired by lirc_mod_mce:
http://mod-mce.sourceforge.net/
The documentation there and code aided in understanding and decoding the protocol, but the bulk of the code is actually borrowed more from the existing in-kernel decoders than anything. I did recycle the keyboard keycode table and a few defines from lirc_mod_mce though.
--- drivers/media/rc/Kconfig | 11 + drivers/media/rc/Makefile | 1 + drivers/media/rc/ir-mce_kbd-decoder.c | 383 +++++++++++++++++++++++++++++++++ drivers/media/rc/ir-raw.c | 1 + drivers/media/rc/rc-core-priv.h | 17 ++ drivers/media/rc/rc-main.c | 1 + include/media/rc-map.h | 3 +- 7 files changed, 416 insertions(+), 1 deletions(-) create mode 100644 drivers/media/rc/ir-mce_kbd-decoder.c
drivers/media/rc/Kconfig +11 -0
@@ -87,6 +87,17 @@ config IR_RC5_SZ_DECODER uses an IR protocol that is almost standard RC-5, but not quite, as it uses an additional bit). +config IR_MCE_KBD_DECODER + tristate "Enable IR raw decoder for the MCE keyboard/mouse protocol" + depends on RC_CORE + select BITREVERSE + default y + + ---help--- + Enable this option if you have a Microsoft Remote Keyboard for + Windows Media Center Edition, which you would like to use with + a raw IR receiver in your system. + config IR_LIRC_CODEC tristate "Enable IR to LIRC bridge" depends on RC_CORE
drivers/media/rc/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o obj-$(CONFIG_IR_JVC_DECODER) += ir-jvc-decoder.o obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o obj-$(CONFIG_IR_RC5_SZ_DECODER) += ir-rc5-sz-decoder.o +obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o # stand-alone IR receivers/transmitters
drivers/media/rc/ir-mce_kbd-decoder.c new file +383 -0
383 lines not on this page · raw message
drivers/media/rc/ir-raw.c +1 -0
@@ -353,6 +353,7 @@ static void init_decoders(struct work_struct *work)load_rc6_decode ();load_jvc_decode ();load_sony_decode (); +load_mce_kbd_decode ();load_lirc_codec ();/* If needed, we may later add some init code. In this case,
drivers/media/rc/rc-core-priv.h +17 -0
@@ -84,6 +84,16 @@ struct ir_raw_event_ctrl {unsigned count;unsigned wanted_bits; } rc5_sz; +struct mce_kbd_dec { +struct input_dev *idev; +char name[64 ]; +char phys[64 ]; +int state; +u8 header; +u32 body; +unsigned count; +unsigned wanted_bits; + } mce_kbd;struct lirc_codec {struct rc_dev *dev;struct lirc_driver *drv;
@@ -182,6 +192,13 @@ void ir_raw_init(void);#define load_sony_decode () 0#endif +/* from ir-mce_kbd-decoder.c */ +#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE +#define load_mce_kbd_decode () request_module("ir-mce_kbd-decoder") +#else +#define load_mce_kbd_decode () 0 +#endif +/* from ir-lirc-codec.c */ #ifdef CONFIG_IR_LIRC_CODEC_MODULE #define load_lirc_codec () request_module("ir-lirc-codec")
drivers/media/rc/rc-main.c +1 -0
@@ -733,6 +733,7 @@ static struct { { RC_TYPE_JVC, "jvc" }, { RC_TYPE_SONY, "sony" }, { RC_TYPE_RC5_SZ, "rc-5-sz" }, + { RC_TYPE_MCE_KBD, "mce_kbd" }, { RC_TYPE_LIRC, "lirc" }, { RC_TYPE_OTHER, "other" }, };
include/media/rc-map.h +2 -1
@@ -18,12 +18,13 @@#define RC_TYPE_JVC (1 << 3)/* JVC protocol */ #define RC_TYPE_SONY (1 << 4)/* Sony12/15/20 protocol */ #define RC_TYPE_RC5_SZ (1 << 5)/* RC5 variant used by Streamzap */ +#define RC_TYPE_MCE_KBD (1 << 29)/* RC6-ish MCE keyboard/mouse */ #define RC_TYPE_LIRC (1 << 30)/* Pass raw IR to lirc userspace */ #define RC_TYPE_OTHER (1u << 31)#define RC_TYPE_ALL (RC_TYPE_RC5 | RC_TYPE_NEC | RC_TYPE_RC6 | \ RC_TYPE_JVC | RC_TYPE_SONY | RC_TYPE_LIRC | \ - RC_TYPE_RC5_SZ | RC_TYPE_OTHER) + RC_TYPE_RC5_SZ | RC_TYPE_MCE_KBD | RC_TYPE_OTHER)struct rc_map_table {u32 scancode;
Signature · 1 line
1.7.5.2
Quoted 15 lines · Jarod Wilson
This is a custom IR protocol decoder, for the RC-6-ish protocol used by the Microsoft Remote Keyboard.
http://www.amazon.com/Microsoft-Remote-Keyboard-Windows-ZV1-00004/dp/B000AOAAN8
Its a standard keyboard with embedded thumb stick mouse pointer and mouse buttons, along with a number of media keys. The media keys are standard RC-6, identical to the signals from the stock MCE remotes, and will be handled as such. The keyboard and mouse signals will be decoded and delivered to the system by an input device registered specifically by this driver.
Successfully tested with an mceusb-driven receiver, but this should actually work with any raw IR rc-core receiver.
Quoted 8 lines
This work is inspired by
lirc_mod_mce:http://mod-mce.sourceforge.net/
The documentation there and code aided in understanding and decoding the protocol, but the bulk of the code is actually borrowed more from the existing in-kernel decoders than anything. I did recycle the keyboard keycode table and a few defines from
lirc_mod_mcethough.
Nb: this should more or less be considered as an RFC.
One thing I already know I need/want to add is a timer callback to make sure we don't get stuck keys due to missing a release event signal.
The main area of contention though is over how the keyboard/mouse device is set up. Currently, if you have three raw rc-core IR receivers in your system, you get three separate keyboard/mouse event devices, stored inside rc_dev->raw->mce_kbd->idev. I *think* this is the right way to do this, but one could argue that the decoder should just have a single input_dev within the decoder itself, which is used to feed along signals from any raw IR device.
The other question is whether or not this module should be loaded by default when rc-core is initialized. The current implementation means this is loaded, and input devices are set up for every raw IR device, and I doubt the vast majority of people with raw IR receivers actually have this keyboard.
Signature · 2 lines
Jarod Wilson [email protected]
Em 03-06-2011 18:28, Jarod Wilson escreveu:
Quoted 19 lines
This is a custom IR protocol decoder, for the RC-6-ish protocol used by the Microsoft Remote Keyboard.
http://www.amazon.com/Microsoft-Remote-Keyboard-Windows-ZV1-00004/dp/B000AOAAN8
Its a standard keyboard with embedded thumb stick mouse pointer and mouse buttons, along with a number of media keys. The media keys are standard RC-6, identical to the signals from the stock MCE remotes, and will be handled as such. The keyboard and mouse signals will be decoded and delivered to the system by an input device registered specifically by this driver.
Successfully tested with an mceusb-driven receiver, but this should actually work with any raw IR rc-core receiver.
This work is inspired by
lirc_mod_mce:
Quoted 7 lines
The documentation there and code aided in understanding and decoding the protocol, but the bulk of the code is actually borrowed more from the existing in-kernel decoders than anything. I did recycle the keyboard keycode table and a few defines from
lirc_mod_mcethough.Signed-off-by Jarod Wilson <[email protected]>---
I did only a quick review, and everything looks fine for me. Just two comments:
drivers/media/rc/ir-mce_kbd-decoder.c line 335
Quoted 5 lines
drivers/media/rc/ir-mce_kbd-decoder.c new file +5
-0+#if 0 +/* Adding this reference means two input devices are associated with +* this rc-core device, which ir-keytable doesn't cope with yet */ + idev->dev.parent = &dev->dev; +#endif
Well, it was never tested with such config ;) Feel free to fix rc-core.
Quoted 8 lines
drivers/media/rc/ir-mce_kbd-decoder.c new file +8
-0+static unsigned char kbd_keycodes[256 ] = { +0 ,0 ,0 ,0 ,30 ,48 ,46 ,32 ,18 ,33 ,34 ,35 ,23 ,36 ,37 ,38 , +50 ,49 ,24 ,25 ,16 ,19 ,31 ,20 ,22 ,47 ,17 ,45 ,21 ,44 ,2 ,3 , +4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,28 ,1 ,14 ,15 ,57 ,12 ,13 ,26 , +27 ,43 ,43 ,39 ,40 ,41 ,51 ,52 ,53 ,58 ,59 ,60 ,61 ,62 ,63 ,64 , +65 ,66 ,67 ,68 ,87 ,88 ,99 ,70 ,119 ,110 ,102 ,104 ,111 ,107 ,109 ,106 , +105 ,108 ,103 ,69 ,98 ,55 ,74 ,78 ,96 ,79 ,80 ,81 ,75 ,76 ,77 ,71 , +72 ,73 ,82 ,83 ,86 ,127 ,116 ,117 ,183 ,184 ,185 ,186 ,187 ,188 ,189 ,190 ,
drivers/media/rc/ir-mce_kbd-decoder.c line 77
Quoted 10 lines
drivers/media/rc/ir-mce_kbd-decoder.c new file +10
-0+191 ,192 ,193 ,194 ,134 ,138 ,130 ,132 ,128 ,129 ,131 ,137 ,133 ,135 ,136 ,113 , +115 ,114 ,0 ,0 ,0 ,121 ,0 ,89 ,93 ,124 ,92 ,94 ,95 ,0 ,0 ,0 , +122 ,123 ,90 ,91 ,85 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +29 ,42 ,56 ,125 ,97 ,54 ,100 ,126 ,164 ,166 ,165 ,163 ,161 ,115 ,114 ,113 , +150 ,158 ,159 ,128 ,136 ,177 ,178 ,176 ,142 ,152 ,173 ,140 +};
This table looks weird to me: too much magic numbers there. Shouldn't the above be replaced by KEY_* definitions?
Cheers,
Mauro
-
PS.: I would like to have one of those keyboards, in order to test some things here, in special, for the xorg input/event proposal on my TODO list ;) Is it a cheap device? I may try to buy one the next time I would travel to US.
Quoted 30 lines · Mauro Carvalho Chehab
Em 03-06-2011 18:28, Jarod Wilson escreveu:
Quoted 19 lines
This is a custom IR protocol decoder, for the RC-6-ish protocol used by the Microsoft Remote Keyboard.
http://www.amazon.com/Microsoft-Remote-Keyboard-Windows-ZV1-00004/dp/B000AOAAN8
Its a standard keyboard with embedded thumb stick mouse pointer and mouse buttons, along with a number of media keys. The media keys are standard RC-6, identical to the signals from the stock MCE remotes, and will be handled as such. The keyboard and mouse signals will be decoded and delivered to the system by an input device registered specifically by this driver.
Successfully tested with an mceusb-driven receiver, but this should actually work with any raw IR rc-core receiver.
This work is inspired by
lirc_mod_mce:Quoted 7 lines
The documentation there and code aided in understanding and decoding the protocol, but the bulk of the code is actually borrowed more from the existing in-kernel decoders than anything. I did recycle the keyboard keycode table and a few defines from
lirc_mod_mcethough.Signed-off-by Jarod Wilson <[email protected]>---
I did only a quick review, and everything looks fine for me. Just two comments:
Quoted 7 lines
drivers/media/rc/ir-mce_kbd-decoder.c line 335
Quoted 5 lines
drivers/media/rc/ir-mce_kbd-decoder.c new file +5
-0+#if 0 +/* Adding this reference means two input devices are associated with +* this rc-core device, which ir-keytable doesn't cope with yet */ + idev->dev.parent = &dev->dev; +#endif Well, it was never tested with such config ;)
D'oh, I meant to mention that #if 0...
Quoted 1 line
Feel free to fix rc-core.
It wasn't actually rc-core that complained, it was ir-keytable that spit out a message about not being able to handle an rc device with multiple input devices, but the fix may well require both userspace and kernelspace changes...
Quoted 13 lines
Quoted 13 lines
drivers/media/rc/ir-mce_kbd-decoder.c new file +13
-0+static unsigned char kbd_keycodes[256 ] = { +0 ,0 ,0 ,0 ,30 ,48 ,46 ,32 ,18 ,33 ,34 ,35 ,23 ,36 ,37 ,38 , +50 ,49 ,24 ,25 ,16 ,19 ,31 ,20 ,22 ,47 ,17 ,45 ,21 ,44 ,2 ,3 , +4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,28 ,1 ,14 ,15 ,57 ,12 ,13 ,26 , +27 ,43 ,43 ,39 ,40 ,41 ,51 ,52 ,53 ,58 ,59 ,60 ,61 ,62 ,63 ,64 , +65 ,66 ,67 ,68 ,87 ,88 ,99 ,70 ,119 ,110 ,102 ,104 ,111 ,107 ,109 ,106 , +105 ,108 ,103 ,69 ,98 ,55 ,74 ,78 ,96 ,79 ,80 ,81 ,75 ,76 ,77 ,71 , +72 ,73 ,82 ,83 ,86 ,127 ,116 ,117 ,183 ,184 ,185 ,186 ,187 ,188 ,189 ,190 , +191 ,192 ,193 ,194 ,134 ,138 ,130 ,132 ,128 ,129 ,131 ,137 ,133 ,135 ,136 ,113 , +115 ,114 ,0 ,0 ,0 ,121 ,0 ,89 ,93 ,124 ,92 ,94 ,95 ,0 ,0 ,0 , +122 ,123 ,90 ,91 ,85 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
Quoted 8 lines
drivers/media/rc/ir-mce_kbd-decoder.c line 77
Quoted 5 lines
drivers/media/rc/ir-mce_kbd-decoder.c new file +5
-0+0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +29 ,42 ,56 ,125 ,97 ,54 ,100 ,126 ,164 ,166 ,165 ,163 ,161 ,115 ,114 ,113 , +150 ,158 ,159 ,128 ,136 ,177 ,178 ,176 ,142 ,152 ,173 ,140 +};This table looks weird to me: too much magic numbers there. Shouldn't the above be replaced by KEY_* definitions?
Yeah, probably. The above is basically the same convention as hid_keyboard in drivers/hid/hid-input.c, but that doesn't mean we can't strive to do better. ;)
Quoted 3 lines
PS.: I would like to have one of those keyboards, in order to test some things here, in special, for the xorg input/event proposal on my TODO list ;) Is it a cheap device? I may try to buy one the next time I would travel to US.
Looks like Amazon has them listed for less than $40USD right now, but they're becoming increasingly hard to find, as I believe they're discontinued. Don't know if I've ever seen them in a brick-n-mortar store anywhere. I should really get one for myself, I have to send this one back to the guy who loaned it to me. I could just make it a double order and stash one on the shelf for ya.
Signature · 2 lines
Jarod Wilson [email protected]
PATCH v2 1/1 rc-core support for Microsoft IR keyboard/mouse
In reply to Jarod WilsonThis is a custom IR protocol decoder, for the RC-6-ish protocol used by the Microsoft Remote Keyboard, apparently developed internally at Microsoft, and officially dubbed MCIR-2, per their March 2011 remote and transceiver requirements and specifications document, which also touches on this IR keyboard/mouse device.
http://www.amazon.com/Microsoft-Remote-Keyboard-Windows-ZV1-00004/dp/B000AOAAN8
Its a standard keyboard with embedded thumb stick mouse pointer and mouse buttons, along with a number of media keys. The media keys are standard RC-6, identical to the signals from the stock MCE remotes, and will be handled as such. The keyboard and mouse signals will be decoded and delivered to the system by an input device registered specifically by this driver.
Successfully tested with multiple mceusb-driven transceivers, as well as with fintek-cir and redrat3 hardware. Essentially, any raw IR hardware with enough sampling resolution should be able to use this decoder, nothing about it is at all receiver-hardware-specific.
This work is inspired by lirc_mod_mce:
http://mod-mce.sourceforge.net/
The documentation there and code aided in understanding and decoding the protocol, but the bulk of the code is actually borrowed more from the existing in-kernel decoders than anything. I did recycle the keyboard keycode table, a few defines, and some of the keyboard and mouse data parsing bits from lirc_mod_mce though.
Special thanks to James Meyer for providing the hardware, and being patient with me as I took forever to get around to writing this.
v2: now know its MCIR-2, updated accordingly, added a key release timer callback routine to ensure we don't get any stuck keys, and used symbolic names for the keytable. Also cc'ing Florian this time, who I believe is the original mod-mce author...
--- drivers/media/rc/Kconfig | 11 + drivers/media/rc/Makefile | 1 + drivers/media/rc/ir-mce_kbd-decoder.c | 448 +++++++++++++++++++++++++++++++++ drivers/media/rc/ir-raw.c | 1 + drivers/media/rc/rc-core-priv.h | 18 ++ drivers/media/rc/rc-main.c | 1 + include/media/rc-map.h | 3 +- 7 files changed, 482 insertions(+), 1 deletions(-) create mode 100644 drivers/media/rc/ir-mce_kbd-decoder.c
drivers/media/rc/Kconfig +11 -0
@@ -87,6 +87,17 @@ config IR_RC5_SZ_DECODER uses an IR protocol that is almost standard RC-5, but not quite, as it uses an additional bit). +config IR_MCE_KBD_DECODER + tristate "Enable IR raw decoder for the MCE keyboard/mouse protocol" + depends on RC_CORE + select BITREVERSE + default y + + ---help--- + Enable this option if you have a Microsoft Remote Keyboard for + Windows Media Center Edition, which you would like to use with + a raw IR receiver in your system. + config IR_LIRC_CODEC tristate "Enable IR to LIRC bridge" depends on RC_CORE
drivers/media/rc/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o obj-$(CONFIG_IR_JVC_DECODER) += ir-jvc-decoder.o obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o obj-$(CONFIG_IR_RC5_SZ_DECODER) += ir-rc5-sz-decoder.o +obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o # stand-alone IR receivers/transmitters
drivers/media/rc/ir-mce_kbd-decoder.c new file +448 -0
448 lines not on this page · raw message
drivers/media/rc/ir-raw.c +1 -0
@@ -355,6 +355,7 @@ static void init_decoders(struct work_struct *work)load_rc6_decode ();load_jvc_decode ();load_sony_decode (); +load_mce_kbd_decode ();load_lirc_codec ();/* If needed, we may later add some init code. In this case,
drivers/media/rc/rc-core-priv.h +18 -0
@@ -84,6 +84,17 @@ struct ir_raw_event_ctrl {unsigned count;unsigned wanted_bits; } rc5_sz; +struct mce_kbd_dec { +struct input_dev *idev; +struct timer_list rx_timeout; +char name[64 ]; +char phys[64 ]; +int state; +u8 header; +u32 body; +unsigned count; +unsigned wanted_bits; + } mce_kbd;struct lirc_codec {struct rc_dev *dev;struct lirc_driver *drv;
@@ -182,6 +193,13 @@ void ir_raw_init(void);#define load_sony_decode () 0#endif +/* from ir-mce_kbd-decoder.c */ +#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE +#define load_mce_kbd_decode () request_module("ir-mce_kbd-decoder") +#else +#define load_mce_kbd_decode () 0 +#endif +/* from ir-lirc-codec.c */ #ifdef CONFIG_IR_LIRC_CODEC_MODULE #define load_lirc_codec () request_module("ir-lirc-codec")
drivers/media/rc/rc-main.c +1 -0
@@ -735,6 +735,7 @@ static struct { { RC_TYPE_JVC, "jvc" }, { RC_TYPE_SONY, "sony" }, { RC_TYPE_RC5_SZ, "rc-5-sz" }, + { RC_TYPE_MCE_KBD, "mce_kbd" }, { RC_TYPE_LIRC, "lirc" }, { RC_TYPE_OTHER, "other" }, };
include/media/rc-map.h +2 -1
@@ -18,12 +18,13 @@#define RC_TYPE_JVC (1 << 3)/* JVC protocol */ #define RC_TYPE_SONY (1 << 4)/* Sony12/15/20 protocol */ #define RC_TYPE_RC5_SZ (1 << 5)/* RC5 variant used by Streamzap */ +#define RC_TYPE_MCE_KBD (1 << 29)/* RC6-ish MCE keyboard/mouse */ #define RC_TYPE_LIRC (1 << 30)/* Pass raw IR to lirc userspace */ #define RC_TYPE_OTHER (1u << 31)#define RC_TYPE_ALL (RC_TYPE_RC5 | RC_TYPE_NEC | RC_TYPE_RC6 | \ RC_TYPE_JVC | RC_TYPE_SONY | RC_TYPE_LIRC | \ - RC_TYPE_RC5_SZ | RC_TYPE_OTHER) + RC_TYPE_RC5_SZ | RC_TYPE_MCE_KBD | RC_TYPE_OTHER)struct rc_map_table {u32 scancode;
Signature · 1 line
1.7.1