Hello, this patch fixes two issues with autocentering in lgff driver. Current implementation incorrectly assumes that the saturation force is always 0x80 which is inconsistent with behavior of the official driver. It also makes it impossible to disable autocentering on some wheels - at least Logitech Formula Force RX is the case. Values of stiffness coefficient were also calculated incorrectly. Formula used in this patch appears to generate the same commands as the official Logitech drivers. The patch also fixes two minor coding style issues. Regards, Michal. Signed-off-by: Michal Malý <madcatxster@xxxxxxxxx> --- drivers/hid/hid-lgff.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c index 088f850..3d30a8e 100644 --- a/drivers/hid/hid-lgff.c +++ b/drivers/hid/hid-lgff.c @@ -129,18 +129,24 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude) 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); __s32 *value = report->field[0]->value; - magnitude = (magnitude >> 12) & 0xf; + u8 saturation_force = magnitude >> 8; + u8 stiffness_coeff; + if (magnitude <= 32768) + stiffness_coeff = saturation_force / 10; + else + stiffness_coeff = (saturation_force / 62) + 11; + *value++ = 0xfe; *value++ = 0x0d; - *value++ = magnitude; /* clockwise strength */ - *value++ = magnitude; /* counter-clockwise strength */ - *value++ = 0x80; + *value++ = stiffness_coeff; /* clockwise strength */ + *value++ = stiffness_coeff; /* counter-clockwise strength */ + *value++ = saturation_force; *value++ = 0x00; *value = 0x00; usbhid_submit_report(hid, report, USB_DIR_OUT); } -int lgff_init(struct hid_device* hid) +int lgff_init(struct hid_device *hid) { struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; @@ -180,7 +186,7 @@ int lgff_init(struct hid_device* hid) if (error) return error; - if ( test_bit(FF_AUTOCENTER, dev->ffbit) ) + if (test_bit(FF_AUTOCENTER, dev->ffbit)) dev->ff->set_autocenter = hid_lgff_set_autocenter; pr_info("Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@xxxxxxxx>\n"); -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html