aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-input.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2007-11-23 07:16:02 -0500
committerJiri Kosina <jkosina@suse.cz>2008-01-28 08:51:20 -0500
commit87bc2aa9933afc032a93490e1642918121e7470b (patch)
treefc09fa3c536a9f9a4dcfc7a6c58ea4551f6c1811 /drivers/hid/hid-input.c
parent10bd065facb2594bd508597ef464d401b212f379 (diff)
HID: separate hid-input event quirks from generic code
This patch separates also the hid-input quirks that have to be applied at the time the event occurs, so that the generic code handling HUT-compliant devices is not messed up by them too much. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r--drivers/hid/hid-input.c63
1 files changed, 5 insertions, 58 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 3d448037c82f..aeb018e31bfc 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -86,11 +86,6 @@ static const struct {
86#define map_abs_clear(c) do { map_abs(c); clear_bit(c, bit); } while (0) 86#define map_abs_clear(c) do { map_abs(c); clear_bit(c, bit); } while (0)
87#define map_key_clear(c) do { map_key(c); clear_bit(c, bit); } while (0) 87#define map_key_clear(c) do { map_key(c); clear_bit(c, bit); } while (0)
88 88
89/* hardware needing special handling due to colliding MSVENDOR page usages */
90#define IS_CHICONY_TACTICAL_PAD(x) (x->vendor == 0x04f2 && device->product == 0x0418)
91#define IS_MS_KB(x) (x->vendor == 0x045e && (x->product == 0x00db || x->product == 0x00f9))
92#define IS_MS_PRESENTER_8000(x) (x->vendor == 0x045e && x->product == 0x0713)
93
94#ifdef CONFIG_USB_HIDINPUT_POWERBOOK 89#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
95 90
96struct hidinput_key_translation { 91struct hidinput_key_translation {
@@ -177,7 +172,7 @@ static struct hidinput_key_translation *find_translation(struct hidinput_key_tra
177 return NULL; 172 return NULL;
178} 173}
179 174
180static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, 175int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
181 struct hid_usage *usage, __s32 value) 176 struct hid_usage *usage, __s32 value)
182{ 177{
183 struct hidinput_key_translation *trans; 178 struct hidinput_key_translation *trans;
@@ -269,7 +264,7 @@ static void hidinput_apple_setup(struct input_dev *input)
269 264
270} 265}
271#else 266#else
272static inline int hidinput_apple_event(struct hid_device *hid, 267inline int hidinput_apple_event(struct hid_device *hid,
273 struct input_dev *input, 268 struct input_dev *input,
274 struct hid_usage *usage, __s32 value) 269 struct hid_usage *usage, __s32 value)
275{ 270{
@@ -386,6 +381,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
386 goto ignore; 381 goto ignore;
387 } 382 }
388 383
384 /* handle input mappings for quirky devices */
389 ret = hidinput_mapping_quirks(usage, input, bit, &max); 385 ret = hidinput_mapping_quirks(usage, input, bit, &max);
390 if (ret) 386 if (ret)
391 goto mapped; 387 goto mapped;
@@ -857,38 +853,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
857 if (!usage->type) 853 if (!usage->type)
858 return; 854 return;
859 855
860 if (((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005)) 856 /* handle input events for quirky devices */
861 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) { 857 hidinput_event_quirks(hid, field, usage, value);
862 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
863 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
864 return;
865 }
866
867 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
868 (usage->type == EV_REL) &&
869 (usage->code == REL_WHEEL)) {
870 hid->delayed_value = value;
871 return;
872 }
873
874 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
875 (usage->hid == 0x000100b8)) {
876 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
877 return;
878 }
879
880 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
881 input_event(input, usage->type, usage->code, -value);
882 return;
883 }
884
885 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
886 input_event(input, usage->type, REL_HWHEEL, value);
887 return;
888 }
889
890 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
891 return;
892 858
893 if (usage->hat_min < usage->hat_max || usage->hat_dir) { 859 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
894 int hat_dir = usage->hat_dir; 860 int hat_dir = usage->hat_dir;
@@ -949,25 +915,6 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
949 return; 915 return;
950 } 916 }
951 917
952 /* Handling MS keyboards special buttons */
953 if (IS_MS_KB(hid) && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
954 int key = 0;
955 static int last_key = 0;
956 switch (value) {
957 case 0x01: key = KEY_F14; break;
958 case 0x02: key = KEY_F15; break;
959 case 0x04: key = KEY_F16; break;
960 case 0x08: key = KEY_F17; break;
961 case 0x10: key = KEY_F18; break;
962 default: break;
963 }
964 if (key) {
965 input_event(input, usage->type, key, 1);
966 last_key = key;
967 } else {
968 input_event(input, usage->type, last_key, 0);
969 }
970 }
971 /* report the usage code as scancode if the key status has changed */ 918 /* report the usage code as scancode if the key status has changed */
972 if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value) 919 if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
973 input_event(input, EV_MSC, MSC_SCAN, usage->hid); 920 input_event(input, EV_MSC, MSC_SCAN, usage->hid);