-
Notifications
You must be signed in to change notification settings - Fork 545
Expand file tree
/
Copy pathPS4Descriptors.h
More file actions
761 lines (657 loc) · 26.2 KB
/
PS4Descriptors.h
File metadata and controls
761 lines (657 loc) · 26.2 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
/*
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: Copyright (c) 2024 OpenStickCommunity (gp2040-ce.info)
*/
#pragma once
#include <stdint.h>
#define PS4_ENDPOINT_SIZE 64
// Mayflash
//#define PS4_VENDOR_ID 0x33df
//#define PS4_PRODUCT_ID 0x0011
// Razer Panthera
#define PS4_VENDOR_ID 0x1532
#define PS4_PRODUCT_ID 0x0401
// Madcatz Fightstick Alpha PS4
//#define PS4_VENDOR_ID 0x0738
//#define PS4_PRODUCT_ID 0x8180
// DS4
#define DS4_VENDOR_ID 0x054C
#define DS4_PRODUCT_ID 0x09CC
// G29
#define PS4_WHEEL_VENDOR_ID 0x046D
#define PS4_WHEEL_PRODUCT_ID 0xC260
#define DS4_ORG_PRODUCT_ID 0x05C4
/**************************************************************************
*
* Endpoint Buffer Configuration
*
**************************************************************************/
#define ENDPOINT0_SIZE 64
#define PS4_FEATURES_SIZE 32
#define GAMEPAD_INTERFACE 0
#define GAMEPAD_ENDPOINT 1
#define GAMEPAD_SIZE 64
#ifndef LSB
#define LSB(n) ((n) & 255)
#endif
#ifndef MSB
#define MSB(n) (((n) >> 8) & 255)
#endif
// HAT report (4 bits)
#define PS4_HAT_UP 0x00
#define PS4_HAT_UPRIGHT 0x01
#define PS4_HAT_RIGHT 0x02
#define PS4_HAT_DOWNRIGHT 0x03
#define PS4_HAT_DOWN 0x04
#define PS4_HAT_DOWNLEFT 0x05
#define PS4_HAT_LEFT 0x06
#define PS4_HAT_UPLEFT 0x07
#define PS4_HAT_NOTHING 0x0F
// Button report (16 bits)
#define PS4_MASK_SQUARE (1U << 0)
#define PS4_MASK_CROSS (1U << 1)
#define PS4_MASK_CIRCLE (1U << 2)
#define PS4_MASK_TRIANGLE (1U << 3)
#define PS4_MASK_L1 (1U << 4)
#define PS4_MASK_R1 (1U << 5)
#define PS4_MASK_L2 (1U << 6)
#define PS4_MASK_R2 (1U << 7)
#define PS4_MASK_SELECT (1U << 8)
#define PS4_MASK_START (1U << 9)
#define PS4_MASK_L3 (1U << 10)
#define PS4_MASK_R3 (1U << 11)
#define PS4_MASK_PS (1U << 12)
#define PS4_MASK_TP (1U << 13)
// PS4 analog sticks only report 8 bits
#define PS4_JOYSTICK_MIN 0x00
#define PS4_JOYSTICK_MID 0x80
#define PS4_JOYSTICK_MAX 0xFF
// PS4 navigation (HOTAS/flight/wheel) analog inputs report 16 bits
#define PS4_NAV_JOYSTICK_MIN 0x0000
#define PS4_NAV_JOYSTICK_MID 0x8000
#define PS4_NAV_JOYSTICK_MAX 0xFFFF
// touchpad resolution = 1920x943
#define PS4_TP_X_MIN 0
#define PS4_TP_X_MAX 1920
#define PS4_TP_Y_MIN 0
#define PS4_TP_Y_MAX 943
#define PS4_TP_MAX_COUNT 128
#define PS4_MAX_GEARS 8
#define PS4_ACCEL_RES 8192
#define PS4_ACCEL_RANGE (PS4_ACCEL_RES * 4)
#define PS4_GYRO_RES 1024
#define PS4_GYRO_RANGE (PS4_GYRO_RES * 2048)
struct TouchpadXY {
uint8_t counter : 7;
uint8_t unpressed : 1;
// 12 bit X, followed by 12 bit Y
uint8_t data[3];
void set_x(uint16_t x) {
data[0] = x & 0xff;
data[1] = (data[1] & 0xf0) | ((x >> 8) & 0xf);
}
void set_y(uint16_t y) {
data[1] = (data[1] & 0x0f) | ((y & 0xf) << 4);
data[2] = y >> 4;
return;
}
};
struct TouchpadData {
TouchpadXY p1;
TouchpadXY p2;
};
struct PSSensor {
int16_t x;
int16_t y;
int16_t z;
};
struct PSSensorData {
uint16_t battery;
PSSensor gyroscope;
PSSensor accelerometer;
uint8_t misc[4];
uint8_t powerLevel : 4;
uint8_t charging : 1;
uint8_t headphones : 1;
uint8_t microphone : 1;
uint8_t extension : 1;
uint8_t extData0 : 1;
uint8_t extData1 : 1;
uint8_t notConnected : 1;
uint8_t extData3 : 5;
uint8_t misc2;
} __attribute__((packed));
typedef struct __attribute__((packed)) {
// 0
uint8_t reportID;
// 1
uint8_t enableUpdateRumble : 1;
uint8_t enableUpdateLED : 1;
uint8_t enableUpdateLEDBlink : 1;
uint8_t enableUpdateExtData : 1;
uint8_t enableUpdateVolLeft : 1;
uint8_t enableUpdateVolRight : 1;
uint8_t enableUpdateVolMic : 1;
uint8_t enableUpdateVolSpeaker : 1;
// 2
uint8_t : 8;
// 3
uint8_t unknown0;
// 4
uint8_t rumbleRight;
// 5
uint8_t rumbleLeft;
// 6
uint8_t ledRed;
// 7
uint8_t ledGreen;
// 8
uint8_t ledBlue;
// 9
uint8_t ledBlinkOn;
// 10
uint8_t ledBlinkOff;
// 11
uint8_t extData[8];
// 19
uint8_t volumeLeft; // 0x00-0x4F
// 20
uint8_t volumeRight; // 0x00-0x4F
// 21
uint8_t volumeMic; // 0x01-0x4F, 0x00 is special state
// 22
uint8_t volumeSpeaker; // 0x00-0x4F
// 23
uint8_t unknownAudio;
// 24
uint8_t padding[8];
} PS4FeatureOutputReport;
typedef struct __attribute__((packed)) {
uint16_t gyroRange = 0;
uint16_t gyroResPerDegDenom = 0;
uint16_t gyroResPerDegNumer = 0;
uint16_t accelRange = 0;
uint16_t accelResPerG = 0;
} PS4IMUConfig;
typedef struct __attribute__((packed)) {
uint16_t hidUsage = 0x2127;
uint8_t mystery0 = 0x04;
// features
union {
//uint8_t featureValue = 0xEF;
struct __attribute__((packed)) {
uint8_t enableController : 1;
uint8_t enableMotion : 1;
uint8_t enableLED : 1;
uint8_t enableRumble : 1;
uint8_t enableAnalog : 1;
uint8_t enableUnknown0: 1;
uint8_t enableTouchpad : 1;
uint8_t enableUnknown1: 1;
} features;
};
uint8_t controllerType = 0; // use PS4ControllerType
uint8_t touchpadParam[2] = {0x00,0x00};
PS4IMUConfig imuConfig;
uint16_t magicID = 0x0d0d;
uint8_t mystery1[4] = {0x00,0x00,0x00,0x00};
uint8_t wheelParam[3] = {0x00,0x00,0x00};
uint8_t mystery2[21] = {0x00};
} PS4ControllerConfig;
typedef struct __attribute__((packed)) {
uint8_t reportID;
uint8_t leftStickX;
uint8_t leftStickY;
uint8_t rightStickX;
uint8_t rightStickY;
// 4 bits for the d-pad.
uint8_t dpad : 4;
// 14 bits for buttons.
uint16_t buttonWest : 1;
uint16_t buttonSouth : 1;
uint16_t buttonEast : 1;
uint16_t buttonNorth : 1;
uint16_t buttonL1 : 1;
uint16_t buttonR1 : 1;
uint16_t buttonL2 : 1;
uint16_t buttonR2 : 1;
uint16_t buttonSelect : 1;
uint16_t buttonStart : 1;
uint16_t buttonL3 : 1;
uint16_t buttonR3 : 1;
uint16_t buttonHome : 1;
uint16_t buttonTouchpad : 1;
// 6 bit report counter.
uint8_t reportCounter : 6;
uint8_t leftTrigger : 8;
uint8_t rightTrigger : 8;
// vendor specific
// ---------------
union {
uint8_t miscData[54];
struct __attribute__((packed)) {
// 16 bit timing counter
uint16_t axisTiming;
PSSensorData sensorData;
uint8_t touchpadActive : 2;
uint8_t padding : 6;
uint8_t tpadIncrement;
TouchpadData touchpadData;
uint8_t mystery2[21];
} gamepad;
struct __attribute__((packed)) {
uint8_t mystery0[22];
uint8_t powerLevel : 4;
uint8_t : 4;
uint8_t mystery1[10];
uint8_t pickup;
uint8_t whammy;
uint8_t tilt;
union {
uint8_t fretValue;
struct __attribute__((packed)) {
uint8_t green : 1;
uint8_t red : 1;
uint8_t yellow : 1;
uint8_t blue : 1;
uint8_t orange : 1;
uint8_t : 3;
} frets;
};
union {
uint8_t soloFretValue;
struct __attribute__((packed)) {
uint8_t green : 1;
uint8_t red : 1;
uint8_t yellow : 1;
uint8_t blue : 1;
uint8_t orange : 1;
uint8_t : 3;
} soloFrets;
};
uint8_t mystery2[14];
} guitar;
struct __attribute__((packed)) {
uint8_t mystery0[22];
uint8_t powerLevel : 4;
uint8_t : 4;
uint8_t mystery1[10];
uint8_t velocityDrumRed;
uint8_t velocityDrumBlue;
uint8_t velocityDrumYellow;
uint8_t velocityDrumGreen;
uint8_t velocityCymbalYellow;
uint8_t velocityCymbalBlue;
uint8_t velocityCymbalGreen;
uint8_t mystery2[12];
} drums;
struct __attribute__((packed)) {
uint8_t mystery0[22];
uint8_t powerLevel : 4;
uint8_t : 4;
uint8_t mystery1[10];
uint16_t joystickX;
uint16_t joystickY;
uint8_t twistRudder;
uint8_t throttle;
uint8_t rockerSwitch;
uint8_t pedalRudder;
uint8_t pedalLeft;
uint8_t pedalRight;
} hotas;
struct __attribute__((packed)) {
uint8_t mystery0[22];
uint8_t powerLevel : 4;
uint8_t : 4;
uint8_t mystery1[10];
uint16_t steeringWheel;
uint16_t gasPedal;
uint16_t brakePedal;
uint16_t clutchPedal; // ?
union {
uint8_t shifterValue;
struct __attribute__((packed)) {
uint8_t shifterGear1 : 1;
uint8_t shifterGear2 : 1;
uint8_t shifterGear3 : 1;
uint8_t shifterGear4 : 1;
uint8_t shifterGear5 : 1;
uint8_t shifterGear6 : 1;
uint8_t shifterGearR : 1;
uint8_t : 1;
} shifter;
};
uint16_t unknownVal;
uint8_t buttonDialEnter : 1;
uint8_t buttonDialDown : 1;
uint8_t buttonDialUp : 1;
uint8_t buttonMinus : 1;
uint8_t buttonPlus : 1;
uint8_t : 3;
uint8_t mystery2[7];
} wheel;
};
} PS4Report;
static const uint8_t ps4_string_language[] = { 0x09, 0x04 };
static const uint8_t ps4_string_manufacturer[] = "Open Stick Community";
static const uint8_t ps4_string_product[] = "GP2040-CE (PS4)";
static const uint8_t ps4_string_version[] = "1.0";
static const uint8_t *ps4_string_descriptors[] __attribute__((unused)) =
{
ps4_string_language,
ps4_string_manufacturer,
ps4_string_product,
ps4_string_version
};
static const uint8_t ps4_device_descriptor[] =
{
18, // bLength
1, // bDescriptorType
0x00, 0x02, // bcdUSB
0, // bDeviceClass
0, // bDeviceSubClass
0, // bDeviceProtocol
ENDPOINT0_SIZE, // bMaxPacketSize0
LSB(PS4_VENDOR_ID), MSB(PS4_VENDOR_ID), // idVendor
LSB(PS4_PRODUCT_ID), MSB(PS4_PRODUCT_ID), // idProduct
0x00, 0x01, // bcdDevice
1, // iManufacturer
2, // iProduct
0, // iSerialNumber
1 // bNumConfigurations
};
static const uint8_t ps4_report_descriptor[] =
{
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x05, // Usage (Game Pad)
0xA1, 0x01, // Collection (Application)
0x85, 0x01, // Report ID (1)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x09, 0x35, // Usage (Rz)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x75, 0x08, // Report Size (8)
0x95, 0x04, // Report Count (4)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x09, 0x39, // Usage (Hat switch)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x07, // Logical Maximum (7)
0x35, 0x00, // Physical Minimum (0)
0x46, 0x3B, 0x01, // Physical Maximum (315)
0x65, 0x14, // Unit (System: English Rotation, Length: Centimeter)
0x75, 0x04, // Report Size (4)
0x95, 0x01, // Report Count (1)
0x81, 0x42, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State)
0x65, 0x00, // Unit (None)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (0x01)
0x29, 0x0E, // Usage Maximum (0x0E)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x0E, // Report Count (14)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00)
0x09, 0x20, // Usage (0x20)
0x75, 0x06, // Report Size (6)
0x95, 0x01, // Report Count (1)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x33, // Usage (Rx)
0x09, 0x34, // Usage (Ry)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x75, 0x08, // Report Size (8)
0x95, 0x02, // Report Count (2)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00)
0x09, 0x21, // Usage (0x21)
0x95, 0x36, // Report Count (54)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x85, 0x05, // Report ID (5)
0x09, 0x22, // Usage (0x22)
0x95, 0x1F, // Report Count (31)
0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x03, // Report ID (3)
0x0A, 0x21, 0x27, // Usage (0x2721)
0x95, 0x2F, // Report Count (47)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x02, // Report ID (2)
0x09, 0x24, // Usage (0x24)
0x95, 0x24, // Report Count (36)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x08, // Report ID (8)
0x09, 0x25, // Usage (0x25)
0x95, 0x03, // Report Count (3)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x10, // Report ID (16)
0x09, 0x26, // Usage (0x26)
0x95, 0x04, // Report Count (4)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x11, // Report ID (17)
0x09, 0x27, // Usage (0x27)
0x95, 0x02, // Report Count (2)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x12, // Report ID (18)
0x06, 0x02, 0xFF, // Usage Page (Vendor Defined 0xFF02)
0x09, 0x21, // Usage (0x21)
0x95, 0x0F, // Report Count (15)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x13, // Report ID (19)
0x09, 0x22, // Usage (0x22)
0x95, 0x16, // Report Count (22)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x14, // Report ID (20)
0x06, 0x05, 0xFF, // Usage Page (Vendor Defined 0xFF05)
0x09, 0x20, // Usage (0x20)
0x95, 0x10, // Report Count (16)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x15, // Report ID (21)
0x09, 0x21, // Usage (0x21)
0x95, 0x2C, // Report Count (44)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x06, 0x80, 0xFF, // Usage Page (Vendor Defined 0xFF80)
0x85, 0x80, // Report ID (128)
0x09, 0x20, // Usage (0x20)
0x95, 0x06, // Report Count (6)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x81, // Report ID (129)
0x09, 0x21, // Usage (0x21)
0x95, 0x06, // Report Count (6)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x82, // Report ID (130)
0x09, 0x22, // Usage (0x22)
0x95, 0x05, // Report Count (5)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x83, // Report ID (131)
0x09, 0x23, // Usage (0x23)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x84, // Report ID (132)
0x09, 0x24, // Usage (0x24)
0x95, 0x04, // Report Count (4)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x85, // Report ID (133)
0x09, 0x25, // Usage (0x25)
0x95, 0x06, // Report Count (6)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x86, // Report ID (134)
0x09, 0x26, // Usage (0x26)
0x95, 0x06, // Report Count (6)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x87, // Report ID (135)
0x09, 0x27, // Usage (0x27)
0x95, 0x23, // Report Count (35)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x88, // Report ID (136)
0x09, 0x28, // Usage (0x28)
0x95, 0x22, // Report Count (34)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x89, // Report ID (137)
0x09, 0x29, // Usage (0x29)
0x95, 0x02, // Report Count (2)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x90, // Report ID (144)
0x09, 0x30, // Usage (0x30)
0x95, 0x05, // Report Count (5)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x91, // Report ID (145)
0x09, 0x31, // Usage (0x31)
0x95, 0x03, // Report Count (3)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x92, // Report ID (146)
0x09, 0x32, // Usage (0x32)
0x95, 0x03, // Report Count (3)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0x93, // Report ID (147)
0x09, 0x33, // Usage (0x33)
0x95, 0x0C, // Report Count (12)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA0, // Report ID (160)
0x09, 0x40, // Usage (0x40)
0x95, 0x06, // Report Count (6)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA1, // Report ID (161)
0x09, 0x41, // Usage (0x41)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA2, // Report ID (162)
0x09, 0x42, // Usage (0x42)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA3, // Report ID (163)
0x09, 0x43, // Usage (0x43)
0x95, 0x30, // Report Count (48)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA4, // Report ID (164)
0x09, 0x44, // Usage (0x44)
0x95, 0x0D, // Report Count (13)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA5, // Report ID (165)
0x09, 0x45, // Usage (0x45)
0x95, 0x15, // Report Count (21)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA6, // Report ID (166)
0x09, 0x46, // Usage (0x46)
0x95, 0x15, // Report Count (21)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA7, // Report ID (247)
0x09, 0x4A, // Usage (0x4A)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA8, // Report ID (250)
0x09, 0x4B, // Usage (0x4B)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xA9, // Report ID (251)
0x09, 0x4C, // Usage (0x4C)
0x95, 0x08, // Report Count (8)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xAA, // Report ID (252)
0x09, 0x4E, // Usage (0x4E)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xAB, // Report ID (253)
0x09, 0x4F, // Usage (0x4F)
0x95, 0x39, // Report Count (57)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xAC, // Report ID (254)
0x09, 0x50, // Usage (0x50)
0x95, 0x39, // Report Count (57)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xAD, // Report ID (255)
0x09, 0x51, // Usage (0x51)
0x95, 0x0B, // Report Count (11)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xAE, // Report ID (256)
0x09, 0x52, // Usage (0x52)
0x95, 0x01, // Report Count (1)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xAF, // Report ID (175)
0x09, 0x53, // Usage (0x53)
0x95, 0x02, // Report Count (2)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xB0, // Report ID (176)
0x09, 0x54, // Usage (0x54)
0x95, 0x3F, // Report Count (63)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0xC0, // End Collection
0x06, 0xF0, 0xFF, // Usage Page (Vendor Defined 0xFFF0)
0x09, 0x40, // Usage (0x40)
0xA1, 0x01, // Collection (Application)
0x85, 0xF0, // Report ID (-16) AUTH F0
0x09, 0x47, // Usage (0x47)
0x95, 0x3F, // Report Count (63)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xF1, // Report ID (-15) AUTH F1
0x09, 0x48, // Usage (0x48)
0x95, 0x3F, // Report Count (63)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xF2, // Report ID (-14) AUTH F2
0x09, 0x49, // Usage (0x49)
0x95, 0x0F, // Report Count (15)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x85, 0xF3, // Report ID (-13) Auth F3 (Reset)
0x0A, 0x01, 0x47, // Usage (0x4701)
0x95, 0x07, // Report Count (7)
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0xC0, // End Collection
};
static const uint8_t ps4_hid_descriptor[] =
{
0x09, // bLength
0x21, // bDescriptorType (HID)
0x11, 0x01, // bcdHID 1.11
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType[0] (HID)
LSB(sizeof(ps4_report_descriptor)), MSB(sizeof(ps4_report_descriptor))
};
#define PS4_CONFIG1_DESC_SIZE (9+9+9+7+7)
static const uint8_t ps4_configuration_descriptor[] =
{
// configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
9, // bLength;
2, // bDescriptorType;
LSB(PS4_CONFIG1_DESC_SIZE), // wTotalLength
MSB(PS4_CONFIG1_DESC_SIZE),
1, // bNumInterfaces
1, // bConfigurationValue
0, // iConfiguration
0x80, // bmAttributes
50, // bMaxPower
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
9, // bLength
4, // bDescriptorType
GAMEPAD_INTERFACE, // bInterfaceNumber
0, // bAlternateSetting
2, // bNumEndpoints
0x03, // bInterfaceClass (0x03 = HID)
0x00, // bInterfaceSubClass (0x00 = No Boot)
0x00, // bInterfaceProtocol (0x00 = No Protocol)
0, // iInterface
// HID interface descriptor, HID 1.11 spec, section 6.2.1
9, // bLength
0x21, // bDescriptorType
0x11, 0x01, // bcdHID
0, // bCountryCode
1, // bNumDescriptors
0x22, // bDescriptorType
LSB(sizeof(ps4_report_descriptor)), // wDescriptorLength
MSB(sizeof(ps4_report_descriptor)),
// endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
7, // bLength
5, // bDescriptorType
GAMEPAD_ENDPOINT | 0x80, // bEndpointAddress
0x03, // bmAttributes (0x03=intr)
GAMEPAD_SIZE, 0, // wMaxPacketSize
1, // bInterval (1 ms)
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x03, // bEndpointAddress (OUT/H2D)
0x03, // bmAttributes (Interrupt)
0x40, 0x00, // wMaxPacketSize 64
0x01, // bInterval 1 (unit depends on device speed)
};