New HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors.

Changed over all project and demo HID report descriptors to use the new HID report item macros.

Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/.
pull/1469/head
Dean Camera 14 years ago
parent 32830a2b82
commit 039a714ee4

@ -45,22 +45,23 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{ {
0x06, 0x9c, 0xff, /* Usage Page (Vendor Defined) */ HID_RI_USAGE_PAGE(16), 0x00, 0xFF, /* Vendor Page 1 */
0x09, 0x01, /* Usage (Vendor Defined) */ HID_RI_USAGE(8), 0x01, /* Vendor Usage 1 */
0xa1, 0x01, /* Collection (Vendor Defined) */ HID_RI_COLLECTION(8), 0x01, /* Vendor Usage 1 */
0x09, 0x02, /* Usage (Vendor Defined) */ HID_RI_USAGE(8), 0x02, /* Vendor Usage 2 */
0x75, 0x08, /* Report Size (8) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */ HID_RI_LOGICAL_MAXIMUM(8), 0xFF,
0x15, 0x80, /* Logical Minimum (-128) */ HID_RI_REPORT_SIZE(8), 8,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x09, 0x03, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */ HID_RI_USAGE(8), 0x03, /* Vendor Usage 3 */
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_LOGICAL_MAXIMUM(8), 0xFF,
0x25, 0xff, /* Logical Maximum (255) */ HID_RI_REPORT_SIZE(8), 8,
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE,
0xc0 /* End Collection */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -42,35 +42,34 @@
* descriptor is parsed by the host and its contents used to determine what data (and in what encoding) * descriptor is parsed by the host and its contents used to determine what data (and in what encoding)
* the device will send, and what it may be sent back from the host. Refer to the HID specification for * the device will send, and what it may be sent back from the host. Refer to the HID specification for
* more details on HID report descriptors. * more details on HID report descriptors.
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x04, /* Usage (Joystick) */ HID_RI_USAGE(8), 0x04, /* Joystick */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xa1, 0x00, /* Collection (Physical) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x30, /* Usage (X) */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x09, 0x31, /* Usage (Y) */ HID_RI_LOGICAL_MINIMUM(8), -100,
0x15, 0x9c, /* Logical Minimum (-100) */ HID_RI_LOGICAL_MAXIMUM(8), 100,
0x25, 0x64, /* Logical Maximum (100) */ HID_RI_REPORT_SIZE(8), 8,
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 2,
0x95, 0x02, /* Report Count (2) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x81, 0x82, /* Input (Data, Variable, Absolute, Volatile) */ HID_RI_END_COLLECTION(0),
0xc0, /* End Collection */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE(8), 0x02, /* Button 1 */
0x09, 0x02, /* Usage (Button 2) */ HID_RI_USAGE(8), 0x01, /* Button 2 */
0x09, 0x01, /* Usage (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x01, /* Report Size (1) */ HID_RI_REPORT_COUNT(8), 2,
0x95, 0x02, /* Report Count (2) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 6,
0x75, 0x06, /* Report Size (6) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x01, /* Report Count (1) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x81, 0x01, /* Input (Constant) */ HID_RI_END_COLLECTION(0),
0xc0 /* End Collection */
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -45,38 +45,41 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x06, /* Usage (Keyboard) */ HID_RI_USAGE(8), 0x06, /* Keyboard */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */
0x95, 0x08, /* Report Count (8) */ HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */
0x05, 0x07, /* Usage Page (Key Codes) */ HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_SIZE(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_COUNT(8), 8,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x03, /* Input (Const, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 8,
0x95, 0x05, /* Report Count (5) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x75, 0x01, /* Report Size (1) */
0x05, 0x08, /* Usage Page (LEDs) */ HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */
0x19, 0x01, /* Usage Minimum (Num Lock) */ HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */
0x29, 0x05, /* Usage Maximum (Kana) */ HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 5,
0x95, 0x01, /* Report Count (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x03, /* Report Size (3) */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x91, 0x03, /* Output (Const, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x06, /* Report Count (6) */ HID_RI_REPORT_SIZE(8), 3,
0x75, 0x08, /* Report Size (8) */ HID_RI_OUTPUT(8), HID_IOF_CONSTANT,
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x65, /* Logical Maximum (101) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x05, 0x07, /* Usage Page (Keyboard) */ HID_RI_LOGICAL_MAXIMUM(8), 0x65,
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */ HID_RI_USAGE_PAGE(8), 0x07, /* Keyboard */
0x29, 0x65, /* Usage Maximum (Keyboard Application) */ HID_RI_USAGE_MINIMUM(8), 0x00, /* Reserved (no event indicated) */
0x81, 0x00, /* Input (Data, Array, Absolute) */ HID_RI_USAGE_MAXIMUM(8), 0x65, /* Keyboard Application */
0xc0 /* End Collection */ 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_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -47,69 +47,76 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x02, /* Usage (Mouse) */ HID_RI_USAGE(8), 0x02, /* Mouse */
0xA1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xA1, 0x00, /* Collection (Physical) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x95, 0x03, /* Report Count (3) */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_MINIMUM(8), 0x01,
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE_MAXIMUM(8), 0x03,
0x19, 0x01, /* Usage Minimum (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0x03, /* Usage Maximum (Button 3) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_COUNT(8), 3,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x01, /* Input (Constant) */ HID_RI_REPORT_SIZE(8), 5,
0x75, 0x08, /* Report Size (8) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x95, 0x02, /* Report Count (2) */
0x05, 0x01, /* Usage Page (Generic Desktop Control) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x30, /* Usage X */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x31, /* Usage Y */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x15, 0x81, /* Logical Minimum (-127) */ HID_RI_LOGICAL_MINIMUM(8), -1,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x81, 0x06, /* Input (Data, Variable, Relative) */ HID_RI_PHYSICAL_MINIMUM(8), -1,
0xC0, /* End Collection */ HID_RI_PHYSICAL_MAXIMUM(8), 1,
0xC0, /* End Collection */ HID_RI_REPORT_COUNT(8), 2,
HID_RI_REPORT_SIZE(8), 8,
HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
}; };
/** Same as the MouseReport structure, but defines the keyboard HID interface's report structure. */ /** Same as the MouseReport structure, but defines the keyboard HID interface's report structure. */
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x06, /* Usage (Keyboard) */ HID_RI_USAGE(8), 0x06, /* Keyboard */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */
0x95, 0x08, /* Report Count (8) */ HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */
0x05, 0x07, /* Usage Page (Key Codes) */ HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_SIZE(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_COUNT(8), 8,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x03, /* Input (Const, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 8,
0x95, 0x05, /* Report Count (5) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x75, 0x01, /* Report Size (1) */
0x05, 0x08, /* Usage Page (LEDs) */ HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */
0x19, 0x01, /* Usage Minimum (Num Lock) */ HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */
0x29, 0x05, /* Usage Maximum (Kana) */ HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 5,
0x95, 0x01, /* Report Count (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x03, /* Report Size (3) */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x91, 0x03, /* Output (Const, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x06, /* Report Count (6) */ HID_RI_REPORT_SIZE(8), 3,
0x75, 0x08, /* Report Size (8) */ HID_RI_OUTPUT(8), HID_IOF_CONSTANT,
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x65, /* Logical Maximum (101) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x05, 0x07, /* Usage Page (Keyboard) */ HID_RI_LOGICAL_MAXIMUM(8), 0x65,
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */ HID_RI_USAGE_PAGE(8), 0x07, /* Keyboard */
0x29, 0x65, /* Usage Maximum (Keyboard Application) */ HID_RI_USAGE_MINIMUM(8), 0x00, /* Reserved (no event indicated) */
0x81, 0x00, /* Input (Data, Array, Absolute) */ HID_RI_USAGE_MAXIMUM(8), 0x65, /* Keyboard Application */
0xC0 /* End Collection */ 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_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -58,38 +58,41 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x06, /* Usage (Keyboard) */ HID_RI_USAGE(8), 0x06, /* Keyboard */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */
0x95, 0x08, /* Report Count (8) */ HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */
0x05, 0x07, /* Usage Page (Key Codes) */ HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_SIZE(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_COUNT(8), 8,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x03, /* Input (Const, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 8,
0x95, 0x05, /* Report Count (5) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x75, 0x01, /* Report Size (1) */
0x05, 0x08, /* Usage Page (LEDs) */ HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */
0x19, 0x01, /* Usage Minimum (Num Lock) */ HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */
0x29, 0x05, /* Usage Maximum (Kana) */ HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 5,
0x95, 0x01, /* Report Count (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x03, /* Report Size (3) */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x91, 0x03, /* Output (Const, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x06, /* Report Count (6) */ HID_RI_REPORT_SIZE(8), 3,
0x75, 0x08, /* Report Size (8) */ HID_RI_OUTPUT(8), HID_IOF_CONSTANT,
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x65, /* Logical Maximum (101) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x05, 0x07, /* Usage Page (Keyboard) */ HID_RI_LOGICAL_MAXIMUM(8), 0x65,
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */ HID_RI_USAGE_PAGE(8), 0x07, /* Keyboard */
0x29, 0x65, /* Usage Maximum (Keyboard Application) */ HID_RI_USAGE_MINIMUM(8), 0x00, /* Reserved (no event indicated) */
0x81, 0x00, /* Input (Data, Array, Absolute) */ HID_RI_USAGE_MAXIMUM(8), 0x65, /* Keyboard Application */
0xc0 /* End Collection */ 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_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -45,32 +45,36 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x02, /* Usage (Mouse) */ HID_RI_USAGE(8), 0x02, /* Mouse */
0xA1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xA1, 0x00, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x95, 0x03, /* Report Count (3) */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_MINIMUM(8), 0x01,
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE_MAXIMUM(8), 0x03,
0x19, 0x01, /* Usage Minimum (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0x03, /* Usage Maximum (Button 3) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_COUNT(8), 3,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x01, /* Input (Constant) */ HID_RI_REPORT_SIZE(8), 5,
0x75, 0x08, /* Report Size (8) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x95, 0x02, /* Report Count (2) */
0x05, 0x01, /* Usage Page (Generic Desktop Control) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x30, /* Usage X */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x31, /* Usage Y */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x15, 0x81, /* Logical Minimum (-127) */ HID_RI_LOGICAL_MINIMUM(8), -1,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x81, 0x06, /* Input (Data, Variable, Relative) */ HID_RI_PHYSICAL_MINIMUM(8), -1,
0xC0, /* End Collection */ HID_RI_PHYSICAL_MAXIMUM(8), 1,
0xC0 /* End Collection */ HID_RI_REPORT_COUNT(8), 2,
HID_RI_REPORT_SIZE(8), 8,
HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -57,32 +57,36 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x02, /* Usage (Mouse) */ HID_RI_USAGE(8), 0x02, /* Mouse */
0xA1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xA1, 0x00, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x95, 0x03, /* Report Count (3) */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_MINIMUM(8), 0x01,
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE_MAXIMUM(8), 0x03,
0x19, 0x01, /* Usage Minimum (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0x03, /* Usage Maximum (Button 3) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_COUNT(8), 3,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x01, /* Input (Constant) */ HID_RI_REPORT_SIZE(8), 5,
0x75, 0x08, /* Report Size (8) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x95, 0x02, /* Report Count (2) */
0x05, 0x01, /* Usage Page (Generic Desktop Control) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x30, /* Usage X */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x31, /* Usage Y */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x15, 0x81, /* Logical Minimum (-127) */ HID_RI_LOGICAL_MINIMUM(8), -1,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x81, 0x06, /* Input (Data, Variable, Relative) */ HID_RI_PHYSICAL_MINIMUM(8), -1,
0xC0, /* End Collection */ HID_RI_PHYSICAL_MAXIMUM(8), 1,
0xC0 /* End Collection */ HID_RI_REPORT_COUNT(8), 2,
HID_RI_REPORT_SIZE(8), 8,
HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -45,22 +45,23 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{ {
0x06, 0x9c, 0xff, /* Usage Page (Vendor Defined) */ HID_RI_USAGE_PAGE(16), 0x00, 0xFF, /* Vendor Page 1 */
0x09, 0x01, /* Usage (Vendor Defined) */ HID_RI_USAGE(8), 0x01, /* Vendor Usage 1 */
0xa1, 0x01, /* Collection (Vendor Defined) */ HID_RI_COLLECTION(8), 0x01, /* Vendor Usage 1 */
0x09, 0x02, /* Usage (Vendor Defined) */ HID_RI_USAGE(8), 0x02, /* Vendor Usage 2 */
0x75, 0x08, /* Report Size (8) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */ HID_RI_LOGICAL_MAXIMUM(8), 0xFF,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_SIZE(8), 8,
0x25, 0xff, /* Logical Maximum (255) */ HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x09, 0x03, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */ HID_RI_USAGE(8), 0x03, /* Vendor Usage 3 */
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_LOGICAL_MAXIMUM(8), 0xFF,
0x25, 0xff, /* Logical Maximum (255) */ HID_RI_REPORT_SIZE(8), 8,
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE,
0xc0 /* End Collection */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -45,32 +45,31 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x04, /* Usage (Joystick) */ HID_RI_USAGE(8), 0x04, /* Joystick */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xa1, 0x00, /* Collection (Physical) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x30, /* Usage (X) */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x09, 0x31, /* Usage (Y) */ HID_RI_LOGICAL_MINIMUM(8), -100,
0x15, 0x9c, /* Logical Minimum (-100) */ HID_RI_LOGICAL_MAXIMUM(8), 100,
0x25, 0x64, /* Logical Maximum (100) */ HID_RI_REPORT_SIZE(8), 8,
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 2,
0x95, 0x02, /* Report Count (2) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x81, 0x82, /* Input (Data, Variable, Absolute, Volatile) */ HID_RI_END_COLLECTION(0),
0xc0, /* End Collection */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE(8), 0x02, /* Button 1 */
0x09, 0x02, /* Usage (Button 2) */ HID_RI_USAGE(8), 0x01, /* Button 2 */
0x09, 0x01, /* Usage (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x01, /* Report Size (1) */ HID_RI_REPORT_COUNT(8), 2,
0x95, 0x02, /* Report Count (2) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 6,
0x75, 0x06, /* Report Size (6) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x01, /* Report Count (1) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x81, 0x01, /* Input (Constant) */ HID_RI_END_COLLECTION(0),
0xc0 /* End Collection */
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -46,38 +46,41 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x06, /* Usage (Keyboard) */ HID_RI_USAGE(8), 0x06, /* Keyboard */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */
0x95, 0x08, /* Report Count (8) */ HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */
0x05, 0x07, /* Usage Page (Key Codes) */ HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_SIZE(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_COUNT(8), 8,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x03, /* Input (Const, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 8,
0x95, 0x05, /* Report Count (5) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x75, 0x01, /* Report Size (1) */
0x05, 0x08, /* Usage Page (LEDs) */ HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */
0x19, 0x01, /* Usage Minimum (Num Lock) */ HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */
0x29, 0x05, /* Usage Maximum (Kana) */ HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 5,
0x95, 0x01, /* Report Count (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x03, /* Report Size (3) */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x91, 0x03, /* Output (Const, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x06, /* Report Count (6) */ HID_RI_REPORT_SIZE(8), 3,
0x75, 0x08, /* Report Size (8) */ HID_RI_OUTPUT(8), HID_IOF_CONSTANT,
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x65, /* Logical Maximum (101) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x05, 0x07, /* Usage Page (Keyboard) */ HID_RI_LOGICAL_MAXIMUM(8), 0x65,
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */ HID_RI_USAGE_PAGE(8), 0x07, /* Keyboard */
0x29, 0x65, /* Usage Maximum (Keyboard Application) */ HID_RI_USAGE_MINIMUM(8), 0x00, /* Reserved (no event indicated) */
0x81, 0x00, /* Input (Data, Array, Absolute) */ HID_RI_USAGE_MAXIMUM(8), 0x65, /* Keyboard Application */
0xc0 /* End Collection */ 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_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -48,69 +48,76 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x02, /* Usage (Mouse) */ HID_RI_USAGE(8), 0x02, /* Mouse */
0xA1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xA1, 0x00, /* Collection (Physical) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x95, 0x03, /* Report Count (3) */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_MINIMUM(8), 0x01,
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE_MAXIMUM(8), 0x03,
0x19, 0x01, /* Usage Minimum (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0x03, /* Usage Maximum (Button 3) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_COUNT(8), 3,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x01, /* Input (Constant) */ HID_RI_REPORT_SIZE(8), 5,
0x75, 0x08, /* Report Size (8) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x95, 0x02, /* Report Count (2) */
0x05, 0x01, /* Usage Page (Generic Desktop Control) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x30, /* Usage X */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x31, /* Usage Y */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x15, 0x81, /* Logical Minimum (-127) */ HID_RI_LOGICAL_MINIMUM(8), -1,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x81, 0x06, /* Input (Data, Variable, Relative) */ HID_RI_PHYSICAL_MINIMUM(8), -1,
0xC0, /* End Collection */ HID_RI_PHYSICAL_MAXIMUM(8), 1,
0xC0, /* End Collection */ HID_RI_REPORT_COUNT(8), 2,
HID_RI_REPORT_SIZE(8), 8,
HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
}; };
/** Same as the MouseReport structure, but defines the keyboard HID interface's report structure. */ /** Same as the MouseReport structure, but defines the keyboard HID interface's report structure. */
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x06, /* Usage (Keyboard) */ HID_RI_USAGE(8), 0x06, /* Keyboard */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */
0x95, 0x08, /* Report Count (8) */ HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */
0x05, 0x07, /* Usage Page (Key Codes) */ HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_SIZE(8), 1,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_COUNT(8), 8,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x03, /* Input (Const, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 8,
0x95, 0x05, /* Report Count (5) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x75, 0x01, /* Report Size (1) */
0x05, 0x08, /* Usage Page (LEDs) */ HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */
0x19, 0x01, /* Usage Minimum (Num Lock) */ HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */
0x29, 0x05, /* Usage Maximum (Kana) */ HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 5,
0x95, 0x01, /* Report Count (1) */ HID_RI_REPORT_SIZE(8), 1,
0x75, 0x03, /* Report Size (3) */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x91, 0x03, /* Output (Const, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), 1,
0x95, 0x06, /* Report Count (6) */ HID_RI_REPORT_SIZE(8), 3,
0x75, 0x08, /* Report Size (8) */ HID_RI_OUTPUT(8), HID_IOF_CONSTANT,
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x65, /* Logical Maximum (101) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x05, 0x07, /* Usage Page (Keyboard) */ HID_RI_LOGICAL_MAXIMUM(8), 0x65,
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */ HID_RI_USAGE_PAGE(8), 0x07, /* Keyboard */
0x29, 0x65, /* Usage Maximum (Keyboard Application) */ HID_RI_USAGE_MINIMUM(8), 0x00, /* Reserved (no event indicated) */
0x81, 0x00, /* Input (Data, Array, Absolute) */ HID_RI_USAGE_MAXIMUM(8), 0x65, /* Keyboard Application */
0xC0 /* End Collection */ 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_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -45,32 +45,36 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x02, /* Usage (Mouse) */ HID_RI_USAGE(8), 0x02, /* Mouse */
0xA1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xA1, 0x00, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x95, 0x03, /* Report Count (3) */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_MINIMUM(8), 0x01,
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE_MAXIMUM(8), 0x03,
0x19, 0x01, /* Usage Minimum (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0x03, /* Usage Maximum (Button 3) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_COUNT(8), 3,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x01, /* Input (Constant) */ HID_RI_REPORT_SIZE(8), 5,
0x75, 0x08, /* Report Size (8) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x95, 0x02, /* Report Count (2) */
0x05, 0x01, /* Usage Page (Generic Desktop Control) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x30, /* Usage X */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x31, /* Usage Y */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x15, 0x81, /* Logical Minimum (-127) */ HID_RI_LOGICAL_MINIMUM(8), -1,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x81, 0x06, /* Input (Data, Variable, Relative) */ HID_RI_PHYSICAL_MINIMUM(8), -1,
0xC0, /* End Collection */ HID_RI_PHYSICAL_MAXIMUM(8), 1,
0xC0 /* End Collection */ HID_RI_REPORT_COUNT(8), 2,
HID_RI_REPORT_SIZE(8), 8,
HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -45,32 +45,34 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x02, /* Usage (Mouse) */ HID_RI_USAGE(8), 0x02, /* Mouse */
0xA1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x09, 0x01, /* Usage (Pointer) */ HID_RI_USAGE(8), 0x01, /* Pointer */
0xA1, 0x00, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x00, /* Physical */
0x95, 0x03, /* Report Count (3) */ HID_RI_USAGE_PAGE(8), 0x09, /* Button */
0x75, 0x01, /* Report Size (1) */ HID_RI_USAGE_MINIMUM(8), 0x01,
0x05, 0x09, /* Usage Page (Button) */ HID_RI_USAGE_MAXIMUM(8), 0x03,
0x19, 0x01, /* Usage Minimum (Button 1) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x29, 0x03, /* Usage Maximum (Button 3) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_REPORT_COUNT(8), 3,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x01, /* Input (Constant) */ HID_RI_REPORT_SIZE(8), 5,
0x75, 0x08, /* Report Size (8) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x95, 0x02, /* Report Count (2) */
0x05, 0x01, /* Usage Page (Generic Desktop Control) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x30, /* Usage X */ HID_RI_USAGE(8), 0x30, /* Usage X */
0x09, 0x31, /* Usage Y */ HID_RI_USAGE(8), 0x31, /* Usage Y */
0x15, 0x81, /* Logical Minimum (-127) */ HID_RI_LOGICAL_MINIMUM(8), -128,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_LOGICAL_MAXIMUM(8), 127,
0x81, 0x06, /* Input (Data, Variable, Relative) */ HID_RI_REPORT_COUNT(8), 2,
0xC0, /* End Collection */ HID_RI_REPORT_SIZE(8), 8,
0xC0 /* End Collection */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

File diff suppressed because one or more lines are too long

@ -52,6 +52,7 @@
/* Includes: */ /* Includes: */
#include "../../HighLevel/StdDescriptors.h" #include "../../HighLevel/StdDescriptors.h"
#include "HIDParser.h"
#include <string.h> #include <string.h>

@ -29,9 +29,6 @@
*/ */
#define __INCLUDE_FROM_USB_DRIVER #define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_HID_DRIVER #define __INCLUDE_FROM_HID_DRIVER
#include "HIDParser.h" #include "HIDParser.h"
@ -61,28 +58,28 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
ReportData++; ReportData++;
ReportSize--; ReportSize--;
switch (HIDReportItem & DATA_SIZE_MASK) switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
{ {
case DATA_SIZE_4: case HID_RI_DATA_BITS_32:
ReportItemData = *((uint32_t*)ReportData); ReportItemData = *((uint32_t*)ReportData);
ReportSize -= 4; ReportSize -= 4;
ReportData += 4; ReportData += 4;
break; break;
case DATA_SIZE_2: case HID_RI_DATA_BITS_16:
ReportItemData = *((uint16_t*)ReportData); ReportItemData = *((uint16_t*)ReportData);
ReportSize -= 2; ReportSize -= 2;
ReportData += 2; ReportData += 2;
break; break;
case DATA_SIZE_1: case HID_RI_DATA_BITS_8:
ReportItemData = *((uint8_t*)ReportData); ReportItemData = *((uint8_t*)ReportData);
ReportSize -= 1; ReportSize -= 1;
ReportData += 1; ReportData += 1;
break; break;
} }
switch (HIDReportItem & (TYPE_MASK | TAG_MASK)) switch (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK))
{ {
case (TYPE_GLOBAL | TAG_GLOBAL_PUSH): case HID_RI_PUSH(0):
if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1]) if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1])
return HID_PARSE_HIDStackOverflow; return HID_PARSE_HIDStackOverflow;
@ -92,40 +89,40 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
CurrStateTable++; CurrStateTable++;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_POP): case HID_RI_POP(0):
if (CurrStateTable == &StateTable[0]) if (CurrStateTable == &StateTable[0])
return HID_PARSE_HIDStackUnderflow; return HID_PARSE_HIDStackUnderflow;
CurrStateTable--; CurrStateTable--;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): case HID_RI_USAGE_PAGE(0):
CurrStateTable->Attributes.Usage.Page = ReportItemData; CurrStateTable->Attributes.Usage.Page = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN): case HID_RI_LOGICAL_MINIMUM(0):
CurrStateTable->Attributes.Logical.Minimum = ReportItemData; CurrStateTable->Attributes.Logical.Minimum = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX): case HID_RI_LOGICAL_MAXIMUM(0):
CurrStateTable->Attributes.Logical.Maximum = ReportItemData; CurrStateTable->Attributes.Logical.Maximum = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN): case HID_RI_PHYSICAL_MINIMUM(0):
CurrStateTable->Attributes.Physical.Minimum = ReportItemData; CurrStateTable->Attributes.Physical.Minimum = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX): case HID_RI_PHYSICAL_MAXIMUM(0):
CurrStateTable->Attributes.Physical.Maximum = ReportItemData; CurrStateTable->Attributes.Physical.Maximum = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP): case HID_RI_UNIT_EXPONENT(0):
CurrStateTable->Attributes.Unit.Exponent = ReportItemData; CurrStateTable->Attributes.Unit.Exponent = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_UNIT): case HID_RI_UNIT(0):
CurrStateTable->Attributes.Unit.Type = ReportItemData; CurrStateTable->Attributes.Unit.Type = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): case HID_RI_REPORT_SIZE(0):
CurrStateTable->Attributes.BitSize = ReportItemData; CurrStateTable->Attributes.BitSize = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): case HID_RI_REPORT_COUNT(0):
CurrStateTable->ReportCount = ReportItemData; CurrStateTable->ReportCount = ReportItemData;
break; break;
case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): case HID_RI_REPORT_ID(0):
CurrStateTable->ReportID = ReportItemData; CurrStateTable->ReportID = ReportItemData;
if (ParserData->UsingReportIDs) if (ParserData->UsingReportIDs)
@ -155,19 +152,19 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
CurrReportIDInfo->ReportID = CurrStateTable->ReportID; CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
break; break;
case (TYPE_LOCAL | TAG_LOCAL_USAGE): case HID_RI_USAGE(0):
if (UsageListSize == HID_USAGE_STACK_DEPTH) if (UsageListSize == HID_USAGE_STACK_DEPTH)
return HID_PARSE_UsageListOverflow; return HID_PARSE_UsageListOverflow;
UsageList[UsageListSize++] = ReportItemData; UsageList[UsageListSize++] = ReportItemData;
break; break;
case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): case HID_RI_USAGE_MINIMUM(0):
UsageMinMax.Minimum = ReportItemData; UsageMinMax.Minimum = ReportItemData;
break; break;
case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): case HID_RI_USAGE_MAXIMUM(0):
UsageMinMax.Maximum = ReportItemData; UsageMinMax.Maximum = ReportItemData;
break; break;
case (TYPE_MAIN | TAG_MAIN_COLLECTION): case HID_RI_COLLECTION(0):
if (CurrCollectionPath == NULL) if (CurrCollectionPath == NULL)
{ {
CurrCollectionPath = &ParserData->CollectionPaths[0]; CurrCollectionPath = &ParserData->CollectionPaths[0];
@ -207,15 +204,15 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
} }
break; break;
case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): case HID_RI_END_COLLECTION(0):
if (CurrCollectionPath == NULL) if (CurrCollectionPath == NULL)
return HID_PARSE_UnexpectedEndCollection; return HID_PARSE_UnexpectedEndCollection;
CurrCollectionPath = CurrCollectionPath->Parent; CurrCollectionPath = CurrCollectionPath->Parent;
break; break;
case (TYPE_MAIN | TAG_MAIN_INPUT): case HID_RI_INPUT(0):
case (TYPE_MAIN | TAG_MAIN_OUTPUT): case HID_RI_OUTPUT(0):
case (TYPE_MAIN | TAG_MAIN_FEATURE): case HID_RI_FEATURE(0):
for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++) for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++)
{ {
HID_ReportItem_t NewReportItem; HID_ReportItem_t NewReportItem;
@ -242,11 +239,11 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
NewReportItem.Attributes.Usage.Usage = UsageMinMax.Minimum++; NewReportItem.Attributes.Usage.Usage = UsageMinMax.Minimum++;
} }
uint8_t ItemTag = (HIDReportItem & TAG_MASK); uint8_t ItemTypeTag = (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK));
if (ItemTag == TAG_MAIN_INPUT) if (ItemTypeTag == HID_RI_INPUT(0))
NewReportItem.ItemType = HID_REPORT_ITEM_In; NewReportItem.ItemType = HID_REPORT_ITEM_In;
else if (ItemTag == TAG_MAIN_OUTPUT) else if (ItemTypeTag == HID_RI_OUTPUT(0))
NewReportItem.ItemType = HID_REPORT_ITEM_Out; NewReportItem.ItemType = HID_REPORT_ITEM_Out;
else else
NewReportItem.ItemType = HID_REPORT_ITEM_Feature; NewReportItem.ItemType = HID_REPORT_ITEM_Feature;
@ -258,7 +255,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset) if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
ParserData->LargestReportSizeBits = NewReportItem.BitOffset; ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
{ {
if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
return HID_PARSE_InsufficientReportItems; return HID_PARSE_InsufficientReportItems;
@ -273,7 +270,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
break; break;
} }
if ((HIDReportItem & TYPE_MASK) == TYPE_MAIN) if ((HIDReportItem & HID_RI_TYPE_MASK) == HID_RI_TYPE_MAIN)
{ {
UsageMinMax.Minimum = 0; UsageMinMax.Minimum = 0;
UsageMinMax.Maximum = 0; UsageMinMax.Maximum = 0;
@ -356,6 +353,3 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,
return 0; return 0;
} }
#endif

