usb hid consumer control works

This commit is contained in:
hathach 2018-07-31 21:19:02 +07:00
parent fd661c1d57
commit ef58adacd3
3 changed files with 9 additions and 11 deletions

View File

@ -39,7 +39,7 @@
// 1 to enable device, 0 to disable // 1 to enable device, 0 to disable
#define USB_HID_DEVICE_KEYBOARD 1 #define USB_HID_DEVICE_KEYBOARD 1
#define USB_HID_DEVICE_MOUSE 1 #define USB_HID_DEVICE_MOUSE 1
#define USB_HID_DEVICE_CONSUMER 0 #define USB_HID_DEVICE_CONSUMER 1
#define USB_HID_DEVICE_GAMEPAD 0 #define USB_HID_DEVICE_GAMEPAD 0
enum { enum {

View File

@ -30,6 +30,7 @@
#include "common-hal/usb_hid/Device.h" #include "common-hal/usb_hid/Device.h"
#include "shared-bindings/usb_hid/Device.h" #include "shared-bindings/usb_hid/Device.h"
#include "tusb.h"
#define USB_HID_REPORT_LENGTH_KEYBOARD 8 #define USB_HID_REPORT_LENGTH_KEYBOARD 8
#define USB_HID_REPORT_LENGTH_MOUSE 4 #define USB_HID_REPORT_LENGTH_MOUSE 4
@ -66,8 +67,8 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
.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 = 0x01, .usage_page = HID_USAGE_PAGE_DESKTOP,
.usage = 0x06, .usage = HID_USAGE_DESKTOP_KEYBOARD,
}, },
#endif #endif
@ -77,8 +78,8 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
.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 = 0x01, .usage_page = HID_USAGE_PAGE_DESKTOP,
.usage = 0x02, .usage = HID_USAGE_DESKTOP_MOUSE,
}, },
#endif #endif
@ -86,11 +87,10 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type },
.report_buffer = consumer_report_buffer, .report_buffer = consumer_report_buffer,
.endpoint = USB_HID_ENDPOINT_IN,
.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 = 0x0C, .usage_page = HID_USAGE_PAGE_CONSUMER,
.usage = 0x01, .usage = HID_USAGE_CONSUMER_CONTROL,
}, },
#endif #endif
@ -98,7 +98,6 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type },
.report_buffer = sys_control_report_buffer, .report_buffer = sys_control_report_buffer,
.endpoint = USB_HID_ENDPOINT_IN,
.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 = 0x01, .usage_page = 0x01,
@ -109,7 +108,6 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
{ {
.base = { .type = &usb_hid_device_type }, .base = { .type = &usb_hid_device_type },
.report_buffer = gamepad_report_buffer, .report_buffer = gamepad_report_buffer,
.endpoint = USB_HID_ENDPOINT_IN,
.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 = 0x01, .usage_page = 0x01,

View File

@ -150,7 +150,7 @@ uint8_t const usb_desc_hid_generic_report[] =
#endif #endif
#if USB_HID_DEVICE_CONSUMER #if USB_HID_DEVICE_CONSUMER
HID_REPORT_DESC_MOUSE( HID_REPORT_ID(USB_HID_REPORT_ID_CONSUMER), ) HID_REPORT_DESC_CONSUMER( HID_REPORT_ID(USB_HID_REPORT_ID_CONSUMER), )
#endif #endif
}; };