summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2018-07-31 21:19:02 +0700
committerhathach <thach@tinyusb.org>2018-07-31 21:19:02 +0700
commitef58adacd3a37c0df37bf0f1f2b9568e70c163f8 (patch)
tree8b60ee8d57614a9282e4d0cea787f240375cf6d9
parentfd661c1d57ebf4090e8fd37db9a6a01358ce6a46 (diff)
usb hid consumer control works
-rw-r--r--ports/nrf/common-hal/usb_hid/Device.h2
-rw-r--r--ports/nrf/common-hal/usb_hid/__init__.c16
-rw-r--r--ports/nrf/usb/usb_desc.c2
3 files changed, 9 insertions, 11 deletions
diff --git a/ports/nrf/common-hal/usb_hid/Device.h b/ports/nrf/common-hal/usb_hid/Device.h
index a0d26fd31..b6a832f5c 100644
--- a/ports/nrf/common-hal/usb_hid/Device.h
+++ b/ports/nrf/common-hal/usb_hid/Device.h
@@ -39,7 +39,7 @@
// 1 to enable device, 0 to disable
#define USB_HID_DEVICE_KEYBOARD 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
enum {
diff --git a/ports/nrf/common-hal/usb_hid/__init__.c b/ports/nrf/common-hal/usb_hid/__init__.c
index 0c637e63c..536ad07fa 100644
--- a/ports/nrf/common-hal/usb_hid/__init__.c
+++ b/ports/nrf/common-hal/usb_hid/__init__.c
@@ -30,6 +30,7 @@
#include "common-hal/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_MOUSE 4
@@ -66,8 +67,8 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
.report_buffer = keyboard_report_buffer,
.report_id = USB_HID_REPORT_ID_KEYBOARD,
.report_length = USB_HID_REPORT_LENGTH_KEYBOARD,
- .usage_page = 0x01,
- .usage = 0x06,
+ .usage_page = HID_USAGE_PAGE_DESKTOP,
+ .usage = HID_USAGE_DESKTOP_KEYBOARD,
},
#endif
@@ -77,8 +78,8 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
.report_buffer = mouse_report_buffer,
.report_id = USB_HID_REPORT_ID_MOUSE,
.report_length = USB_HID_REPORT_LENGTH_MOUSE,
- .usage_page = 0x01,
- .usage = 0x02,
+ .usage_page = HID_USAGE_PAGE_DESKTOP,
+ .usage = HID_USAGE_DESKTOP_MOUSE,
},
#endif
@@ -86,11 +87,10 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
{
.base = { .type = &usb_hid_device_type },
.report_buffer = consumer_report_buffer,
- .endpoint = USB_HID_ENDPOINT_IN,
.report_id = USB_HID_REPORT_ID_CONSUMER,
.report_length = USB_HID_REPORT_LENGTH_CONSUMER,
- .usage_page = 0x0C,
- .usage = 0x01,
+ .usage_page = HID_USAGE_PAGE_CONSUMER,
+ .usage = HID_USAGE_CONSUMER_CONTROL,
},
#endif
@@ -98,7 +98,6 @@ usb_hid_device_obj_t usb_hid_devices[USB_HID_NUM_DEVICES] = {
{
.base = { .type = &usb_hid_device_type },
.report_buffer = sys_control_report_buffer,
- .endpoint = USB_HID_ENDPOINT_IN,
.report_id = USB_HID_REPORT_ID_SYS_CONTROL,
.report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL,
.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 },
.report_buffer = gamepad_report_buffer,
- .endpoint = USB_HID_ENDPOINT_IN,
.report_id = USB_HID_REPORT_ID_GAMEPAD,
.report_length = USB_HID_REPORT_LENGTH_GAMEPAD,
.usage_page = 0x01,
diff --git a/ports/nrf/usb/usb_desc.c b/ports/nrf/usb/usb_desc.c
index 07d8c837d..54d313367 100644
--- a/ports/nrf/usb/usb_desc.c
+++ b/ports/nrf/usb/usb_desc.c
@@ -150,7 +150,7 @@ uint8_t const usb_desc_hid_generic_report[] =
#endif
#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
};