@@ -23,91 +23,61 @@ def device(report_id: int) -> usb_hid.Device:
23
23
24
24
:param int report_id: The report ID to use for the device.
25
25
"""
26
+ # fmt: off
26
27
return usb_hid .Device (
27
- # fmt: off
28
- report_descriptor = bytes (
29
- (
30
- 0x05 ,
31
- 0x01 , # Usage Page (Generic Desktop)
32
- 0x09 ,
33
- 0x0E , # Usage (System Multi-Axis Controller)
34
- 0xA1 ,
35
- 0x01 , # Collection (Application)
36
- 0x85 ,
37
- report_id , # Report Id (Radial Controller)
38
- 0x05 ,
39
- 0x0D , # Usage Page (Digitizers)
40
- 0x09 ,
41
- 0x21 , # Usage (Puck)
42
- 0xA1 ,
43
- 0x00 , # Collection (Physical)
44
- # The Microsoft example packs the report into 1 bit and 15 bits,
45
- # but that's more work. We'll just use 1 bit of one byte and then 16 bits.
46
- # Button
47
- 0x05 ,
48
- 0x09 , # Usage Page (Buttons)
49
- 0x09 ,
50
- 0x01 , # Usage (Button 1)
51
- 0x15 ,
52
- 0x00 , # Logical Minimum (0)
53
- 0x25 ,
54
- 0x01 , # Logical Maximum (1)
55
- 0x75 ,
56
- 0x01 , # Report Size (1)
57
- 0x95 ,
58
- 0x01 , # Report Count (1)
59
- 0x81 ,
60
- 0x02 , # Input (Data,Var,Abs)
61
- # Padding
62
- 0x75 ,
63
- 0x07 , # Report Size (7)
64
- 0x95 ,
65
- 0x01 , # Report Count (1)
66
- 0x81 ,
67
- 0x01 , # Input (Data,Var,Abs)
68
- # Rotation
69
- 0x05 ,
70
- 0x01 , # Usage Page (Generic Desktop)
71
- 0x09 ,
72
- 0x37 , # Usage (Dial)
73
- 0x55 ,
74
- 0x0F , # Unit Exponent (-1)
75
- 0x65 ,
76
- 0x14 , # Unit (Degrees, English Rotation)
77
- 0x36 ,
78
- 0xF0 ,
79
- 0xF1 , # Physical Minimum (-3600)
80
- 0x46 ,
81
- 0x10 ,
82
- 0x0E , # Physical Maximum (3600)
83
- 0x16 ,
84
- 0xF0 ,
85
- 0xF1 , # Logical Minimum (-3600)
86
- 0x26 ,
87
- 0x10 ,
88
- 0x0E , # Logical Maximum (3600)
89
- 0x75 ,
90
- 0x10 , # Report Size (16)
91
- 0x95 ,
92
- 0x01 , # Report Count (1)
93
- 0x81 ,
94
- 0x06 , # Input (Data,Var,Rel)
95
- 0xC0 , # End Collection
96
- 0xC0 , # End Collection
97
- # The presence of this (empty) System Control Collection makes the device
98
- # appear in /dev/input in Linux, which will help if radial controller
99
- # functionality is added in userspace code.
100
- 0x09 ,
101
- 0x80 , # Usage (System Control)
102
- 0xA1 ,
103
- 0x01 , # Collection (Application)
104
- 0xC0 , # End Collection
105
- )
106
- ),
107
- # fmt: on
28
+ report_descriptor = bytes ((
29
+ 0x05 , 0x01 , # Usage Page (Generic Desktop)
30
+ 0x09 , 0x0e , # Usage (System Multi-Axis Controller)
31
+ 0xa1 , 0x01 , # Collection (Application)
32
+ 0x85 , report_id , # Report Id (Radial Controller)
33
+ 0x05 , 0x0d , # Usage Page (Digitizers)
34
+ 0x09 , 0x21 , # Usage (Puck)
35
+ 0xa1 , 0x00 , # Collection (Physical)
36
+
37
+ # The Microsoft example packs the report into 1 bit and 15 bits,
38
+ # but that's more work. We'll just use 1 bit of one byte and then 16 bits.
39
+
40
+ # Button
41
+ 0x05 , 0x09 , # Usage Page (Buttons)
42
+ 0x09 , 0x01 , # Usage (Button 1)
43
+ 0x15 , 0x00 , # Logical Minimum (0)
44
+ 0x25 , 0x01 , # Logical Maximum (1)
45
+ 0x75 , 0x01 , # Report Size (1)
46
+ 0x95 , 0x01 , # Report Count (1)
47
+ 0x81 , 0x02 , # Input (Data,Var,Abs)
48
+
49
+ # Padding
50
+ 0x75 , 0x07 , # Report Size (7)
51
+ 0x95 , 0x01 , # Report Count (1)
52
+ 0x81 , 0x01 , # Input (Data,Var,Abs)
53
+
54
+ # Rotation
55
+ 0x05 , 0x01 , # Usage Page (Generic Desktop)
56
+ 0x09 , 0x37 , # Usage (Dial)
57
+ 0x55 , 0x0f , # Unit Exponent (-1)
58
+ 0x65 , 0x14 , # Unit (Degrees, English Rotation)
59
+ 0x36 , 0xf0 , 0xf1 , # Physical Minimum (-3600)
60
+ 0x46 , 0x10 , 0x0e , # Physical Maximum (3600)
61
+ 0x16 , 0xf0 , 0xf1 , # Logical Minimum (-3600)
62
+ 0x26 , 0x10 , 0x0e , # Logical Maximum (3600)
63
+ 0x75 , 0x10 , # Report Size (16)
64
+ 0x95 , 0x01 , # Report Count (1)
65
+ 0x81 , 0x06 , # Input (Data,Var,Rel)
66
+
67
+ 0xc0 , # End Collection
68
+ 0xc0 , # End Collection
69
+
70
+ # The presence of this (empty) System Control Collection makes the device
71
+ # appear in /dev/input in Linux, which will help if radial controller
72
+ # functionality is added in userspace code.
73
+ 0x09 , 0x80 , # Usage (System Control)
74
+ 0xa1 , 0x01 , # Collection (Application)
75
+ 0xc0 , # End Collection
76
+ )),
108
77
usage_page = 0x01 ,
109
78
usage = 0x0E ,
110
79
report_ids = (report_id ,),
111
80
in_report_lengths = (3 ,),
112
81
out_report_lengths = (0 ,),
113
82
)
83
+ # fmt: on
0 commit comments