Page 1 of 1

USB Joystick HID descriptor

Posted: Sat Nov 14, 2015 8:39 am
by szacpp
Hi,
I wrote HID descriptor for Joystick, the joystick has 8 axis. I want to know did I write correct code for axis and how can I add 8 buttons into the below code I have many tried for buttons but failed?
sorry for my bad english.
pls help me.

0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
0x09, 0xbb, // USAGE (Throttle)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X) for ailerons
0x09, 0x31, // USAGE (Y) for elevator
0x09, 0x32, // USAGE (Z) for rudder
0x09, 0x33, // USAGE (Rx) for spoiler
0x09, 0x34, // USAGE (Ry) for throttle 1
0x09, 0x35, // USAGE (Rz) for throttle 2
0x09, 0x38, // USAGE (Wheel) for trim wheel
0x09, 0x37, // USAGE (Dial) for flap
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION

Re: USB Joystick HID descriptor

Posted: Tue Nov 17, 2015 5:40 am
by ulao
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x15, 0x00, // LOGICAL_MINIMUM (0) this is none sense.
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
0x09, 0xbb, // USAGE (Throttle)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)

0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X) for ailerons
0x09, 0x31, // USAGE (Y) for elevator
0x09, 0x32, // USAGE (Z) for rudder
0x09, 0x33, // USAGE (Rx) for spoiler
0x09, 0x34, // USAGE (Ry) for throttle 1
0x09, 0x35, // USAGE (Rz) for throttle 2
0x09, 0x38, // USAGE (Wheel) for trim wheel
0x09, 0x37, // USAGE (Dial) for flap
0x75, 0x08, // REPORT_SIZE (8) //use need a report size here
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION

//button
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, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT


0xc0 // END_COLLECTION


Don't forget to change your report count in your main. I think that is 10 by my count.