aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-input-quirks.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-quirks.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-quirks.c')
-rw-r--r--drivers/hid/hid-input-quirks.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/drivers/hid/hid-input-quirks.c b/drivers/hid/hid-input-quirks.c
index e05e9ad5522e..7f2f80b00d74 100644
--- a/drivers/hid/hid-input-quirks.c
+++ b/drivers/hid/hid-input-quirks.c
@@ -322,5 +322,68 @@ int hidinput_mapping_quirks(struct hid_usage *usage,
322 } 322 }
323 return 0; 323 return 0;
324} 324}
325EXPORT_SYMBOL_GPL(hidinput_mapping_quirks); 325
326#define IS_MS_KB(x) (x->vendor == 0x045e && (x->product == 0x00db || x->product == 0x00f9))
327
328void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
329{
330 struct input_dev *input;
331 unsigned *quirks = &hid->quirks;
332
333 input = field->hidinput->input;
334
335 if (((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005))
336 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) {
337 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
338 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
339 return;
340 }
341
342 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
343 (usage->type == EV_REL) &&
344 (usage->code == REL_WHEEL)) {
345 hid->delayed_value = value;
346 return;
347 }
348
349 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
350 (usage->hid == 0x000100b8)) {
351 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
352 return;
353 }
354
355 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
356 input_event(input, usage->type, usage->code, -value);
357 return;
358 }
359
360 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
361 input_event(input, usage->type, REL_HWHEEL, value);
362 return;
363 }
364
365 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
366 return;
367
368 /* Handling MS keyboards special buttons */
369 if (IS_MS_KB(hid) && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
370 int key = 0;
371 static int last_key = 0;
372 switch (value) {
373 case 0x01: key = KEY_F14; break;
374 case 0x02: key = KEY_F15; break;
375 case 0x04: key = KEY_F16; break;
376 case 0x08: key = KEY_F17; break;
377 case 0x10: key = KEY_F18; break;
378 default: break;
379 }
380 if (key) {
381 input_event(input, usage->type, key, 1);
382 last_key = key;
383 } else {
384 input_event(input, usage->type, last_key, 0);
385 }
386 }
387}
388
326 389