diff options
author | Michal Malý <madcatxster@gmail.com> | 2011-08-04 10:22:07 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-08-04 10:45:55 -0400 |
commit | 6e2de8e0ab238f7ee818c545a7ea97a4fc333e33 (patch) | |
tree | 597ba14698237bcc456819edec972d023ef297c4 /drivers/hid/hid-lg4ff.c | |
parent | 30bb75d71b3732c0adb6297815288ce0fb9cc04c (diff) |
HID: lg4ff - Add autocentering command accepted by Formula Force EX
The Logitech driver sends Formula Force EX wheel a different command to
autocenering force. FFEX will accept the standard command used by the rest of
the wheels, but it won't set the centering properly.
Signed-off-by: Michal Malý <madcatxster@gmail.com>
Signed-off-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-lg4ff.c')
-rw-r--r-- | drivers/hid/hid-lg4ff.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 5c9eef2267e..dc38c2d89df 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c | |||
@@ -157,7 +157,9 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e | |||
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | 159 | ||
160 | static void hid_lg4ff_set_autocenter(struct input_dev *dev, u16 magnitude) | 160 | /* Sends default autocentering command compatible with |
161 | * all wheels except Formula Force EX */ | ||
162 | static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude) | ||
161 | { | 163 | { |
162 | struct hid_device *hid = input_get_drvdata(dev); | 164 | struct hid_device *hid = input_get_drvdata(dev); |
163 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | 165 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
@@ -174,6 +176,26 @@ static void hid_lg4ff_set_autocenter(struct input_dev *dev, u16 magnitude) | |||
174 | usbhid_submit_report(hid, report, USB_DIR_OUT); | 176 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
175 | } | 177 | } |
176 | 178 | ||
179 | /* Sends autocentering command compatible with Formula Force EX */ | ||
180 | static void hid_lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude) | ||
181 | { | ||
182 | struct hid_device *hid = input_get_drvdata(dev); | ||
183 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
184 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); | ||
185 | magnitude = magnitude * 90 / 65535; | ||
186 | |||
187 | |||
188 | report->field[0]->value[0] = 0xfe; | ||
189 | report->field[0]->value[1] = 0x03; | ||
190 | report->field[0]->value[2] = magnitude >> 14; | ||
191 | report->field[0]->value[3] = magnitude >> 14; | ||
192 | report->field[0]->value[4] = magnitude; | ||
193 | report->field[0]->value[5] = 0x00; | ||
194 | report->field[0]->value[6] = 0x00; | ||
195 | |||
196 | usbhid_submit_report(hid, report, USB_DIR_OUT); | ||
197 | } | ||
198 | |||
177 | /* Sends command to set range compatible with G25/G27/Driving Force GT */ | 199 | /* Sends command to set range compatible with G25/G27/Driving Force GT */ |
178 | static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range) | 200 | static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range) |
179 | { | 201 | { |
@@ -390,8 +412,16 @@ int lg4ff_init(struct hid_device *hid) | |||
390 | if (error) | 412 | if (error) |
391 | return error; | 413 | return error; |
392 | 414 | ||
393 | if (test_bit(FF_AUTOCENTER, dev->ffbit)) | 415 | /* Check if autocentering is available and |
394 | dev->ff->set_autocenter = hid_lg4ff_set_autocenter; | 416 | * set the centering force to zero by default */ |
417 | if (test_bit(FF_AUTOCENTER, dev->ffbit)) { | ||
418 | if(rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN) /* Formula Force EX expects different autocentering command */ | ||
419 | dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex; | ||
420 | else | ||
421 | dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default; | ||
422 | |||
423 | dev->ff->set_autocenter(dev, 0); | ||
424 | } | ||
395 | 425 | ||
396 | /* Initialize device_list if this is the first device to handle by lg4ff */ | 426 | /* Initialize device_list if this is the first device to handle by lg4ff */ |
397 | if (!list_inited) { | 427 | if (!list_inited) { |