Initialised all controller interfaces together on CFrame construction to fix the crash that would occur if the controller config were opened before a game was started.
This commit is contained in:
parent
5e645732f2
commit
b9fb6ad3e8
|
@ -361,8 +361,13 @@ void EmuThread()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Keyboard::Initialize(s_window_handle);
|
bool init_controllers = false;
|
||||||
Pad::Initialize(s_window_handle);
|
if (!g_controller_interface.IsInit())
|
||||||
|
{
|
||||||
|
Pad::Initialize(s_window_handle);
|
||||||
|
Keyboard::Initialize(s_window_handle);
|
||||||
|
init_controllers = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Load and Init Wiimotes - only if we are booting in Wii mode
|
// Load and Init Wiimotes - only if we are booting in Wii mode
|
||||||
if (core_parameter.bWii)
|
if (core_parameter.bWii)
|
||||||
|
@ -481,8 +486,12 @@ void EmuThread()
|
||||||
|
|
||||||
Wiimote::Shutdown();
|
Wiimote::Shutdown();
|
||||||
|
|
||||||
Keyboard::Shutdown();
|
if (init_controllers)
|
||||||
Pad::Shutdown();
|
{
|
||||||
|
Keyboard::Shutdown();
|
||||||
|
Pad::Shutdown();
|
||||||
|
init_controllers = false;
|
||||||
|
}
|
||||||
|
|
||||||
g_video_backend->Shutdown();
|
g_video_backend->Shutdown();
|
||||||
AudioCommon::ShutdownSoundStream();
|
AudioCommon::ShutdownSoundStream();
|
||||||
|
|
|
@ -35,8 +35,9 @@ void Shutdown()
|
||||||
// if plugin isn't initialized, init and load config
|
// if plugin isn't initialized, init and load config
|
||||||
void Initialize(void* const hwnd)
|
void Initialize(void* const hwnd)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<4; ++i)
|
if (s_config.controllers.empty())
|
||||||
s_config.controllers.push_back(new GCKeyboard(i));
|
for (unsigned int i = 0; i < 4; ++i)
|
||||||
|
s_config.controllers.push_back(new GCKeyboard(i));
|
||||||
|
|
||||||
g_controller_interface.Initialize(hwnd);
|
g_controller_interface.Initialize(hwnd);
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,9 @@ void Shutdown()
|
||||||
void Initialize(void* const hwnd)
|
void Initialize(void* const hwnd)
|
||||||
{
|
{
|
||||||
// add 4 gcpads
|
// add 4 gcpads
|
||||||
for (unsigned int i=0; i<4; ++i)
|
if (s_config.controllers.empty())
|
||||||
s_config.controllers.push_back(new GCPad(i));
|
for (unsigned int i = 0; i < 4; ++i)
|
||||||
|
s_config.controllers.push_back(new GCPad(i));
|
||||||
|
|
||||||
g_controller_interface.Initialize(hwnd);
|
g_controller_interface.Initialize(hwnd);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ const std::string hotkey_labels[] =
|
||||||
_trans("Change Disc"),
|
_trans("Change Disc"),
|
||||||
_trans("Refresh List"),
|
_trans("Refresh List"),
|
||||||
|
|
||||||
_trans("Play/Pause"),
|
_trans("Toggle Pause"),
|
||||||
_trans("Stop"),
|
_trans("Stop"),
|
||||||
_trans("Reset"),
|
_trans("Reset"),
|
||||||
_trans("Frame Advance"),
|
_trans("Frame Advance"),
|
||||||
|
@ -205,7 +205,8 @@ bool IsPressed(int Id, bool held)
|
||||||
|
|
||||||
void Initialize(void* const hwnd)
|
void Initialize(void* const hwnd)
|
||||||
{
|
{
|
||||||
s_config.controllers.push_back(new HotkeyManager());
|
if (s_config.controllers.empty())
|
||||||
|
s_config.controllers.push_back(new HotkeyManager());
|
||||||
|
|
||||||
g_controller_interface.Initialize(hwnd);
|
g_controller_interface.Initialize(hwnd);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
#include "Core/HW/DVDInterface.h"
|
#include "Core/HW/DVDInterface.h"
|
||||||
|
#include "Core/HW/GCKeyboard.h"
|
||||||
|
#include "Core/HW/GCPad.h"
|
||||||
|
|
||||||
#include "DolphinWX/Frame.h"
|
#include "DolphinWX/Frame.h"
|
||||||
#include "DolphinWX/GameListCtrl.h"
|
#include "DolphinWX/GameListCtrl.h"
|
||||||
|
@ -345,15 +347,19 @@ END_EVENT_TABLE()
|
||||||
// Creation and close, quit functions
|
// Creation and close, quit functions
|
||||||
|
|
||||||
|
|
||||||
bool CFrame::InitHotkeys()
|
bool CFrame::InitControllers()
|
||||||
{
|
{
|
||||||
if (!g_controller_interface.IsInit())
|
if (!g_controller_interface.IsInit())
|
||||||
{
|
{
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
Window win = X11Utils::XWindowFromHandle(GetHandle());
|
Window win = X11Utils::XWindowFromHandle(GetHandle());
|
||||||
HotkeyManagerEmu::Initialize(reinterpret_cast<void*>(win));
|
HotkeyManagerEmu::Initialize(reinterpret_cast<void*>(win));
|
||||||
|
Pad::Initialize(reinterpret_cast<void*>(win));
|
||||||
|
Keyboard::Initialize(reinterpret_cast<void*>(win));
|
||||||
#else
|
#else
|
||||||
HotkeyManagerEmu::Initialize(reinterpret_cast<void*>(GetHandle()));
|
HotkeyManagerEmu::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||||
|
Pad::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||||
|
Keyboard::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +503,7 @@ CFrame::CFrame(wxFrame* parent,
|
||||||
g_pCodeWindow->UpdateButtonStates();
|
g_pCodeWindow->UpdateButtonStates();
|
||||||
|
|
||||||
// check if game is running
|
// check if game is running
|
||||||
m_bHotkeysInit = InitHotkeys();
|
m_bHotkeysInit = InitControllers();
|
||||||
|
|
||||||
m_poll_hotkey_timer = new wxTimer(this);
|
m_poll_hotkey_timer = new wxTimer(this);
|
||||||
Bind(wxEVT_TIMER, &CFrame::PollHotkeys, this);
|
Bind(wxEVT_TIMER, &CFrame::PollHotkeys, this);
|
||||||
|
@ -511,6 +517,9 @@ CFrame::~CFrame()
|
||||||
if (m_bHotkeysInit)
|
if (m_bHotkeysInit)
|
||||||
{
|
{
|
||||||
HotkeyManagerEmu::Shutdown();
|
HotkeyManagerEmu::Shutdown();
|
||||||
|
Keyboard::Shutdown();
|
||||||
|
Pad::Shutdown();
|
||||||
|
m_bHotkeysInit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
drives.clear();
|
drives.clear();
|
||||||
|
@ -1261,7 +1270,7 @@ void CFrame::PollHotkeys(wxTimerEvent& event)
|
||||||
{
|
{
|
||||||
if (Core::GetState() == Core::CORE_UNINITIALIZED || Core::GetState() == Core::CORE_PAUSE)
|
if (Core::GetState() == Core::CORE_UNINITIALIZED || Core::GetState() == Core::CORE_PAUSE)
|
||||||
{
|
{
|
||||||
InitHotkeys();
|
m_bHotkeysInit = InitControllers();
|
||||||
g_controller_interface.UpdateInput();
|
g_controller_interface.UpdateInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ private:
|
||||||
void PollHotkeys(wxTimerEvent&);
|
void PollHotkeys(wxTimerEvent&);
|
||||||
void ParseHotkeys(wxKeyEvent &event);
|
void ParseHotkeys(wxKeyEvent &event);
|
||||||
|
|
||||||
bool InitHotkeys();
|
bool InitControllers();
|
||||||
|
|
||||||
// Event table
|
// Event table
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
Loading…
Reference in New Issue