Skip to content

usb_hid usage 0x00 needed but not allowed #10576

@akseidel

Description

@akseidel

CircuitPython version and board name

Adafruit CircuitPython 9.2.8 on 2025-05-28; Raspberry Pi Pico with rp2040

Code/REPL

# boot.py for pm2be_emulator

import supervisor
import usb_hid
...

PM2BE_REPORT_DESCRIPTOR = bytes((
0x05, 0x01,        # Usage Page (Generic Desktop Ctrls)
0x09, 0x00,        # Usage (Undefined)
0xA1, 0x01,        # Collection (Application)
0x05, 0x08,        #   Usage Page (LEDs)
0x09, 0x4B,        #   Usage (Generic Indicator)
0x15, 0x00,        #   Logical Minimum (0)
0x25, 0x01,        #   Logical Maximum (1)
0x95, 0x08,        #   Report Count (8)
0x75, 0x01,        #   Report Size (1)
0x91, 0x02,        #   Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x05, 0x09,        #   Usage Page (Button)
0x15, 0x00,        #   Logical Minimum (0)
0x25, 0x01,        #   Logical Maximum (1)
0x75, 0x01,        #   Report Size (1)
0x95, 0x08,        #   Report Count (8)
0x81, 0x01,        #   Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x19, 0x01,        #   Usage Minimum (0x01)
0x29, 0x0E,        #   Usage Maximum (0x0E)
0x15, 0x00,        #   Logical Minimum (0)
0x25, 0x01,        #   Logical Maximum (1)
0x95, 0x0E,        #   Report Count (14)
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, 0xFF,        #   Usage Page (Reserved 0xFF)
0x09, 0x00,        #   Usage (0x00)
0x15, 0x00,        #   Logical Minimum (0)
0x26, 0xFF, 0x00,  #   Logical Maximum (255)
0x75, 0x08,        #   Report Size (8)
0x95, 0x27,        #   Report Count (39)
0xB1, 0x00,        #   Feature (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0xC0,              # End Collection
))

...

pm2be = usb_hid.Device(
    report_descriptor=PM2BE_REPORT_DESCRIPTOR,
    usage_page=0x01,           # Usage Page (Generic Desktop Ctrls)
    usage=0x00,                # Usage (Undefined)
    report_ids=(0,),           # Descriptor uses report ID 1
    in_report_lengths=(3,),    # This PM2BEL sends 3 bytes in its report.
    out_report_lengths=(8,),   #
)

Behavior

%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "", line 88, in
ValueError: usage must be 1-65535

Line 88 is “0x09, 0x00, # Usage (Undefined)” within the PM2BE_REPORT_DESCRIPTOR.

Description

The intent is to emulate using Circuitpython a usb device that has a USB report descriptor that starts with:

0x05, 0x01, # Usage Page (Generic Desktop Ctrls)
0x09, 0x00, # Usage (Undefined)

Usage=0x00, supposedly means undefined but apparently is not prohibited since the the device to be emulated does function just fine. It appears there is an argument range check for “usage” that does not include 0x00 usage.

Additional information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions