Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485869

[Patch-V2 3/6] HID:hid-logitech: Compute combined pedals value

From Simon Wood <gitsend@mungewell.org>
Newsgroups linux.kernel
Subject [Patch-V2 3/6] HID:hid-logitech: Compute combined pedals value
Date 2016-09-18 19:00 +0200
Message-ID <siNBE-26i-43@gated-at.bofh.it> (permalink)
References <sfCW5-tE-7@gated-at.bofh.it> <siNBD-26i-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add support for computing a combined accelerator/brake axis for wheels
which don't contain combined data in their HID stream.

This includes DFGT, G25, G27, G29 and Wii-Wheel.

Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 79d34c2..cc5c9ebd 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -332,6 +332,7 @@ int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
 int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
 		u8 *rd, int size, struct lg_drv_data *drv_data)
 {
+	int offset;
 	struct lg4ff_device_entry *entry = drv_data->device_props;
 
 	if (!entry)
@@ -353,9 +354,25 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
 			rd[5] = rd[4];
 			rd[6] = 0x7F;
 			return 1;
+		case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
+		case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
+			offset = 5;
+			break;
+		case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
+		case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
+			offset = 6;
+			break;
+		case USB_DEVICE_ID_LOGITECH_WII_WHEEL:
+			offset = 3;
+			break;
 		default:
 			return 0;
 		}
+
+		/* Compute a combined axis when wheel does not supply it */
+		rd[offset] = (0xFF + rd[offset] - rd[offset+1]) >> 1;
+		rd[offset+1] = 0x7F;
+		return 1;
 	}
 
 	return 0;
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/5] HID:hid-logitech: Introduce dev_attr for combined pedals feature Simon Wood <gitsend@mungewell.org> - 2016-09-10 01:00 +0200
  [PATCH 5/5] HID:hid-logitech: Documentation updates/corrections Simon Wood <gitsend@mungewell.org> - 2016-09-10 01:00 +0200
  [PATCH 3/5] HID:hid-logitech: Compute combined pedals if not supplied Simon Wood <gitsend@mungewell.org> - 2016-09-10 01:00 +0200
  [Patch-V2 2/6] HID:hid-logitech: Add combined pedal support Logitech wheels Simon Wood <gitsend@mungewell.org> - 2016-09-18 19:00 +0200
  [Patch-V2 4/6] HID:hid-logitech: Rewrite of descriptor for all DF wheels Simon Wood <gitsend@mungewell.org> - 2016-09-18 19:00 +0200
  [Patch-V2 6/6] HID:hid-logitech: Documentation updates/corrections Simon Wood <gitsend@mungewell.org> - 2016-09-18 19:00 +0200
  [Patch-V2 1/6] HID:hid-logitech: Introduce control for combined pedals feature Simon Wood <gitsend@mungewell.org> - 2016-09-18 19:00 +0200
    [Patch-V2 3/6] HID:hid-logitech: Compute combined pedals value Simon Wood <gitsend@mungewell.org> - 2016-09-18 19:00 +0200
    [Patch-V2 5/6] HID:hid-logitech: Improve Wingman Formula Force GP support Simon Wood <gitsend@mungewell.org> - 2016-09-18 19:00 +0200

csiph-web