diff --git a/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.cpp b/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.cpp index d28f5d85..8111955f 100644 --- a/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.cpp +++ b/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.cpp @@ -20,6 +20,10 @@ #include // IWYU pragma: keep #include // for uint8_t +#ifdef ARDUINO_ARCH_GD32 +#include "USBCore.h" +#endif + #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult, EventHandlerResult::OK // This is a terrible hack until Arduino#6964 gets implemented. @@ -54,6 +58,22 @@ EventHandlerResult HostPowerManagement::beforeEachCycle() { } #endif +#ifdef ARDUINO_ARCH_GD32 + if (USBCore().isSuspended()) { + if (!was_suspended_) { + was_suspended_ = true; + hostPowerManagementEventHandler(Suspend); + } else { + hostPowerManagementEventHandler(Sleep); + } + } else { + if (was_suspended_) { + was_suspended_ = false; + hostPowerManagementEventHandler(Resume); + } + } +#endif + return EventHandlerResult::OK; }