| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
trackPadTouch0Id: data[35] & 127,
trackPadTouch0Active: (data[35] >> 7) === 0,
Ah, many thanks for the track/ps button find, was going to dig through the other values at the bit level next.
Here's my current complete nodejs Buffer -> Object mapping code:
{
leftAnalogX: buf[1],
leftAnalogY: buf[2],
rightAnalogX: buf[3],
rightAnalogY: buf[4],
l2Analog: buf[8],
r2Analog: buf[9],
dPadUp: buf[5] === 0 || buf[5] === 1 || buf [5] === 7,
dPadRight: buf[5] === 1 || buf[5] === 2 || buf [5] === 3,
dPadDown: buf[5] === 3 || buf[5] === 4 || buf [5] === 5,
dPadLeft: buf[5] === 5 || buf[5] === 6 || buf [5] === 7,
x: (buf[5] & 32) !== 0,
cricle: (buf[5] & 64) !== 0,
square: (buf[5] & 16) !== 0,
triangle: (buf[5] & 128) !== 0,
l1: (buf[6] & 0x01) !== 0,
l2: (buf[6] & 0x04) !== 0,
r1: (buf[6] & 0x02) !== 0,
r2: (buf[6] & 0x08) !== 0,
l3: (buf[6] & 0x40) !== 0,
r3: (buf[6] & 0x80) !== 0,
share: (buf[6] & 0x10) !== 0,
options: (buf[6] & 0x20) !== 0,
trackPadButton: (buf[7] & 2) !== 0,
psButton: (buf[7] & 1) !== 0,
//// usb only, doesn't work via bluetooth
//// GYRO
// TODO
//// TRACKPAD
trackPadTouch0Id: buf[35] & 0x7f,
trackPadTouch0Active: (buf[35] >> 7) === 0,
trackPadTouch0X: ((buf[37] & 0x0f) << 8) | buf[36],
trackPadTouch0Y: buf[38] << 4 | ((buf[37] & 0xf0) >> 4),
trackPadTouch1Id: buf[39] & 0x7f,
trackPadTouch1Active: (buf[39] >> 7) === 0,
trackPadTouch1X: ((buf[41] & 0x0f) << 8) | buf[40],
trackPadTouch1Y: buf[42] << 4 | ((buf[41] & 0xf0) >> 4),
timestamp: buf[7] >> 2,
battery: buf[12],
batteryShort1: buf[12] & 0x0f,
batteryShort2: buf[12] & 0xf0,
}
Noticed psdevwiki has barebones info, so linked to here from http://www.psdevwiki.com/ps4/Talk:DualShock_4
A dev with access to USB passthrough has got rumble and LEDs working ‐ http://www.youtube.com/watch?v=RkbjUj5nN6g but afaik wont be sharing the protocol :<
Have been messing locally with sending packets to the controller to trigger rumble, but it doesn’t appear to use anything like PS3s rumble/LED packet.