aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMichal Malý <madcatxster@gmail.com>2011-08-04 16:22:07 +0200
committerJiri Kosina <jkosina@suse.cz>2011-08-04 16:45:55 +0200
commit6e2de8e0ab238f7ee818c545a7ea97a4fc333e33 (patch)
tree597ba14698237bcc456819edec972d023ef297c4 /drivers
parent30bb75d71b3732c0adb6297815288ce0fb9cc04c (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')
-rw-r--r--drivers/hid/hid-lg4ff.c36
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
return 0;
}
-static void hid_lg4ff_set_autocenter(struct input_dev *dev, u16 magnitude)
+/* Sends default autocentering command compatible with
+ * all wheels except Formula Force EX */
+static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude)
{
struct hid_device *hid = input_get_drvdata(dev);
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)
usbhid_submit_report(hid, report, USB_DIR_OUT);
}
+/* Sends autocentering command compatible with Formula Force EX */
+static void hid_lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude)
+{
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+ struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
+ magnitude = magnitude * 90 / 65535;
+
+
+ report->field[0]->value[0] = 0xfe;
+ report->field[0]->value[1] = 0x03;
+ report->field[0]->value[2] = magnitude >> 14;
+ report->field[0]->value[3] = magnitude >> 14;
+ report->field[0]->value[4] = magnitude;
+ report->field[0]->value[5] = 0x00;
+ report->field[0]->value[6] = 0x00;
+
+ usbhid_submit_report(hid, report, USB_DIR_OUT);
+}
+
/* Sends command to set range compatible with G25/G27/Driving Force GT */
static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range)
{
@@ -390,8 +412,16 @@ int lg4ff_init(struct hid_device *hid)
if (error)
return error;
- if (test_bit(FF_AUTOCENTER, dev->ffbit))
- dev->ff->set_autocenter = hid_lg4ff_set_autocenter;
+ /* Check if autocentering is available and
+ * set the centering force to zero by default */
+ if (test_bit(FF_AUTOCENTER, dev->ffbit)) {
+ if(rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN) /* Formula Force EX expects different autocentering command */
+ dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex;
+ else
+ dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default;
+
+ dev->ff->set_autocenter(dev, 0);
+ }
/* Initialize device_list if this is the first device to handle by lg4ff */
if (!list_inited) {