aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergei Kolzun <x0r@dv-life.ru>2011-08-04 03:25:57 -0400
committerJiri Kosina <jkosina@suse.cz>2011-08-04 09:25:34 -0400
commitb55ebc27b0a54ff4cdbfdcb218a85f96e502db3c (patch)
tree5466444843c59c434eafa7f56a1cecd659d1d9a6
parent364b936fc38dec7653c690d710e10657af235a36 (diff)
HID: ACRUX - handle gamepads with different report layout
There are gamepads that share the same VID and PID but have different report structure - instead of having 4 fields with one value they have one field that can hold all 4 values. Make the driver cope with devices using both styles. Signed-off-by: Sergei Kolzun <x0r@dv-life.ru> Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-axff.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/hid/hid-axff.c b/drivers/hid/hid-axff.c
index 121514149e0b..3bdb4500f95e 100644
--- a/drivers/hid/hid-axff.c
+++ b/drivers/hid/hid-axff.c
@@ -6,7 +6,7 @@
6 * Xbox 360 controller. 6 * Xbox 360 controller.
7 * 7 *
8 * 1a34:0802 "ACRUX USB GAMEPAD 8116" 8 * 1a34:0802 "ACRUX USB GAMEPAD 8116"
9 * - tested with a EXEQ EQ-PCU-02090 game controller. 9 * - tested with an EXEQ EQ-PCU-02090 game controller.
10 * 10 *
11 * Copyright (c) 2010 Sergei Kolzun <x0r@dv-life.ru> 11 * Copyright (c) 2010 Sergei Kolzun <x0r@dv-life.ru>
12 */ 12 */
@@ -45,7 +45,10 @@ static int axff_play(struct input_dev *dev, void *data, struct ff_effect *effect
45{ 45{
46 struct hid_device *hid = input_get_drvdata(dev); 46 struct hid_device *hid = input_get_drvdata(dev);
47 struct axff_device *axff = data; 47 struct axff_device *axff = data;
48 struct hid_report *report = axff->report;
49 int field_count = 0;
48 int left, right; 50 int left, right;
51 int i, j;
49 52
50 left = effect->u.rumble.strong_magnitude; 53 left = effect->u.rumble.strong_magnitude;
51 right = effect->u.rumble.weak_magnitude; 54 right = effect->u.rumble.weak_magnitude;
@@ -55,10 +58,14 @@ static int axff_play(struct input_dev *dev, void *data, struct ff_effect *effect
55 left = left * 0xff / 0xffff; 58 left = left * 0xff / 0xffff;
56 right = right * 0xff / 0xffff; 59 right = right * 0xff / 0xffff;
57 60
58 axff->report->field[0]->value[0] = left; 61 for (i = 0; i < report->maxfield; i++) {
59 axff->report->field[1]->value[0] = right; 62 for (j = 0; j < report->field[i]->report_count; j++) {
60 axff->report->field[2]->value[0] = left; 63 report->field[i]->value[j] =
61 axff->report->field[3]->value[0] = right; 64 field_count % 2 ? right : left;
65 field_count++;
66 }
67 }
68
62 dbg_hid("running with 0x%02x 0x%02x", left, right); 69 dbg_hid("running with 0x%02x 0x%02x", left, right);
63 usbhid_submit_report(hid, axff->report, USB_DIR_OUT); 70 usbhid_submit_report(hid, axff->report, USB_DIR_OUT);
64 71
@@ -72,6 +79,8 @@ static int axff_init(struct hid_device *hid)
72 struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list); 79 struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
73 struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list; 80 struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list;
74 struct input_dev *dev = hidinput->input; 81 struct input_dev *dev = hidinput->input;
82 int field_count = 0;
83 int i, j;
75 int error; 84 int error;
76 85
77 if (list_empty(report_list)) { 86 if (list_empty(report_list)) {
@@ -80,9 +89,16 @@ static int axff_init(struct hid_device *hid)
80 } 89 }
81 90
82 report = list_first_entry(report_list, struct hid_report, list); 91 report = list_first_entry(report_list, struct hid_report, list);
92 for (i = 0; i < report->maxfield; i++) {
93 for (j = 0; j < report->field[i]->report_count; j++) {
94 report->field[i]->value[j] = 0x00;
95 field_count++;
96 }
97 }
83 98
84 if (report->maxfield < 4) { 99 if (field_count < 4) {
85 hid_err(hid, "no fields in the report: %d\n", report->maxfield); 100 hid_err(hid, "not enough fields in the report: %d\n",
101 field_count);
86 return -ENODEV; 102 return -ENODEV;
87 } 103 }
88 104
@@ -97,13 +113,9 @@ static int axff_init(struct hid_device *hid)
97 goto err_free_mem; 113 goto err_free_mem;
98 114
99 axff->report = report; 115 axff->report = report;
100 axff->report->field[0]->value[0] = 0x00;
101 axff->report->field[1]->value[0] = 0x00;
102 axff->report->field[2]->value[0] = 0x00;
103 axff->report->field[3]->value[0] = 0x00;
104 usbhid_submit_report(hid, axff->report, USB_DIR_OUT); 116 usbhid_submit_report(hid, axff->report, USB_DIR_OUT);
105 117
106 hid_info(hid, "Force Feedback for ACRUX game controllers by Sergei Kolzun<x0r@dv-life.ru>\n"); 118 hid_info(hid, "Force Feedback for ACRUX game controllers by Sergei Kolzun <x0r@dv-life.ru>\n");
107 119
108 return 0; 120 return 0;
109 121