Commit 30f6d2bf authored by Dean Camera's avatar Dean Camera
Browse files

Oops - forgot to add in LOGICAL MINIMUM and LOGICAL MAXIMUM report items into...

Oops - forgot to add in LOGICAL MINIMUM and LOGICAL MAXIMUM report items into the standard library Joystick HID report descriptor macro. Add in support for joystick resolution reporting via PHYSICAL_MINIMUM and PHYSICAL_MAXIMUM items.
parent e6dc9516
......@@ -45,7 +45,7 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{
/* Use the HID class driver's standard Joystick report.
/* Use the HID class driver's standard Vendor HID report.
* Vendor Usage Page: 1
* Vendor Collection Usage: 1
* Vendor Report IN Usage: 2
......
......@@ -48,9 +48,11 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
/* Use the HID class driver's standard Joystick report.
* Min X/Y Axis values: -100
* Max X/Y Axis values: 100
* Min physical X/Y Axis values (used to determine resolution): -1
* Max physical X/Y Axis values (used to determine resolution): 1
* Buttons: 2
*/
HID_DESCRIPTOR_JOYSTICK(-100, 100, 2)
HID_DESCRIPTOR_JOYSTICK(-100, 100, -1, 1, 2)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
......
......@@ -54,8 +54,10 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
HID_RI_USAGE(8, 0x31), /* Usage Y */
HID_RI_LOGICAL_MINIMUM(8, -100),
HID_RI_LOGICAL_MAXIMUM(8, 100),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_PHYSICAL_MINIMUM(8, -1),
HID_RI_PHYSICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
HID_RI_USAGE_PAGE(8, 0x09), /* Button */
......
......@@ -343,11 +343,13 @@
* Where \c uintA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the
* ranges of the signed \c MinAxisVal and \c MaxAxisVal values.
*
* \param[in] MinAxisVal Minimum X/Y logical axis value
* \param[in] MaxAxisVal Maximum X/Y logical axis value
* \param[in] Buttons Total number of buttons in the device
* \param[in] MinAxisVal Minimum X/Y logical axis value
* \param[in] MaxAxisVal Maximum X/Y logical axis value
* \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations
* \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations
* \param[in] Buttons Total number of buttons in the device
*/
#define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, Buttons) \
#define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \
HID_RI_USAGE_PAGE(8, 0x01), \
HID_RI_USAGE(8, 0x04), \
HID_RI_COLLECTION(8, 0x01), \
......@@ -355,8 +357,12 @@
HID_RI_COLLECTION(8, 0x00), \
HID_RI_USAGE(8, 0x30), \
HID_RI_USAGE(8, 0x31), \
HID_RI_REPORT_SIZE(8, (((((uint16_t)MinAxisVal > 0xFF) && ((uint16_t)MaxAxisVal < 0xFF)) ? 8 : 16))), \
HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \
HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \
HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \
HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \
HID_RI_REPORT_COUNT(8, 0x02), \
HID_RI_REPORT_SIZE(8, (((((uint16_t)MinAxisVal > 0xFF) && ((uint16_t)MaxAxisVal < 0xFF)) ? 8 : 16))), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_END_COLLECTION(0), \
HID_RI_USAGE_PAGE(8, 0x09), \
......
......@@ -57,7 +57,7 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{
/* Use the HID class driver's standard Joystick report.
/* Use the HID class driver's standard Vendor HID report.
* Vendor Usage Page: 1
* Vendor Collection Usage: 1
* Vendor Report IN Usage: 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment