From 5988fce59b7f450a225781ba4f4dbbe0d7210d24 Mon Sep 17 00:00:00 2001 From: Eric Tang Date: Tue, 26 Jun 2018 12:36:58 -0700 Subject: [PATCH] Implement the delay macro action --- right/src/macros.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/right/src/macros.c b/right/src/macros.c index 24590d2..75bc73b 100644 --- a/right/src/macros.c +++ b/right/src/macros.c @@ -1,6 +1,7 @@ #include "macros.h" #include "config_parser/parse_macro.h" #include "config_parser/config_globals.h" +#include "timer.h" macro_reference_t AllMacros[MAX_MACRO_NUM]; uint8_t AllMacrosCount; @@ -242,11 +243,27 @@ bool processKeyMacroAction(void) return false; } +bool processDelayMacroAction(void) +{ + static bool inDelay; + static uint32_t delayStart; + + if (inDelay) { + if (Timer_GetElapsedTime(&delayStart) >= currentMacroAction.delay.delay) { + inDelay = false; + } + } else { + Timer_SetCurrentTime(&delayStart); + inDelay = true; + } + return inDelay; +} + bool processCurrentMacroAction(void) { switch (currentMacroAction.type) { case MacroActionType_Delay: - return false; + return processDelayMacroAction(); case MacroActionType_Key: return processKeyMacroAction(); case MacroActionType_MouseButton: