|
9 | 9 |
|
10 | 10 | #include "core/core.h" |
11 | 11 |
|
| 12 | +#include "common/assert.h" |
12 | 13 | #include "common/bitutils.h" |
13 | 14 |
|
14 | 15 | #include "fmt/format.h" |
|
20 | 21 |
|
21 | 22 | #include "moc_inputbindingdialog.cpp" |
22 | 23 |
|
| 24 | +InputBindingDialog* InputBindingDialog::s_current_hook_dialog = nullptr; |
| 25 | + |
23 | 26 | InputBindingDialog::InputBindingDialog(SettingsInterface* sif, InputBindingInfo::Type bind_type, |
24 | 27 | std::string section_name, std::string key_name, |
25 | 28 | std::vector<std::string> bindings, QWidget* parent) |
@@ -403,13 +406,21 @@ void InputBindingDialog::onResetSensitivityClicked() |
403 | 406 |
|
404 | 407 | void InputBindingDialog::hookInputManager() |
405 | 408 | { |
406 | | - InputManager::SetHook([this](InputBindingKey key, float value) { |
407 | | - QMetaObject::invokeMethod(this, &InputBindingDialog::inputManagerHookCallback, Qt::QueuedConnection, key, value); |
408 | | - return InputInterceptHook::CallbackResult::StopProcessingEvent; |
| 409 | + DebugAssert(!s_current_hook_dialog); |
| 410 | + s_current_hook_dialog = this; |
| 411 | + Host::RunOnCoreThread([]() { |
| 412 | + InputManager::SetHook([](InputBindingKey key, float value) { |
| 413 | + Host::RunOnUIThread([key, value]() { |
| 414 | + if (s_current_hook_dialog) |
| 415 | + s_current_hook_dialog->inputManagerHookCallback(key, value); |
| 416 | + }); |
| 417 | + return InputInterceptHook::CallbackResult::StopProcessingEvent; |
| 418 | + }); |
409 | 419 | }); |
410 | 420 | } |
411 | 421 |
|
412 | 422 | void InputBindingDialog::unhookInputManager() |
413 | 423 | { |
414 | | - InputManager::RemoveHook(); |
| 424 | + s_current_hook_dialog = nullptr; |
| 425 | + Host::RunOnCoreThread(&InputManager::RemoveHook); |
415 | 426 | } |
0 commit comments