summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-lg4ff.c
diff options
context:
space:
mode:
authorSimon Wood <simon@mungewell.org>2013-11-06 12:30:44 -0700
committerJiri Kosina <jkosina@suse.cz>2013-11-08 14:12:08 +0100
commit1859762ed538477fc80ada926571d12dc4c9c062 (patch)
tree2aa6f13f66d7c090f430b48cf00b00083d51e035 /drivers/hid/hid-lg4ff.c
parent114a55cf9dd1576e7ac56189832cd4d7dc56c218 (diff)
HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2
The MOMO and MOMO2 wheels have a slightly different autocenter command, and accept values in the range 0..F (rather than 0..7 for the other wheels). This patch uses the product ID to determine how to compute the strength. 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.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 5492809a579f..befe0e336471 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -234,6 +234,20 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
__s32 *value = report->field[0]->value;
__u32 expand_a, expand_b;
+ struct lg4ff_device_entry *entry;
+ struct lg_drv_data *drv_data;
+
+ drv_data = hid_get_drvdata(hid);
+ if (!drv_data) {
+ hid_err(hid, "Private driver data not found!\n");
+ return;
+ }
+
+ entry = drv_data->device_props;
+ if (!entry) {
+ hid_err(hid, "Device properties not found!\n");
+ return;
+ }
/* De-activate Auto-Center */
if (magnitude == 0) {
@@ -257,6 +271,16 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa);
}
+ /* Adjust for non-MOMO wheels */
+ switch (entry->product_id) {
+ case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
+ case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
+ break;
+ default:
+ expand_a = expand_a >> 1;
+ break;
+ }
+
value[0] = 0xfe;
value[1] = 0x0d;
value[2] = expand_a / 0xaaaa;