]> err.no Git - linux-2.6/blobdiff - drivers/hid/hid-input.c
Merge branch 'merge' into powerpc-next
[linux-2.6] / drivers / hid / hid-input.c
index 3d448037c82fc9b4cc726c857e6cab7800793b97..5c52a20ad3447abd4cd4b94d7bc37f14746ab230 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: hid-input.c,v 1.2 2002/04/23 00:59:25 rdamazio Exp $
- *
  *  Copyright (c) 2000-2001 Vojtech Pavlik
  *  Copyright (c) 2006-2007 Jiri Kosina
  *
@@ -86,11 +84,6 @@ static const struct {
 #define map_abs_clear(c)       do { map_abs(c); clear_bit(c, bit); } while (0)
 #define map_key_clear(c)       do { map_key(c); clear_bit(c, bit); } while (0)
 
-/* hardware needing special handling due to colliding MSVENDOR page usages */
-#define IS_CHICONY_TACTICAL_PAD(x) (x->vendor == 0x04f2 && device->product == 0x0418)
-#define IS_MS_KB(x) (x->vendor == 0x045e && (x->product == 0x00db || x->product == 0x00f9))
-#define IS_MS_PRESENTER_8000(x) (x->vendor == 0x045e && x->product == 0x0713)
-
 #ifdef CONFIG_USB_HIDINPUT_POWERBOOK
 
 struct hidinput_key_translation {
@@ -102,18 +95,21 @@ struct hidinput_key_translation {
 #define APPLE_FLAG_FKEY 0x01
 
 static struct hidinput_key_translation apple_fn_keys[] = {
-       { KEY_F1,       KEY_BRIGHTNESSDOWN,     APPLE_FLAG_FKEY },
-       { KEY_F2,       KEY_BRIGHTNESSUP,       APPLE_FLAG_FKEY },
-       { KEY_F3,       KEY_CYCLEWINDOWS,       APPLE_FLAG_FKEY }, /* Exposé */
-       { KEY_F4,       KEY_FN_F4,              APPLE_FLAG_FKEY }, /* Dashboard */
-       { KEY_F5,       KEY_FN_F5 },
-       { KEY_F6,       KEY_FN_F6 },
-       { KEY_F7,       KEY_BACK,               APPLE_FLAG_FKEY },
-       { KEY_F8,       KEY_PLAYPAUSE,          APPLE_FLAG_FKEY },
-       { KEY_F9,       KEY_FORWARD,            APPLE_FLAG_FKEY },
-       { KEY_F10,      KEY_MUTE,               APPLE_FLAG_FKEY },
-       { KEY_F11,      KEY_VOLUMEDOWN,         APPLE_FLAG_FKEY },
-       { KEY_F12,      KEY_VOLUMEUP,           APPLE_FLAG_FKEY },
+       { KEY_BACKSPACE, KEY_DELETE },
+       { KEY_F1,       KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
+       { KEY_F2,       KEY_BRIGHTNESSUP,   APPLE_FLAG_FKEY },
+       { KEY_F3,       KEY_FN_F5,          APPLE_FLAG_FKEY }, /* Exposé */
+       { KEY_F4,       KEY_FN_F4,          APPLE_FLAG_FKEY }, /* Dashboard */
+       { KEY_F7,       KEY_PREVIOUSSONG,   APPLE_FLAG_FKEY },
+       { KEY_F8,       KEY_PLAYPAUSE,      APPLE_FLAG_FKEY },
+       { KEY_F9,       KEY_NEXTSONG,       APPLE_FLAG_FKEY },
+       { KEY_F10,      KEY_MUTE,           APPLE_FLAG_FKEY },
+       { KEY_F11,      KEY_VOLUMEDOWN,     APPLE_FLAG_FKEY },
+       { KEY_F12,      KEY_VOLUMEUP,       APPLE_FLAG_FKEY },
+       { KEY_UP,       KEY_PAGEUP },
+       { KEY_DOWN,     KEY_PAGEDOWN },
+       { KEY_LEFT,     KEY_HOME },
+       { KEY_RIGHT,    KEY_END },
        { }
 };
 
@@ -177,7 +173,7 @@ static struct hidinput_key_translation *find_translation(struct hidinput_key_tra
        return NULL;
 }
 
-static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
+int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
                struct hid_usage *usage, __s32 value)
 {
        struct hidinput_key_translation *trans;
@@ -220,8 +216,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
                        }
                }
 
-               if (test_bit(usage->code, hid->pb_pressed_numlock) ||
-                               test_bit(LED_NUML, input->led)) {
+               if (hid->quirks & HID_QUIRK_APPLE_NUMLOCK_EMULATION && (
+                               test_bit(usage->code, hid->pb_pressed_numlock) ||
+                               test_bit(LED_NUML, input->led))) {
                        trans = find_translation(powerbook_numlock_keys, usage->code);
 
                        if (trans) {
@@ -269,7 +266,7 @@ static void hidinput_apple_setup(struct input_dev *input)
 
 }
 #else
-static inline int hidinput_apple_event(struct hid_device *hid,
+inline int hidinput_apple_event(struct hid_device *hid,
                                       struct input_dev *input,
                                       struct hid_usage *usage, __s32 value)
 {
@@ -386,7 +383,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                goto ignore;
        }
 
-       ret = hidinput_mapping_quirks(usage, input, bit, &max);
+       /* handle input mappings for quirky devices */
+       ret = hidinput_mapping_quirks(usage, input, &bit, &max);
        if (ret)
                goto mapped;
 
@@ -857,37 +855,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
        if (!usage->type)
                return;
 
-       if (((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005))
-               || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) {
-               if (value) hid->quirks |=  HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
-               else       hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
-               return;
-       }
-
-       if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
-                       (usage->type == EV_REL) &&
-                       (usage->code == REL_WHEEL)) {
-               hid->delayed_value = value;
-               return;
-       }
-
-       if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
-                       (usage->hid == 0x000100b8)) {
-               input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
-               return;
-       }
-
-       if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
-               input_event(input, usage->type, usage->code, -value);
-               return;
-       }
-
-       if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
-               input_event(input, usage->type, REL_HWHEEL, value);
-               return;
-       }
-
-       if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
+       /* handle input events for quirky devices */
+       if (hidinput_event_quirks(hid, field, usage, value))
                return;
 
        if (usage->hat_min < usage->hat_max || usage->hat_dir) {
@@ -949,25 +918,6 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                return;
        }
 
-       /* Handling MS keyboards special buttons */
-       if (IS_MS_KB(hid) && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
-               int key = 0;
-               static int last_key = 0;
-               switch (value) {
-                       case 0x01: key = KEY_F14; break;
-                       case 0x02: key = KEY_F15; break;
-                       case 0x04: key = KEY_F16; break;
-                       case 0x08: key = KEY_F17; break;
-                       case 0x10: key = KEY_F18; break;
-                       default: break;
-               }
-               if (key) {
-                       input_event(input, usage->type, key, 1);
-                       last_key = key;
-               } else {
-                       input_event(input, usage->type, last_key, 0);
-               }
-       }
        /* report the usage code as scancode if the key status has changed */
        if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
                input_event(input, EV_MSC, MSC_SCAN, usage->hid);