diff options
author | Frank Praznik <frank.praznik@oh.rr.com> | 2014-01-16 21:43:12 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-01-17 04:47:41 -0500 |
commit | ed19d8cf28b2b03ec05e75de9c1f73981b342978 (patch) | |
tree | cea001fb70c57598dc44f7b18746c4222d4cc9f3 /drivers/hid/hid-sony.c | |
parent | 6c79c18c97411cd1b0302169e7bc9dbe40f5d286 (diff) |
HID: sony: Map gyroscopes and accelerometers to axes
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>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-sony.c')
-rw-r--r-- | drivers/hid/hid-sony.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index a7c81677c540..edffe2c47cf9 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
@@ -73,6 +73,73 @@ static const u8 sixaxis_rdesc_fixup2[] = { | |||
73 | 0xb1, 0x02, 0xc0, 0xc0, | 73 | 0xb1, 0x02, 0xc0, 0xc0, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static u8 dualshock4_usb_rdesc[] = { | ||
77 | 0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, | ||
78 | 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, | ||
79 | 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, | ||
80 | 0x04, 0x81, 0x02, 0x09, 0x39, 0x15, 0x00, 0x25, | ||
81 | 0x07, 0x35, 0x00, 0x46, 0x3b, 0x01, 0x65, 0x14, | ||
82 | 0x75, 0x04, 0x95, 0x01, 0x81, 0x42, 0x65, 0x00, | ||
83 | 0x05, 0x09, 0x19, 0x01, 0x29, 0x0e, 0x15, 0x00, | ||
84 | 0x25, 0x01, 0x75, 0x01, 0x95, 0x0e, 0x81, 0x02, | ||
85 | 0x06, 0x00, 0xff, 0x09, 0x20, 0x75, 0x06, 0x95, | ||
86 | 0x01, 0x15, 0x00, 0x25, 0x7f, 0x81, 0x02, 0x05, | ||
87 | 0x01, 0x09, 0x33, 0x09, 0x34, 0x15, 0x00, 0x26, | ||
88 | 0xff, 0x00, 0x75, 0x08, 0x95, 0x02, 0x81, 0x02, | ||
89 | 0x06, 0x00, 0xff, 0x09, 0x21, 0x95, 0x03, 0x81, | ||
90 | 0x02, 0x05, 0x01, 0x19, 0x40, 0x29, 0x42, 0x16, | ||
91 | 0x00, 0x80, 0x26, 0x00, 0x7f, 0x75, 0x10, 0x95, | ||
92 | 0x03, 0x81, 0x02, 0x05, 0x01, 0x19, 0x43, 0x29, | ||
93 | 0x45, 0x16, 0xff, 0xbf, 0x26, 0x00, 0x40, 0x95, | ||
94 | 0x03, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09, 0x21, | ||
95 | 0x75, 0x08, 0x95, 0x27, 0x81, 0x02, 0x85, 0x05, | ||
96 | 0x09, 0x22, 0x95, 0x1f, 0x91, 0x02, 0x85, 0x04, | ||
97 | 0x09, 0x23, 0x95, 0x24, 0xb1, 0x02, 0x85, 0x02, | ||
98 | 0x09, 0x24, 0x95, 0x24, 0xb1, 0x02, 0x85, 0x08, | ||
99 | 0x09, 0x25, 0x95, 0x03, 0xb1, 0x02, 0x85, 0x10, | ||
100 | 0x09, 0x26, 0x95, 0x04, 0xb1, 0x02, 0x85, 0x11, | ||
101 | 0x09, 0x27, 0x95, 0x02, 0xb1, 0x02, 0x85, 0x12, | ||
102 | 0x06, 0x02, 0xff, 0x09, 0x21, 0x95, 0x0f, 0xb1, | ||
103 | 0x02, 0x85, 0x13, 0x09, 0x22, 0x95, 0x16, 0xb1, | ||
104 | 0x02, 0x85, 0x14, 0x06, 0x05, 0xff, 0x09, 0x20, | ||
105 | 0x95, 0x10, 0xb1, 0x02, 0x85, 0x15, 0x09, 0x21, | ||
106 | 0x95, 0x2c, 0xb1, 0x02, 0x06, 0x80, 0xff, 0x85, | ||
107 | 0x80, 0x09, 0x20, 0x95, 0x06, 0xb1, 0x02, 0x85, | ||
108 | 0x81, 0x09, 0x21, 0x95, 0x06, 0xb1, 0x02, 0x85, | ||
109 | 0x82, 0x09, 0x22, 0x95, 0x05, 0xb1, 0x02, 0x85, | ||
110 | 0x83, 0x09, 0x23, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
111 | 0x84, 0x09, 0x24, 0x95, 0x04, 0xb1, 0x02, 0x85, | ||
112 | 0x85, 0x09, 0x25, 0x95, 0x06, 0xb1, 0x02, 0x85, | ||
113 | 0x86, 0x09, 0x26, 0x95, 0x06, 0xb1, 0x02, 0x85, | ||
114 | 0x87, 0x09, 0x27, 0x95, 0x23, 0xb1, 0x02, 0x85, | ||
115 | 0x88, 0x09, 0x28, 0x95, 0x22, 0xb1, 0x02, 0x85, | ||
116 | 0x89, 0x09, 0x29, 0x95, 0x02, 0xb1, 0x02, 0x85, | ||
117 | 0x90, 0x09, 0x30, 0x95, 0x05, 0xb1, 0x02, 0x85, | ||
118 | 0x91, 0x09, 0x31, 0x95, 0x03, 0xb1, 0x02, 0x85, | ||
119 | 0x92, 0x09, 0x32, 0x95, 0x03, 0xb1, 0x02, 0x85, | ||
120 | 0x93, 0x09, 0x33, 0x95, 0x0c, 0xb1, 0x02, 0x85, | ||
121 | 0xa0, 0x09, 0x40, 0x95, 0x06, 0xb1, 0x02, 0x85, | ||
122 | 0xa1, 0x09, 0x41, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
123 | 0xa2, 0x09, 0x42, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
124 | 0xa3, 0x09, 0x43, 0x95, 0x30, 0xb1, 0x02, 0x85, | ||
125 | 0xa4, 0x09, 0x44, 0x95, 0x0d, 0xb1, 0x02, 0x85, | ||
126 | 0xa5, 0x09, 0x45, 0x95, 0x15, 0xb1, 0x02, 0x85, | ||
127 | 0xa6, 0x09, 0x46, 0x95, 0x15, 0xb1, 0x02, 0x85, | ||
128 | 0xf0, 0x09, 0x47, 0x95, 0x3f, 0xb1, 0x02, 0x85, | ||
129 | 0xf1, 0x09, 0x48, 0x95, 0x3f, 0xb1, 0x02, 0x85, | ||
130 | 0xf2, 0x09, 0x49, 0x95, 0x0f, 0xb1, 0x02, 0x85, | ||
131 | 0xa7, 0x09, 0x4a, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
132 | 0xa8, 0x09, 0x4b, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
133 | 0xa9, 0x09, 0x4c, 0x95, 0x08, 0xb1, 0x02, 0x85, | ||
134 | 0xaa, 0x09, 0x4e, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
135 | 0xab, 0x09, 0x4f, 0x95, 0x39, 0xb1, 0x02, 0x85, | ||
136 | 0xac, 0x09, 0x50, 0x95, 0x39, 0xb1, 0x02, 0x85, | ||
137 | 0xad, 0x09, 0x51, 0x95, 0x0b, 0xb1, 0x02, 0x85, | ||
138 | 0xae, 0x09, 0x52, 0x95, 0x01, 0xb1, 0x02, 0x85, | ||
139 | 0xaf, 0x09, 0x53, 0x95, 0x02, 0xb1, 0x02, 0x85, | ||
140 | 0xb0, 0x09, 0x54, 0x95, 0x3f, 0xb1, 0x02, 0xc0, | ||
141 | }; | ||
142 | |||
76 | static __u8 ps3remote_rdesc[] = { | 143 | static __u8 ps3remote_rdesc[] = { |
77 | 0x05, 0x01, /* GUsagePage Generic Desktop */ | 144 | 0x05, 0x01, /* GUsagePage Generic Desktop */ |
78 | 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ | 145 | 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ |
@@ -307,6 +374,17 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
307 | rdesc[55] = 0x06; | 374 | rdesc[55] = 0x06; |
308 | } | 375 | } |
309 | 376 | ||
377 | /* | ||
378 | * The default Dualshock 4 USB descriptor doesn't assign | ||
379 | * the gyroscope values to corresponding axes so we need a | ||
380 | * modified one. | ||
381 | */ | ||
382 | if ((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && *rsize == 467) { | ||
383 | hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n"); | ||
384 | rdesc = dualshock4_usb_rdesc; | ||
385 | *rsize = sizeof(dualshock4_usb_rdesc); | ||
386 | } | ||
387 | |||
310 | /* The HID descriptor exposed over BT has a trailing zero byte */ | 388 | /* The HID descriptor exposed over BT has a trailing zero byte */ |
311 | if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) || | 389 | if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) || |
312 | ((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) && | 390 | ((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) && |