Skip to content

Instantly share code, notes, and snippets.

@wereii
Last active November 14, 2024 01:57
Show Gist options
  • Save wereii/b215c799a267af10154087b5d5af3a6b to your computer and use it in GitHub Desktop.
Save wereii/b215c799a267af10154087b5d5af3a6b to your computer and use it in GitHub Desktop.
Very Simple Gamepad HID Descriptor
//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
};
@Ugobyte
Copy link

Ugobyte commented Sep 22, 2022

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