From a082e9324fce217378915fa2946fda5cfccf8c8d Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Tue, 11 Oct 2016 12:54:35 -0700 Subject: HW: Don't be responsible for g_controller_interface Currently, `g_controller_interface` is initialized and shut down by each of `GCKeyboard`, `GCPad`, `Wiimote`, and `HotkeyManager`. This 1) is weird conceptually, because it necessitates passing a pointer to the native window to each of those classes, which don't need it, and 2) can cause issues when controller backends are initialized or shutdown multiple times in succession. --- Source/Core/DolphinWX/Frame.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'Source/Core/DolphinWX/Frame.cpp') diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 2253297bb6..401451b666 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -333,19 +333,16 @@ bool CFrame::InitControllers() if (!g_controller_interface.IsInit()) { #if defined(HAVE_X11) && HAVE_X11 - Window win = X11Utils::XWindowFromHandle(GetHandle()); - Pad::Initialize(reinterpret_cast(win)); - Keyboard::Initialize(reinterpret_cast(win)); - Wiimote::Initialize(reinterpret_cast(win), - Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); - HotkeyManagerEmu::Initialize(reinterpret_cast(win)); + void* win = reinterpret_cast(X11Utils::XWindowFromHandle(GetHandle())); #else - Pad::Initialize(reinterpret_cast(GetHandle())); - Keyboard::Initialize(reinterpret_cast(GetHandle())); - Wiimote::Initialize(reinterpret_cast(GetHandle()), - Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); - HotkeyManagerEmu::Initialize(reinterpret_cast(GetHandle())); + void* win = reinterpret_cast(GetHandle()); #endif + g_controller_interface.Initialize(win); + Pad::Initialize(); + Keyboard::Initialize(); + Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); + HotkeyManagerEmu::Initialize(); + return true; } return false; @@ -547,6 +544,7 @@ CFrame::~CFrame() Keyboard::Shutdown(); Pad::Shutdown(); HotkeyManagerEmu::Shutdown(); + g_controller_interface.Shutdown(); drives.clear(); -- cgit v1.2.3