mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 15:19:42 -06:00
Fixed the crash that would occur when the Refresh button was pressed in the controllers config.
- Simplified the locking mechanism when controllers were updated - Reloaded the config of the controls instead of re-initialising the control plugins - Fixed controls being unresponsive after the Refresh button was pressed - Disables the hotkeys while the controller config is open
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "Common/SysConf.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
@ -207,12 +208,13 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateWiimoteConfigSizer()
|
||||
wiimote_configure_bt[i]->Bind(wxEVT_BUTTON, &ControllerConfigDiag::ConfigEmulatedWiimote, this);
|
||||
|
||||
// Disable controller type selection for certain circumstances.
|
||||
if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive())
|
||||
bool wii_game_started = SConfig::GetInstance().m_LocalCoreStartupParameter.bWii || Core::GetState() == Core::CORE_UNINITIALIZED;
|
||||
if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive() || !wii_game_started)
|
||||
wiimote_source_ch[i]->Disable();
|
||||
|
||||
m_orig_wiimote_sources[i] = g_wiimote_sources[i];
|
||||
wiimote_source_ch[i]->Select(m_orig_wiimote_sources[i]);
|
||||
if (m_orig_wiimote_sources[i] != WIIMOTE_SRC_EMU && m_orig_wiimote_sources[i] != WIIMOTE_SRC_HYBRID)
|
||||
if (!wii_game_started || (m_orig_wiimote_sources[i] != WIIMOTE_SRC_EMU && m_orig_wiimote_sources[i] != WIIMOTE_SRC_HYBRID))
|
||||
wiimote_configure_bt[i]->Disable();
|
||||
}
|
||||
|
||||
@ -390,28 +392,13 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateGeneralWiimoteSettingsSizer()
|
||||
void ControllerConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& ev)
|
||||
{
|
||||
InputConfig* const wiimote_plugin = Wiimote::GetConfig();
|
||||
bool was_init = false;
|
||||
if (g_controller_interface.IsInit()) // check if game is running
|
||||
{
|
||||
was_init = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window win = X11Utils::XWindowFromHandle(GetHandle());
|
||||
Wiimote::Initialize(reinterpret_cast<void*>(win));
|
||||
#else
|
||||
Wiimote::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||
#endif
|
||||
}
|
||||
|
||||
HotkeyManagerEmu::Enable(false);
|
||||
|
||||
InputConfigDialog m_ConfigFrame(this, *wiimote_plugin, _("Dolphin Emulated Wiimote Configuration"), m_wiimote_index_from_conf_bt_id[ev.GetId()]);
|
||||
m_ConfigFrame.ShowModal();
|
||||
|
||||
if (!was_init) // if game isn't running
|
||||
{
|
||||
Wiimote::Shutdown();
|
||||
}
|
||||
HotkeyManagerEmu::Enable(true);
|
||||
}
|
||||
|
||||
void ControllerConfigDiag::RefreshRealWiimotes(wxCommandEvent&)
|
||||
@ -535,24 +522,7 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
|
||||
InputConfig* const key_plugin = Keyboard::GetConfig();
|
||||
const int port_num = m_gc_port_config_ids[event.GetId()];
|
||||
|
||||
bool was_init = false;
|
||||
|
||||
// check if game is running
|
||||
if (g_controller_interface.IsInit())
|
||||
{
|
||||
was_init = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window win = X11Utils::XWindowFromHandle(GetHandle());
|
||||
Pad::Initialize(reinterpret_cast<void*>(win));
|
||||
Keyboard::Initialize(reinterpret_cast<void*>(win));
|
||||
#else
|
||||
Pad::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||
Keyboard::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||
#endif
|
||||
}
|
||||
HotkeyManagerEmu::Enable(false);
|
||||
|
||||
if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD)
|
||||
{
|
||||
@ -565,10 +535,5 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
|
||||
m_ConfigFrame.ShowModal();
|
||||
}
|
||||
|
||||
// if game isn't running
|
||||
if (!was_init)
|
||||
{
|
||||
Keyboard::Shutdown();
|
||||
Pad::Shutdown();
|
||||
}
|
||||
HotkeyManagerEmu::Enable(true);
|
||||
}
|
||||
|
@ -1263,7 +1263,7 @@ const CGameListCtrl *CFrame::GetGameListCtrl() const
|
||||
|
||||
void CFrame::PollHotkeys(wxTimerEvent& event)
|
||||
{
|
||||
if (!HotkeyManagerEmu::IsReady())
|
||||
if (!HotkeyManagerEmu::IsEnabled())
|
||||
return;
|
||||
|
||||
if (Core::GetState() == Core::CORE_UNINITIALIZED || Core::GetState() == Core::CORE_PAUSE)
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "Core/State.h"
|
||||
#include "Core/HW/CPU.h"
|
||||
#include "Core/HW/DVDInterface.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/ProcessorInterface.h"
|
||||
#include "Core/HW/SI_Device.h"
|
||||
@ -1366,27 +1367,31 @@ void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED (event))
|
||||
InputConfig* const hotkey_plugin = HotkeyManagerEmu::GetConfig();
|
||||
|
||||
// check if game is running
|
||||
if (g_controller_interface.IsInit())
|
||||
bool game_running = false;
|
||||
if (Core::GetState() == Core::CORE_RUN)
|
||||
{
|
||||
was_init = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window win = X11Utils::XWindowFromHandle(GetHandle());
|
||||
HotkeyManagerEmu::Initialize(reinterpret_cast<void*>(win));
|
||||
#else
|
||||
HotkeyManagerEmu::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||
#endif
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
game_running = true;
|
||||
}
|
||||
|
||||
HotkeyManagerEmu::Enable(false);
|
||||
|
||||
InputConfigDialog m_ConfigFrame(this, *hotkey_plugin, _("Dolphin Hotkeys"));
|
||||
m_ConfigFrame.ShowModal();
|
||||
|
||||
// Update references in case controllers were refreshed
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
Wiimote::LoadConfig();
|
||||
Keyboard::LoadConfig();
|
||||
Pad::LoadConfig();
|
||||
HotkeyManagerEmu::LoadConfig();
|
||||
|
||||
HotkeyManagerEmu::Enable(true);
|
||||
|
||||
// if game isn't running
|
||||
if (!was_init)
|
||||
if (game_running)
|
||||
{
|
||||
HotkeyManagerEmu::Shutdown();
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
}
|
||||
|
||||
// Update the GUI in case menu accelerators were changed
|
||||
|
@ -44,6 +44,10 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "DolphinWX/InputConfigDiag.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
@ -740,6 +744,8 @@ void InputConfigDialog::UpdateDeviceComboBox()
|
||||
|
||||
void GamepadPage::RefreshDevices(wxCommandEvent&)
|
||||
{
|
||||
bool was_unpaused = Core::PauseAndLock(true);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||
|
||||
// refresh devices
|
||||
@ -750,6 +756,14 @@ void GamepadPage::RefreshDevices(wxCommandEvent&)
|
||||
|
||||
// update device cbox
|
||||
m_config_dialog->UpdateDeviceComboBox();
|
||||
|
||||
//if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
Wiimote::LoadConfig();
|
||||
Keyboard::LoadConfig();
|
||||
Pad::LoadConfig();
|
||||
HotkeyManagerEmu::LoadConfig();
|
||||
|
||||
Core::PauseAndLock(false, was_unpaused);
|
||||
}
|
||||
|
||||
ControlGroupBox::~ControlGroupBox()
|
||||
|
Reference in New Issue
Block a user