Fall back to OBS-only key press if global key press can't be simulated

This commit is contained in:
WarmUpTill
2022-12-21 21:13:43 +01:00
committed by WarmUpTill
parent 0027ae9bb8
commit 601b035285
2 changed files with 6 additions and 4 deletions

View File

@@ -484,7 +484,7 @@ AdvSceneSwitcher.action.hotkey.rightAlt="Right Alt"
AdvSceneSwitcher.action.hotkey.leftMeta="Left Meta"
AdvSceneSwitcher.action.hotkey.rightMeta="Right Meta"
AdvSceneSwitcher.action.hotkey.onlyOBS="Send keypress only to OBS"
AdvSceneSwitcher.action.hotkey.disabled="Cannot simulate key presses - functionality disabled!"
AdvSceneSwitcher.action.hotkey.disabled="Cannot simulate global key presses - functionality limited to sending key press to OBS!"
AdvSceneSwitcher.action.hotkey.entry="Press {{keys}} for {{duration}} milliseconds"
AdvSceneSwitcher.action.sceneOrder="Scene item order"
AdvSceneSwitcher.action.sceneOrder.type.moveUp="Move up"

View File

@@ -225,7 +225,7 @@ bool MacroActionHotkey::PerformAction()
if (!keys.empty()) {
int dur = _duration;
if (_onlySendToObs) {
if (_onlySendToObs || !canSimulateKeyPresses) {
std::thread t([keys, dur]() { InjectKeys(keys, dur); });
t.detach();
} else {
@@ -463,9 +463,10 @@ MacroActionHotkeyEdit::MacroActionHotkeyEdit(
mainLayout->addLayout(line2Layout);
mainLayout->addWidget(_onlySendToOBS);
mainLayout->addWidget(_noKeyPressSimulationWarning);
setLayout(mainLayout);
_onlySendToOBS->setEnabled(canSimulateKeyPresses);
_entryData = entryData;
UpdateEntryData();
_loading = false;
@@ -493,7 +494,8 @@ void MacroActionHotkeyEdit::UpdateEntryData()
_leftMeta->setChecked(_entryData->_leftMeta);
_rightMeta->setChecked(_entryData->_rightMeta);
_duration->setValue(_entryData->_duration);
_onlySendToOBS->setChecked(_entryData->_onlySendToObs);
_onlySendToOBS->setChecked(_entryData->_onlySendToObs ||
!canSimulateKeyPresses);
SetWarningVisibility();
}