mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Fix hotkey condition evaluating to true if macro was paused
The condition check now also takes the time during which the macro was paused into consideration
This commit is contained in:
parent
0c97b3be4a
commit
aeb0e7f8ad
|
|
@ -48,7 +48,8 @@ EXPORT int64_t MillisecondsSinceMacroConditionCheck(Macro *);
|
|||
EXPORT bool MacroIsStopped(Macro *);
|
||||
EXPORT bool MacroIsPaused(Macro *);
|
||||
EXPORT bool
|
||||
MacroWasPausedSince(Macro *, const std::chrono::high_resolution_clock::time_point &);
|
||||
MacroWasPausedSince(Macro *,
|
||||
const std::chrono::high_resolution_clock::time_point &);
|
||||
|
||||
EXPORT void AddMacroHelperThread(Macro *, std::thread &&);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "macro-condition-hotkey.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
#include "macro-helpers.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
|
|
@ -22,8 +23,14 @@ MacroConditionHotkey::MacroConditionHotkey(Macro *m) : MacroCondition(m)
|
|||
|
||||
bool MacroConditionHotkey::CheckCondition()
|
||||
{
|
||||
bool ret = _hotkey->GetPressed() ||
|
||||
_hotkey->GetLastPressed() > _lastCheck;
|
||||
const bool hotkeyIsCurrentlyPressed = _hotkey->GetPressed();
|
||||
const bool hotkeyWasPressedSinceLastCheck = _hotkey->GetLastPressed() >
|
||||
_lastCheck;
|
||||
const bool macroWasPausedSinceLastCheck =
|
||||
MacroWasPausedSince(GetMacro(), _lastCheck);
|
||||
bool ret = hotkeyIsCurrentlyPressed ||
|
||||
(hotkeyWasPressedSinceLastCheck &&
|
||||
!macroWasPausedSinceLastCheck);
|
||||
_lastCheck = std::chrono::high_resolution_clock::now();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user