]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
HID: proper LED-mapping for SpaceNavigator
authorSimon Budig <simon@budig.de>
Mon, 15 Jan 2007 16:28:47 +0000 (17:28 +0100)
committerJiri Kosina <jkosina@suse.cz>
Sun, 21 Jan 2007 21:17:53 +0000 (22:17 +0100)
This change introduces a mapping for LED indicators between the HID
specification and the Linux input subsystem. The previous code properly
mapped the LEDs relevant for Keyboards, but garbeled the remaining ones.
With this change all LED enums from the input system get mapped to more
or less equivalent LED numbers from the HID specification.

This patch also ensures that the unused bits in a HID report to the
device are zeroed out. This makes the 3Dconnexion SpaceNavigator fully
usable with the linux input system.

Signed-off-by: Simon Budig <simon@budig.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c
drivers/hid/hid-input.c

index 1e1a7770a6b9a53f18be6f138f89ecfc474e33e4..38db8321b211887f4ce86e842e0823bc294a1207 100644 (file)
@@ -880,6 +880,10 @@ static void hid_output_field(struct hid_field *field, __u8 *data)
        unsigned size = field->report_size;
        unsigned n;
 
+       /* make sure the unused bits in the last byte are zeros */
+       if (count > 0 && size > 0)
+               data[(count*size-1)/8] = 0;
+
        for (n = 0; n < count; n++) {
                if (field->logical_minimum < 0) /* signed values */
                        implement(data, offset + n * size, size, s32ton(field->value[n], size));
index 28689e3eb552c2ec672ce64a42b0fec5c0fef724..95b9573c5f93191b20c2360cf8efa5cd93ac8008 100644 (file)
@@ -364,9 +364,22 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        break;
 
                case HID_UP_LED:
-                       if (((usage->hid - 1) & 0xffff) >= LED_MAX)
-                               goto ignore;
-                       map_led((usage->hid - 1) & 0xffff);
+
+                       switch (usage->hid & 0xffff) {                        /* HID-Value:                   */
+                               case 0x01:  map_led (LED_NUML);     break;    /*   "Num Lock"                 */
+                               case 0x02:  map_led (LED_CAPSL);    break;    /*   "Caps Lock"                */
+                               case 0x03:  map_led (LED_SCROLLL);  break;    /*   "Scroll Lock"              */
+                               case 0x04:  map_led (LED_COMPOSE);  break;    /*   "Compose"                  */
+                               case 0x05:  map_led (LED_KANA);     break;    /*   "Kana"                     */
+                               case 0x27:  map_led (LED_SLEEP);    break;    /*   "Stand-By"                 */
+                               case 0x4c:  map_led (LED_SUSPEND);  break;    /*   "System Suspend"           */
+                               case 0x09:  map_led (LED_MUTE);     break;    /*   "Mute"                     */
+                               case 0x4b:  map_led (LED_MISC);     break;    /*   "Generic Indicator"        */
+                               case 0x19:  map_led (LED_MAIL);     break;    /*   "Message Waiting"          */
+                               case 0x4d:  map_led (LED_CHARGING); break;    /*   "External Power Connected" */
+
+                               default: goto ignore;
+                       }
                        break;
 
                case HID_UP_DIGITIZER: