HID Gamepad - not more than 16 buttons?
Posted: Tue Sep 09, 2014 11:33 pm
Is there a limit as to how many digital buttons a HID gamepad supports?
When I increase the USAGE_MAXIMUM beyond "Button 16" my computer doesn't accept any inputs from the device anymore - not from any of the buttons, nor from the analog axis.
My working HID descriptor:
And the structure that holds the values:
If I change USAGE_MAXIMUM to 0x20 (Button 32), REPORT_COUNT to 0x20 (32) and the relevant part of the structure to uint32_t buttons like so...
...then the device gets installed correctly and I can see all 32 buttons in the game controller setup dialog of windows, but it doesn't accept any inputs anymore. Not from any of the buttons, not from any of the axis.
I verified that the USB communication is indeed correct and the respective bits are set when I press buttons. I've debugged this for half a day now and I'm fairly confident that the code is correct.
Is there a hard limit of 16 digital buttons for gamepads?
I a related matter, does anyone have a working HIDreportDescriptor for a joystick? I know for a fact that those support more than 16 buttons
Thanks in advance
When I increase the USAGE_MAXIMUM beyond "Button 16" my computer doesn't accept any inputs from the device anymore - not from any of the buttons, nor from the analog axis.
My working HID descriptor:
Code: Select all
PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {
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, 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,Var,Abs)
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, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};
And the structure that holds the values:
Code: Select all
typedef struct {
uint16_t buttons;
uint8_t x;
uint8_t y;
uint8_t z;
uint8_t rx;
uint8_t ry;
uint8_t rz;
} gamepad_report_t;
If I change USAGE_MAXIMUM to 0x20 (Button 32), REPORT_COUNT to 0x20 (32) and the relevant part of the structure to uint32_t buttons like so...
Code: Select all
PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {
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, 0x20, // USAGE_MAXIMUM (Button 32)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x20, // REPORT_COUNT (32)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
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, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};
typedef struct {
uint32_t buttons;
uint8_t x;
uint8_t y;
uint8_t z;
uint8_t rx;
uint8_t ry;
uint8_t rz;
} gamepad_report_t;
...then the device gets installed correctly and I can see all 32 buttons in the game controller setup dialog of windows, but it doesn't accept any inputs anymore. Not from any of the buttons, not from any of the axis.
I verified that the USB communication is indeed correct and the respective bits are set when I press buttons. I've debugged this for half a day now and I'm fairly confident that the code is correct.
Is there a hard limit of 16 digital buttons for gamepads?
I a related matter, does anyone have a working HIDreportDescriptor for a joystick? I know for a fact that those support more than 16 buttons
Thanks in advance