+
+
+/* hooks */
+__attribute__((weak))
+void hook_early_init(void) {}
+
+__attribute__((weak))
+void hook_late_init(void) {}
+
+static uint8_t _led_stats = 0;
+ __attribute__((weak))
+void hook_usb_suspend_entry(void)
+{
+ // Turn LED off to save power
+ // Set 0 with putting aside status before suspend and restore
+ // it after wakeup, then LED is updated at keyboard_task() in main loop
+ _led_stats = keyboard_led_stats;
+ keyboard_led_stats = 0;
+ led_set(keyboard_led_stats);
+
+ matrix_clear();
+ clear_keyboard();
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_enable();
+#endif
+}
+
+__attribute__((weak))
+void hook_usb_suspend_loop(void)
+{
+ suspend_power_down();
+ if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
+ USB_Device_SendRemoteWakeup();
+ }
+}
+
+__attribute__((weak))
+void hook_usb_wakeup(void)
+{
+ suspend_wakeup_init();
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_disable();
+#endif
+
+ // Restore LED status
+ // BIOS/grub won't recognize/enumerate if led_set() takes long(around 40ms?)
+ // Converters fall into the case and miss wakeup event(timeout to reply?) in the end.
+ //led_set(host_keyboard_leds());
+ // Instead, restore stats and update at keyboard_task() in main loop
+ keyboard_led_stats = _led_stats;
+}