import pyb

# HID descriptor for a joystick
hid_desc = bytes([
   0x05, 0x01,        # Usage Page (Generic Desktop Ctrls)
   0x09, 0x04,        # Usage (Joystick)
   0xA1, 0x01,        # Collection (Application)
   0x05, 0x01,        #   Usage Page (Generic Desktop Ctrls)
   0x09, 0x01,        #   Usage (Pointer)
   0x15, 0x00,        #   Logical Minimum (0)
   0x26, 0xFF, 0x0F,  #   Logical Maximum (4095)
   0xA1, 0x00,        #   Collection (Physical)
   0x95, 0x01,        #     Report Count (1)
   0x75, 0x10,        #     Report Size (16)
   0x09, 0x30,        #     Usage (X)
   0x81, 0x02,        #     Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
   0x09, 0x31,        #     Usage (Y)
   0x81, 0x02,        #     Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
   0xC0,              #   End Collection
   0xC0,              # End Collection
])

pyb.usb_mode("VCP+HID", pid=0x1234, hid=(0, 2, 4, hid_desc))