- kbd1.SetReport(0, 0, 2, 0, 1, &usb_led);
- kbd2.SetReport(0, 0, 2, 0, 1, &usb_led);
- kbd3.SetReport(0, 0, 2, 0, 1, &usb_led);
- kbd4.SetReport(0, 0, 2, 0, 1, &usb_led);
+ if (kbd1.isReady()) kbd1.SetReport(0, 0, 2, 0, 1, &usb_led);
+ if (kbd2.isReady()) kbd2.SetReport(0, 0, 2, 0, 1, &usb_led);
+ if (kbd3.isReady()) kbd3.SetReport(0, 0, 2, 0, 1, &usb_led);
+ if (kbd4.isReady()) kbd4.SetReport(0, 0, 2, 0, 1, &usb_led);
+}
+
+// We need to keep doing UHS2 USB::Task() to initialize keyboard
+// even before USB is not configured.
+void hook_usb_startup_wait_loop(void)
+{
+ matrix_scan();
+}
+
+// We need to keep doing UHS2 USB::Task() to initialize keyboard
+// even during USB bus is suspended and remote wakeup is not enabled yet on LUFA side.
+// This situation can happen just after pluging converter into USB port.
+void hook_usb_suspend_loop(void)
+{
+#ifndef TMK_LUFA_DEBUG_UART
+ // This corrupts debug print when suspend
+ suspend_power_down();
+#endif
+ if (USB_Device_RemoteWakeupEnabled) {
+ if (suspend_wakeup_condition()) {
+ USB_Device_SendRemoteWakeup();
+ }
+ } else {
+ matrix_scan();
+ }