Message ID | alpine.DEB.2.10.1401162137400.15779@franz-virtual-machine (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Jiri Kosina |
Headers | show |
Hi On Fri, Jan 17, 2014 at 3:43 AM, Frank Praznik <frank.praznik@oh.rr.com> wrote: > 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, > +}; > + Ugh, wow, hard to review. Could you provide an annotated version like the ps3remote_rdesc below? As it might get pretty huge, you might wanna move it to the end of the file (or into a separate file hid_sony_rdescs.c, I don't know..). It would also be nice to see a comparison to the original descriptor. Anyhow, patch looks fine otherwise. Thanks David > 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-input" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 16 Jan 2014 21:43:12 -0500 (EST) Frank Praznik <frank.praznik@oh.rr.com> wrote: > Use a modified HID descriptor for the Dualshock 4 to assign the gyroscope > sensors and accelerometers to axes. > What about putting the descriptor fixup on hold for now? Jiri, have you already pushed these patches? Once the ABS2 stuff from David Hermann is done then proper mapping following the Gamepad API[1] and the Motion-Tracking API[2] could be added. [1] Documentation/input/gamepad.txt [2] Documentation/input/motion-tracking.txt We could even have the DS3 and DS4 expose the same mapping. Just a suggestion. Thanks, Antonio > 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, > +}; > + Consider using gHID[3] to play with HID descriptors it can generate a C array representation of the descriptor with indentation and comments kernel-style. [3] https://code.google.com/p/ghid/ > 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-input" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 17 Jan 2014, Antonio Ospite wrote: > > Use a modified HID descriptor for the Dualshock 4 to assign the gyroscope > > sensors and accelerometers to axes. > > > > What about putting the descriptor fixup on hold for now? > Jiri, have you already pushed these patches? > > Once the ABS2 stuff from David Hermann is done then proper mapping > following the Gamepad API[1] and the Motion-Tracking API[2] could be > added. > > [1] Documentation/input/gamepad.txt > [2] Documentation/input/motion-tracking.txt > > We could even have the DS3 and DS4 expose the same mapping. > > Just a suggestion. Hi, yes, I have already pushed it, but we can of course discuss not including it into pull for Linus if necessary. My understanding is that once ABS2 stuff is done, this can just be switched to using it in a backwards-compatible way, and the report fixup could be dropped, no?
Hi On Fri, Jan 17, 2014 at 1:21 PM, Jiri Kosina <jkosina@suse.cz> wrote: > On Fri, 17 Jan 2014, Antonio Ospite wrote: > >> > Use a modified HID descriptor for the Dualshock 4 to assign the gyroscope >> > sensors and accelerometers to axes. >> > >> >> What about putting the descriptor fixup on hold for now? >> Jiri, have you already pushed these patches? >> >> Once the ABS2 stuff from David Hermann is done then proper mapping >> following the Gamepad API[1] and the Motion-Tracking API[2] could be >> added. >> >> [1] Documentation/input/gamepad.txt >> [2] Documentation/input/motion-tracking.txt >> >> We could even have the DS3 and DS4 expose the same mapping. >> >> Just a suggestion. > > Hi, > > yes, I have already pushed it, but we can of course discuss not including > it into pull for Linus if necessary. > > My understanding is that once ABS2 stuff is done, this can just be > switched to using it in a backwards-compatible way, and the report fixup > could be dropped, no? No. With ABS2 we can introduce ABS_GYRO_X/Y/Z and ABS_ACCEL_X/Y/Z, so we would change the mappings. Antonio just wants to point out that if we wait for ABS2, we could use the new mappings right from the beginning so we never change them and will risk backwards-incompatibility. But Dmitry was actually concerned of adding more and more ABS_* bits due to memory-consumption, I guess. I currently keep the ABS2 patches on hold until we agree how to move forward. Maybe Dmitry can comment on that? Because I see no point of introducing ABS2 if we later decide to not add ABS_* bits for all the different axes. Thanks David -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 1/17/2014 07:21, Jiri Kosina wrote: > On Fri, 17 Jan 2014, Antonio Ospite wrote: > >>> Use a modified HID descriptor for the Dualshock 4 to assign the gyroscope >>> sensors and accelerometers to axes. >>> >> What about putting the descriptor fixup on hold for now? >> Jiri, have you already pushed these patches? >> >> Once the ABS2 stuff from David Hermann is done then proper mapping >> following the Gamepad API[1] and the Motion-Tracking API[2] could be >> added. >> >> [1] Documentation/input/gamepad.txt >> [2] Documentation/input/motion-tracking.txt >> >> We could even have the DS3 and DS4 expose the same mapping. >> >> Just a suggestion. > Hi, > > yes, I have already pushed it, but we can of course discuss not including > it into pull for Linus if necessary. > > My understanding is that once ABS2 stuff is done, this can just be > switched to using it in a backwards-compatible way, and the report fixup > could be dropped, no? > The default descriptor doesn't map the accelerometers or gyros to anything. It's just a 'user defined' page that causes the HID system to skip over the bytes in the report. My changes to the descriptor map the accelerometers to usage 0x40, 0x41 and 0x42 and the gyroscope values to 0x43, 0x44 and 0x45. These are the proper HID usage values for accelerometers and gyros according to the HID spec and according to the updated motion-tracking.txt this is exactly what they need to be mapped to to work with the ABS2 changes. Unless I'm missing something, these descriptor changes should be forward-compatible. If I recall, the Dualshock 3 maps it's accelerometers and gyros to the same set of usage values as well. -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi On Fri, Jan 17, 2014 at 6:19 PM, Frank Praznik <frank.praznik@gmail.com> wrote: > On 1/17/2014 07:21, Jiri Kosina wrote: >> >> On Fri, 17 Jan 2014, Antonio Ospite wrote: >> >>>> Use a modified HID descriptor for the Dualshock 4 to assign the >>>> gyroscope >>>> sensors and accelerometers to axes. >>>> >>> What about putting the descriptor fixup on hold for now? >>> Jiri, have you already pushed these patches? >>> >>> Once the ABS2 stuff from David Hermann is done then proper mapping >>> following the Gamepad API[1] and the Motion-Tracking API[2] could be >>> added. >>> >>> [1] Documentation/input/gamepad.txt >>> [2] Documentation/input/motion-tracking.txt >>> >>> We could even have the DS3 and DS4 expose the same mapping. >>> >>> Just a suggestion. >> >> Hi, >> >> yes, I have already pushed it, but we can of course discuss not including >> it into pull for Linus if necessary. >> >> My understanding is that once ABS2 stuff is done, this can just be >> switched to using it in a backwards-compatible way, and the report fixup >> could be dropped, no? >> > The default descriptor doesn't map the accelerometers or gyros to anything. > It's just a 'user defined' page that causes the HID system to skip over the > bytes in the report. My changes to the descriptor map the accelerometers to > usage 0x40, 0x41 and 0x42 and the gyroscope values to 0x43, 0x44 and 0x45. > These are the proper HID usage values for accelerometers and gyros according > to the HID spec and according to the updated motion-tracking.txt this is > exactly what they need to be mapped to to work with the ABS2 changes. > Unless I'm missing something, these descriptor changes should be > forward-compatible. Your patch is fine. Issue is, once we introduce the interfaces described in motion-tracking.txt, we would have to decide whether we want to adjust hid-input.c to use it. If we do that, we might break user-space, but if we don't do that, we will never map the stuff correctly. Not that easy to fix. So in case we postpone your patch, we could make sure it maps to the new bits right from the beginning. But I'm not so sure it's worth it as ABS2 is still not fully discussed. Thanks David -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 17 Jan 2014, Frank Praznik wrote: > Any objections to moving all of the rdesc data to an hid-sony.h header > file? Please don't. This doesn't really belong in a header file. Header files are used to declare things, not to have large data structures there. There are other drivers which contain annotated descriptor and are readable; for example look at hid-waltop. Thanks,
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)) &&
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(+)