From a852ea8e43d6df9642df3524a974073d2229fa4c Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 26 Jan 2011 21:33:07 +0000 Subject: Added new KeyboardMouseMultiReport Device ClassDriver demo. Fixed ReportID not being removed from the feature/out report data array in the HID class driver when Report IDs are used. Added new MAX() and MIN() convenience macros. --- LUFA/Drivers/USB/Class/Common/HID.h | 8 ++++---- LUFA/Drivers/USB/Class/Device/HID.c | 12 ++++++++---- LUFA/Drivers/USB/LowLevel/USBInterrupt.h | 10 +++++----- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'LUFA/Drivers/USB') diff --git a/LUFA/Drivers/USB/Class/Common/HID.h b/LUFA/Drivers/USB/Class/Common/HID.h index 2c6ec4136..8cb5f6d46 100644 --- a/LUFA/Drivers/USB/Class/Common/HID.h +++ b/LUFA/Drivers/USB/Class/Common/HID.h @@ -340,7 +340,7 @@ * } Joystick_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 + * 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 @@ -370,7 +370,7 @@ HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \ HID_RI_REPORT_COUNT(8, 0x01), \ HID_RI_INPUT(8, HID_IOF_CONSTANT), \ - HID_RI_END_COLLECTION(0), + HID_RI_END_COLLECTION(0) /** \hideinitializer * A list of HID report item array elements that describe a typical HID USB keyboard. The resulting report descriptor @@ -421,7 +421,7 @@ HID_RI_REPORT_COUNT(8, MaxKeys), \ 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), + HID_RI_END_COLLECTION(0) /** \hideinitializer * A list of HID report item array elements that describe a typical HID USB mouse. The resulting report descriptor @@ -475,7 +475,7 @@ 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 | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE) | HID_IOF_NON_VOLATILE), \ HID_RI_END_COLLECTION(0), \ - HID_RI_END_COLLECTION(0), + HID_RI_END_COLLECTION(0) //@} /* Type Defines: */ diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index e75b022f5..412673824 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -59,8 +59,11 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, ReportData, &ReportSize); if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) - memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData, HIDInterfaceInfo->Config.PrevReportINBufferSize); - + { + memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData, + HIDInterfaceInfo->Config.PrevReportINBufferSize); + } + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_ClearSETUP(); @@ -80,8 +83,9 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_ClearSETUP(); Endpoint_Read_Control_Stream_LE(ReportData, ReportSize); Endpoint_ClearIN(); - - CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, ReportData, ReportSize); + + CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, + &ReportData[ReportID ? 1 : 0], ReportSize - (ReportID ? 1 : 0)); } break; diff --git a/LUFA/Drivers/USB/LowLevel/USBInterrupt.h b/LUFA/Drivers/USB/LowLevel/USBInterrupt.h index 29ad93388..da516b45f 100644 --- a/LUFA/Drivers/USB/LowLevel/USBInterrupt.h +++ b/LUFA/Drivers/USB/LowLevel/USBInterrupt.h @@ -60,11 +60,11 @@ /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ - #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE - #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE - #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE - #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false) - #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false) + #define USB_INT_Enable(int) do { USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); } while(0) + #define USB_INT_Disable(int) do { USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); } while(0) + #define USB_INT_Clear(int) do { USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); } while(0) + #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false) + #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false) #define USB_INT_GET_EN_REG(a, b, c, d) a #define USB_INT_GET_EN_MASK(a, b, c, d) b -- cgit v1.2.3