2 * HID-input usage mapping quirks
4 * This is used to handle HID-input mappings for devices violating
5 * HUT 1.12 specification.
7 * Copyright (c) 2007-2008 Jiri Kosina
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License
16 #include <linux/input.h>
17 #include <linux/hid.h>
19 #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, bit, \
22 static int quirk_gyration_remote(struct hid_usage
*usage
,
23 struct hid_input
*hidinput
, unsigned long **bit
, int *max
)
25 if ((usage
->hid
& HID_USAGE_PAGE
) != HID_UP_LOGIVENDOR
)
28 set_bit(EV_REP
, hidinput
->input
->evbit
);
29 switch(usage
->hid
& HID_USAGE
) {
30 /* Reported on Gyration MCE Remote */
31 case 0x00d: map_key_clear(KEY_HOME
); break;
32 case 0x024: map_key_clear(KEY_DVD
); break;
33 case 0x025: map_key_clear(KEY_PVR
); break;
34 case 0x046: map_key_clear(KEY_MEDIA
); break;
35 case 0x047: map_key_clear(KEY_MP3
); break;
36 case 0x049: map_key_clear(KEY_CAMERA
); break;
37 case 0x04a: map_key_clear(KEY_VIDEO
); break;
45 static int quirk_petalynx_remote(struct hid_usage
*usage
,
46 struct hid_input
*hidinput
, unsigned long **bit
, int *max
)
48 if (((usage
->hid
& HID_USAGE_PAGE
) != HID_UP_LOGIVENDOR
) &&
49 ((usage
->hid
& HID_USAGE_PAGE
) != HID_UP_CONSUMER
))
52 if ((usage
->hid
& HID_USAGE_PAGE
) == HID_UP_LOGIVENDOR
)
53 switch(usage
->hid
& HID_USAGE
) {
54 case 0x05a: map_key_clear(KEY_TEXT
); break;
55 case 0x05b: map_key_clear(KEY_RED
); break;
56 case 0x05c: map_key_clear(KEY_GREEN
); break;
57 case 0x05d: map_key_clear(KEY_YELLOW
); break;
58 case 0x05e: map_key_clear(KEY_BLUE
); break;
63 if ((usage
->hid
& HID_USAGE_PAGE
) == HID_UP_CONSUMER
)
64 switch(usage
->hid
& HID_USAGE
) {
65 case 0x0f6: map_key_clear(KEY_NEXT
); break;
66 case 0x0fa: map_key_clear(KEY_BACK
); break;
73 static int quirk_cherry_genius_29e(struct hid_usage
*usage
,
74 struct hid_input
*hidinput
, unsigned long **bit
, int *max
)
76 if ((usage
->hid
& HID_USAGE_PAGE
) != HID_UP_CONSUMER
)
79 switch (usage
->hid
& HID_USAGE
) {
80 case 0x156: map_key_clear(KEY_WORDPROCESSOR
); break;
81 case 0x157: map_key_clear(KEY_SPREADSHEET
); break;
82 case 0x158: map_key_clear(KEY_PRESENTATION
); break;
83 case 0x15c: map_key_clear(KEY_STOP
); break;
91 #define VENDOR_ID_GYRATION 0x0c16
92 #define DEVICE_ID_GYRATION_REMOTE 0x0002
94 #define VENDOR_ID_MONTEREY 0x0566
95 #define DEVICE_ID_GENIUS_KB29E 0x3004
97 #define VENDOR_ID_PETALYNX 0x18b1
98 #define DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
100 static const struct hid_input_blacklist
{
103 int (*quirk
)(struct hid_usage
*, struct hid_input
*, unsigned long **,
105 } hid_input_blacklist
[] = {
106 { VENDOR_ID_GYRATION
, DEVICE_ID_GYRATION_REMOTE
, quirk_gyration_remote
},
108 { VENDOR_ID_MONTEREY
, DEVICE_ID_GENIUS_KB29E
, quirk_cherry_genius_29e
},
110 { VENDOR_ID_PETALYNX
, DEVICE_ID_PETALYNX_MAXTER_REMOTE
, quirk_petalynx_remote
},
115 int hidinput_mapping_quirks(struct hid_usage
*usage
,
116 struct hid_input
*hi
, unsigned long **bit
, int *max
)
118 struct hid_device
*device
= input_get_drvdata(hi
->input
);
121 while (hid_input_blacklist
[i
].quirk
) {
122 if (hid_input_blacklist
[i
].idVendor
== device
->vendor
&&
123 hid_input_blacklist
[i
].idProduct
== device
->product
)
124 return hid_input_blacklist
[i
].quirk(usage
, hi
, bit
,
131 int hidinput_event_quirks(struct hid_device
*hid
, struct hid_field
*field
, struct hid_usage
*usage
, __s32 value
)
133 struct input_dev
*input
;
135 input
= field
->hidinput
->input
;
137 /* Gyration MCE remote "Sleep" key */
138 if (hid
->vendor
== VENDOR_ID_GYRATION
&&
139 hid
->product
== DEVICE_ID_GYRATION_REMOTE
&&
140 (usage
->hid
& HID_USAGE_PAGE
) == HID_UP_GENDESK
&&
141 (usage
->hid
& 0xff) == 0x82) {
142 input_event(input
, usage
->type
, usage
->code
, 1);
144 input_event(input
, usage
->type
, usage
->code
, 0);