-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathboot.py
60 lines (58 loc) · 2.55 KB
/
boot.py
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
import usb_hid
# fmt: off
report_descriptor = bytes(
[
0x05, 0x01, # Usage Page (Generic Desktop Ctrls)
0x09, 0x05, # Usage (Game Pad)
0xA1, 0x01, # Collection (Application)
0x15, 0x00, # Logical Minimum (0)
0x25, 0x01, # Logical Maximum (1)
0x35, 0x00, # Physical Minimum (0)
0x45, 0x01, # Physical Maximum (1)
0x75, 0x01, # Report Size (1)
0x95, 0x0E, # Report Count (14)
0x05, 0x09, # Usage Page (Button)
0x19, 0x01, # Usage Minimum (0x01)
0x29, 0x0E, # Usage Maximum (0x0E)
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x95, 0x02, # Report Count (2)
0x81, 0x01, # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x05, 0x01, # Usage Page (Generic Desktop Ctrls)
0x25, 0x07, # Logical Maximum (7)
0x46, 0x3B, 0x01, # Physical Maximum (315)
0x75, 0x04, # Report Size (4)
0x95, 0x01, # Report Count (1)
0x65, 0x14, # Unit (System: English Rotation, Length: Centimeter)
0x09, 0x39, # Usage (Hat switch)
0x81, 0x42, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State)
0x65, 0x00, # Unit (None)
0x95, 0x01, # Report Count (1)
0x81, 0x01, # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x26, 0xFF, 0x00, # Logical Maximum (255)
0x46, 0xFF, 0x00, # Physical Maximum (255)
0x09, 0x30, # Usage (X)
0x09, 0x31, # Usage (Y)
0x09, 0x32, # Usage (Z)
0x09, 0x35, # Usage (Rz)
0x75, 0x08, # Report Size (8)
0x95, 0x04, # Report Count (4)
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x75, 0x08, # Report Size (8)
0x95, 0x01, # Report Count (1)
0x81, 0x01, # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0, # End Collection
]
)
# fmt: on
usb_hid.enable(
(
usb_hid.Device(
report_descriptor=report_descriptor,
usage_page=0x01,
usage=0x05,
report_ids=(0,),
in_report_lengths=(8,),
out_report_lengths=(0,),
),
)
)