summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authord3v1c3nv11 <d3v1c3nv11@users.noreply.github.com>2017-11-06 16:34:02 +0200
committerGitHub <noreply@github.com>2017-11-06 16:34:02 +0200
commit5878e5478d6d1c5e14e4fc52d919345de51dd625 (patch)
tree88d9cd473d6a251b97f59274f683d69c883c0365
parentb50a6a2db956129d911ca6f6afb2563e38fe1dae (diff)
Update Descriptors.h
-rw-r--r--TERES-HID/Descriptors.h66
1 files changed, 65 insertions, 1 deletions
diff --git a/TERES-HID/Descriptors.h b/TERES-HID/Descriptors.h
index 92331fa..045c5ac 100644
--- a/TERES-HID/Descriptors.h
+++ b/TERES-HID/Descriptors.h
@@ -53,6 +53,70 @@
#include <LUFA/Drivers/USB/USB.h>
+
+ /** \hideinitializer
+ * A list of HID report item array elements that describe a typical HID USB mouse. The resulting report descriptor
+ * is compatible with \ref USB_MouseReport_Data_t if the \c MinAxisVal and \c MaxAxisVal values fit within a \c int8_t range
+ * and the number of Buttons is less than 8. For other values, the report is structured according to the following layout:
+ *
+ * \code
+ * struct
+ * {
+ * uintA_t Buttons; // Pressed buttons bitmask
+ * intB_t X; // X axis value
+ * intB_t Y; // Y axis value
+ * } Mouse_Report;
+ * \endcode
+ *
+ * Where \c intA_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 (16-bit).
+ * \param[in] MaxAxisVal Maximum X/Y logical axis value (16-bit).
+ * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations (16-bit).
+ * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations (16-bit).
+ * \param[in] Buttons Total number of buttons in the device (8-bit).
+ * \param[in] AbsoluteCoords Boolean \c true to use absolute X/Y coordinates (e.g. touchscreen).
+ */
+ #define HID_DESCRIPTOR_WHEEL_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \
+ HID_RI_USAGE_PAGE(8, 0x01), \
+ HID_RI_USAGE(8, 0x02), \
+ HID_RI_COLLECTION(8, 0x01), \
+ HID_RI_USAGE(8, 0x01), \
+ HID_RI_COLLECTION(8, 0x00), \
+ HID_RI_USAGE_PAGE(8, 0x09), \
+ HID_RI_USAGE_MINIMUM(8, 0x01), \
+ HID_RI_USAGE_MAXIMUM(8, Buttons), \
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
+ HID_RI_REPORT_COUNT(8, Buttons), \
+ HID_RI_REPORT_SIZE(8, 0x01), \
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
+ HID_RI_REPORT_COUNT(8, 0x01), \
+ HID_RI_REPORT_SIZE(8, (Buttons % 8) ? (8 - (Buttons % 8)) : 0), \
+ HID_RI_INPUT(8, HID_IOF_CONSTANT), \
+ HID_RI_USAGE_PAGE(8, 0x01), \
+ HID_RI_USAGE(8, 0x30), \
+ HID_RI_USAGE(8, 0x31), \
+ 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, (((MinAxisVal >= -128) && (MaxAxisVal <= 127)) ? 8 : 16)), \
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \
+ HID_RI_USAGE(8, 0x38), \
+ HID_RI_LOGICAL_MINIMUM(8, -127), \
+ HID_RI_LOGICAL_MAXIMUM(8, 127), \
+ HID_RI_PHYSICAL_MINIMUM(8, -1), \
+ HID_RI_PHYSICAL_MAXIMUM(8, 1), \
+ HID_RI_REPORT_SIZE(8, 0x08), \
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), \
+ HID_RI_END_COLLECTION(0), \
+ HID_RI_END_COLLECTION(0)
+
+
+
/* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which
@@ -112,7 +176,7 @@
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
- const uint8_t wIndex,
+ const uint16_t wIndex,
const void** const DescriptorAddress)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
typedef struct