From 2b24a960016b8d3221a6dd2764ab97247c48dd97 Mon Sep 17 00:00:00 2001 From: Michal Malý Date: Sun, 23 Sep 2012 22:41:08 +0200 Subject: HID: hid-lg4ff: Adjust X axis input value accordingly to selected range. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Range limiting command for the Driving Force Pro wheel is only a FF_SPRING effect so that the wheel creates resistance when the user tries to turn it past the limit. It is however possible to overpower the FFB motors quite easily which leads to the X axis value exceeding the expected limit. This confuses games which dynamically adjust calibration using the highest/lowest min and max values reported by the wheel. Joydev device driver also doesn't take in account any changes in an axis range after the joystick device is created. This patch recalculates received ABS_X axis value so it is always in <0; 16383> range where 0 is the left limit and 16383 the right limit. Logitech driver for Windows does the same thing. As for any concerns about possible loss of precision, I compared a large set of raw/adjusted values generated by "mult_frac" to values returned by the Windows driver and I got a 100% match. Other Logitech wheels will probably need a similar fix, but I currently lack the information needed to write one. Signed-off-by: Michal Malý Signed-off-by: Jiri Kosina --- drivers/hid/hid-lg.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/hid/hid-lg.c') diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index fc37ed6b108c..760b30bc2734 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c @@ -342,6 +342,9 @@ static int lg_event(struct hid_device *hdev, struct hid_field *field, -value); return 1; } + if (drv_data->quirks & LG_FF4) { + return lg4ff_adjust_input_event(hdev, field, usage, value, drv_data); + } return 0; } -- cgit v1.2.3-59-g8ed1b