diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-01-17 19:44:48 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-01-17 19:44:48 +0000 |
commit | efd57cfe51ec0501d4378d01e019f3e23b989274 (patch) | |
tree | e2e60d4ba5a72c56012b2a6426849e28d762c53e /Projects | |
parent | 47fec03694c933a388eadf3242a6e40177b57d74 (diff) | |
download | lufa-efd57cfe51ec0501d4378d01e019f3e23b989274.tar.gz lufa-efd57cfe51ec0501d4378d01e019f3e23b989274.tar.bz2 lufa-efd57cfe51ec0501d4378d01e019f3e23b989274.zip |
Abuse the the C preprocessor so that the HID macros can automatically encode data into the array from the HID macros automagically, by specifying the bit-width of the data, and the data itself as a single integer value of that width.
Diffstat (limited to 'Projects')
-rw-r--r-- | Projects/Magstripe/Descriptors.c | 65 | ||||
-rw-r--r-- | Projects/TempDataLogger/Descriptors.c | 31 |
2 files changed, 46 insertions, 50 deletions
diff --git a/Projects/Magstripe/Descriptors.c b/Projects/Magstripe/Descriptors.c index 7feae8ce6..c7b21fdbf 100644 --- a/Projects/Magstripe/Descriptors.c +++ b/Projects/Magstripe/Descriptors.c @@ -46,40 +46,37 @@ */ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = { - HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */ - HID_RI_USAGE(8), 0x06, /* Keyboard */ - HID_RI_COLLECTION(8), 0x01, /* Application */ - HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */ - HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */ - HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */ - HID_RI_LOGICAL_MINIMUM(8), 0, - HID_RI_LOGICAL_MAXIMUM(8), 1, - HID_RI_REPORT_SIZE(8), 1, - HID_RI_REPORT_COUNT(8), 8, - HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), - - HID_RI_REPORT_COUNT(8), 1, - HID_RI_REPORT_SIZE(8), 8, - HID_RI_INPUT(8), HID_IOF_CONSTANT, - - HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */ - HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */ - HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */ - HID_RI_REPORT_COUNT(8), 5, - HID_RI_REPORT_SIZE(8), 1, - HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), - HID_RI_REPORT_COUNT(8), 1, - HID_RI_REPORT_SIZE(8), 3, - HID_RI_OUTPUT(8), HID_IOF_CONSTANT, - - HID_RI_LOGICAL_MINIMUM(8), 0x00, - HID_RI_LOGICAL_MAXIMUM(8), 0x65, - HID_RI_USAGE_PAGE(8), 0x07, /* Keyboard */ - HID_RI_USAGE_MINIMUM(8), 0x00, /* Reserved (no event indicated) */ - HID_RI_USAGE_MAXIMUM(8), 0x65, /* Keyboard Application */ - HID_RI_REPORT_COUNT(8), 6, - HID_RI_REPORT_SIZE(8), 8, - HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x06), /* Keyboard */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ + HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ + HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_REPORT_COUNT(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_CONSTANT), + HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ + HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ + HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ + HID_RI_REPORT_COUNT(8, 0x05), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x03), + HID_RI_OUTPUT(8, HID_IOF_CONSTANT), + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x65), + HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */ + HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */ + HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */ + HID_RI_REPORT_COUNT(8, 0x06), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), HID_RI_END_COLLECTION(0), }; diff --git a/Projects/TempDataLogger/Descriptors.c b/Projects/TempDataLogger/Descriptors.c index a0252be56..1e61df117 100644 --- a/Projects/TempDataLogger/Descriptors.c +++ b/Projects/TempDataLogger/Descriptors.c @@ -57,22 +57,21 @@ */ USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = { - HID_RI_USAGE_PAGE(16), 0x00, 0xFF, /* Vendor Page 1 */ - HID_RI_USAGE(8), 0x01, /* Vendor Usage 1 */ - HID_RI_COLLECTION(8), 0x01, /* Vendor Usage 1 */ - HID_RI_USAGE(8), 0x02, /* Vendor Usage 2 */ - HID_RI_LOGICAL_MINIMUM(8), 0x00, - HID_RI_LOGICAL_MAXIMUM(8), 0xFF, - HID_RI_REPORT_SIZE(8), 8, - HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE, - HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE), - - HID_RI_USAGE(8), 0x03, /* Vendor Usage 3 */ - HID_RI_LOGICAL_MINIMUM(8), 0x00, - HID_RI_LOGICAL_MAXIMUM(8), 0xFF, - HID_RI_REPORT_SIZE(8), 8, - HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE, - HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE), + HID_RI_USAGE_PAGE(16, 0x00FF), /* Vendor Page 1 */ + HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */ + HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */ + HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE), + HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE), + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE), HID_RI_END_COLLECTION(0), }; |