Skip to contentSkip to conversation

usb: Key codes for Microsoft Natural Ergonomic 4000 USB keyboard

PATCH In review John Zaitseff 2 participants 4 messages Oct 10, 2007 – Oct 11, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: Key codes for Microsoft Natural Ergonomic 4000 USB keyboard

From: John Zaitseff <[email protected]>

The following patch to Linux kernel 2.6.23 enables most of the extra keys found on the Microsoft Natural Ergonomic 4000 USB keyboard. I had to add one keycode to include/linux/input.h; feel free to reallocate the ID assigned to it (KEY_SPELL).

Main changes:

* Enabled the use of the extra "(" and ")" in the top right-hand part of the keyboard, above the keypad

* Enable the My Favorites key in the centre of the keyboard (mapped to KEY_FAVORITES)

* Map the F1-F12 keys to appropriate keys when the F Lock is off (this is quite easy as the keyboard already generates different USB key events)

Changes still to be made:

* Map the five buttons above My Favorites to KEY_FN_F1 to KEY_FN_F5

I am not sure how to do this last change correctly: the keyboard returns a usage->hid of (HID_UP_MSVENDOR | 0xff05) whenever any of the five keys are pressed or let go (as well as at certain other times, when the value is 0):

  value = 0x00  --->  none of the five keys are pressed
  value = 0x01  --->  key 1 is pressed
  value = 0x02  --->  key 2 is pressed
  value = 0x04  --->  key 3 is pressed
  value = 0x08  --->  key 4 is pressed
  value = 0x10  --->  key 5 is pressed

Note that although this looks like a bitfield, multiple keys CANNOT in effect be pressed simultaneously: only one of these six values is ever returned (as tested).

In any case, this will be for a second patch, once the one in this e-mail is applied.

Please apply if at all possible! Please CC me on any discussion, as I am not subscribed to the mailing lists.

---

 drivers/hid/hid-debug.c     |    4 +++-
 drivers/hid/hid-input.c     |    4 +++-
 drivers/hid/usbhid/usbkbd.c |    2 +-
 include/linux/input.h       |    1 +
 4 files changed, 8 insertions(+), 3 deletions(-)
