diff options
author | Devaev Maxim <[email protected]> | 2021-04-23 00:11:53 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-04-23 00:11:53 +0300 |
commit | 19039cd1893e8309acf76c7d703f092d9024c62d (patch) | |
tree | 4e53caa23d118c44d7111733e176c1279266d5a5 | |
parent | 71427c8c04b9fce7a3d5cd58f43504844792c359 (diff) |
improved mac boot keys handling
-rw-r--r-- | hid/src/usb/hid.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/hid/src/usb/hid.h b/hid/src/usb/hid.h index 92519329..e347a368 100644 --- a/hid/src/usb/hid.h +++ b/hid/src/usb/hid.h @@ -76,11 +76,15 @@ class UsbKeyboard { void periodic() { # ifdef HID_USB_CHECK_ENDPOINT - if (is_micros_timed_out(_last, 10000)) { - if (!_sent) { + static unsigned long prev_ts = 0; + if (is_micros_timed_out(prev_ts, 10000)) { + static bool prev_online = true; + bool online = !getOfflineAs(1); + if (!_sent || (online && !prev_online)) { _sendCurrent(); } - _last = micros(); + prev_online = online; + prev_ts = micros(); } # endif } @@ -112,7 +116,6 @@ class UsbKeyboard { private: BootKeyboard_ _kbd; bool _sent = true; - unsigned long _last = 0; void _sendCurrent() { # ifdef HID_USB_CHECK_ENDPOINT |