From b7b2074cc2e78bb13160372ee82be7f85d0e3772 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 13 Oct 2014 12:45:47 -0400 Subject: 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. --- .../ControllerInterface/ControllerInterface.cpp | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp') 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 // @@ -119,16 +130,6 @@ void ControllerInterface::Shutdown() m_is_init = false; } -// -// SetHwnd -// -// Sets the hwnd used for some crap when initializing, use before calling Init -// -void ControllerInterface::SetHwnd( void* const hwnd ) -{ - m_hwnd = hwnd; -} - // // UpdateInput // -- cgit v1.2.3