All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Praznik <frank.praznik@oh.rr.com>
To: linux-input@vger.kernel.org
Cc: Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 4/4] HID: sony: Map gyroscopes and accelerometers to axes
Date: Thu, 16 Jan 2014 21:43:12 -0500 (EST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1401162137400.15779@franz-virtual-machine> (raw)

Use a modified HID descriptor for the Dualshock 4 to assign the gyroscope
sensors and accelerometers to axes.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>

---

 Apply against jikos/hid.git/for-3.14/sony
 
 drivers/hid/hid-sony.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index a7c8167..225a4cf 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -73,6 +73,73 @@ static const u8 sixaxis_rdesc_fixup2[] = {
 	0xb1, 0x02, 0xc0, 0xc0,
 };
 
+static u8 dualshock4_usb_rdesc[] = {
+	0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01,
+	0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x09, 0x35,
+	0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
+	0x04, 0x81, 0x02, 0x09, 0x39, 0x15, 0x00, 0x25,
+	0x07, 0x35, 0x00, 0x46, 0x3b, 0x01, 0x65, 0x14,
+	0x75, 0x04, 0x95, 0x01, 0x81, 0x42, 0x65, 0x00,
+	0x05, 0x09, 0x19, 0x01, 0x29, 0x0e, 0x15, 0x00,
+	0x25, 0x01, 0x75, 0x01, 0x95, 0x0e, 0x81, 0x02,
+	0x06, 0x00, 0xff, 0x09, 0x20, 0x75, 0x06, 0x95,
+	0x01, 0x15, 0x00, 0x25, 0x7f, 0x81, 0x02, 0x05,
+	0x01, 0x09, 0x33, 0x09, 0x34, 0x15, 0x00, 0x26,
+	0xff, 0x00, 0x75, 0x08, 0x95, 0x02, 0x81, 0x02,
+	0x06, 0x00, 0xff, 0x09, 0x21, 0x95, 0x03, 0x81,
+	0x02, 0x05, 0x01, 0x19, 0x40, 0x29, 0x42, 0x16,
+	0x00, 0x80, 0x26, 0x00, 0x7f, 0x75, 0x10, 0x95,
+	0x03, 0x81, 0x02, 0x05, 0x01, 0x19, 0x43, 0x29,
+	0x45, 0x16, 0xff, 0xbf, 0x26, 0x00, 0x40, 0x95,
+	0x03, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09, 0x21,
+	0x75, 0x08, 0x95, 0x27, 0x81, 0x02, 0x85, 0x05,
+	0x09, 0x22, 0x95, 0x1f, 0x91, 0x02, 0x85, 0x04,
+	0x09, 0x23, 0x95, 0x24, 0xb1, 0x02, 0x85, 0x02,
+	0x09, 0x24, 0x95, 0x24, 0xb1, 0x02, 0x85, 0x08,
+	0x09, 0x25, 0x95, 0x03, 0xb1, 0x02, 0x85, 0x10,
+	0x09, 0x26, 0x95, 0x04, 0xb1, 0x02, 0x85, 0x11,
+	0x09, 0x27, 0x95, 0x02, 0xb1, 0x02, 0x85, 0x12,
+	0x06, 0x02, 0xff, 0x09, 0x21, 0x95, 0x0f, 0xb1,
+	0x02, 0x85, 0x13, 0x09, 0x22, 0x95, 0x16, 0xb1,
+	0x02, 0x85, 0x14, 0x06, 0x05, 0xff, 0x09, 0x20,
+	0x95, 0x10, 0xb1, 0x02, 0x85, 0x15, 0x09, 0x21,
+	0x95, 0x2c, 0xb1, 0x02, 0x06, 0x80, 0xff, 0x85,
+	0x80, 0x09, 0x20, 0x95, 0x06, 0xb1, 0x02, 0x85,
+	0x81, 0x09, 0x21, 0x95, 0x06, 0xb1, 0x02, 0x85,
+	0x82, 0x09, 0x22, 0x95, 0x05, 0xb1, 0x02, 0x85,
+	0x83, 0x09, 0x23, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0x84, 0x09, 0x24, 0x95, 0x04, 0xb1, 0x02, 0x85,
+	0x85, 0x09, 0x25, 0x95, 0x06, 0xb1, 0x02, 0x85,
+	0x86, 0x09, 0x26, 0x95, 0x06, 0xb1, 0x02, 0x85,
+	0x87, 0x09, 0x27, 0x95, 0x23, 0xb1, 0x02, 0x85,
+	0x88, 0x09, 0x28, 0x95, 0x22, 0xb1, 0x02, 0x85,
+	0x89, 0x09, 0x29, 0x95, 0x02, 0xb1, 0x02, 0x85,
+	0x90, 0x09, 0x30, 0x95, 0x05, 0xb1, 0x02, 0x85,
+	0x91, 0x09, 0x31, 0x95, 0x03, 0xb1, 0x02, 0x85,
+	0x92, 0x09, 0x32, 0x95, 0x03, 0xb1, 0x02, 0x85,
+	0x93, 0x09, 0x33, 0x95, 0x0c, 0xb1, 0x02, 0x85,
+	0xa0, 0x09, 0x40, 0x95, 0x06, 0xb1, 0x02, 0x85,
+	0xa1, 0x09, 0x41, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0xa2, 0x09, 0x42, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0xa3, 0x09, 0x43, 0x95, 0x30, 0xb1, 0x02, 0x85,
+	0xa4, 0x09, 0x44, 0x95, 0x0d, 0xb1, 0x02, 0x85,
+	0xa5, 0x09, 0x45, 0x95, 0x15, 0xb1, 0x02, 0x85,
+	0xa6, 0x09, 0x46, 0x95, 0x15, 0xb1, 0x02, 0x85,
+	0xf0, 0x09, 0x47, 0x95, 0x3f, 0xb1, 0x02, 0x85,
+	0xf1, 0x09, 0x48, 0x95, 0x3f, 0xb1, 0x02, 0x85,
+	0xf2, 0x09, 0x49, 0x95, 0x0f, 0xb1, 0x02, 0x85,
+	0xa7, 0x09, 0x4a, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0xa8, 0x09, 0x4b, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0xa9, 0x09, 0x4c, 0x95, 0x08, 0xb1, 0x02, 0x85,
+	0xaa, 0x09, 0x4e, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0xab, 0x09, 0x4f, 0x95, 0x39, 0xb1, 0x02, 0x85,
+	0xac, 0x09, 0x50, 0x95, 0x39, 0xb1, 0x02, 0x85,
+	0xad, 0x09, 0x51, 0x95, 0x0b, 0xb1, 0x02, 0x85,
+	0xae, 0x09, 0x52, 0x95, 0x01, 0xb1, 0x02, 0x85,
+	0xaf, 0x09, 0x53, 0x95, 0x02, 0xb1, 0x02, 0x85,
+	0xb0, 0x09, 0x54, 0x95, 0x3f, 0xb1, 0x02, 0xc0,
+};
+
 static __u8 ps3remote_rdesc[] = {
 	0x05, 0x01,          /* GUsagePage Generic Desktop */
 	0x09, 0x05,          /* LUsage 0x05 [Game Pad] */
@@ -307,6 +374,17 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 		rdesc[55] = 0x06;
 	}
 
+	/*
+	 * The default Dualshock 4 USB descriptor doesn't assign
+	 * the gyroscope values to corresponding axes so we need a
+	 * modified one.
+	 */
+	if ((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && *rsize == 467) {
+		hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n");
+		rdesc = dualshock4_usb_rdesc;
+		*rsize = sizeof(dualshock4_usb_rdesc);
+	}
+
 	/* The HID descriptor exposed over BT has a trailing zero byte */
 	if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) ||
 			((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) &&
-- 
1.8.3.2


             reply	other threads:[~2014-01-17  2:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17  2:43 Frank Praznik [this message]
2014-01-17 11:11 ` [PATCH 4/4] HID: sony: Map gyroscopes and accelerometers to axes David Herrmann
     [not found]   ` <52D965E2.6010907@gmail.com>
2014-01-17 19:03     ` Jiri Kosina
2014-01-17 11:51 ` Antonio Ospite
2014-01-17 12:21   ` Jiri Kosina
2014-01-17 12:34     ` David Herrmann
2014-01-17 17:19     ` Frank Praznik
2014-01-17 17:38       ` David Herrmann

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=alpine.DEB.2.10.1401162137400.15779@franz-virtual-machine \
    --to=frank.praznik@oh.rr.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.