summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-10-13 12:45:47 -0400
committerLioncash <mathew1800@gmail.com>2014-10-15 09:29:25 -0400
commitb7b2074cc2e78bb13160372ee82be7f85d0e3772 (patch)
treec5760301847ada1d17a10bfe01ec638d758d8388 /Source
parent89123155960021d4a026f98a8fb6c1ca3a03a630 (diff)
ControllerInterface: Get rid of SetHwnd(), introduce Reinitialize()
Initialize now just takes the handle directly. Reinitialize is added because it is much more straightforward in comparison to doing the Shutdown-Initialize manually.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/GCPad.cpp3
-rw-r--r--Source/Core/Core/HW/Wiimote.cpp4
-rw-r--r--Source/Core/DolphinWX/InputConfigDiag.cpp3
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp31
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.h4
5 files changed, 21 insertions, 24 deletions
diff --git a/Source/Core/Core/HW/GCPad.cpp b/Source/Core/Core/HW/GCPad.cpp
index 6f27e7f73e..55d5c3a62d 100644
--- a/Source/Core/Core/HW/GCPad.cpp
+++ b/Source/Core/Core/HW/GCPad.cpp
@@ -40,8 +40,7 @@ void Initialize(void* const hwnd)
for (unsigned int i=0; i<4; ++i)
s_config.controllers.push_back(new GCPad(i));
- g_controller_interface.SetHwnd(hwnd);
- g_controller_interface.Initialize();
+ g_controller_interface.Initialize(hwnd);
// load the saved controller config
s_config.LoadConfig(true);
diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp
index 9b3bf898c8..0f1870aad9 100644
--- a/Source/Core/Core/HW/Wiimote.cpp
+++ b/Source/Core/Core/HW/Wiimote.cpp
@@ -44,9 +44,7 @@ void Initialize(void* const hwnd, bool wait)
for (unsigned int i = WIIMOTE_CHAN_0; i<MAX_BBMOTES; ++i)
s_config.controllers.push_back(new WiimoteEmu::Wiimote(i));
-
- g_controller_interface.SetHwnd(hwnd);
- g_controller_interface.Initialize();
+ g_controller_interface.Initialize(hwnd);
s_config.LoadConfig(false);
diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp
index 01a3c5e90d..72b33077bb 100644
--- a/Source/Core/DolphinWX/InputConfigDiag.cpp
+++ b/Source/Core/DolphinWX/InputConfigDiag.cpp
@@ -745,8 +745,7 @@ void GamepadPage::RefreshDevices(wxCommandEvent&)
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
// refresh devices
- g_controller_interface.Shutdown();
- g_controller_interface.Initialize();
+ g_controller_interface.Reinitialize();
// update all control references
m_config_dialog->UpdateControlReferences();
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 09fcf12ed8..ec2973f3d3 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -41,25 +41,27 @@ ControllerInterface g_controller_interface;
//
// Detect devices and inputs outputs / will make refresh function later
//
-void ControllerInterface::Initialize()
+void ControllerInterface::Initialize(void* const hwnd)
{
if (m_is_init)
return;
+ m_hwnd = hwnd;
+
#ifdef CIFACE_USE_DINPUT
- ciface::DInput::Init(m_devices, (HWND)m_hwnd);
+ ciface::DInput::Init(m_devices, (HWND)hwnd);
#endif
#ifdef CIFACE_USE_XINPUT
ciface::XInput::Init(m_devices);
#endif
#ifdef CIFACE_USE_XLIB
- ciface::Xlib::Init(m_devices, m_hwnd);
+ ciface::Xlib::Init(m_devices, hwnd);
#ifdef CIFACE_USE_X11_XINPUT2
- ciface::XInput2::Init(m_devices, m_hwnd);
+ ciface::XInput2::Init(m_devices, hwnd);
#endif
#endif
#ifdef CIFACE_USE_OSX
- ciface::OSX::Init(m_devices, m_hwnd);
+ ciface::OSX::Init(m_devices, hwnd);
#endif
#ifdef CIFACE_USE_SDL
ciface::SDL::Init(m_devices);
@@ -71,6 +73,15 @@ void ControllerInterface::Initialize()
m_is_init = true;
}
+void ControllerInterface::Reinitialize()
+{
+ if (!m_is_init)
+ return;
+
+ Shutdown();
+ Initialize(m_hwnd);
+}
+
//
// DeInit
//
@@ -120,16 +131,6 @@ void ControllerInterface::Shutdown()
}
//
-// SetHwnd
-//
-// Sets the hwnd used for some crap when initializing, use before calling Init
-//
-void ControllerInterface::SetHwnd( void* const hwnd )
-{
- m_hwnd = hwnd;
-}
-
-//
// UpdateInput
//
// Update input for all devices, return true if all devices returned successful
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
index 24bb493520..2420b65ed7 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
@@ -114,8 +114,8 @@ public:
ControllerInterface() : m_is_init(false), m_hwnd(nullptr) {}
- void SetHwnd(void* const hwnd);
- void Initialize();
+ void Initialize(void* const hwnd);
+ void Reinitialize();
void Shutdown();
bool IsInit() const { return m_is_init; }