From 3bc04470f2e8d72aabdc4c29c7b6921ad6bb33eb Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 10 Dec 2023 10:09:12 -0600 Subject: [PATCH] try to fix up simulator-tests --- .../virtual/DefaultHIDReportConsumer.cpp | 50 +++++++++---------- testing/KeyboardReport.cpp | 2 +- testing/KeyboardReport.h | 8 +-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/kaleidoscope/device/virtual/DefaultHIDReportConsumer.cpp b/src/kaleidoscope/device/virtual/DefaultHIDReportConsumer.cpp index 83d4cd9cfd..d4ec788099 100644 --- a/src/kaleidoscope/device/virtual/DefaultHIDReportConsumer.cpp +++ b/src/kaleidoscope/device/virtual/DefaultHIDReportConsumer.cpp @@ -19,8 +19,8 @@ #include "kaleidoscope/device/virtual/DefaultHIDReportConsumer.h" // From KeyboardioHID: -#include // for HID_REPORTID_NKRO_KEYBOARD -#include // for HID_KeyboardReport_Data_t, (anonymous u... +#include // for HID_REPORTID_NKRO_KEYBOARD +#include // for HID_BootKeyboardReport_Data_t, (anonymous u... // From system: #include // for uint8_t // From Arduino core: @@ -52,12 +52,12 @@ using namespace logging; // NOLINT(build/namespaces) void DefaultHIDReportConsumer::processHIDReport( uint8_t id, const void *data, int len, int result) { - if (id != HID_REPORTID_NKRO_KEYBOARD) { + if (id != HID_REPORTID_KEYBOARD) { log_info("***Ignoring hid report with id = %d\n", id); return; } - const HID_KeyboardReport_Data_t &report_data = *static_cast(data); + const HID_BootKeyboardReport_Data_t &report_data = *static_cast(data); std::stringstream keypresses; bool anything = false; @@ -65,8 +65,8 @@ void DefaultHIDReportConsumer::processHIDReport( if (report_data.modifiers) { anything = true; } else { - for (int i = 0; i < KEY_BYTES; i++) { - if (report_data.keys[i]) { + for (int i = 0; i < NKRO_KEY_BYTES; i++) { + if (report_data.nkro_keys[i]) { anything = true; break; } @@ -80,53 +80,53 @@ void DefaultHIDReportConsumer::processHIDReport( FOREACHBIT(report_data.modifiers, keypresses, "lctrl ", "lshift ", "lalt ", "lgui ", "rctrl ", "rshift ", "ralt ", "rgui ") - FOREACHBIT(report_data.keys[0], keypresses, + FOREACHBIT(report_data.nkro_keys[0], keypresses, "NO_EVENT ", "ERROR_ROLLOVER ", "POST_FAIL ", "ERROR_UNDEFINED ", "a ", "b ", "c ", "d ") - FOREACHBIT(report_data.keys[1], keypresses, + FOREACHBIT(report_data.nkro_keys[1], keypresses, "e ", "f ", "g ", "h ", "i ", "j ", "k ", "l ") - FOREACHBIT(report_data.keys[2], keypresses, + FOREACHBIT(report_data.nkro_keys[2], keypresses, "m ", "n ", "o ", "p ", "q ", "r ", "s ", "t ") - FOREACHBIT(report_data.keys[3], keypresses, + FOREACHBIT(report_data.nkro_keys[3], keypresses, "u ", "v ", "w ", "x ", "y ", "z ", "1/! ", "2/@ ") - FOREACHBIT(report_data.keys[4], keypresses, + FOREACHBIT(report_data.nkro_keys[4], keypresses, "3/# ", "4/$ ", "5/% ", "6/^ ", "7/& ", "8/* ", "9/( ", "0/) ") - FOREACHBIT(report_data.keys[5], keypresses, + FOREACHBIT(report_data.nkro_keys[5], keypresses, "enter ", "esc ", "del/bksp ", "tab ", "space ", "-/_ ", "=/+ ", "[/{ ") - FOREACHBIT(report_data.keys[6], keypresses, + FOREACHBIT(report_data.nkro_keys[6], keypresses, "]/} ", "\\/| ", "#/~ ", ";/: ", "'/\" ", "`/~ ", ",/< ", "./> ") - FOREACHBIT(report_data.keys[7], keypresses, + FOREACHBIT(report_data.nkro_keys[7], keypresses, "//? ", "capslock ", "F1 ", "F2 ", "F3 ", "F4 ", "F5 ", "F6 ") - FOREACHBIT(report_data.keys[8], keypresses, + FOREACHBIT(report_data.nkro_keys[8], keypresses, "F7 ", "F8 ", "F9 ", "F10 ", "F11 ", "F12 ", "prtscr ", "scrolllock ") - FOREACHBIT(report_data.keys[9], keypresses, + FOREACHBIT(report_data.nkro_keys[9], keypresses, "pause ", "ins ", "home ", "pgup ", "del ", "end ", "pgdn ", "r_arrow ") - FOREACHBIT(report_data.keys[10], keypresses, + FOREACHBIT(report_data.nkro_keys[10], keypresses, "l_arrow ", "d_arrow ", "u_arrow ", "numlock ", "num/ ", "num* ", "num- ", "num+ ") - FOREACHBIT(report_data.keys[11], keypresses, + FOREACHBIT(report_data.nkro_keys[11], keypresses, "numenter ", "num1 ", "num2 ", "num3 ", "num4 ", "num5 ", "num6 ", "num7 ") - FOREACHBIT(report_data.keys[12], keypresses, + FOREACHBIT(report_data.nkro_keys[12], keypresses, "num8 ", "num9 ", "num0 ", "num. ", "\\/| ", "app ", "power ", "num= ") - FOREACHBIT(report_data.keys[13], keypresses, + FOREACHBIT(report_data.nkro_keys[13], keypresses, "F13 ", "F14 ", "F15 ", "F16 ", "F17 ", "F18 ", "F19 ", "F20 ") - FOREACHBIT(report_data.keys[14], keypresses, + FOREACHBIT(report_data.nkro_keys[14], keypresses, "F21 ", "F22 ", "F23 ", "F24 ", "exec ", "help ", "menu ", "sel ") - FOREACHBIT(report_data.keys[15], keypresses, + FOREACHBIT(report_data.nkro_keys[15], keypresses, "stop ", "again ", "undo ", "cut ", "copy ", "paste ", "find ", "mute ") - FOREACHBIT(report_data.keys[16], keypresses, + FOREACHBIT(report_data.nkro_keys[16], keypresses, "volup ", "voldn ", "capslock_l ", "numlock_l ", "scrolllock_l ", "num, ", "num= ", "(other) ") // clang-format on - for (int i = 17; i < KEY_BYTES; i++) { + for (int i = 17; i < NKRO_KEY_BYTES; i++) { // A little imprecise, in two ways: // (1) obviously, "(other)" refers to many distinct keys // (2) this might undercount the number of "other" keys pressed // Therefore, if any keys are frequently used, they should be handled above and not via "other" - if (report_data.keys[i]) keypresses << "(other) "; + if (report_data.nkro_keys[i]) keypresses << "(other) "; } } diff --git a/testing/KeyboardReport.cpp b/testing/KeyboardReport.cpp index 429e0f2682..9ebbfc1ced 100644 --- a/testing/KeyboardReport.cpp +++ b/testing/KeyboardReport.cpp @@ -64,7 +64,7 @@ std::vector KeyboardReport::ActiveNonModifierKeycodes() const { for (uint8_t i = 0; i < HID_LAST_KEY; ++i) { uint8_t bit = 1 << (uint8_t(i) % 8); - uint8_t keycode = report_data_.keys[i / 8] & bit; + uint8_t keycode = report_data_.nkro_keys[i / 8] & bit; if (keycode) active_keycodes.push_back(i); } diff --git a/testing/KeyboardReport.h b/testing/KeyboardReport.h index 47d06e7730..0e26d660a9 100644 --- a/testing/KeyboardReport.h +++ b/testing/KeyboardReport.h @@ -19,17 +19,17 @@ #include // for uint8_t, uint32_t #include // for vector -#include "HID-Settings.h" // for HID_REPORTID_NKRO_KEYBOARD -#include "MultiReport/Keyboard.h" // for HID_KeyboardReport_Data_t +#include "HID-Settings.h" // for HID_REPORTID_NKRO_KEYBOARD +#include "BootKeyboard/BootKeyboard.h" // for HID_KeyboardReport_Data_t namespace kaleidoscope { namespace testing { class KeyboardReport { public: - typedef HID_KeyboardReport_Data_t ReportData; + typedef HID_BootKeyboardReport_Data_t ReportData; - static constexpr uint8_t kHidReportType = HID_REPORTID_NKRO_KEYBOARD; + static constexpr uint8_t kHidReportType = HID_REPORTID_KEYBOARD; KeyboardReport(const void *data);