|
|
@@ -12,17 +12,24 @@
|
|
|
|
|
|
HidGyroController g_hidGyroCtl;
|
|
|
|
|
|
+// Genuine DualShock 4 (054C:05C4) USB report descriptor. Input report 0x01 declares 63 payload bytes
|
|
|
+// (4 stick bytes, hat + 14 buttons + 6-bit counter, 2 trigger bytes, 54 vendor bytes) = 64 on the wire with
|
|
|
+// the id, matching what hidGyroBuild() sends. Do NOT collapse the stick block into the hat item: hosts that
|
|
|
+// parse the descriptor (Windows RawInput/HIDClass, macOS IOHIDManager) size every read from the DECLARED
|
|
|
+// length, so a short declaration both shifts all field offsets and makes SDL's PS4 driver drop the report
|
|
|
+// (HIDAPI_DriverPS4_IsPacketValid requires size >= 64) -- the whole pad reads as dead.
|
|
|
static const uint8_t GYRO_HID_DESC[] = {
|
|
|
- 0x05, 0x01, 0x09, 0x05, 0xA1, 0x01, 0x85, 0x01, 0x09, 0x30, 0x09,
|
|
|
- 0x31, 0x09, 0x32, 0x09, 0x35, 0x15, 0x00, 0x25, 0x07, 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, 0x36, 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, 0xC0
|
|
|
+ 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, 0x36, 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, 0xC0
|
|
|
};
|
|
|
#define DS4_TOUCH_H 942
|
|
|
#define DS4_STATUS_USB 0x1B // cable + level 11 (full)
|
|
|
@@ -164,18 +171,8 @@ static void hidGyroBuild(uint8_t usbSlot, uint8_t slot, uint8_t out[63])
|
|
|
((b & TB_STEAM) ? 0x01 : 0);
|
|
|
out[7] = g_in[slot].lt;
|
|
|
out[8] = g_in[slot].rt;
|
|
|
- out[12] = g_in[slot].gx & 0xFF;
|
|
|
- out[13] = g_in[slot].gx >> 8;
|
|
|
- out[14] = g_in[slot].gz & 0xFF;
|
|
|
- out[15] = g_in[slot].gz >> 8;
|
|
|
- out[16] = (-g_in[slot].gy) & 0xFF;
|
|
|
- out[17] = (-g_in[slot].gy) >> 8;
|
|
|
- out[18] = g_in[slot].ax & 0xFF;
|
|
|
- out[19] = g_in[slot].ax >> 8;
|
|
|
- out[20] = g_in[slot].ay & 0xFF;
|
|
|
- out[21] = g_in[slot].ay >> 8;
|
|
|
- out[22] = g_in[slot].az & 0xFF;
|
|
|
- out[23] = g_in[slot].az >> 8;
|
|
|
+ // gyro X/Y/Z then accel X/Y/Z, 6 x le16 (hid-sony: rd[13..] / rd[19..])
|
|
|
+ psImuPack(out + 12, g_in[slot]);
|
|
|
out[29] = DS4_STATUS_USB;
|
|
|
if (lTouch || rTouch) {
|
|
|
uint16_t tlx, tly, trx, trry;
|