-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusb_descriptors.h
732 lines (683 loc) · 26.8 KB
/
usb_descriptors.h
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
#ifndef USB_DESCRIPTORS_H
#define USB_DESCRIPTORS_H
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "hid_pid.h"
#include "config.h"
#define HID_UNIT_SECONDS 0x1003 // Documented as "Eng Lin:Time" in the PID spec
/////////////////////////////////////////////////////////////////////
// Input Report: Joystick postition, buttons, etc.
/////////////////////////////////////////////////////////////////////
#ifdef FIRMWARE_SHIFT
#define NUM_BUTTONS 16
// don't need any padding in this case
#define BUTTON_PADDING HID_REPORT_COUNT(1)
#else
#define NUM_BUTTONS 9
#define BUTTON_PADDING \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(7), \
HID_INPUT(HID_CONSTANT | HID_ARRAY | HID_ABSOLUTE)
#endif
#define SIDEWINDER_REPORT_DESC_INPUT_JOYSTICK(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_DESKTOP), \
HID_USAGE(HID_USAGE_DESKTOP_JOYSTICK), \
HID_COLLECTION(HID_COLLECTION_APPLICATION), \
/* Report ID */ __VA_ARGS__ \
HID_USAGE_PAGE(HID_USAGE_PAGE_BUTTON), \
HID_USAGE_MIN(1), \
HID_USAGE_MAX(NUM_BUTTONS), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(1), \
HID_REPORT_COUNT(NUM_BUTTONS), \
HID_REPORT_SIZE(1), \
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
BUTTON_PADDING, \
\
HID_USAGE_PAGE(HID_USAGE_PAGE_DESKTOP), \
/* X and Y are both reported as unsigned 10-bit */ \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(1023, 2), \
/* X: 10 data bits, 6 padding bits */ \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(10), \
HID_USAGE(HID_USAGE_DESKTOP_X), \
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(6), \
HID_INPUT(HID_CONSTANT | HID_ARRAY | HID_ABSOLUTE), \
/* Y: 10 data bits, 6 padding bits */ \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(10), \
HID_USAGE(HID_USAGE_DESKTOP_Y), \
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(6), \
HID_INPUT(HID_CONSTANT | HID_ARRAY | HID_ABSOLUTE), \
/* Rz (joystick twist): 6 data bits, 2 padding bits */ \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(63), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(6), \
HID_USAGE(HID_USAGE_DESKTOP_RZ), \
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(2), \
HID_INPUT(HID_CONSTANT | HID_ARRAY | HID_ABSOLUTE), \
/* Slider (throttle; kind of a dial): 7 data bits, 1 padding bit */ \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(127), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(7), \
HID_USAGE(HID_USAGE_DESKTOP_SLIDER), \
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(1), \
HID_INPUT(HID_CONSTANT | HID_ARRAY | HID_ABSOLUTE), \
/* Hat switch: 4 data bits, 4 padding bits */ \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(8), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(4), \
HID_USAGE(HID_USAGE_DESKTOP_HAT_SWITCH), \
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_REPORT_COUNT(1), \
HID_REPORT_SIZE(4), \
HID_INPUT(HID_CONSTANT | HID_ARRAY | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report: Set Effect - define params for an effect
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_SET_EFFECT(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_SET_EFFECT_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Effect Type */ \
HID_USAGE(HID_USAGE_PID_EFFECT_TYPE), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
HID_USAGE(HID_USAGE_PID_ET_CONSTANT_FORCE), \
HID_USAGE(HID_USAGE_PID_ET_RAMP), \
HID_USAGE(HID_USAGE_PID_ET_SQUARE), \
HID_USAGE(HID_USAGE_PID_ET_SINE), \
HID_USAGE(HID_USAGE_PID_ET_TRIANGLE), \
HID_USAGE(HID_USAGE_PID_ET_SAWTOOTH_UP), \
HID_USAGE(HID_USAGE_PID_ET_SAWTOOTH_DOWN), \
HID_USAGE(HID_USAGE_PID_ET_SPRING), \
HID_USAGE(HID_USAGE_PID_ET_DAMPER), \
HID_USAGE(HID_USAGE_PID_ET_INERTIA), \
HID_USAGE(HID_USAGE_PID_ET_FRICTION), \
/* Unlike the FF2, ET_CUSTOM_FORCE is not supported here. */ \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(11), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(11), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_ARRAY | HID_ABSOLUTE), \
HID_COLLECTION_END, \
\
/* Duration, Trigger Repeat, Sample Period */ \
HID_USAGE(HID_USAGE_PID_DURATION), \
HID_USAGE(HID_USAGE_PID_TRIGGER_REPEAT_INTERVAL), \
HID_USAGE(HID_USAGE_PID_SAMPLE_PERIOD), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(0xffff, 3), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(0xffff, 3), \
HID_UNIT_N(HID_UNIT_SECONDS, 2), \
HID_UNIT_EXPONENT(-3), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(3), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Gain */ \
HID_USAGE(HID_USAGE_PID_GAIN), \
HID_UNIT_EXPONENT(0), \
HID_UNIT(0), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(0x7f), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Trigger Button */ \
HID_USAGE(HID_USAGE_PID_TRIGGER_BUTTON), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(9), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(9), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Axes Enable */ \
HID_USAGE(HID_USAGE_PID_AXES_ENABLE), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
HID_USAGE_PAGE(HID_USAGE_PAGE_DESKTOP), \
HID_USAGE(HID_USAGE_DESKTOP_X), \
HID_USAGE(HID_USAGE_DESKTOP_Y), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(1), \
HID_REPORT_SIZE(1), \
HID_REPORT_COUNT(2), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_COLLECTION_END, \
\
/* Direction Enable */ \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_DIRECTION_ENABLE), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_REPORT_COUNT(5), \
HID_OUTPUT(HID_CONSTANT | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Direction */ \
HID_USAGE(HID_USAGE_PID_DIRECTION), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* NOTE: The HID spec specifies these should be Joystick usages, but Windows expects Ordinal.*/ \
/* TODO: check Linux and try to reconcile */ \
HID_USAGE_PAGE(HID_USAGE_PAGE_ORDINAL), \
HID_USAGE(1), \
HID_USAGE(2), \
HID_UNIT(20), \
HID_UNIT_EXPONENT(0), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(180, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(360, 2), \
HID_UNIT(0), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(2), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_UNIT_EXPONENT(0), \
HID_UNIT(0), \
HID_COLLECTION_END, \
\
/* Start Delay */ \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_START_DELAY), \
HID_UNIT_N(HID_UNIT_SECONDS, 2), \
HID_UNIT_EXPONENT(-3), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(32767, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(32767, 2), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
HID_UNIT(0), \
HID_UNIT_EXPONENT(0), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 2: Set Envelope - define envelope for an effect
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_SET_ENVELOPE(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_SET_ENVELOPE_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Attack Level, Fade Level */ \
HID_USAGE(HID_USAGE_PID_ATTACK_LEVEL), \
HID_USAGE(HID_USAGE_PID_FADE_LEVEL), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(2), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Attack Time, Fade Time */ \
HID_USAGE(HID_USAGE_PID_ATTACK_TIME), \
HID_USAGE(HID_USAGE_PID_FADE_TIME), \
HID_UNIT_N(HID_UNIT_SECONDS, 2), \
HID_UNIT_EXPONENT(-3), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(32767, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(32767, 2), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(2), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_PHYSICAL_MAX(0), \
HID_UNIT(0), \
HID_UNIT_EXPONENT(0), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 3: Set Condition - params for spring/damper/inertia
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_SET_CONDITION(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_SET_CONDITION_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Parameter Block Offset */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_OFFSET), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(1), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX(1), \
HID_REPORT_SIZE(8), /* 4 in SW FF2, since Specific Block Offset is also given afterward */ \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Center-Point Offset */ \
HID_USAGE(HID_USAGE_PID_CENTER_POINT_OFFSET), \
HID_LOGICAL_MIN(-128), \
HID_LOGICAL_MAX(127), \
HID_PHYSICAL_MIN_N(-10000, 2), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Positive/Negative Coefficient/Saturation; Dead Band */ \
HID_USAGE(HID_USAGE_PID_POSITIVE_COEFFICIENT), \
HID_USAGE(HID_USAGE_PID_NEGATIVE_COEFFICIENT), \
HID_USAGE(HID_USAGE_PID_POSITIVE_SATURATION), \
HID_USAGE(HID_USAGE_PID_NEGATIVE_SATURATION), \
HID_USAGE(HID_USAGE_PID_DEAD_BAND), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(5), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 4: Set Periodic - set params for periodic wave effects
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_SET_PERIODIC(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_SET_PERIODIC_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Magnitude */ \
HID_USAGE(HID_USAGE_PID_MAGNITUDE), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Offset */ \
HID_USAGE(HID_USAGE_PID_OFFSET), \
HID_LOGICAL_MIN(-128), \
HID_LOGICAL_MAX(127), \
HID_PHYSICAL_MIN_N(-10000, 2), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Phase */ \
HID_USAGE(HID_USAGE_PID_PHASE), \
HID_UNIT(20), \
HID_UNIT_EXPONENT(-2), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX(0), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Period */ \
HID_USAGE(HID_USAGE_PID_PERIOD), \
HID_UNIT_N(HID_UNIT_SECONDS, 2), \
HID_UNIT_EXPONENT(-3), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(32767, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(32767, 2), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_UNIT(0), \
HID_UNIT_EXPONENT(0), \
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 5: Set Constant - describe a constant force
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_SET_CONSTANT(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_SET_CONSTANT_FORCE_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Magnitude */ \
HID_USAGE(HID_USAGE_PID_MAGNITUDE), \
HID_LOGICAL_MIN_N(-255, 2), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MIN_N(-10000, 2), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 6: Set Ramp - describe a ramp force
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_SET_RAMP(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_SET_RAMP_FORCE_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Ramp Start and End */ \
HID_USAGE(HID_USAGE_PID_RAMP_START), \
HID_USAGE(HID_USAGE_PID_RAMP_END), \
HID_LOGICAL_MIN(-128), \
HID_LOGICAL_MAX(127), \
HID_PHYSICAL_MIN_N(-10000, 2), \
HID_PHYSICAL_MAX_N(10000, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(2), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 10: Effect Operation - stop/start effects
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_EFFECT_OPERATION(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_EFFECT_OPERATION_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Effect Operation */ \
HID_USAGE(HID_USAGE_PID_EFFECT_OPERATION), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
HID_USAGE(HID_USAGE_PID_OP_EFFECT_START), \
HID_USAGE(HID_USAGE_PID_OP_EFFECT_START_SOLO), \
HID_USAGE(HID_USAGE_PID_OP_EFFECT_STOP), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(3), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_ARRAY | HID_ABSOLUTE), \
HID_COLLECTION_END, \
\
/* Loop Count */ \
HID_USAGE(HID_USAGE_PID_LOOP_COUNT), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MIN(0), \
HID_PHYSICAL_MAX_N(255, 2), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 11: Block Free - delete an effect and free its space
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_BLOCK_FREE(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_FREE_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 12: Device Control - commands affecting entire device
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_DEVICE_CONTROL(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_DEVICE_CONTROL), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_DC_ENABLE_ACTUATORS), \
HID_USAGE(HID_USAGE_PID_DC_DISABLE_ACTUATORS), \
HID_USAGE(HID_USAGE_PID_DC_STOP_ALL_EFFECTS), \
HID_USAGE(HID_USAGE_PID_DC_RESET), \
HID_USAGE(HID_USAGE_PID_DC_PAUSE), \
HID_USAGE(HID_USAGE_PID_DC_CONTINUE), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(6), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_ARRAY | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Output Report 13: Device Gain - gain across all effects
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_OUTPUT_DEVICE_GAIN(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_DEVICE_GAIN_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Device Gain */ \
HID_USAGE(HID_USAGE_PID_DEVICE_GAIN), \
HID_LOGICAL_MIN(0), \
HID_LOGICAL_MAX(0x7f), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Feature Report 1: Create New Effect (in device memory)
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_FEATURE_CREATE_NEW_EFFECT(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_CREATE_NEW_EFFECT_PARAM_BLOCK_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Effect Type */ \
HID_USAGE(HID_USAGE_PID_EFFECT_TYPE), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
HID_USAGE(HID_USAGE_PID_ET_CONSTANT_FORCE), \
HID_USAGE(HID_USAGE_PID_ET_RAMP), \
HID_USAGE(HID_USAGE_PID_ET_SQUARE), \
HID_USAGE(HID_USAGE_PID_ET_SINE), \
HID_USAGE(HID_USAGE_PID_ET_TRIANGLE), \
HID_USAGE(HID_USAGE_PID_ET_SAWTOOTH_UP), \
HID_USAGE(HID_USAGE_PID_ET_SAWTOOTH_DOWN), \
HID_USAGE(HID_USAGE_PID_ET_SPRING), \
HID_USAGE(HID_USAGE_PID_ET_DAMPER), \
HID_USAGE(HID_USAGE_PID_ET_INERTIA), \
HID_USAGE(HID_USAGE_PID_ET_FRICTION), \
/* Unlike the FF2, ET_CUSTOM_FORCE is not supported here. */ \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(11), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(11), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_FEATURE(HID_DATA | HID_ARRAY | HID_ABSOLUTE), \
HID_COLLECTION_END, \
\
/* Byte Count from FF2 descriptor omitted, since we don't support custom forces. */ \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Feature Report 2: Effect Block Load Report - was effect creation successful?
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_FEATURE_BLOCK_LOAD(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_LOAD_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* Block Index */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_INDEX), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(40), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(40), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_FEATURE(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Block Load Status */ \
HID_USAGE(HID_USAGE_PID_EFFECT_PARAM_BLOCK_LOAD_STATUS), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
HID_USAGE(HID_USAGE_PID_BLOCK_LOAD_SUCCESS), \
HID_USAGE(HID_USAGE_PID_BLOCK_LOAD_FULL), \
HID_USAGE(HID_USAGE_PID_BLOCK_LOAD_ERROR), \
HID_LOGICAL_MIN(1), \
HID_LOGICAL_MAX(3), \
HID_PHYSICAL_MIN(1), \
HID_PHYSICAL_MAX(3), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_FEATURE(HID_DATA | HID_ARRAY | HID_ABSOLUTE), \
HID_COLLECTION_END, \
\
/* RAM Pool Available */ \
HID_USAGE(HID_USAGE_PID_RAM_POOL_AVAILABLE), \
HID_LOGICAL_MIN(0), \
HID_PHYSICAL_MIN(0), \
HID_LOGICAL_MAX_N(0xFFFF, 3), \
HID_PHYSICAL_MAX_N(0xFFFF, 3), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(1), \
HID_FEATURE(HID_DATA | HID_ARRAY | HID_ABSOLUTE), \
\
HID_COLLECTION_END
/////////////////////////////////////////////////////////////////////
// Feature Report 3: Pool size, max simultaneous effects, etc.
/////////////////////////////////////////////////////////////////////
#define SIDEWINDER_REPORT_DESC_FEATURE_POOL_REPORT(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_PID), \
HID_USAGE(HID_USAGE_PID_PARAM_BLOCK_POOLS_REPORT), \
HID_COLLECTION(HID_COLLECTION_LOGICAL), \
/* Report ID */ __VA_ARGS__ \
\
/* RAM Pool Size */ \
HID_USAGE(HID_USAGE_PID_RAM_POOL_SIZE), \
HID_REPORT_SIZE(16), \
HID_REPORT_COUNT(1), \
HID_LOGICAL_MIN(0), \
HID_PHYSICAL_MIN(0), \
HID_LOGICAL_MAX_N(0xFFFF, 3), \
HID_PHYSICAL_MAX_N(0xFFFF, 3), \
HID_FEATURE(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Simultaneous Maximum Effects */ \
HID_USAGE(HID_USAGE_PID_SIMULTANEOUS_EFFECTS_MAX), \
HID_LOGICAL_MAX_N(255, 2), \
HID_PHYSICAL_MAX_N(255, 2), \
HID_REPORT_SIZE(8), \
HID_REPORT_COUNT(1), \
HID_FEATURE(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* Managed Pool, Shared Blocks */ \
HID_USAGE(HID_USAGE_PID_DEVICE_MANAGED_POOL), \
HID_USAGE(HID_USAGE_PID_SHARED_PARAMETER_BLOCKS), \
HID_LOGICAL_MAX(1), \
HID_PHYSICAL_MAX(1), \
HID_REPORT_SIZE(1), \
HID_REPORT_COUNT(2), \
HID_FEATURE(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \
\
/* padding */ \
HID_REPORT_SIZE(6), \
HID_REPORT_COUNT(1), \
HID_FEATURE(HID_CONSTANT | HID_VARIABLE | HID_ABSOLUTE), \
\
HID_COLLECTION_END
#endif // USB_DESCRIPTORS_H