diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 03a95e82e..8086cf59d 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -18,6 +18,7 @@ #include #include +#include "base/mutex.h" #include "base/colorutil.h" #include "base/logging.h" #include "i18n/i18n.h" @@ -437,6 +438,9 @@ bool AnalogTestScreen::key(const KeyInput &key) { screenManager()->finishDialog(this, DR_BACK); return true; } + + lock_guard guard(eventLock_); + char buf[512]; snprintf(buf, sizeof(buf), "Keycode: %d Device ID: %d [%s%s%s%s]", key.keyCode, key.deviceId, (key.flags & KEY_IS_REPEAT) ? "REP" : "", @@ -457,6 +461,8 @@ bool AnalogTestScreen::axis(const AxisInput &axis) { // a controller would be confusing for the user. char buf[512]; + lock_guard guard(eventLock_); + if (IgnoreAxisForMapping(axis.axisId)) return false; @@ -476,6 +482,8 @@ bool AnalogTestScreen::axis(const AxisInput &axis) { void AnalogTestScreen::CreateViews() { using namespace UI; + lock_guard guard(eventLock_); + I18NCategory *di = GetI18NCategory("Dialog"); root_ = new LinearLayout(ORIENT_VERTICAL); diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index b97183990..69fd34e73 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -19,6 +19,7 @@ #include #include "base/functional.h" +#include "base/mutex.h" #include "ui/view.h" #include "ui/ui_screen.h" @@ -80,4 +81,6 @@ protected: UI::TextView *lastKeyEvent_; UI::TextView *lastLastKeyEvent_; + + recursive_mutex eventLock_; };