]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - tmk_core/common/host.c
Configure Vagrant to use qmk_base_container (#6194)
[qmk_firmware.git] / tmk_core / common / host.c
index e12b6221656f53173e13e3a4f2a14465b863470b..f5d0416996b10b23959f8dcc862011a95d6ec31c 100644 (file)
@@ -22,6 +22,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "util.h"
 #include "debug.h"
 
+#ifdef NKRO_ENABLE
+  #include "keycode_config.h"
+  extern keymap_config_t keymap_config;
+#endif
+
 static host_driver_t *driver;
 static uint16_t last_system_report = 0;
 static uint16_t last_consumer_report = 0;
@@ -46,6 +51,20 @@ uint8_t host_keyboard_leds(void)
 void host_keyboard_send(report_keyboard_t *report)
 {
     if (!driver) return;
+#if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP)
+    if (keyboard_protocol && keymap_config.nkro) {
+        /* The callers of this function assume that report->mods is where mods go in.
+         * But report->nkro.mods can be at a different offset if core keyboard does not have a report ID.
+         */
+        report->nkro.mods = report->mods;
+        report->nkro.report_id = REPORT_ID_NKRO;
+    } else
+#endif
+    {
+#ifdef KEYBOARD_SHARED_EP
+        report->report_id = REPORT_ID_KEYBOARD;
+#endif
+    }
     (*driver->send_keyboard)(report);
 
     if (debug_keyboard) {
@@ -60,6 +79,9 @@ void host_keyboard_send(report_keyboard_t *report)
 void host_mouse_send(report_mouse_t *report)
 {
     if (!driver) return;
+#ifdef MOUSE_SHARED_EP
+    report->report_id = REPORT_ID_MOUSE;
+#endif
     (*driver->send_mouse)(report);
 }