diff --git a/lib_xua/src/hid/hid_report_descriptor.c b/lib_xua/src/hid/hid_report_descriptor.c index 76983e89..c55ff8f0 100644 --- a/lib_xua/src/hid/hid_report_descriptor.c +++ b/lib_xua/src/hid/hid_report_descriptor.c @@ -5,24 +5,12 @@ #include #include "xua_hid_report_descriptor.h" -#define HID_REPORT_ITEM_HDR_SIZE_MASK ( 0x03 ) -#define HID_REPORT_ITEM_HDR_SIZE_SHIFT ( 0 ) - -#define HID_REPORT_ITEM_HDR_TAG_MASK ( 0xF0 ) -#define HID_REPORT_ITEM_HDR_TAG_SHIFT ( 4 ) - -#define HID_REPORT_ITEM_HDR_TYPE_MASK ( 0x0C ) -#define HID_REPORT_ITEM_HDR_TYPE_SHIFT ( 2 ) - #define HID_REPORT_ITEM_LOC_BIT_MASK ( 0x70 ) #define HID_REPORT_ITEM_LOC_BIT_SHIFT ( 4 ) #define HID_REPORT_ITEM_LOC_BYTE_MASK ( 0x0F ) #define HID_REPORT_ITEM_LOC_BYTE_SHIFT ( 0 ) -#define HID_REPORT_ITEM_USAGE_TAG ( 0 ) -#define HID_REPORT_ITEM_USAGE_TYPE ( 2 ) - #if 0 /* Existing static report descriptor kept for reference */ unsigned char hidReportDescriptor[] = @@ -289,7 +277,7 @@ void hidInitReportDescriptor( void ) unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsigned char header, const unsigned char data[] ) { - unsigned retVal = 2; + unsigned retVal = HID_STATUS_BAD_LOCATION; unsigned bSize = hidGetItemSize( header ); unsigned bTag = hidGetItemTag ( header ); unsigned bType = hidGetItemType( header ); @@ -297,7 +285,7 @@ unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsign if(( HID_REPORT_ITEM_MAX_SIZE < bSize ) && ( HID_REPORT_ITEM_USAGE_TAG == bTag ) && ( HID_REPORT_ITEM_USAGE_TAG == bType )) { - retVal = 1; + retVal = HID_STATUS_BAD_HEADER; } else { for( unsigned itemIdx = 0; itemIdx < sizeof hidConfigurableItems / sizeof( USB_HID_Short_Item_t ); ++itemIdx ) { USB_HID_Short_Item_t item = *hidConfigurableItems[ itemIdx ]; @@ -313,7 +301,7 @@ unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsign *hidConfigurableItems[ itemIdx ] = item; hidReportDescriptorInitialised = 0; - retVal = 0; + retVal = HID_STATUS_GOOD; } } } diff --git a/lib_xua/src/hid/xua_hid_report_descriptor.h b/lib_xua/src/hid/xua_hid_report_descriptor.h index 2195ddc3..94e335d8 100644 --- a/lib_xua/src/hid/xua_hid_report_descriptor.h +++ b/lib_xua/src/hid/xua_hid_report_descriptor.h @@ -11,11 +11,23 @@ #ifndef _HID_REPORT_DESCRIPTOR_ #define _HID_REPORT_DESCRIPTOR_ -#define HID_REPORT_ITEM_MAX_SIZE ( 2 ) +#define HID_REPORT_ITEM_HDR_SIZE_MASK ( 0x03 ) +#define HID_REPORT_ITEM_HDR_SIZE_SHIFT ( 0 ) -#define HID_STATUS_GOOD ( 0 ) -#define HID_STATUS_BAD_HEADER ( 1 ) -#define HID_STATUS_BAD_LOCATION ( 2 ) +#define HID_REPORT_ITEM_HDR_TAG_MASK ( 0xF0 ) +#define HID_REPORT_ITEM_HDR_TAG_SHIFT ( 4 ) + +#define HID_REPORT_ITEM_HDR_TYPE_MASK ( 0x0C ) +#define HID_REPORT_ITEM_HDR_TYPE_SHIFT ( 2 ) + +#define HID_REPORT_ITEM_MAX_SIZE ( 2 ) + +#define HID_REPORT_ITEM_USAGE_TAG ( 0 ) +#define HID_REPORT_ITEM_USAGE_TYPE ( 2 ) + +#define HID_STATUS_GOOD ( 0 ) +#define HID_STATUS_BAD_HEADER ( 1 ) +#define HID_STATUS_BAD_LOCATION ( 2 ) /** * @brief USB HID Report Descriptor. Short Item