|
|
@ -26,15 +26,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult, EventHandlerResult::OK
|
|
|
|
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult, EventHandlerResult::OK
|
|
|
|
|
|
|
|
|
|
|
|
// This is a terrible hack until Arduino#6964 gets implemented.
|
|
|
|
|
|
|
|
// It makes the `_usbSuspendState` symbol available to us.
|
|
|
|
|
|
|
|
extern uint8_t _usbSuspendState;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace plugin {
|
|
|
|
namespace plugin {
|
|
|
|
|
|
|
|
|
|
|
|
bool HostPowerManagement::was_suspended_ = false;
|
|
|
|
bool HostPowerManagement::was_suspended_ = false;
|
|
|
|
bool HostPowerManagement::initial_suspend_ = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool HostPowerManagement::isSuspended() {
|
|
|
|
bool HostPowerManagement::isSuspended() {
|
|
|
|
#if defined(__AVR__)
|
|
|
|
#if defined(__AVR__)
|
|
|
@ -48,17 +43,13 @@ bool HostPowerManagement::isSuspended() {
|
|
|
|
|
|
|
|
|
|
|
|
EventHandlerResult HostPowerManagement::beforeEachCycle() {
|
|
|
|
EventHandlerResult HostPowerManagement::beforeEachCycle() {
|
|
|
|
if (isSuspended()) {
|
|
|
|
if (isSuspended()) {
|
|
|
|
if (!initial_suspend_) {
|
|
|
|
|
|
|
|
if (!was_suspended_) {
|
|
|
|
if (!was_suspended_) {
|
|
|
|
was_suspended_ = true;
|
|
|
|
was_suspended_ = true;
|
|
|
|
hostPowerManagementEventHandler(Suspend);
|
|
|
|
hostPowerManagementEventHandler(Suspend);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
hostPowerManagementEventHandler(Sleep);
|
|
|
|
hostPowerManagementEventHandler(Sleep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (initial_suspend_)
|
|
|
|
|
|
|
|
initial_suspend_ = false;
|
|
|
|
|
|
|
|
if (was_suspended_) {
|
|
|
|
if (was_suspended_) {
|
|
|
|
was_suspended_ = false;
|
|
|
|
was_suspended_ = false;
|
|
|
|
hostPowerManagementEventHandler(Resume);
|
|
|
|
hostPowerManagementEventHandler(Resume);
|
|
|
|