From b3aaffb792aed373fecd4af16478cb3c2b8c2a8f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 29 Mar 2012 19:41:05 +0000 Subject: [PATCH] Removed variable axis support from the HID_DESCRIPTOR_JOYSTICK() macro due to OS incompatibilities, replaced with fixed 3-axis joystick report structure. --- .../Device/ClassDriver/Joystick/Descriptors.c | 11 ++++----- Demos/Device/ClassDriver/Joystick/Joystick.h | 1 + Demos/Device/LowLevel/Joystick/Descriptors.c | 3 ++- Demos/Device/LowLevel/Joystick/Joystick.h | 1 + LUFA/DoxygenPages/ChangeLog.txt | 3 ++- LUFA/DoxygenPages/MigrationInformation.txt | 3 +++ .../Drivers/USB/Class/Common/HIDClassCommon.h | 23 +++++++++---------- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Demos/Device/ClassDriver/Joystick/Descriptors.c b/Demos/Device/ClassDriver/Joystick/Descriptors.c index 2e8390075f..da6fc3d094 100644 --- a/Demos/Device/ClassDriver/Joystick/Descriptors.c +++ b/Demos/Device/ClassDriver/Joystick/Descriptors.c @@ -46,14 +46,13 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = { /* Use the HID class driver's standard Joystick report. - * Number of Axis: 2 (X/Y) - * 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 + * Min X/Y/Z Axis values: -100 + * Max X/Y/Z Axis values: 100 + * Min physical X/Y/Z Axis values (used to determine resolution): -1 + * Max physical X/Y/Z Axis values (used to determine resolution): 1 * Buttons: 2 */ - HID_DESCRIPTOR_JOYSTICK(2, -100, 100, -1, 1, 2) + HID_DESCRIPTOR_JOYSTICK(-100, 100, -1, 1, 2) }; /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall diff --git a/Demos/Device/ClassDriver/Joystick/Joystick.h b/Demos/Device/ClassDriver/Joystick/Joystick.h index ab1503809d..4bc5056547 100644 --- a/Demos/Device/ClassDriver/Joystick/Joystick.h +++ b/Demos/Device/ClassDriver/Joystick/Joystick.h @@ -59,6 +59,7 @@ { int8_t X; /**< Current absolute joystick X position, as a signed 8-bit integer */ int8_t Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */ + int8_t Z; /**< Current absolute joystick Z position, as a signed 8-bit integer */ uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */ } USB_JoystickReport_Data_t; diff --git a/Demos/Device/LowLevel/Joystick/Descriptors.c b/Demos/Device/LowLevel/Joystick/Descriptors.c index e380c69331..272595d995 100644 --- a/Demos/Device/LowLevel/Joystick/Descriptors.c +++ b/Demos/Device/LowLevel/Joystick/Descriptors.c @@ -52,11 +52,12 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = HID_RI_COLLECTION(8, 0x00), /* Physical */ HID_RI_USAGE(8, 0x30), /* Usage X */ HID_RI_USAGE(8, 0x31), /* Usage Y */ + HID_RI_USAGE(8, 0x32), /* Usage Z */ HID_RI_LOGICAL_MINIMUM(8, -100), HID_RI_LOGICAL_MAXIMUM(8, 100), HID_RI_PHYSICAL_MINIMUM(8, -1), HID_RI_PHYSICAL_MAXIMUM(8, 1), - HID_RI_REPORT_COUNT(8, 0x02), + HID_RI_REPORT_COUNT(8, 0x03), HID_RI_REPORT_SIZE(8, 0x08), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), HID_RI_END_COLLECTION(0), diff --git a/Demos/Device/LowLevel/Joystick/Joystick.h b/Demos/Device/LowLevel/Joystick/Joystick.h index a76ab51067..f3cdf36b79 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.h +++ b/Demos/Device/LowLevel/Joystick/Joystick.h @@ -72,6 +72,7 @@ { int8_t X; /**< Current absolute joystick X position, as a signed 8-bit integer */ int8_t Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */ + int8_t Z; /**< Current absolute joystick Z position, as a signed 8-bit integer */ uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */ } USB_JoystickReport_Data_t; diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt index 20b190675c..48dec12696 100644 --- a/LUFA/DoxygenPages/ChangeLog.txt +++ b/LUFA/DoxygenPages/ChangeLog.txt @@ -18,8 +18,10 @@ * - Core: * - Android Accessory Host property strings changed from a struct of pointer to an array to prevent unaligned access on greater than 8-bit architectures * - Audio Device Class driver changed to also require the index of the Audio Control interface within the device, for SET/GET/CUR/MIN/MAX/RES property adjustments + * - Removed variable axis support from the HID_DESCRIPTOR_JOYSTICK() macro due to OS incompatibilities, replaced with fixed 3-axis joystick report structure * - Library Applications: * - Raised the guard bits in the AVRISP-MKII clone project when in PDI and TPI to 32, to prevent communication errors on low quality connections to a target + * - Added additional bootloader API data to expose the bootloader start address and class to the DFU and CDC class bootloaders * * Fixed: * - Core: @@ -33,7 +35,6 @@ * - Fixed error in the AVRISP-MKII programmer when ISP mode is used at 64KHz (thanks to Ben R. Porter) * - Fixed AVRISP-MKII programmer project failing to compile for the U4 chips when VTARGET_ADC_CHANNEL is defined to an invalid channel and NO_VTARGET_DETECT is * defined (thanks to Steven Morehouse) - * - Added additional bootloader API data to expose the bootloader start address and class to the DFU and CDC class bootloaders * * \section Sec_ChangeLog120219 Version 120219 * New: diff --git a/LUFA/DoxygenPages/MigrationInformation.txt b/LUFA/DoxygenPages/MigrationInformation.txt index e005af7ebb..93082bb5cf 100644 --- a/LUFA/DoxygenPages/MigrationInformation.txt +++ b/LUFA/DoxygenPages/MigrationInformation.txt @@ -14,6 +14,9 @@ * Device Mode * - The device mode Audio Class driver now requires an additional configuration parameter, the Audio Control interface index. Existing applications should * be adjusted to specify the additional configuration parameter. + * - The HID_DESCRIPTOR_JOYSTICK() macro no longer takes a variable number of axis as a parameter, due to OS incompatibilities; this macro now uses a fixed + * 3 axis of data. User applications should update their calls to this macro and their report structures to suit a fixed 3-axis joystick report. If a user + * application requires more than 3 axis' of data, a custom report descriptor will need to be constructed by hand. * * Host Mode * - The Android Accessory Host class driver property strings are now a array of \c char* rather than a struct of named pointers. Existing applications diff --git a/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h b/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h index add6cf8c00..64383aef7a 100644 --- a/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h +++ b/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h @@ -337,37 +337,36 @@ * \code * struct * { - * intB_t X; // Signed X axis value - * intB_t Y; // Signed Y axis value - * int8_t Z; // Signed Z axis value - * // Additional axis elements here - * uintA_t Buttons; // Pressed buttons bitmask + * intA_t X; // Signed X axis value + * intA_t Y; // Signed Y axis value + * intA_t Z; // Signed Z axis value + * uintB_t Buttons; // Pressed buttons bitmask * } Joystick_Report; * \endcode * - * 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. + * Where \c uintA_t is a type large enough to hold the ranges of the signed \c MinAxisVal and \c MaxAxisVal values, + * and \c intB_t is a type large enough to hold one bit per button. * - * \param[in] NumAxis Number of axis in the joystick (8-bit) * \param[in] MinAxisVal Minimum logical axis value (16-bit). * \param[in] MaxAxisVal Maximum logical axis value (16-bit). * \param[in] MinPhysicalVal Minimum physical axis value, for movement resolution calculations (16-bit). * \param[in] MaxPhysicalVal Maximum physical axis value, for movement resolution calculations (16-bit). * \param[in] Buttons Total number of buttons in the device (8-bit). */ - #define HID_DESCRIPTOR_JOYSTICK(NumAxis, MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, 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), \ HID_RI_USAGE(8, 0x01), \ HID_RI_COLLECTION(8, 0x00), \ - HID_RI_USAGE_MINIMUM(8, 0x30), \ - HID_RI_USAGE_MAXIMUM(8, (0x30 + (NumAxis - 1))), \ + HID_RI_USAGE_(8, 0x30), \ + HID_RI_USAGE_(8, 0x31), \ + HID_RI_USAGE_(8, 0x32), \ 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, NumAxis), \ + HID_RI_REPORT_COUNT(8, 3), \ HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ HID_RI_END_COLLECTION(0), \