]> err.no Git - linux-2.6/blobdiff - drivers/hid/hid-input.c
HID: proper LED-mapping for SpaceNavigator
[linux-2.6] / drivers / hid / hid-input.c
index 998638020ea0957f12ef5b88b340e22e6d6f96c8..95b9573c5f93191b20c2360cf8efa5cd93ac8008 100644 (file)
@@ -68,6 +68,7 @@ static const struct {
 #define map_led(c)     do { usage->code = c; usage->type = EV_LED; bit = input->ledbit; max = LED_MAX; } while (0)
 
 #define map_abs_clear(c)       do { map_abs(c); clear_bit(c, bit); } while (0)
+#define map_rel_clear(c)       do { map_rel(c); clear_bit(c, bit); } while (0)
 #define map_key_clear(c)       do { map_key(c); clear_bit(c, bit); } while (0)
 
 #ifdef CONFIG_USB_HIDINPUT_POWERBOOK
@@ -292,7 +293,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                        }
                        }
 
-                       map_key(code);
+                       map_key_clear(code);
                        break;
 
 
@@ -343,9 +344,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ:
                                case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL:
                                        if (field->flags & HID_MAIN_ITEM_RELATIVE)
-                                               map_rel(usage->hid & 0xf);
+                                               map_rel_clear(usage->hid & 0xf);
                                        else
-                                               map_abs(usage->hid & 0xf);
+                                               map_abs_clear(usage->hid & 0xf);
                                        break;
 
                                case HID_GD_HATSWITCH:
@@ -363,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:
@@ -500,7 +514,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                case 0x22f: map_key_clear(KEY_ZOOMRESET);       break;
                                case 0x233: map_key_clear(KEY_SCROLLUP);        break;
                                case 0x234: map_key_clear(KEY_SCROLLDOWN);      break;
-                               case 0x238: map_rel(REL_HWHEEL);                break;
+                               case 0x238: map_rel_clear(REL_HWHEEL);          break;
                                case 0x25f: map_key_clear(KEY_CANCEL);          break;
                                case 0x279: map_key_clear(KEY_REDO);            break;