diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-11-12 17:26:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-12 17:26:03 +0100 |
| commit | 97e3200f5799cb43f508fd6c385321bc778c5ffb (patch) | |
| tree | 4fb4833f00991fdea4d75a773f13bc736639f3ea /Source/Core/InputCommon/ControllerInterface | |
| parent | 4de7161eaa9a59c6b80f179c66abd3015bf3b4c9 (diff) | |
| parent | 6392be61ebf00188cd048b42c99fff60f0a56139 (diff) | |
Merge pull request #7519 from stenzek/controller-window
Core: Switch controller interface to render surface on booting
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 29 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 8 |
2 files changed, 27 insertions, 10 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 0e6857c137..9f6e7c5179 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -41,12 +41,12 @@ ControllerInterface g_controller_interface; // // Detect devices and inputs outputs / will make refresh function later // -void ControllerInterface::Initialize(void* const hwnd) +void ControllerInterface::Initialize(const WindowSystemInfo& wsi) { if (m_is_init) return; - m_hwnd = hwnd; + m_wsi = wsi; m_is_populating_devices = true; #ifdef CIFACE_USE_DINPUT @@ -59,7 +59,8 @@ void ControllerInterface::Initialize(void* const hwnd) // nothing needed #endif #ifdef CIFACE_USE_OSX - ciface::OSX::Init(hwnd); + if (m_wsi.type == WindowSystemType::MacOS) + ciface::OSX::Init(wsi.render_surface); // nothing needed for Quartz #endif #ifdef CIFACE_USE_SDL @@ -79,6 +80,15 @@ void ControllerInterface::Initialize(void* const hwnd) RefreshDevices(); } +void ControllerInterface::ChangeWindow(void* hwnd) +{ + if (!m_is_init) + return; + + m_wsi.render_surface = hwnd; + RefreshDevices(); +} + void ControllerInterface::RefreshDevices() { if (!m_is_init) @@ -92,17 +102,22 @@ void ControllerInterface::RefreshDevices() m_is_populating_devices = true; #ifdef CIFACE_USE_DINPUT - ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_hwnd)); + if (m_wsi.type == WindowSystemType::Windows) + ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_wsi.render_surface)); #endif #ifdef CIFACE_USE_XINPUT ciface::XInput::PopulateDevices(); #endif #ifdef CIFACE_USE_XLIB - ciface::XInput2::PopulateDevices(m_hwnd); + if (m_wsi.type == WindowSystemType::X11) + ciface::XInput2::PopulateDevices(m_wsi.render_surface); #endif #ifdef CIFACE_USE_OSX - ciface::OSX::PopulateDevices(m_hwnd); - ciface::Quartz::PopulateDevices(m_hwnd); + if (m_wsi.type == WindowSystemType::MacOS) + { + ciface::OSX::PopulateDevices(m_wsi.render_surface); + ciface::Quartz::PopulateDevices(m_wsi.render_surface); + } #endif #ifdef CIFACE_USE_SDL ciface::SDL::PopulateDevices(); diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index c576b20fb3..d5567222a4 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -10,6 +10,7 @@ #include <mutex> #include <vector> +#include "Common/WindowSystemInfo.h" #include "InputCommon/ControllerInterface/Device.h" // enable disable sources @@ -39,8 +40,9 @@ class ControllerInterface : public ciface::Core::DeviceContainer { public: - ControllerInterface() : m_is_init(false), m_hwnd(nullptr) {} - void Initialize(void* const hwnd); + ControllerInterface() : m_is_init(false) {} + void Initialize(const WindowSystemInfo& wsi); + void ChangeWindow(void* hwnd); void RefreshDevices(); void Shutdown(); void AddDevice(std::shared_ptr<ciface::Core::Device> device); @@ -56,7 +58,7 @@ private: mutable std::mutex m_callbacks_mutex; bool m_is_init; std::atomic<bool> m_is_populating_devices{false}; - void* m_hwnd; + WindowSystemInfo m_wsi; }; extern ControllerInterface g_controller_interface; |
