xpad icon indicating copy to clipboard operation
xpad copied to clipboard

xpad one: (0)07 & (0)03 packets also send axes data

Open dantob opened this issue 9 years ago • 5 comments

Currently axis data is only read from (0)20 packets, (0)07 packets also appear to send axes data for triggers and sticks. Missing these packets could cause input lag / delays.

Packets look like this:

( 0)  20 Button packet 
( 1)  ??Always 00
( 2)  Packet id, inc from 00, wraps at FF 
( 3)  ??Always 0E
( 4)  Menu = 04, View = 08, A = 10, B = 20, X = 40, Y = 80
( 5)  UP = 01, DOWN = 02, LEFT = 04, RIGHT = 08, LB = 10, RB = 20, LSTICK = 40, RSTICK = 80
( 6)  LT AXIS (2 bytes) le
( 7)  LT AXIS (2 bytes) le
( 8)  RT AXIS (2 bytes) le
( 9)  RT AXIS (2 bytes) le
(10)  LSTICK LEFT-RIGHT AXIS (2 Bytes) le
(11)  LSTICK LEFT-RIGHT AXIS (2 Bytes) le
(12)  LSTICK DOWN-UP AXIS (2 Bytes) le
(13)  LSTICK DOWN-UP AXIS (2 Bytes) le
(14)  RSTICK LEFT-RIGHT AXIS (2 Bytes) le
(15)  RSTICK LEFT-RIGHT AXIS (2 Bytes) le
(16)  RSTICK DOWN-UP AXIS (2 Bytes) le
(17)  RSTICK DOWN-UP AXIS (2 Bytes) le
( 0)  07 Home button special packet (packet also sends axes data)
( 1)  ??Always 20
( 2)  Packet id, inc from 00, wraps at FF 
( 3)  ??Always 02
( 4)  HOME = 01
( 5)  ??Always 5B
( 6)  LT AXIS (2 bytes) le
( 7)  LT AXIS (2 bytes) le
( 8)  RT AXIS (2 bytes) le
( 9)  RT AXIS (2 bytes) le
(10)  LSTICK LEFT-RIGHT AXIS (2 Bytes) le
(11)  LSTICK LEFT-RIGHT AXIS (2 Bytes) le
(12)  LSTICK DOWN-UP AXIS (2 Bytes) le
(13)  LSTICK DOWN-UP AXIS (2 Bytes) le
(14)  RSTICK LEFT-RIGHT AXIS (2 Bytes) le
(15)  RSTICK LEFT-RIGHT AXIS (2 Bytes) le
(16)  RSTICK DOWN-UP AXIS (2 Bytes) le
(17)  RSTICK DOWN-UP AXIS (2 Bytes) le
( 0)  03 Heartbeat packet (packet also sends axes data)
( 1)  ??Always 20
( 2)  Packet id, inc from 00, wraps at FF 
( 3)  ??Always 04
( 4)  ??Always 8B
( 5)  ??Always 00
( 6)  LT AXIS (2 bytes) le (??FIRMWARE BUG: Always 00)
( 7)  LT AXIS (2 bytes) le (??FIRMWARE BUG: Always 00)
( 8)  RT AXIS (2 bytes) le
( 9)  RT AXIS (2 bytes) le
(10)  LSTICK LEFT-RIGHT AXIS (2 Bytes) le
(11)  LSTICK LEFT-RIGHT AXIS (2 Bytes) le
(12)  LSTICK DOWN-UP AXIS (2 Bytes) le
(13)  LSTICK DOWN-UP AXIS (2 Bytes) le
(14)  RSTICK LEFT-RIGHT AXIS (2 Bytes) le
(15)  RSTICK LEFT-RIGHT AXIS (2 Bytes) le
(16)  RSTICK DOWN-UP AXIS (2 Bytes) le
(17)  RSTICK DOWN-UP AXIS (2 Bytes) le

dantob avatar May 04 '16 09:05 dantob

Probably less important, but (0)03 heartbeat packets also send axes data. But there appears to be a bug with LT (bytes 6-7) are reset to 00. RT & sticks are sent same as above. I'll update the first post

dantob avatar May 04 '16 09:05 dantob

is the 07 packet sent on any button press or only on home button press?

paroj avatar May 04 '16 10:05 paroj

07 appears to be once for press and once for release of home button. Possibly Windows asks for it more often, only logging on Linux. 03 appears to be every 20 seconds

I used this in xpadone_process_packet to print packets & dmesg --follow

/* print recieved packet to kernel log */
u8 i;
for (i = 0; i < XPAD_PKT_LEN; i++) {
        printk("(%i)%02x ", i, data[i]);
} printk("\n");

dantob avatar May 04 '16 10:05 dantob

Missing these packets could cause input lag / delays.

this is rather theoretical then..

paroj avatar May 05 '16 14:05 paroj

Yeah, (0)20 packets appear to be sent about every 8 milliseconds minimum. When a (0)03 packet is sent it doesn't appear to increase that.

Wall time      Packet     Diff
---------------------------------------
[52606.292251] (0)20 ...
[52606.300249] (0)20 ... 7998μs
[52606.308242] (0)20 ... 7993μs
[52606.316247] (0)20 ... 8005μs
[52606.324247] (0)20 ... 8000μs
[52606.332216] (0)20 ... 7969μs
[52606.340248] (0)20 ... 8032μs
[52606.344239] (0)03 ...           3991μs  appears to just slot itself between the 8ms button packets
[52606.348246] (0)20 ... 7998μs    4007μs
[52606.356245] (0)20 ... 7999μs
[52606.364212] (0)20 ... 7967μs
[52606.372236] (0)20 ... 8024μs

EDIT: (0)07 appear to cause about 4 milliseconds delay

Wall time      Packet     Diff
---------------------------------------
[54156.366199] (0)20 ... 
[54156.374230] (0)20 ... 8031μs
[54156.382200] (0)20 ... 7970μs
[54156.390228] (0)20 ... 8028μs
[54156.398219] (0)07 ...           7991μs
[54156.402193] (0)20 ... 11965μs   3974μs      12ms between (0)20 packets
[54156.410189] (0)20 ... 7996μs
[54156.418224] (0)20 ... 8035μs
[54156.426216] (0)20 ... 7992μs
...
[54156.490186] (0)20 ... 
[54156.498217] (0)20 ... 8031μs
[54156.506183] (0)20 ... 7966μs
[54156.514172] (0)07 ...           7989μs
[54156.518192] (0)20 ... 12009μs   4020μs    12ms between (0)20 packets
[54156.522214] (0)20 ... 4022μs              This packet is then sent early?
[54156.530214] (0)20 ... 8000μs
[54156.538213] (0)20 ... 7999μs

dantob avatar May 05 '16 15:05 dantob