Enable detection of user holding down hotkey

Previously only the key down event would trigger the condition
This commit is contained in:
WarmUpTill 2022-12-03 05:48:50 +01:00 committed by WarmUpTill
parent f3e5fb59f3
commit c07ef3c699
2 changed files with 8 additions and 15 deletions

View File

@ -12,15 +12,12 @@ bool MacroConditionHotkey::_registered = MacroConditionFactory::Register(
static void hotkeyCB(void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed)
{
if (pressed) {
auto c = static_cast<MacroConditionHotkey *>(data);
auto macro = c->GetMacro();
if (!macro) {
c->SetPressed();
}
if (macro && !macro->Paused()) {
c->SetPressed();
}
auto hotkeyCondition = static_cast<MacroConditionHotkey *>(data);
auto macro = hotkeyCondition->GetMacro();
if (macro) {
hotkeyCondition->SetPressed(pressed && !macro->Paused());
} else {
hotkeyCondition->SetPressed(pressed);
}
}
@ -49,11 +46,7 @@ MacroConditionHotkey::~MacroConditionHotkey()
bool MacroConditionHotkey::CheckCondition()
{
if (_pressed) {
_pressed = false;
return true;
}
return false;
return _pressed;
}
bool MacroConditionHotkey::Save(obs_data_t *obj)

View File

@ -15,7 +15,7 @@ public:
{
return std::make_shared<MacroConditionHotkey>(m);
}
void SetPressed() { _pressed = true; }
void SetPressed(bool value) { _pressed = value; }
std::string _name;
obs_hotkey_id _hotkeyID = OBS_INVALID_HOTKEY_ID;