[PATCH] Chicony USB Keyboard

From: Antonio Cuni
Date: Wed May 12 2004 - 16:36:41 EST


Hi,
I've got a Chicony KU-0108 USB keyboard with some multimedial keys: most of
them works fine, but there is no chance to use the 'cut', 'copy' and 'paste'
keys with the official kernels: the problem is that the keyboard reports
strange usages for those keys, so I write a little patch that fixes the bug.

This patch (against 2.6.6) modifies the hidinput_configure_usage function in
drivers/usb/input/hid-input.c: it checks for the usages reported by the
keyboard and fixes the values so that they can be seen as "standard" keys.

Comments are appreciated
[I've subscribed only linux-usb-devel, so plese CC replies from linux-kernel]

cheers,
Antonio

--- drivers/usb/input/hid-input.c.orig 2004-04-25 10:23:49.000000000 +0200
+++ drivers/usb/input/hid-input.c 2004-04-25 10:32:54.000000000 +0200
@@ -122,6 +122,22 @@ static void hidinput_configure_usage(str
case HID_GD_GAMEPAD: usage->code += 0x10;
case HID_GD_JOYSTICK: usage->code += 0x10;
case HID_GD_MOUSE: usage->code += 0x10; break;
+
+ case 0x000C0003:
+ /* reported on a Chicony KU-0108 USB Keyboard.
+ * The 'cut', 'copy' and 'paste' keys are seen as
+ * HID_UP_BUTTON instead of, e.g.,
+ * HID_UP_CONSUMER. The keys report a keycode > 255,
+ * so we need to fix it.
+ */
+
+ switch (usage->code) {
+ case 0x10f: usage->code = KEY_CUT; break;
+ case 0x100: usage->code = KEY_COPY; break;
+ case 0x101: usage->code = KEY_PASTE; break;
+ }
+ break;
+
default:
if (field->physical == HID_GD_POINTER)
usage->code += 0x10;