This commit is contained in:
hathach 2018-08-01 08:20:20 +07:00
parent 1e524f1b98
commit 6ddd8583da
2 changed files with 56 additions and 50 deletions

View File

@ -66,67 +66,67 @@ static uint8_t digitizer_report_buffer[USB_HID_REPORT_LENGTH_DIGITIZER];
usb_hid_device_obj_t usb_hid_devices[] = { usb_hid_device_obj_t usb_hid_devices[] = {
#if USB_HID_DEVICE_KEYBOARD #if USB_HID_DEVICE_KEYBOARD
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type } ,
.report_buffer = keyboard_report_buffer, .report_buffer = keyboard_report_buffer ,
.report_id = USB_HID_REPORT_ID_KEYBOARD, .report_id = USB_HID_REPORT_ID_KEYBOARD ,
.report_length = USB_HID_REPORT_LENGTH_KEYBOARD, .report_length = USB_HID_REPORT_LENGTH_KEYBOARD ,
.usage_page = HID_USAGE_PAGE_DESKTOP, .usage_page = HID_USAGE_PAGE_DESKTOP ,
.usage = HID_USAGE_DESKTOP_KEYBOARD, .usage = HID_USAGE_DESKTOP_KEYBOARD ,
}, },
#endif #endif
#if USB_HID_DEVICE_MOUSE #if USB_HID_DEVICE_MOUSE
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type } ,
.report_buffer = mouse_report_buffer, .report_buffer = mouse_report_buffer ,
.report_id = USB_HID_REPORT_ID_MOUSE, .report_id = USB_HID_REPORT_ID_MOUSE ,
.report_length = USB_HID_REPORT_LENGTH_MOUSE, .report_length = USB_HID_REPORT_LENGTH_MOUSE ,
.usage_page = HID_USAGE_PAGE_DESKTOP, .usage_page = HID_USAGE_PAGE_DESKTOP ,
.usage = HID_USAGE_DESKTOP_MOUSE, .usage = HID_USAGE_DESKTOP_MOUSE ,
}, },
#endif #endif
#if USB_HID_DEVICE_CONSUMER #if USB_HID_DEVICE_CONSUMER
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type } ,
.report_buffer = consumer_report_buffer, .report_buffer = consumer_report_buffer ,
.report_id = USB_HID_REPORT_ID_CONSUMER, .report_id = USB_HID_REPORT_ID_CONSUMER ,
.report_length = USB_HID_REPORT_LENGTH_CONSUMER, .report_length = USB_HID_REPORT_LENGTH_CONSUMER ,
.usage_page = HID_USAGE_PAGE_CONSUMER, .usage_page = HID_USAGE_PAGE_CONSUMER ,
.usage = HID_USAGE_CONSUMER_CONTROL, .usage = HID_USAGE_CONSUMER_CONTROL ,
}, },
#endif #endif
#if USB_HID_DEVICE_SYS_CONTROL #if USB_HID_DEVICE_SYS_CONTROL
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type } ,
.report_buffer = sys_control_report_buffer, .report_buffer = sys_control_report_buffer ,
.report_id = USB_HID_REPORT_ID_SYS_CONTROL, .report_id = USB_HID_REPORT_ID_SYS_CONTROL ,
.report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL, .report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL ,
.usage_page = HID_USAGE_PAGE_DESKTOP, .usage_page = HID_USAGE_PAGE_DESKTOP ,
.usage = HID_USAGE_DESKTOP_SYSTEM_CONTROL, .usage = HID_USAGE_DESKTOP_SYSTEM_CONTROL ,
}, },
#endif #endif
#if USB_HID_DEVICE_GAMEPAD #if USB_HID_DEVICE_GAMEPAD
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type } ,
.report_buffer = gamepad_report_buffer, .report_buffer = gamepad_report_buffer ,
.report_id = USB_HID_REPORT_ID_GAMEPAD, .report_id = USB_HID_REPORT_ID_GAMEPAD ,
.report_length = USB_HID_REPORT_LENGTH_GAMEPAD, .report_length = USB_HID_REPORT_LENGTH_GAMEPAD ,
.usage_page = HID_USAGE_PAGE_DESKTOP, .usage_page = HID_USAGE_PAGE_DESKTOP ,
.usage = HID_USAGE_DESKTOP_GAMEPAD, .usage = HID_USAGE_DESKTOP_GAMEPAD ,
}, },
#endif #endif
#if USB_HID_DEVICE_DIGITIZER #if USB_HID_DEVICE_DIGITIZER
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type } ,
.report_buffer = digitizer_report_buffer, .report_buffer = digitizer_report_buffer ,
.report_id = USB_HID_REPORT_ID_DIGITIZER, .report_id = USB_HID_REPORT_ID_DIGITIZER ,
.report_length = USB_HID_REPORT_LENGTH_DIGITIZER, .report_length = USB_HID_REPORT_LENGTH_DIGITIZER ,
.usage_page = 0x0D, .usage_page = 0x0D ,
.usage = 0x02, .usage = 0x02 ,
}, },
#endif #endif
}; };

View File

@ -37,15 +37,23 @@
#define USB_PID 0x802A #define USB_PID 0x802A
/*------------- Interface Numbering -------------*/ /*------------- Interface Numbering -------------*/
#define ITF_NUM_CDC 0 enum {
#define ITF_NUM_MSC 2 ITF_NUM_CDC = 0 ,
#define ITF_NUM_HID_GEN 3 ITF_NUM_CDC_DATA ,
#define ITF_TOTAL 4 ITF_NUM_MSC ,
ITF_NUM_HID_GEN ,
ITF_NUM_TOTAL
};
enum {
#define ITF_STR_CDC 4 ITF_STR_LANGUAGE = 0 ,
#define ITF_STR_MSC 5 ITF_STR_MANUFACTURER ,
#define ITF_STR_HID 6 ITF_STR_PRODUCT ,
ITF_STR_SERIAL ,
ITF_STR_CDC ,
ITF_STR_MSC ,
ITF_STR_HID
};
/*------------- Endpoint Numbering & Size -------------*/ /*------------- Endpoint Numbering & Size -------------*/
#define _EP_IN(x) (0x80 | (x)) #define _EP_IN(x) (0x80 | (x))
@ -169,10 +177,8 @@ usb_desc_cfg_t const usb_desc_cfg =
{ {
.bLength = sizeof(tusb_desc_configuration_t), .bLength = sizeof(tusb_desc_configuration_t),
.bDescriptorType = TUSB_DESC_CONFIGURATION, .bDescriptorType = TUSB_DESC_CONFIGURATION,
.wTotalLength = sizeof(usb_desc_cfg_t), .wTotalLength = sizeof(usb_desc_cfg_t),
.bNumInterfaces = ITF_TOTAL, .bNumInterfaces = ITF_NUM_TOTAL,
.bConfigurationValue = 1, .bConfigurationValue = 1,
.iConfiguration = 0x00, .iConfiguration = 0x00,
.bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER, .bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
@ -371,9 +377,9 @@ usb_desc_cfg_t const usb_desc_cfg =
// tud_desc_set is required by tinyusb stack // tud_desc_set is required by tinyusb stack
tud_desc_set_t tud_desc_set = tud_desc_set_t tud_desc_set =
{ {
.device = (uint8_t const*) &usb_desc_dev, .device = &usb_desc_dev,
.config = (uint8_t const*) &usb_desc_cfg, .config = &usb_desc_cfg,
.string_arr = (uint8_t const **) string_desc_arr, .string_arr = (uint8_t const **) string_desc_arr,
.string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]), .string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
.hid_report = .hid_report =