Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V-USB: implement NKRO #22398

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ static void send_keyboard(report_keyboard_t *report) {
keyboard_report_sent = *report;
}

static void send_nkro(report_nkro_t *report) {
// TODO: Implement NKRO
}

#ifndef KEYBOARD_SHARED_EP
# define usbInterruptIsReadyShared usbInterruptIsReady3
# define usbSetInterruptShared usbSetInterrupt3
Expand All @@ -269,6 +265,12 @@ static void send_nkro(report_nkro_t *report) {
# define usbSetInterruptShared usbSetInterrupt
#endif

static void send_nkro(report_nkro_t *report) {
#ifdef NKRO_ENABLE
send_report(3, report, sizeof(report_nkro_t));
#endif
}

static void send_mouse(report_mouse_t *report) {
#ifdef MOUSE_ENABLE
if (usbInterruptIsReadyShared()) {
Expand Down Expand Up @@ -470,6 +472,45 @@ const PROGMEM uchar shared_hid_report[] = {
# define SHARED_REPORT_STARTED
#endif

#ifdef NKRO_ENABLE
// NKRO report descriptor
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x06, // Usage (Keyboard)
0xA1, 0x01, // Collection (Application)
0x85, REPORT_ID_NKRO, // Report ID
// Modifiers (8 bits)
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x08, // Report Count (8)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
// Keycodes
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0x00, // Usage Minimum (0)
0x29, NKRO_REPORT_BITS * 8 - 1, // Usage Maximum
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, NKRO_REPORT_BITS * 8, // Report Count
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)

// Status LEDs (5 bits)
0x05, 0x08, // Usage Page (LED)
0x19, 0x01, // Usage Minimum (Num Lock)
0x29, 0x05, // Usage Maximum (Kana)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x91, 0x02, // Output (Data, Variable, Absolute)
// LED padding (3 bits)
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x91, 0x03, // Output (Constant)
0xC0, // End Collection
#endif

#ifdef MOUSE_ENABLE
// Mouse report descriptor
0x05, 0x01, // Usage Page (Generic Desktop)
Expand Down