drivers/hid/hid-debug.c +3 -1
diff -ruNp linux-2.6.23.orig/drivers/hid/hid-debug.c linux-2.6.23/drivers/hid/hid-debug.c
@@ -692,7 +692,9 @@ static char *keys[KEY_MAX + 1] = {
 	[KEY_SLOW] = "Slow",			[KEY_SHUFFLE] = "Shuffle",
 	[KEY_BREAK] = "Break",			[KEY_PREVIOUS] = "Previous",
 	[KEY_DIGITS] = "Digits",		[KEY_TEEN] = "TEEN",
-	[KEY_TWEN] = "TWEN",			[KEY_DEL_EOL] = "DeleteEOL",
+	[KEY_TWEN] = "TWEN",			[KEY_HELP] = "Help",
+	[KEY_ZOOMIN] = "ZoomIn",		[KEY_ZOOMOUT] = "ZoomOut",
+	[KEY_DEL_EOL] = "DeleteEOL",
 	[KEY_DEL_EOS] = "DeleteEOS",		[KEY_INS_LINE] = "InsertLine",
 	[KEY_DEL_LINE] = "DeleteLine",
 	[KEY_SEND] = "Send",			[KEY_REPLY] = "Reply",
drivers/hid/hid-input.c +3 -1
diff -ruNp linux-2.6.23.orig/drivers/hid/hid-input.c linux-2.6.23/drivers/hid/hid-input.c
@@ -53,7 +53,7 @@ static const unsigned char hid_keyboard[
 	115,114,unk,unk,unk,121,unk, 89, 93,124, 92, 94, 95,unk,unk,unk,
 	122,123, 90, 91, 85,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
 	unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
-	unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
+	unk,unk,unk,unk,unk,unk,179,180,unk,unk,unk,unk,unk,unk,unk,unk,
 	unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
 	unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
 	 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
@@ -595,6 +595,7 @@ static void hidinput_configure_usage(str
 				case 0x0f6: map_key_clear(KEY_NEXT);		break;
 				case 0x0fa: map_key_clear(KEY_BACK);		break;
 
+				case 0x182: map_key_clear(KEY_FAVORITES);	break;
 				case 0x183: map_key_clear(KEY_CONFIG);		break;
 				case 0x184: map_key_clear(KEY_WORDPROCESSOR);	break;
 				case 0x185: map_key_clear(KEY_EDITOR);		break;
@@ -614,6 +615,7 @@ static void hidinput_configure_usage(str
 				case 0x19e: map_key_clear(KEY_COFFEE);		break;
 				case 0x1a6: map_key_clear(KEY_HELP);		break;
 				case 0x1a7: map_key_clear(KEY_DOCUMENTS);	break;
+				case 0x1ab: map_key_clear(KEY_SPELL);		break;
 				case 0x1bc: map_key_clear(KEY_MESSENGER);	break;
 				case 0x1bd: map_key_clear(KEY_INFO);		break;
 				case 0x201: map_key_clear(KEY_NEW);		break;
drivers/hid/usbhid/usbkbd.c +1 -1
diff -ruNp linux-2.6.23.orig/drivers/hid/usbhid/usbkbd.c linux-2.6.23/drivers/hid/usbhid/usbkbd.c
@@ -57,7 +57,7 @@ static unsigned char usb_kbd_keycode[256
 	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,179,180,  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,
include/linux/input.h +1 -0
diff -ruNp linux-2.6.23.orig/include/linux/input.h linux-2.6.23/include/linux/input.h
@@ -522,6 +522,7 @@ struct input_absinfo {
 #define KEY_ADDRESSBOOK		0x1ad	/* AL Contacts/Address Book */
 #define KEY_MESSENGER		0x1ae	/* AL Instant Messaging */
 #define KEY_DISPLAYTOGGLE	0x1af	/* Turn display (LCD) on and off */
+#define KEY_SPELL		0x1b0
 
 #define KEY_DEL_EOL		0x1c0
 #define KEY_DEL_EOS		0x1c1
Signature · 4 lines
John Zaitseff                    ,--_|\    The ZAP Group
Phone:  +61 2 9643 7737         /      \   Sydney, Australia
E-mail: [email protected]   \_,--._*   http://www.zap.org.au/
                                      v
#1 lore raw
Quoted 4 lines · John Zaitseff

The following patch to Linux kernel 2.6.23 enables most of the extra keys found on the Microsoft Natural Ergonomic 4000 USB keyboard. I had to add one keycode to include/linux/input.h; feel free to reallocate the ID assigned to it (KEY_SPELL).

Hi John,

thanks a lot for the patch! However I think I have already added all the needed support for this keyboard. It is currently in my tree, queued until Linus opens the merge window for 2.6.24. Please look at
http://git.kernel.org/?p=linux/kernel/git/jikos/hid.git;a=commitdiff;h=0f48b3ce23a34dbe70dcd04b4216fbcb965ab906

Commit 945bcc3a in the same branch is also related.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw

Dear Jiri,

Quoted 7 lines · Jiri Kosina
Quoted 4 lines · John Zaitseff

The following patch to Linux kernel 2.6.23 enables most of the extra keys found on the Microsoft Natural Ergonomic 4000 USB keyboard. I had to add one keycode to include/linux/input.h; feel free to reallocate the ID assigned to it (KEY_SPELL).

Quoted 7 lines

thanks a lot for the patch! However I think I have already added all the needed support for this keyboard. It is currently in my tree, queued until Linus opens the merge window for 2.6.24. Please look at
http://git.kernel.org/?p=linux/kernel/git/jikos/hid.git;a=commitdiff;h=0f48b3ce23a34dbe70dcd04b4216fbcb965ab906

Commit 945bcc3a in the same branch is also related.

Excellent! However, I don't see the following:

* case 0x182: map_key_clear(KEY_FAVORITES);
... in drivers/usb/input/hid-input.c, to handle the My Favorites key

* the change to drivers/hid/usbhid/usbkbd.c to enable the "(" and ")" on the right hand side of the keyboard

Have these already been included elsewhere?

Yours truly,

John Zaitseff

Signature · 4 lines
John Zaitseff                    ,--_|\    The ZAP Group
Phone:  +61 2 9643 7737         /      \   Sydney, Australia
E-mail: [email protected]   \_,--._*   http://www.zap.org.au/
                                      v
#3 lore raw
Quoted 3 lines · John Zaitseff

Excellent! However, I don't see the following:
* case 0x182: map_key_clear(KEY_FAVORITES);
... in drivers/usb/input/hid-input.c, to handle the My Favorites key

There is also a patch queued on top of the patchset you were looking at, which adds support for Natural Ergonomic 6000 Keyboard, which also establishes the mapping of 0x182 to KEY_BOOKMARKS.

Quoted 2 lines

* the change to drivers/hid/usbhid/usbkbd.c to enable the "(" and ")" on the right hand side of the keyboard

usbkbd.c is not used under normal circumstances (it uses the hid boot protocol), I don't think it is needed to care too much for updating the keymap there.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs