]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Fix drop key stroke
authorJun Wako <wakojun@gmail.com>
Sat, 17 Oct 2015 06:28:21 +0000 (15:28 +0900)
committerJun Wako <wakojun@gmail.com>
Sat, 17 Oct 2015 06:28:21 +0000 (15:28 +0900)
Keyboard report should be checked if its transfer finishs successfully.
Otherwise key stroke can be missing when other key event occurs
before the last report transfer is done.

Boot protocol 10ms interval probably causes this problem in case
it receives key events in a row within the period. NKRO protocol
suffers less or nothing due to its interval 1ms.

tmk_core/protocol/chibios/usb_main.c

index 619b798bbd4f6801840ce13f2bd62aae977f5bb4..0fc2f6e3eb22b11e4578bcc339d7057785f0bc0d 100644 (file)
@@ -1121,19 +1121,24 @@ void send_keyboard(report_keyboard_t *report) {
   }
   osalSysUnlock();
 
+  bool ret;
 #ifdef NKRO_ENABLE
   if(keyboard_nkro) {  /* NKRO protocol */
     usbPrepareTransmit(&USB_DRIVER, NKRO_ENDPOINT, (uint8_t *)report, sizeof(report_keyboard_t));
-    osalSysLock();
-    usbStartTransmitI(&USB_DRIVER, NKRO_ENDPOINT);
-    osalSysUnlock();
+    do {
+        osalSysLock();
+        ret = usbStartTransmitI(&USB_DRIVER, NKRO_ENDPOINT);
+        osalSysUnlock();
+    } while (ret);
   } else
 #endif /* NKRO_ENABLE */
   { /* boot protocol */
     usbPrepareTransmit(&USB_DRIVER, KBD_ENDPOINT, (uint8_t *)report, KBD_EPSIZE);
-    osalSysLock();
-    usbStartTransmitI(&USB_DRIVER, KBD_ENDPOINT);
-    osalSysUnlock();
+    do {
+        osalSysLock();
+        ret = usbStartTransmitI(&USB_DRIVER, KBD_ENDPOINT);
+        osalSysUnlock();
+    } while (ret);
   }
   keyboard_report_sent = *report;
 }