linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wood <gitsend@mungewell.org>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Jiri Kosina <jkosina@suse.cz>,
	Edwin Velds <edwin@velds.nl>,
	Elias Vanderstuyft <elias.vds@gmail.com>,
	Michal Maly <madcatxster@gmail.com>,
	Simon Wood <simon@mungewell.org>
Subject: [PATCH 2/5] HID:hid-logitech: Add combined pedal support Logitech wheels
Date: Fri,  9 Sep 2016 16:50:46 -0600	[thread overview]
Message-ID: <1473461449-8060-2-git-send-email-simon@mungewell.org> (raw)
In-Reply-To: <1473461449-8060-1-git-send-email-simon@mungewell.org>

Add support for reporting a combined accelerator/brake axis for wheels
which contain combined data in their HID stream.

This includes DF, MOMO, MOMO2 and DFP.

Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg.c    | 12 ++++++++++++
 drivers/hid/hid-lg4ff.c | 32 ++++++++++++++++++++++++++++++++
 drivers/hid/hid-lg4ff.h |  4 ++++
 3 files changed, 48 insertions(+)

diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index feb2be7..06f8a5e 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -657,6 +657,17 @@ static int lg_event(struct hid_device *hdev, struct hid_field *field,
 	return 0;
 }
 
+static int lg_raw_event(struct hid_device *hdev, struct hid_report *report,
+		u8 *rd, int size)
+{
+	struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
+
+	if (drv_data->quirks & LG_FF4)
+		return lg4ff_raw_event(hdev, report, rd, size, drv_data);
+
+	return 0;
+}
+
 static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
 	struct usb_interface *iface = to_usb_interface(hdev->dev.parent);
@@ -830,6 +841,7 @@ static struct hid_driver lg_driver = {
 	.input_mapping = lg_input_mapping,
 	.input_mapped = lg_input_mapped,
 	.event = lg_event,
+	.raw_event = lg_raw_event,
 	.probe = lg_probe,
 	.remove = lg_remove,
 };
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index ca31ce4..79d34c2 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -329,6 +329,38 @@ 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)
+{
+	struct lg4ff_device_entry *entry = drv_data->device_props;
+
+	if (!entry)
+		return 0;
+
+	/* adjust HID report present combined pedals data */
+	if (entry->wdata.combine) {
+		switch (entry->wdata.product_id) {
+		case USB_DEVICE_ID_LOGITECH_WHEEL:
+			rd[5] = rd[3];
+			rd[6] = 0x7F;
+			return 1;
+		case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
+		case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
+			rd[4] = rd[3];
+			rd[5] = 0x7F;
+			return 1;
+		case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
+			rd[5] = rd[4];
+			rd[6] = 0x7F;
+			return 1;
+		default:
+			return 0;
+		}
+	}
+
+	return 0;
+}
+
 static void lg4ff_init_wheel_data(struct lg4ff_wheel_data * const wdata, const struct lg4ff_wheel *wheel,
 				  const struct lg4ff_multimode_wheel *mmode_wheel,
 				  const u16 real_product_id)
diff --git a/drivers/hid/hid-lg4ff.h b/drivers/hid/hid-lg4ff.h
index 66201af..de1f350 100644
--- a/drivers/hid/hid-lg4ff.h
+++ b/drivers/hid/hid-lg4ff.h
@@ -6,11 +6,15 @@ extern int lg4ff_no_autoswitch; /* From hid-lg.c */
 
 int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
 			     struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data);
+int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
+		u8 *rd, int size, struct lg_drv_data *drv_data);
 int lg4ff_init(struct hid_device *hdev);
 int lg4ff_deinit(struct hid_device *hdev);
 #else
 static inline int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
 					   struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data) { return 0; }
+static inline int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
+		u8 *rd, int size, struct lg_drv_data *drv_data) { return 0; }
 static inline int lg4ff_init(struct hid_device *hdev) { return -1; }
 static inline int lg4ff_deinit(struct hid_device *hdev) { return -1; }
 #endif
-- 
2.7.4

  reply	other threads:[~2016-09-09 22:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 22:50 [PATCH 1/5] HID:hid-logitech: Introduce dev_attr for combined pedals feature Simon Wood
2016-09-09 22:50 ` Simon Wood [this message]
2016-09-09 22:50 ` [PATCH 3/5] HID:hid-logitech: Compute combined pedals if not supplied Simon Wood
2016-09-09 22:50 ` [PATCH 4/5] HID:hid-logitech: Rewrite of descriptor for all DF wheels Simon Wood
2016-09-10  1:34   ` kbuild test robot
2016-09-14 18:55   ` Simon Wood
2016-09-09 22:50 ` [PATCH 5/5] HID:hid-logitech: Documentation updates/corrections Simon Wood
2016-09-18 16:55 ` [Patch-V2 1/6] HID:hid-logitech: Introduce control for combined pedals feature Simon Wood
2016-09-18 16:55   ` [Patch-V2 2/6] HID:hid-logitech: Add combined pedal support Logitech wheels Simon Wood
2016-09-18 16:55   ` [Patch-V2 3/6] HID:hid-logitech: Compute combined pedals value Simon Wood
2016-09-18 16:55   ` [Patch-V2 4/6] HID:hid-logitech: Rewrite of descriptor for all DF wheels Simon Wood
2016-09-18 16:55   ` [Patch-V2 5/6] HID:hid-logitech: Improve Wingman Formula Force GP support Simon Wood
2016-09-18 16:55   ` [Patch-V2 6/6] HID:hid-logitech: Documentation updates/corrections Simon Wood
2016-09-26 13:41   ` [Patch-V2 1/6] HID:hid-logitech: Introduce control for combined pedals feature Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473461449-8060-2-git-send-email-simon@mungewell.org \
    --to=gitsend@mungewell.org \
    --cc=edwin@velds.nl \
    --cc=elias.vds@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madcatxster@gmail.com \
    --cc=simon@mungewell.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).