@ -0,0 +1,118 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
* \brief Constants for HID report item attributes.
*
* HID report item constants for report item attributes. Refer to the HID specification for
* details on each flag's meaning when applied to an IN, OUT or FEATURE item.
*/
/** \ingroup Group_HIDParser
* @defgroup Group_HIDIOFConst Input/Output/Feature Masks
*
* Masks indicating the type of Input, Output of Feature HID report item.
*
* @{
*/
#ifndef __HIDREPORTDATA_H__
#define __HIDREPORTDATA_H__
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define HID_RI_DATA_SIZE_MASK 0x03
#define HID_RI_TYPE_MASK 0x0C
#define HID_RI_TAG_MASK 0xF0
#define HID_RI_TYPE_MAIN 0x00
#define HID_RI_TYPE_GLOBAL 0x04
#define HID_RI_TYPE_LOCAL 0x08
#define HID_RI_DATA_BITS_0 0x00
#define HID_RI_DATA_BITS_8 0x01
#define HID_RI_DATA_BITS_16 0x02
#define HID_RI_DATA_BITS_32 0x03
#define HID_RI_DATA_BITS(DataBits) HID_RI_DATA_BITS_ ## DataBits
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** \name HID Input, Output and Feature Report Descriptor Item Flags */
//@{
#define HID_IOF_CONSTANT (1 << 0)
#define HID_IOF_DATA (0 << 0)
#define HID_IOF_VARIABLE (1 << 1)
#define HID_IOF_ARRAY (0 << 1)
#define HID_IOF_RELATIVE (1 << 2)
#define HID_IOF_ABSOLUTE (0 << 2)
#define HID_IOF_WRAP (1 << 3)
#define HID_IOF_NO_WRAP (0 << 3)
#define HID_IOF_NON_LINEAR (1 << 4)
#define HID_IOF_LINEAR (0 << 4)
#define HID_IOF_NO_PREFERRED_STATE (1 << 5)
#define HID_IOF_PREFERRED_STATE (0 << 5)
#define HID_IOF_NULLSTATE (1 << 6)
#define HID_IOF_NO_NULL_POSITION (0 << 6)
#define HID_IOF_VOLATILE (1 << 7)
#define HID_IOF_NON_VOLATILE (0 << 7)
#define HID_IOF_BUFFERED_BYTES (1 << 8)
#define HID_IOF_BITFIELD (0 << 8)
//@}
/** \name HID Report Descriptor Item Macros */
//@{
#define HID_RI_INPUT(DataBits) (HID_RI_TYPE_MAIN | 0x80 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_OUTPUT(DataBits) (HID_RI_TYPE_MAIN | 0x90 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_COLLECTION(DataBits) (HID_RI_TYPE_MAIN | 0xA0 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_FEATURE(DataBits) (HID_RI_TYPE_MAIN | 0xB0 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_END_COLLECTION(DataBits) (HID_RI_TYPE_MAIN | 0xC0 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_USAGE_PAGE(DataBits) (HID_RI_TYPE_GLOBAL | 0x00 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_LOGICAL_MINIMUM(DataBits) (HID_RI_TYPE_GLOBAL | 0x10 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_LOGICAL_MAXIMUM(DataBits) (HID_RI_TYPE_GLOBAL | 0x20 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_PHYSICAL_MINIMUM(DataBits) (HID_RI_TYPE_GLOBAL | 0x30 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_PHYSICAL_MAXIMUM(DataBits) (HID_RI_TYPE_GLOBAL | 0x40 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_UNIT_EXPONENT(DataBits) (HID_RI_TYPE_GLOBAL | 0x50 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_UNIT(DataBits) (HID_RI_TYPE_GLOBAL | 0x60 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_REPORT_SIZE(DataBits) (HID_RI_TYPE_GLOBAL | 0x70 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_REPORT_ID(DataBits) (HID_RI_TYPE_GLOBAL | 0x80 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_REPORT_COUNT(DataBits) (HID_RI_TYPE_GLOBAL | 0x90 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_PUSH(DataBits) (HID_RI_TYPE_GLOBAL | 0xA0 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_POP(DataBits) (HID_RI_TYPE_GLOBAL | 0xB0 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_USAGE(DataBits) (HID_RI_TYPE_LOCAL | 0x00 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_USAGE_MINIMUM(DataBits) (HID_RI_TYPE_LOCAL | 0x10 | HID_RI_DATA_BITS(DataBits))
#define HID_RI_USAGE_MAXIMUM(DataBits) (HID_RI_TYPE_LOCAL | 0x20 | HID_RI_DATA_BITS(DataBits))
//@}
/** @} */
#endif

@ -43,6 +43,7 @@
* \section Sec_Dependencies Module Source Dependencies * \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module: * The following files must be built with any user project that uses this module:
* - LUFA/Drivers/USB/Class/Device/HID.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i> * - LUFA/Drivers/USB/Class/Device/HID.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>
* - LUFA/Drivers/USB/Class/Common/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
* *
* \section Sec_ModDescription Module Description * \section Sec_ModDescription Module Description
* Device Mode USB Class driver framework interface, for the HID USB Class driver. * Device Mode USB Class driver framework interface, for the HID USB Class driver.

@ -43,7 +43,7 @@
* \section Sec_Dependencies Module Source Dependencies * \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module: * The following files must be built with any user project that uses this module:
* - LUFA/Drivers/USB/Class/Host/HID.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i> * - LUFA/Drivers/USB/Class/Host/HID.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>
* - LUFA/Drivers/USB/Class/Host/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i> * - LUFA/Drivers/USB/Class/Common/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
* *
* \section Sec_ModDescription Module Description * \section Sec_ModDescription Module Description
* Host Mode USB Class driver framework interface, for the HID USB Class driver. * Host Mode USB Class driver framework interface, for the HID USB Class driver.
@ -57,7 +57,6 @@
/* Includes: */ /* Includes: */
#include "../../USB.h" #include "../../USB.h"
#include "../Common/HID.h" #include "../Common/HID.h"
#include "HIDParser.h"
/* Enable C linkage for C++ Compilers: */ /* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -1,142 +0,0 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
* \brief Constants for HID report item attributes.
*
* HID report item constants for report item attributes. Refer to the HID specification for
* details on each flag's meaning when applied to an IN, OUT or FEATURE item.
*/
/** \ingroup Group_HIDParser
* @defgroup Group_HIDIOFConst Input/Output/Feature Masks
*
* Masks indicating the type of Input, Output of Feature HID report item.
*
* @{
*/
#ifndef __HIDREPORTDATA_H__
#define __HIDREPORTDATA_H__
/* Public Interface - May be used in end-application: */
/* Macros: */
/** \ref HID_ReportItem_t.ItemFlags flag for constant data. */
#define IOF_CONSTANT (1 << 0)
/** \ref HID_ReportItem_t.ItemFlags flag for data. */
#define IOF_DATA (0 << 0)
/** \ref HID_ReportItem_t.ItemFlags flag for variable data. */
#define IOF_VARIABLE (1 << 1)
/** \ref HID_ReportItem_t.ItemFlags flag for array data. */
#define IOF_ARRAY (0 << 1)
/** \ref HID_ReportItem_t.ItemFlags flag for relative data. */
#define IOF_RELATIVE (1 << 2)
/** \ref HID_ReportItem_t.ItemFlags flag for absolute data. */
#define IOF_ABSOLUTE (0 << 2)
/** \ref HID_ReportItem_t.ItemFlags flag for wrapped value data. */
#define IOF_WRAP (1 << 3)
/** \ref HID_ReportItem_t.ItemFlags flag for non-wrapped value data. */
#define IOF_NOWRAP (0 << 3)
/** \ref HID_ReportItem_t.ItemFlags flag for non linear data. */
#define IOF_NONLINEAR (1 << 4)
/** \ref HID_ReportItem_t.ItemFlags flag for linear data. */
#define IOF_LINEAR (0 << 4)
/** \ref HID_ReportItem_t.ItemFlags flag for no preferred state. */
#define IOF_NOPREFERRED (1 << 5)
/** \ref HID_ReportItem_t.ItemFlags flag for preferred state items. */
#define IOF_PREFERREDSTATE (0 << 5)
/** \ref HID_ReportItem_t.ItemFlags flag for null state items. */
#define IOF_NULLSTATE (1 << 6)
/** \ref HID_ReportItem_t.ItemFlags flag for no null position data. */
#define IOF_NONULLPOSITION (0 << 6)
/** \ref HID_ReportItem_t.ItemFlags flag for buffered bytes. */
#define IOF_BUFFEREDBYTES (1 << 8)
/** \ref HID_ReportItem_t.ItemFlags flag for bit field data. */
#define IOF_BITFIELD (0 << 8)
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define DATA_SIZE_MASK 0x03
#define TYPE_MASK 0x0C
#define TAG_MASK 0xF0
#define DATA_SIZE_0 0x00
#define DATA_SIZE_1 0x01
#define DATA_SIZE_2 0x02
#define DATA_SIZE_4 0x03
#define TYPE_MAIN 0x00
#define TYPE_GLOBAL 0x04
#define TYPE_LOCAL 0x08
#define TAG_MAIN_INPUT 0x80
#define TAG_MAIN_OUTPUT 0x90
#define TAG_MAIN_COLLECTION 0xA0
#define TAG_MAIN_FEATURE 0xB0
#define TAG_MAIN_ENDCOLLECTION 0xC0
#define TAG_GLOBAL_USAGEPAGE 0x00
#define TAG_GLOBAL_LOGICALMIN 0x10
#define TAG_GLOBAL_LOGICALMAX 0x20
#define TAG_GLOBAL_PHYSMIN 0x30
#define TAG_GLOBAL_PHYSMAX 0x40
#define TAG_GLOBAL_UNITEXP 0x50
#define TAG_GLOBAL_UNIT 0x60
#define TAG_GLOBAL_REPORTSIZE 0x70
#define TAG_GLOBAL_REPORTID 0x80
#define TAG_GLOBAL_REPORTCOUNT 0x90
#define TAG_GLOBAL_PUSH 0xA0
#define TAG_GLOBAL_POP 0xB0
#define TAG_LOCAL_USAGE 0x00
#define TAG_LOCAL_USAGEMIN 0x10
#define TAG_LOCAL_USAGEMAX 0x20
#endif
/** @} */
#endif

@ -17,6 +17,7 @@
* - Added basic driver example use code to the library documentation * - Added basic driver example use code to the library documentation
* - Added new Endpoint_Null_Stream() and Pipe_Null_stream() functions * - Added new Endpoint_Null_Stream() and Pipe_Null_stream() functions
* - Added new ADC_GET_CHANNEL_MASK() convenience macro * - Added new ADC_GET_CHANNEL_MASK() convenience macro
* - New HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors
* - Library Applications: * - Library Applications:
* - Added ability to write protect Mass Storage disk write operations from the host OS * - Added ability to write protect Mass Storage disk write operations from the host OS
* *
@ -32,6 +33,8 @@
* where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction * where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction
* should be performed in one chunk) * should be performed in one chunk)
* - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature * - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature
* - Changed over all project and demo HID report descriptors to use the new HID report item macros
* - Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/
* - Library Applications: * - Library Applications:
* - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode * - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode
* via the Input Capture register, to reduce user confusion * via the Input Capture register, to reduce user confusion

@ -18,7 +18,6 @@
* -# Add ability to get number of bytes not written with pipe/endpoint write routines after an error * -# Add ability to get number of bytes not written with pipe/endpoint write routines after an error
* -# Change makefiles to allow for absolute LUFA location to be used * -# Change makefiles to allow for absolute LUFA location to be used
* -# Re-add interrupt Pipe/Endpoint support * -# Re-add interrupt Pipe/Endpoint support
* -# Add HID report macros to make HID report editing easier
* -# Investigate dynamically created device descriptors * -# Investigate dynamically created device descriptors
* - Known Bugs * - Known Bugs
* -# No wakeup when plugged into hub, and hub plugged into host * -# No wakeup when plugged into hub, and hub plugged into host

@ -30,7 +30,7 @@ LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Device.c
$(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/HostStandardReq.c \ $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/HostStandardReq.c \
$(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/PipeStream.c \ $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/PipeStream.c \
$(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/USBTask.c \ $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/USBTask.c \
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDParser.c $(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c
LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/Audio.c \ LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/Audio.c \
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDC.c \ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDC.c \
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HID.c \ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HID.c \

@ -46,29 +46,41 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{ {
0x05, 0x01, /* Usage Page (Generic Desktop) */ HID_RI_USAGE_PAGE(8), 0x01, /* Generic Desktop */
0x09, 0x06, /* Usage (Keyboard) */ HID_RI_USAGE(8), 0x06, /* Keyboard */
0xa1, 0x01, /* Collection (Application) */ HID_RI_COLLECTION(8), 0x01, /* Application */
0x05, 0x07, /* Usage Page (Key Codes) */ HID_RI_USAGE_PAGE(8), 0x07, /* Key Codes */
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */ HID_RI_USAGE_MINIMUM(8), 0xE0, /* Keyboard Left Control */
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */ HID_RI_USAGE_MAXIMUM(8), 0xE7, /* Keyboard Right GUI */
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_LOGICAL_MINIMUM(8), 0,
0x25, 0x01, /* Logical Maximum (1) */ HID_RI_LOGICAL_MAXIMUM(8), 1,
0x75, 0x01, /* Report Size (1) */ HID_RI_REPORT_SIZE(8), 1,
0x95, 0x08, /* Report Count (8) */ HID_RI_REPORT_COUNT(8), 8,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */ HID_RI_REPORT_COUNT(8), 1,
0x81, 0x03, /* Input (Const, Variable, Absolute) */ HID_RI_REPORT_SIZE(8), 8,
0x95, 0x06, /* Report Count (6) */ HID_RI_INPUT(8), HID_IOF_CONSTANT,
0x75, 0x08, /* Report Size (8) */
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_USAGE_PAGE(8), 0x08, /* LEDs */
0x25, 0x65, /* Logical Maximum (101) */ HID_RI_USAGE_MINIMUM(8), 0x01, /* Num Lock */
0x05, 0x07, /* Usage Page (Keyboard) */ HID_RI_USAGE_MAXIMUM(8), 0x05, /* Kana */
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */ HID_RI_REPORT_COUNT(8), 5,
0x29, 0x65, /* Usage Maximum (Keyboard Application) */ HID_RI_REPORT_SIZE(8), 1,
0x81, 0x00, /* Input (Data, Array, Absolute) */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
0xc0 /* End Collection */ 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_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -57,22 +57,23 @@
*/ */
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{ {
0x06, 0x9c, 0xff, /* Usage Page (Vendor Defined) */ HID_RI_USAGE_PAGE(16), 0x00, 0xFF, /* Vendor Page 1 */
0x09, 0x01, /* Usage (Vendor Defined) */ HID_RI_USAGE(8), 0x01, /* Vendor Usage 1 */
0xa1, 0x01, /* Collection (Vendor Defined) */ HID_RI_COLLECTION(8), 0x01, /* Vendor Usage 1 */
0x09, 0x02, /* Usage (Vendor Defined) */ HID_RI_USAGE(8), 0x02, /* Vendor Usage 2 */
0x75, 0x08, /* Report Size (8) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */ HID_RI_LOGICAL_MAXIMUM(8), 0xFF,
0x15, 0x80, /* Logical Minimum (-128) */ HID_RI_REPORT_SIZE(8), 8,
0x25, 0x7F, /* Logical Maximum (127) */ HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE,
0x81, 0x02, /* Input (Data, Variable, Absolute) */ HID_RI_INPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
0x09, 0x03, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */ HID_RI_USAGE(8), 0x03, /* Vendor Usage 3 */
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */ HID_RI_LOGICAL_MINIMUM(8), 0x00,
0x15, 0x00, /* Logical Minimum (0) */ HID_RI_LOGICAL_MAXIMUM(8), 0xFF,
0x25, 0xff, /* Logical Maximum (255) */ HID_RI_REPORT_SIZE(8), 8,
0x91, 0x02, /* Output (Data, Variable, Absolute) */ HID_RI_REPORT_COUNT(8), GENERIC_REPORT_SIZE,
0xc0 /* End Collection */ HID_RI_OUTPUT(8), (HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_END_COLLECTION(0),
}; };
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

Loading…
Cancel
Save