aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-a4tech.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-a4tech.c')
-rw-r--r--drivers/hid/hid-a4tech.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
index 98bf694626f7..3a8c4a5971f7 100644
--- a/drivers/hid/hid-a4tech.c
+++ b/drivers/hid/hid-a4tech.c
@@ -23,12 +23,36 @@
23#define A4_2WHEEL_MOUSE_HACK_7 0x01 23#define A4_2WHEEL_MOUSE_HACK_7 0x01
24#define A4_2WHEEL_MOUSE_HACK_B8 0x02 24#define A4_2WHEEL_MOUSE_HACK_B8 0x02
25 25
26#define A4_WHEEL_ORIENTATION (HID_UP_GENDESK | 0x000000b8)
27
26struct a4tech_sc { 28struct a4tech_sc {
27 unsigned long quirks; 29 unsigned long quirks;
28 unsigned int hw_wheel; 30 unsigned int hw_wheel;
29 __s32 delayed_value; 31 __s32 delayed_value;
30}; 32};
31 33
34static int a4_input_mapping(struct hid_device *hdev, struct hid_input *hi,
35 struct hid_field *field, struct hid_usage *usage,
36 unsigned long **bit, int *max)
37{
38 struct a4tech_sc *a4 = hid_get_drvdata(hdev);
39
40 if (a4->quirks & A4_2WHEEL_MOUSE_HACK_B8 &&
41 usage->hid == A4_WHEEL_ORIENTATION) {
42 /*
43 * We do not want to have this usage mapped to anything as it's
44 * nonstandard and doesn't really behave like an HID report.
45 * It's only selecting the orientation (vertical/horizontal) of
46 * the previous mouse wheel report. The input_events will be
47 * generated once both reports are recorded in a4_event().
48 */
49 return -1;
50 }
51
52 return 0;
53
54}
55
32static int a4_input_mapped(struct hid_device *hdev, struct hid_input *hi, 56static int a4_input_mapped(struct hid_device *hdev, struct hid_input *hi,
33 struct hid_field *field, struct hid_usage *usage, 57 struct hid_field *field, struct hid_usage *usage,
34 unsigned long **bit, int *max) 58 unsigned long **bit, int *max)
@@ -52,8 +76,7 @@ static int a4_event(struct hid_device *hdev, struct hid_field *field,
52 struct a4tech_sc *a4 = hid_get_drvdata(hdev); 76 struct a4tech_sc *a4 = hid_get_drvdata(hdev);
53 struct input_dev *input; 77 struct input_dev *input;
54 78
55 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || 79 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput)
56 !usage->type)
57 return 0; 80 return 0;
58 81
59 input = field->hidinput->input; 82 input = field->hidinput->input;
@@ -64,7 +87,7 @@ static int a4_event(struct hid_device *hdev, struct hid_field *field,
64 return 1; 87 return 1;
65 } 88 }
66 89
67 if (usage->hid == 0x000100b8) { 90 if (usage->hid == A4_WHEEL_ORIENTATION) {
68 input_event(input, EV_REL, value ? REL_HWHEEL : 91 input_event(input, EV_REL, value ? REL_HWHEEL :
69 REL_WHEEL, a4->delayed_value); 92 REL_WHEEL, a4->delayed_value);
70 input_event(input, EV_REL, value ? REL_HWHEEL_HI_RES : 93 input_event(input, EV_REL, value ? REL_HWHEEL_HI_RES :
@@ -131,6 +154,7 @@ MODULE_DEVICE_TABLE(hid, a4_devices);
131static struct hid_driver a4_driver = { 154static struct hid_driver a4_driver = {
132 .name = "a4tech", 155 .name = "a4tech",
133 .id_table = a4_devices, 156 .id_table = a4_devices,
157 .input_mapping = a4_input_mapping,
134 .input_mapped = a4_input_mapped, 158 .input_mapped = a4_input_mapped,
135 .event = a4_event, 159 .event = a4_event,
136 .probe = a4_probe, 160 .probe = a4_probe,