linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel
@ 2013-11-06 19:30 Simon Wood
  2013-11-06 19:30 ` [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero Simon Wood
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Simon Wood @ 2013-11-06 19:30 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-kernel, simon, Elias Vanderstuyft,
	Michal Malý

Adjust the scaling and lineartity to match that of the Windows
driver (from MOMO testing).

Reported-by: Elias Vanderstuyft <elias.vds@gmail.com>
Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 8782fe1..530fcd19 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -218,12 +218,21 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
 	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;
+	__u32 expand_a, expand_b;
+
+	if (magnitude <= 0xaaaa) {
+		expand_a = 0x0c * magnitude;
+		expand_b = 0x80 * magnitude;
+	} else {
+		expand_a = (0x0c * 0xaaaa) + 0x06 * (magnitude - 0xaaaa);
+		expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa);
+	}
 
 	value[0] = 0xfe;
 	value[1] = 0x0d;
-	value[2] = magnitude >> 13;
-	value[3] = magnitude >> 13;
-	value[4] = magnitude >> 8;
+	value[2] = expand_a / 0xaaaa;
+	value[3] = expand_a / 0xaaaa;
+	value[4] = expand_b / 0xaaaa;
 	value[5] = 0x00;
 	value[6] = 0x00;
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-11-08 15:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
2013-11-06 19:30 ` [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero Simon Wood
2013-11-06 19:30 ` [PATCH 3/5] HID:hid-lg4ff: ensure ConstantForce is disabled when set to 0 Simon Wood
2013-11-06 19:30 ` [PATCH 4/5] HID:hid-lg4ff: Initialize device properties before we touch autocentering Simon Wood
2013-11-06 19:30 ` [PATCH 5/5] HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2 Simon Wood
2013-11-08 13:14 ` [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Jiri Kosina
2013-11-08 15:54   ` simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).