From 2c6eaf9c764df310309a39f370e7919a3df974e2 Mon Sep 17 00:00:00 2001 From: skidau Date: Thu, 12 Mar 2015 23:33:30 +1100 Subject: [PATCH 1/2] Cleaned up the controls lock that is not needed with 780eef68f6ec7deee1a11f8bc1386f70133b6cc0 --- Source/Core/Core/HW/GCKeyboard.cpp | 2 -- Source/Core/Core/HW/GCPad.cpp | 9 --------- Source/Core/Core/HW/Wiimote.cpp | 3 --- Source/Core/DolphinWX/InputConfigDiag.cpp | 16 ---------------- Source/Core/InputCommon/InputConfig.h | 2 -- 5 files changed, 32 deletions(-) diff --git a/Source/Core/Core/HW/GCKeyboard.cpp b/Source/Core/Core/HW/GCKeyboard.cpp index d6ac24e637..154b7cd308 100644 --- a/Source/Core/Core/HW/GCKeyboard.cpp +++ b/Source/Core/Core/HW/GCKeyboard.cpp @@ -55,8 +55,6 @@ void GetStatus(u8 _port, KeyboardStatus* _pKeyboardStatus) memset(_pKeyboardStatus, 0, sizeof(*_pKeyboardStatus)); _pKeyboardStatus->err = PAD_ERR_NONE; - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - // get input ((GCKeyboard*)s_config.controllers[_port])->GetInput(_pKeyboardStatus); } diff --git a/Source/Core/Core/HW/GCPad.cpp b/Source/Core/Core/HW/GCPad.cpp index b57a6d02f2..68ad6b393d 100644 --- a/Source/Core/Core/HW/GCPad.cpp +++ b/Source/Core/Core/HW/GCPad.cpp @@ -57,26 +57,17 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus) memset(_pPADStatus, 0, sizeof(*_pPADStatus)); _pPADStatus->err = PAD_ERR_NONE; - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - - // get input ((GCPad*)s_config.controllers[_numPAD])->GetInput(_pPADStatus); } void Rumble(u8 _numPAD, const ControlState strength) { - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - ((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(strength); } bool GetMicButton(u8 pad) { - - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - - return ((GCPad*)s_config.controllers[pad])->GetMicButton(); } diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp index 13797a1180..62c88b0ec1 100644 --- a/Source/Core/Core/HW/Wiimote.cpp +++ b/Source/Core/Core/HW/Wiimote.cpp @@ -118,9 +118,6 @@ void Update(int _number) { //PanicAlert( "Wiimote_Update" ); - // TODO: change this to a try_to_lock, and make it give empty input on failure - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number]) ((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update(); else diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp index 4c3d70c99a..591287959d 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/InputConfigDiag.cpp @@ -300,7 +300,6 @@ void GamepadPage::ClearAll(wxCommandEvent&) // no point in using the real ControllerInterface i guess ControllerInterface face; - std::lock_guard lk(m_config.controls_lock); controller->UpdateReferences(face); UpdateGUI(); @@ -310,7 +309,6 @@ void GamepadPage::LoadDefaults(wxCommandEvent&) { controller->LoadDefaults(g_controller_interface); - std::lock_guard lk(m_config.controls_lock); controller->UpdateReferences(g_controller_interface); UpdateGUI(); @@ -320,7 +318,6 @@ bool ControlDialog::Validate() { control_reference->expression = WxStrToStr(textctrl->GetValue()); - std::lock_guard lk(m_config.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -339,7 +336,6 @@ void GamepadPage::SetDevice(wxCommandEvent&) controller->UpdateDefaultDevice(); // update references - std::lock_guard lk(m_config.controls_lock); controller->UpdateReferences(g_controller_interface); } @@ -358,7 +354,6 @@ void ControlDialog::ClearControl(wxCommandEvent&) { control_reference->expression.clear(); - std::lock_guard lk(m_config.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -420,7 +415,6 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&) textctrl->WriteText(expr); control_reference->expression = textctrl->GetValue(); - std::lock_guard lk(m_config.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -455,7 +449,6 @@ void ControlDialog::AppendControl(wxCommandEvent& event) textctrl->WriteText(expr); control_reference->expression = textctrl->GetValue(); - std::lock_guard lk(m_config.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -463,20 +456,17 @@ void ControlDialog::AppendControl(wxCommandEvent& event) void GamepadPage::AdjustSetting(wxCommandEvent& event) { - std::lock_guard lk(m_config.controls_lock); ((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue(); } void GamepadPage::AdjustSettingUI(wxCommandEvent& event) { m_iterate = !m_iterate; - std::lock_guard lk(m_config.controls_lock); ((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue(); } void GamepadPage::AdjustControlOption(wxCommandEvent&) { - std::lock_guard lk(m_config.controls_lock); m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT; } @@ -496,7 +486,6 @@ void GamepadPage::ClearControl(wxEvent& event) btn->control_reference->expression.clear(); btn->control_reference->range = 1.0; - std::lock_guard lk(m_config.controls_lock); controller->UpdateReferences(g_controller_interface); // update changes @@ -516,7 +505,6 @@ void ControlDialog::DetectControl(wxCommandEvent& event) // This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows wxTheApp->Yield(true); - std::lock_guard lk(m_config.controls_lock); ciface::Core::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev); // if we got input, select it in the list @@ -556,7 +544,6 @@ bool GamepadPage::DetectButton(ControlButton* button) // This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows wxTheApp->Yield(true); - std::lock_guard lk(m_config.controls_lock); ciface::Core::Device::Control* const ctrl = button->control_reference->Detect(DETECT_WAIT_TIME, dev); // if we got input, update expression and reference @@ -681,7 +668,6 @@ void GamepadPage::LoadProfile(wxCommandEvent&) IniFile inifile; inifile.Load(fname); - std::lock_guard lk(m_config.controls_lock); controller->LoadConfig(inifile.GetOrCreateSection("Profile")); controller->UpdateReferences(g_controller_interface); @@ -746,8 +732,6 @@ void GamepadPage::RefreshDevices(wxCommandEvent&) { bool was_unpaused = Core::PauseAndLock(true); - std::lock_guard lk(m_config.controls_lock); - // refresh devices g_controller_interface.Reinitialize(); diff --git a/Source/Core/InputCommon/InputConfig.h b/Source/Core/InputCommon/InputConfig.h index a234cdf167..c339cbb243 100644 --- a/Source/Core/InputCommon/InputConfig.h +++ b/Source/Core/InputCommon/InputConfig.h @@ -26,8 +26,6 @@ public: std::vector controllers; - std::recursive_mutex controls_lock; // for changing any control references - const char* const ini_name; const char* const gui_name; const char* const profile_name; From c76008b4b9eccf0c8fc04a0dada0313fc6d8c3f6 Mon Sep 17 00:00:00 2001 From: skidau Date: Thu, 12 Mar 2015 23:41:30 +1100 Subject: [PATCH 2/2] Removed the controller update lock as it is no longer needed. --- Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp | 5 ----- .../InputCommon/ControllerInterface/ControllerInterface.cpp | 2 -- .../InputCommon/ControllerInterface/ControllerInterface.h | 2 -- 3 files changed, 9 deletions(-) diff --git a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp index 3da0253581..e6beb5ef4a 100644 --- a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp +++ b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp @@ -453,11 +453,6 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event)) g_controller_interface.UpdateInput(); - // don't want game thread updating input when we are using it here - std::unique_lock lk(g_controller_interface.update_lock, std::try_to_lock); - if (!lk.owns_lock()) - return; - GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection()); for (ControlGroupBox* g : current_page->control_groups) diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 1330cb1e0a..00a9579daf 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -134,8 +134,6 @@ void ControllerInterface::Shutdown() // void ControllerInterface::UpdateInput() { - std::unique_lock lk(update_lock, std::defer_lock); - for (ciface::Core::Device* d : m_devices) d->UpdateInput(); } diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index 9ab8427ad2..e69907337f 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -122,8 +122,6 @@ public: void UpdateReference(ControlReference* control, const ciface::Core::DeviceQualifier& default_device) const; void UpdateInput(); - std::recursive_mutex update_lock; - private: bool m_is_init; void* m_hwnd;