fix gc; update KEYBOARD report descriptor
The default KEYBOARD report descriptor had a signed/unsigned error, and also could have allowed more keycodes. So I changed it, using the very vanilla descriptor from a very plain extremely common commercial keyboard, modifying it only have 5 LED's instead of 3, and added a report ID.
This commit is contained in:
parent
f37e1d7bf5
commit
38f42818e9
@ -36,37 +36,39 @@
|
||||
#include "tusb.h"
|
||||
|
||||
static const uint8_t keyboard_report_descriptor[] = {
|
||||
0x05, 0x01, // 0,1 Usage Page (Generic Desktop Ctrls)
|
||||
0x09, 0x06, // 2,3 Usage (Keyboard)
|
||||
0xA1, 0x01, // 4,5 Collection (Application)
|
||||
0x85, 0x01, // 6,7 Report ID (1)
|
||||
0x05, 0x07, // Usage Page (Kbrd/Keypad)
|
||||
0x19, 0xE0, // Usage Minimum (0xE0)
|
||||
0x29, 0xE7, // Usage Maximum (0xE7)
|
||||
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,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0x81, 0x01, // Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0x19, 0x00, // Usage Minimum (0x00)
|
||||
0x29, 0xDD, // Usage Maximum (0xDD)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0xDD, // Logical Maximum (-35)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x95, 0x06, // Report Count (6)
|
||||
0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0x05, 0x08, // Usage Page (LEDs)
|
||||
0x19, 0x01, // Usage Minimum (Num Lock)
|
||||
0x29, 0x05, // Usage Maximum (Kana)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x95, 0x05, // Report Count (5)
|
||||
0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
|
||||
0x95, 0x03, // Report Count (3)
|
||||
0x91, 0x01, // Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
|
||||
0xC0, // End Collection
|
||||
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
|
||||
0x09, 0x06, // Usage (Keyboard)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x85, 0x01, // Report ID (1)
|
||||
0x05, 0x07, // Usage Page (Kbrd/Keypad)
|
||||
0x19, 0xE0, // Usage Minimum (0xE0)
|
||||
0x29, 0xE7, // Usage Maximum (0xE7)
|
||||
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,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x01, // Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0x95, 0x03, // Report Count (3)
|
||||
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,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x05, // Report Size (5)
|
||||
0x91, 0x01, // Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
|
||||
0x95, 0x06, // Report Count (6)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x26, 0xFF, 0x00, // Logical Maximum (255)
|
||||
0x05, 0x07, // Usage Page (Kbrd/Keypad)
|
||||
0x19, 0x00, // Usage Minimum (0x00)
|
||||
0x2A, 0xFF, 0x00, // Usage Maximum (0xFF)
|
||||
0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0xC0, // End Collection
|
||||
};
|
||||
|
||||
const usb_hid_device_obj_t usb_hid_device_keyboard_obj = {
|
||||
@ -84,11 +86,11 @@ const usb_hid_device_obj_t usb_hid_device_keyboard_obj = {
|
||||
};
|
||||
|
||||
static const uint8_t mouse_report_descriptor[] = {
|
||||
0x05, 0x01, // 0,1 Usage Page (Generic Desktop Ctrls)
|
||||
0x09, 0x02, // 2,3 Usage (Mouse)
|
||||
0xA1, 0x01, // 4,5 Collection (Application)
|
||||
0x09, 0x01, // 6,7 Usage (Pointer)
|
||||
0xA1, 0x00, // 8,9 Collection (Physical)
|
||||
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
|
||||
0x09, 0x02, // Usage (Mouse)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x09, 0x01, // Usage (Pointer)
|
||||
0xA1, 0x00, // Collection (Physical)
|
||||
0x85, 0x02, // 10, 11 Report ID (2)
|
||||
0x05, 0x09, // Usage Page (Button)
|
||||
0x19, 0x01, // Usage Minimum (0x01)
|
||||
@ -134,10 +136,10 @@ const usb_hid_device_obj_t usb_hid_device_mouse_obj = {
|
||||
};
|
||||
|
||||
static const uint8_t consumer_control_report_descriptor[] = {
|
||||
0x05, 0x0C, // 0,1 Usage Page (Consumer)
|
||||
0x09, 0x01, // 2,3 Usage (Consumer Control)
|
||||
0xA1, 0x01, // 4,5 Collection (Application)
|
||||
0x85, 0x03, // 6,7 Report ID (3)
|
||||
0x05, 0x0C, // Usage Page (Consumer)
|
||||
0x09, 0x01, // Usage (Consumer Control)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x85, 0x03, // Report ID (3)
|
||||
0x75, 0x10, // Report Size (16)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x15, 0x01, // Logical Minimum (1)
|
||||
|
@ -250,8 +250,9 @@ void usb_hid_gc_collect(void) {
|
||||
// and not copied into RAM.
|
||||
gc_collect_ptr((void *)hid_devices[device_idx].report_descriptor);
|
||||
|
||||
// Collect all the OUT report buffers for this device.
|
||||
// Collect all the report buffers for this device.
|
||||
for (size_t id_idx = 0; id_idx < hid_devices[device_idx].num_report_ids; id_idx++) {
|
||||
gc_collect_ptr(hid_devices[id_idx].in_report_buffers[id_idx]);
|
||||
gc_collect_ptr(hid_devices[id_idx].out_report_buffers[id_idx]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user