From 9941c54911e8ab713aad1f156511bf6552ca4b3b Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 01:31:05 -0500 Subject: InputCommon: Provide WindowSystemInfo getter for ControllerInterface. --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 5 +++++ 1 file changed, 5 insertions(+) (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 b7a9c7f307..24653acdd1 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -423,6 +423,11 @@ ciface::InputChannel ControllerInterface::GetCurrentInputChannel() return tls_input_channel; } +WindowSystemInfo ControllerInterface::GetWindowSystemInfo() const +{ + return m_wsi; +} + void ControllerInterface::SetAspectRatioAdjustment(float value) { m_aspect_ratio_adjustment = value; -- cgit v1.2.3 From 498584ac777ac4fc452a83a4380889ef2c99d216 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 01:31:30 -0500 Subject: InputCommon: Add Quartz InputBackend class. --- .../InputCommon/ControllerInterface/ControllerInterface.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 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 24653acdd1..ba3740214a 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -65,7 +65,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi) // nothing needed #endif #ifdef CIFACE_USE_OSX -// nothing needed for Quartz + m_input_backends.emplace_back(ciface::Quartz::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_SDL m_input_backends.emplace_back(ciface::SDL::CreateInputBackend(this)); @@ -166,12 +166,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) if (m_wsi.type == WindowSystemType::X11) ciface::XInput2::PopulateDevices(m_wsi.render_window); #endif -#ifdef CIFACE_USE_OSX - if (m_wsi.type == WindowSystemType::MacOS) - { - ciface::Quartz::PopulateDevices(m_wsi.render_window); - } -#endif #ifdef CIFACE_USE_ANDROID ciface::Android::PopulateDevices(); #endif @@ -223,9 +217,6 @@ void ControllerInterface::Shutdown() #ifdef CIFACE_USE_XLIB // nothing needed #endif -#ifdef CIFACE_USE_OSX - ciface::Quartz::DeInit(); -#endif #ifdef CIFACE_USE_ANDROID ciface::Android::Shutdown(); #endif -- cgit v1.2.3 From 8098be3dfa07aa529f61ea2ec4ff4077ef01b2d8 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 01:42:32 -0500 Subject: InputCommon: Add XInput2 InputBackend class. --- .../Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 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 ba3740214a..fa44e8bf79 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -62,7 +62,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi) ciface::Win32::Init(wsi.render_window); #endif #ifdef CIFACE_USE_XLIB -// nothing needed + m_input_backends.emplace_back(ciface::XInput2::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_OSX m_input_backends.emplace_back(ciface::Quartz::CreateInputBackend(this)); @@ -162,10 +162,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) #ifdef CIFACE_USE_WIN32 ciface::Win32::PopulateDevices(m_wsi.render_window); #endif -#ifdef CIFACE_USE_XLIB - if (m_wsi.type == WindowSystemType::X11) - ciface::XInput2::PopulateDevices(m_wsi.render_window); -#endif #ifdef CIFACE_USE_ANDROID ciface::Android::PopulateDevices(); #endif @@ -214,9 +210,6 @@ void ControllerInterface::Shutdown() #ifdef CIFACE_USE_WIN32 ciface::Win32::DeInit(); #endif -#ifdef CIFACE_USE_XLIB -// nothing needed -#endif #ifdef CIFACE_USE_ANDROID ciface::Android::Shutdown(); #endif -- cgit v1.2.3 From 2ac59bf5813ab44dc3e7f067913b0e951e8b6199 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 01:46:33 -0500 Subject: InputCommon: Add Pipes InputBackend class. --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 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 fa44e8bf79..71dea5512c 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -77,7 +77,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi) m_input_backends.emplace_back(ciface::evdev::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_PIPES -// nothing needed + m_input_backends.emplace_back(ciface::Pipes::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_DUALSHOCKUDPCLIENT m_input_backends.emplace_back(ciface::DualShockUDPClient::CreateInputBackend(this)); @@ -165,9 +165,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) #ifdef CIFACE_USE_ANDROID ciface::Android::PopulateDevices(); #endif -#ifdef CIFACE_USE_PIPES - ciface::Pipes::PopulateDevices(); -#endif for (auto& backend : m_input_backends) backend->PopulateDevices(); -- cgit v1.2.3 From 341f99a3f1feaf981bb704909b2dc3b3a0b70245 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 02:09:31 -0500 Subject: InputCommon: Add Win32 InputBackend class. --- .../InputCommon/ControllerInterface/ControllerInterface.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 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 71dea5512c..8f7bed3af1 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -59,7 +59,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi) m_populating_devices_counter = 1; #ifdef CIFACE_USE_WIN32 - ciface::Win32::Init(wsi.render_window); + m_input_backends.emplace_back(ciface::Win32::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_XLIB m_input_backends.emplace_back(ciface::XInput2::CreateInputBackend(this)); @@ -135,9 +135,8 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) { m_populating_devices_counter.fetch_add(1); - // No need to do anything else in this case. - // Only (Win32) DInput needs the window handle to be updated. - ciface::Win32::ChangeWindow(m_wsi.render_window); + for (auto& backend : m_input_backends) + backend->HandleWindowChange(); if (m_populating_devices_counter.fetch_sub(1) == 1) InvokeDevicesChangedCallbacks(); @@ -159,9 +158,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) // do it async, to not risk the emulated controllers default config loading not finding a default // device. -#ifdef CIFACE_USE_WIN32 - ciface::Win32::PopulateDevices(m_wsi.render_window); -#endif #ifdef CIFACE_USE_ANDROID ciface::Android::PopulateDevices(); #endif @@ -204,9 +200,6 @@ void ControllerInterface::Shutdown() // Update control references so shared_ptrs are freed up BEFORE we shutdown the backends. ClearDevices(); -#ifdef CIFACE_USE_WIN32 - ciface::Win32::DeInit(); -#endif #ifdef CIFACE_USE_ANDROID ciface::Android::Shutdown(); #endif -- cgit v1.2.3 From 3665f7abac4d5c93936f0325fe40bba73703813d Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 02:20:54 -0500 Subject: InputCommon: Implement xlib window change logic. --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 8f7bed3af1..9c272fdec4 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -128,7 +128,7 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) // or removing them as we are populating them (causing missing or duplicate devices). std::lock_guard lk_population(m_devices_population_mutex); -#if defined(CIFACE_USE_WIN32) && !defined(CIFACE_USE_XLIB) && !defined(CIFACE_USE_OSX) +#if defined(CIFACE_USE_WIN32) && !defined(CIFACE_USE_OSX) // If only the window changed, avoid removing and re-adding all devices. // Instead only refresh devices that require the window handle. if (reason == RefreshReason::WindowChangeOnly) -- cgit v1.2.3 From 8583b6751abe08334329c7cae99c83df82683ce2 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 02:28:18 -0500 Subject: InputCommon: Handle window change in Quartz. --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 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 9c272fdec4..b82cba645e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -128,7 +128,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) // or removing them as we are populating them (causing missing or duplicate devices). std::lock_guard lk_population(m_devices_population_mutex); -#if defined(CIFACE_USE_WIN32) && !defined(CIFACE_USE_OSX) // If only the window changed, avoid removing and re-adding all devices. // Instead only refresh devices that require the window handle. if (reason == RefreshReason::WindowChangeOnly) @@ -140,9 +139,9 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) if (m_populating_devices_counter.fetch_sub(1) == 1) InvokeDevicesChangedCallbacks(); + return; } -#endif m_populating_devices_counter.fetch_add(1); -- cgit v1.2.3 From a9a9fdd9e903d47ec83aa7385e7be54871abbf0b Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Mar 2024 02:36:07 -0500 Subject: InputCommon: Add Android InputBackend class. --- .../InputCommon/ControllerInterface/ControllerInterface.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 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 b82cba645e..ab266292bc 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -71,7 +71,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi) m_input_backends.emplace_back(ciface::SDL::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_ANDROID - ciface::Android::Init(); + m_input_backends.emplace_back(ciface::Android::CreateInputBackend(this)); #endif #ifdef CIFACE_USE_EVDEV m_input_backends.emplace_back(ciface::evdev::CreateInputBackend(this)); @@ -157,10 +157,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) // do it async, to not risk the emulated controllers default config loading not finding a default // device. -#ifdef CIFACE_USE_ANDROID - ciface::Android::PopulateDevices(); -#endif - for (auto& backend : m_input_backends) backend->PopulateDevices(); @@ -199,10 +195,6 @@ void ControllerInterface::Shutdown() // Update control references so shared_ptrs are freed up BEFORE we shutdown the backends. ClearDevices(); -#ifdef CIFACE_USE_ANDROID - ciface::Android::Shutdown(); -#endif - // Empty the container of input backends to deconstruct and deinitialize them. m_input_backends.clear(); -- cgit v1.2.3