diff options
| author | Zoltan Szabatin <[email protected]> | 2025-03-05 20:07:54 -0800 |
|---|---|---|
| committer | Zoltan Szabatin <[email protected]> | 2025-03-05 20:07:54 -0800 |
| commit | 513235a9953648026aba927d96b93b0e80b84083 (patch) | |
| tree | 3f37eaf9ed4fc8257f148def2f928de93f4d046f /src/pico/boot.py | |
| parent | fix(Input): Controller button indexes (diff) | |
| download | splitscreen-duo-513235a9953648026aba927d96b93b0e80b84083.tar.xz splitscreen-duo-513235a9953648026aba927d96b93b0e80b84083.zip | |
feat: Add Pico-specific modules
Diffstat (limited to 'src/pico/boot.py')
| -rwxr-xr-x | src/pico/boot.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/pico/boot.py b/src/pico/boot.py new file mode 100755 index 0000000..bc37857 --- /dev/null +++ b/src/pico/boot.py @@ -0,0 +1,42 @@ +import usb_hid
+
+GAMEPAD_REPORT_DESCRIPTOR = bytes([
+ 0x05, 0x01, # Usage Page (Generic Desktop)
+ 0x09, 0x05, # Usage (Game Pad)
+ 0xA1, 0x01, # Collection (Application)
+ 0x85, 0x01, # Report ID (1)
+ 0x05, 0x09, # Usage Page (Button)
+ 0x19, 0x01, # Usage Minimum (Button 1)
+ 0x29, 0x10, # Usage Maximum (Button 16)
+ 0x15, 0x00, # Logical Minimum (0)
+ 0x25, 0x01, # Logical Maximum (1)
+ 0x95, 0x10, # Report Count (16)
+ 0x75, 0x01, # Report Size (1)
+ 0x81, 0x02, # Input (Data, Variable, Absolute)
+ 0x05, 0x01, # Usage Page (Generic Desktop)
+ 0x09, 0x30, # Usage (X)
+ 0x09, 0x31, # Usage (Y)
+ 0x09, 0x32, # Usage (Z)
+ 0x09, 0x33, # Usage (Rx)
+ 0x09, 0x34, # Usage (Ry)
+ 0x09, 0x35, # Usage (Rz)
+ 0x15, 0x81, # Logical Minimum (-127)
+ 0x25, 0x7F, # Logical Maximum (127)
+ 0x75, 0x08, # Report Size (8)
+ 0x95, 0x06, # Report Count (6)
+ 0x81, 0x02, # Input (Data, Variable, Absolute)
+ 0xC0 # End Collection
+])
+
+gamepad_device = usb_hid.Device(
+ report_descriptor=GAMEPAD_REPORT_DESCRIPTOR,
+ usage_page=0x01,
+ usage=0x05,
+ report_ids=(1,),
+ in_report_lengths=(8,), # Total report length is now 8 bytes
+ out_report_lengths=(0,),
+)
+
+usb_hid.enable((gamepad_device,))
+
+print("Custom gamepad HID enabled.")
\ No newline at end of file |