This commit is contained in:
2025-09-17 12:51:01 -07:00
parent 8e0ae599a7
commit 736b7f406d
25 changed files with 16650 additions and 15995 deletions

View File

@@ -37,17 +37,52 @@ extern "C" {
*/
///** @defgroup USBD_HID_Exported_Defines
// * @{
// */
//#ifndef HID_EPIN_ADDR
//#define HID_EPIN_ADDR 0x81U
//#endif /* HID_EPIN_ADDR */
//#define HID_EPIN_SIZE 0x04U
//
//#define USB_HID_CONFIG_DESC_SIZ 34U
//#define USB_HID_DESC_SIZ 9U
//#define HID_MOUSE_REPORT_DESC_SIZE 63U
//
//#define HID_DESCRIPTOR_TYPE 0x21U
//#define HID_REPORT_DESC 0x22U
//
//#ifndef HID_HS_BINTERVAL
//#define HID_HS_BINTERVAL 0x07U
//#endif /* HID_HS_BINTERVAL */
//
//#ifndef HID_FS_BINTERVAL
//#define HID_FS_BINTERVAL 0x0AU
//#endif /* HID_FS_BINTERVAL */
//
//#define USBD_HID_REQ_SET_PROTOCOL 0x0BU
//#define USBD_HID_REQ_GET_PROTOCOL 0x03U
//
//#define USBD_HID_REQ_SET_IDLE 0x0AU
//#define USBD_HID_REQ_GET_IDLE 0x02U
//
//#define USBD_HID_REQ_SET_REPORT 0x09U
//#define USBD_HID_REQ_GET_REPORT 0x01U
///**
// * @}
// */
/** @defgroup USBD_HID_Exported_Defines
* @{
*/
#ifndef HID_EPIN_ADDR
#define HID_EPIN_ADDR 0x81U
#endif /* HID_EPIN_ADDR */
#define HID_EPIN_SIZE 0x04U
#define HID_EPIN_SIZE 0x0EU
#define USB_HID_CONFIG_DESC_SIZ 34U
#define USB_HID_DESC_SIZ 9U
#define HID_MOUSE_REPORT_DESC_SIZE 63U
#define HID_MOUSE_REPORT_DESC_SIZE 0x2DU
#define HID_DESCRIPTOR_TYPE 0x21U
#define HID_REPORT_DESC 0x22U
@@ -72,10 +107,6 @@ extern "C" {
* @}
*/
/** @defgroup USBD_CORE_Exported_TypesDefinitions
* @{
*/
typedef enum
{
USBD_HID_IDLE = 0,

View File

@@ -157,8 +157,8 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_E
0x00, /* bAlternateSetting: Alternate setting */
0x01, /* bNumEndpoints */
0x03, /* bInterfaceClass: HID */
0x01, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
0x01, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
0x0, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
0, /* iInterface: Index of string descriptor */
/******************** Descriptor of Joystick Mouse HID ********************/
/* 18 */
@@ -219,38 +219,69 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x05, // REPORT_COUNT (5)
0x75, 0x01, // REPORT_SIZE (1)
0x05, 0x08, // USAGE_PAGE (LEDs)
0x19, 0x01, // USAGE_MINIMUM (Num Lock)
0x29, 0x05, // USAGE_MAXIMUM (Kana)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x03, // REPORT_SIZE (3)
0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0 // END_COLLECTION
// 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
// 0x09, 0x06, // USAGE (Keyboard)
// 0xa1, 0x01, // COLLECTION (Application)
// 0x05, 0x07, // USAGE_PAGE (Keyboard)
// 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
// 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
// 0x15, 0x00, // LOGICAL_MINIMUM (0)
// 0x25, 0x01, // LOGICAL_MAXIMUM (1)
// 0x75, 0x01, // REPORT_SIZE (1)
// 0x95, 0x08, // REPORT_COUNT (8)
// 0x81, 0x02, // INPUT (Data,Var,Abs)
// 0x95, 0x01, // REPORT_COUNT (1)
// 0x75, 0x08, // REPORT_SIZE (8)
// 0x81, 0x03, // INPUT (Cnst,Var,Abs)
// 0x95, 0x05, // REPORT_COUNT (5)
// 0x75, 0x01, // REPORT_SIZE (1)
// 0x05, 0x08, // USAGE_PAGE (LEDs)
// 0x19, 0x01, // USAGE_MINIMUM (Num Lock)
// 0x29, 0x05, // USAGE_MAXIMUM (Kana)
// 0x91, 0x02, // OUTPUT (Data,Var,Abs)
// 0x95, 0x01, // REPORT_COUNT (1)
// 0x75, 0x03, // REPORT_SIZE (3)
// 0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
// 0x95, 0x06, // REPORT_COUNT (6)
// 0x75, 0x08, // REPORT_SIZE (8)
// 0x15, 0x00, // LOGICAL_MINIMUM (0)
// 0x25, 0x65, // LOGICAL_MAXIMUM (101)
// 0x05, 0x07, // USAGE_PAGE (Keyboard)
// 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
// 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
// 0x81, 0x00, // INPUT (Data,Ary,Abs)
// 0xc0 // END_COLLECTION
// 0xC0 /* End Collection */
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x06, // Usage (Keyboard)
0xA1, 0x01, // Collection (Application)
// Modifiers (8 bits)
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0xE0, // Usage Minimum (224) - Left Control
0x29, 0xE7, // Usage Maximum (231) - Right GUI
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1 bit)
0x95, 0x08, // Report Count (8 bits)
0x81, 0x02, // Input (Data, Variable, Absolute)
// Reserved byte (8 bits)
0x75, 0x08, // Report Size (8 bits)
0x95, 0x01, // Report Count (1)
0x81, 0x01, // Input (Constant)
// Key bitfield (96 bits = 12 bytes)
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0x04, // Usage Minimum (4) — 'A' key
0x29, 0x63, // Usage Maximum (99) — 96 keys total (4 to 99)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1 bit)
0x95, 0x60, // Report Count (96 bits)
0x81, 0x02, // Input (Data, Variable, Absolute)
0xC0 // End Collection
};
static uint8_t HIDInEpAdd = HID_EPIN_ADDR;