X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fprotocol%2Fchibios%2Fusb_main.c;h=106ce0879dbbfcd2dc7e316cae1d2120c735d438;hb=3fe8e1c238fc8e15dacda1b03c0c1745a7b8e8e7;hp=e2c9d9bf1415ad0fe9d946fb1d5116744938aa2f;hpb=fa52d8ba7468a8bbb5754a5be1df249af7ecfece;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index e2c9d9bf..106ce087 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -27,6 +27,25 @@ #include "sleep_led.h" #include "led.h" #endif +#include "hook.h" + +/* TMK hooks */ +__attribute__((weak)) +void hook_usb_wakeup(void) { +#ifdef SLEEP_LED_ENABLE + sleep_led_disable(); + // NOTE: converters may not accept this + led_set(host_keyboard_leds()); +#endif /* SLEEP_LED_ENABLE */ +} + + __attribute__((weak)) +void hook_usb_suspend_entry(void) { +#ifdef SLEEP_LED_ENABLE + sleep_led_enable(); +#endif /* SLEEP_LED_ENABLE */ +} + /* --------------------------------------------------------- * Global interface variables and declarations @@ -795,19 +814,13 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { case USB_EVENT_SUSPEND: //TODO: from ISR! print("[S]"); -#ifdef SLEEP_LED_ENABLE - sleep_led_enable(); -#endif /* SLEEP_LED_ENABLE */ + hook_usb_suspend_entry(); return; case USB_EVENT_WAKEUP: //TODO: from ISR! print("[W]"); suspend_wakeup_init(); -#ifdef SLEEP_LED_ENABLE - sleep_led_disable(); - // NOTE: converters may not accept this - led_set(host_keyboard_leds()); -#endif /* SLEEP_LED_ENABLE */ + hook_usb_wakeup(); return; case USB_EVENT_STALLED: