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 \n");