Skip to content

Commit

Permalink
V-USB: implement NKRO (qmk#22398)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and Nathan committed Feb 11, 2024
1 parent c29cd98 commit 0e7faee
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,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 MOUSE_IN_EPNUM 3
# define SHARED_IN_EPNUM 3
Expand All @@ -242,6 +238,12 @@ static void send_nkro(report_nkro_t *report) {
# define SHARED_IN_EPNUM 1
#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
send_report(MOUSE_IN_EPNUM, report, sizeof(report_mouse_t));
Expand Down Expand Up @@ -433,6 +435,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

0 comments on commit 0e7faee

Please sign in to comment.