From 151330b7210a9faa65e192706dd5107b9b2c5497 Mon Sep 17 00:00:00 2001 From: zyh Date: Wed, 4 Jul 2018 14:13:09 +0800 Subject: [PATCH] =?UTF-8?q?[Components][USB][Device]Support=20customer=20H?= =?UTF-8?q?ID=20class|=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89HID?= =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drivers/include/drivers/usb_common.h | 30 +++++-------------- components/drivers/usb/usbdevice/class/hid.c | 28 +++++++++++++++++ 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h index 26c1d9aac4..922682b1af 100644 --- a/components/drivers/include/drivers/usb_common.h +++ b/components/drivers/include/drivers/usb_common.h @@ -222,26 +222,13 @@ extern "C" { #define USB_EP_DESC_NUM(addr) (addr & USB_EP_DESC_NUM_MASK) #define USB_EP_DIR(addr) ((addr & USB_DIR_MASK)>>7) -#ifdef RT_USB_DEVICE_HID - #ifdef RT_USB_DEVICE_HID_KEYBOARD - #define HID_REPORT_ID_KEYBOARD1 1 - #if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>1 - #define HID_REPORT_ID_KEYBOARD2 2 - #if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>2 - #define HID_REPORT_ID_KEYBOARD3 3 - #endif - #endif - #endif - #ifdef RT_USB_DEVICE_HID_MEDIA - #define HID_REPORT_ID_MEDIA 4 - #endif - #ifdef RT_USB_DEVICE_HID_GENERAL - #define HID_REPORT_ID_GENERAL 5 - #endif - #ifdef RT_USB_DEVICE_HID_MOUSE - #define HID_REPORT_ID_MOUSE 6 - #endif -#endif +#define HID_REPORT_ID_KEYBOARD1 1 +#define HID_REPORT_ID_KEYBOARD2 2 +#define HID_REPORT_ID_KEYBOARD3 3 +#define HID_REPORT_ID_KEYBOARD4 7 +#define HID_REPORT_ID_MEDIA 4 +#define HID_REPORT_ID_GENERAL 5 +#define HID_REPORT_ID_MOUSE 6 #define uswap_32(x) \ ((((x) & 0xff000000) >> 24) | \ @@ -473,7 +460,6 @@ typedef struct usb_os_proerty * usb_os_proerty_t; #define HID_SUB_DESCRIPTOR_MAX 1 #endif -#ifdef RT_USB_DEVICE_HID struct uhid_descriptor { rt_uint8_t bLength; @@ -497,7 +483,7 @@ struct hid_report }; typedef struct hid_report* hid_report_t; extern void HID_Report_Received(hid_report_t report); -#endif + struct urequest { rt_uint8_t request_type; diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c index fe1050e3ef..bbaf7d23ef 100644 --- a/components/drivers/usb/usbdevice/class/hid.c +++ b/components/drivers/usb/usbdevice/class/hid.c @@ -129,6 +129,34 @@ const rt_uint8_t _report_desc[]= USAGE_MAXIMUM(1), 0x65, INPUT(1), 0x00, END_COLLECTION(0), +#if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>3 + USAGE_PAGE(1), 0x01, + USAGE(1), 0x06, + COLLECTION(1), 0x01, + REPORT_ID(1), HID_REPORT_ID_KEYBOARD4, + + USAGE_PAGE(1), 0x07, + USAGE_MINIMUM(1), 0xE0, + USAGE_MAXIMUM(1), 0xE7, + LOGICAL_MINIMUM(1), 0x00, + LOGICAL_MAXIMUM(1), 0x01, + REPORT_SIZE(1), 0x01, + REPORT_COUNT(1), 0x08, + INPUT(1), 0x02, + REPORT_COUNT(1), 0x01, + REPORT_SIZE(1), 0x08, + INPUT(1), 0x01, + + REPORT_COUNT(1), 0x06, + REPORT_SIZE(1), 0x08, + LOGICAL_MINIMUM(1), 0x00, + LOGICAL_MAXIMUM(1), 0x65, + USAGE_PAGE(1), 0x07, + USAGE_MINIMUM(1), 0x00, + USAGE_MAXIMUM(1), 0x65, + INPUT(1), 0x00, + END_COLLECTION(0), +#endif #endif #endif #endif