Use standard timeout checker for MagicCombo

Also, change timestamp from four bytes to two.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent dfdb1c2e25
commit 31c80b5811

@ -21,7 +21,7 @@ namespace kaleidoscope {
namespace plugin { namespace plugin {
uint16_t MagicCombo::min_interval = 500; uint16_t MagicCombo::min_interval = 500;
uint32_t MagicCombo::end_time_; uint16_t MagicCombo::start_time_ = 0;
EventHandlerResult MagicCombo::beforeReportingState() { EventHandlerResult MagicCombo::beforeReportingState() {
for (byte i = 0; i < magiccombo::combos_length; i++) { for (byte i = 0; i < magiccombo::combos_length; i++) {
@ -42,11 +42,11 @@ EventHandlerResult MagicCombo::beforeReportingState() {
if (j != KeyboardHardware.pressedKeyswitchCount()) if (j != KeyboardHardware.pressedKeyswitchCount())
match = false; match = false;
if (match && (millis() >= end_time_)) { if (match && Kaleidoscope.hasTimeExpired(start_time_, min_interval)) {
ComboAction action = (ComboAction) pgm_read_ptr(&(magiccombo::combos[i].action)); ComboAction action = (ComboAction) pgm_read_ptr(&(magiccombo::combos[i].action));
(*action)(i); (*action)(i);
end_time_ = millis() + min_interval; start_time_ = Kaleidoscope.millisAtCycleStart();
} }
} }

@ -51,7 +51,7 @@ class MagicCombo : public kaleidoscope::Plugin {
EventHandlerResult beforeReportingState(); EventHandlerResult beforeReportingState();
private: private:
static uint32_t end_time_; static uint16_t start_time_;
}; };
namespace magiccombo { namespace magiccombo {

Loading…
Cancel
Save