-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
94 lines (84 loc) · 3.88 KB
/
boot.py
File metadata and controls
94 lines (84 loc) · 3.88 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
import os
import digitalio
import storage
import supervisor
import usb_cdc
import usb_hid
import usb_midi
from constants import FW_UPDATE_PIN, REPORT_SIZE
from utils import DEBUG_MODE
supervisor.set_usb_identification("Iron Tigers", "TigerPad Controller", 0x4176, 2025)
usb_hid.set_interface_name("TigerPad Controller") # type: ignore
fw_update_button = digitalio.DigitalInOut(FW_UPDATE_PIN)
fw_update_button.pull = digitalio.Pull.DOWN
usb_midi.disable()
if not (DEBUG_MODE):
storage.disable_usb_drive()
usb_cdc.enable(console=False, data=True)
supervisor.runtime.autoreload = True
else:
usb_cdc.enable(console=True, data=True)
supervisor.runtime.autoreload = False
# fmt: off
GAMEPAD_REPORT_DESCRIPTOR = bytes((
0x05, 0x01, # USAGE_PAGE (Generic Desktop)
0x09, 0x05, # USAGE (Game Pad)
0xa1, 0x01, # COLLECTION (Application)
0xa1, 0x00, # COLLECTION (Physical)
0x05, 0x09, # USAGE_PAGE (Button)
0x19, 0x01, # USAGE_MINIMUM (Button 1)
0x29, 0x0a, # USAGE_MAXIMUM (Button 10)
0x15, 0x00, # LOGICAL_MINIMUM (0)
0x25, 0x01, # LOGICAL_MAXIMUM (1)
0x95, 0x0a, # REPORT_COUNT (10)
0x75, 0x01, # REPORT_SIZE (1)
0x81, 0x02, # INPUT (Data,Var,Abs)
0x95, 0x01, # REPORT_COUNT (1)
0x75, 0x06, # REPORT_SIZE (6)
0x81, 0x03, # INPUT (Cnst,Var,Abs)
0xc0, # END_COLLECTION
0x05, 0x01, # USAGE_PAGE (Generic Desktop)
0xa1, 0x00, # COLLECTION (Physical)
0x09, 0x31, # USAGE (Y)
0x16, 0x00, 0xf8, # LOGICAL_MINIMUM (-2048)
0x26, 0xff, 0x07, # LOGICAL_MAXIMUM (2047)
0x75, 0x10, # REPORT_SIZE (16)
0x95, 0x01, # REPORT_COUNT (1)
0x81, 0x02, # INPUT (Data,Var,Abs)
0xc0, # END_COLLECTION
0xa1, 0x00, # COLLECTION (Physical)
0x09, 0x34, # USAGE (Ry)
0x16, 0x00, 0xf8, # LOGICAL_MINIMUM (-2048)
0x26, 0xff, 0x07, # LOGICAL_MAXIMUM (2047)
0x75, 0x10, # REPORT_SIZE (16)
0x95, 0x01, # REPORT_COUNT (1)
0x81, 0x02, # INPUT (Data,Var,Abs)
0xc0, # END_COLLECTION
0xa1, 0x00, # COLLECTION (Physical)
0x09, 0x32, # USAGE (Z)
0x16, 0x00, 0xf8, # LOGICAL_MINIMUM (-2048)
0x26, 0xff, 0x07, # LOGICAL_MAXIMUM (2047)
0x75, 0x10, # REPORT_SIZE (16)
0x95, 0x01, # REPORT_COUNT (1)
0x81, 0x02, # INPUT (Data,Var,Abs)
0xc0, # END_COLLECTION
0xa1, 0x00, # COLLECTION (Physical)
0x09, 0x37, # USAGE (Dial)
0x15, 0x9c, # LOGICAL_MINIMUM (-100)
0x25, 0x64, # LOGICAL_MAXIMUM (100)
0x75, 0x10, # REPORT_SIZE (16)
0x95, 0x01, # REPORT_COUNT (1)
0x81, 0x02, # INPUT (Data,Var,Abs)
0xc0, # END_COLLECTION
0xc0 # END_COLLECTION
))
# fmt: on
hid_gamepad = usb_hid.Device(
report_descriptor=GAMEPAD_REPORT_DESCRIPTOR,
usage_page=0x01,
usage=0x05,
report_ids=(0,),
in_report_lengths=(REPORT_SIZE,),
out_report_lengths=(0,),
)
usb_hid.enable((hid_gamepad,))