Last active
November 14, 2024 01:57
-
-
Save wereii/b215c799a267af10154087b5d5af3a6b to your computer and use it in GitHub Desktop.
Very Simple Gamepad HID Descriptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//simple_gamepad_hid.h | |
#define REPORT_BYTE_LENGTH 4 // (8 + 16 + 8) / 8 | |
char ReportDescriptor[44] = { | |
0x05, 0x01, // USAGE_PAGE (Generic Desktop) | |
0x09, 0x05, // USAGE (Game Pad) | |
0xa1, 0x01, // COLLECTION (Application) | |
0xa1, 0x00, // COLLECTION (Physical) | |
// ReportID - 8 bits | |
0x85, 0x01, // REPORT_ID (1) | |
// X & Y - 2x8 = 16 bits | |
0x05, 0x01, // USAGE_PAGE (Generic Desktop) | |
0x09, 0x30, // USAGE (X) | |
0x09, 0x31, // USAGE (Y) | |
0x15, 0x81, // LOGICAL_MINIMUM (-127) | |
0x25, 0x7f, // LOGICAL_MAXIMUM (127) | |
0x75, 0x08, // REPORT_SIZE (8) | |
0x95, 0x02, // REPORT_COUNT (2) | |
0x81, 0x02, // INPUT (Data,Var,Abs) | |
// Buttons - 8 bits | |
0x05, 0x09, // USAGE_PAGE (Button) | |
0x19, 0x01, // USAGE_MINIMUM (Button 1) | |
0x29, 0x08, // USAGE_MAXIMUM (Button 8) | |
0x15, 0x00, // LOGICAL_MINIMUM (0) | |
0x25, 0x01, // LOGICAL_MAXIMUM (1) | |
0x75, 0x08, // REPORT_SIZE (8) | |
0x95, 0x01, // REPORT_COUNT (1) | |
0x81, 0x02, // INPUT (Data,Var,Abs) | |
0xc0, // END_COLLECTION | |
0xc0 // END_COLLECTION | |
}; |
I believe the button's report size and report count should be switched - youve indicated 1 button, with 8 bytes of data. Really it should be 8 buttons over 1 byte of data
0x15, 0x81, // LOGICAL_MINIMUM (-127)
better:
0x15, 0x80, // LOGICAL_MINIMUM (-128)
How do you make the Joystick X & Y axes output floating point values?
Your description has the minimum and maximum values at: -128 and 127. However, most games are expecting -1.00 to 1.00.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, could you tell me where to find an example of gamapad for stm32F103
Thanks!!!