summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2024-03-11 02:20:54 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2024-03-11 03:25:31 -0500
commit3665f7abac4d5c93936f0325fe40bba73703813d (patch)
tree616dae23c6a2953b564f07e9b4b8771c58aeff0f /Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
parent341f99a3f1feaf981bb704909b2dc3b3a0b70245 (diff)
InputCommon: Implement xlib window change logic.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
index 5de0840354..e4b717e3af 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
@@ -66,11 +66,14 @@ constexpr int XINPUT_MAJOR = 2, XINPUT_MINOR = 1;
namespace ciface::XInput2
{
+constexpr std::string_view SOURCE_NAME = "XInput2";
+
class InputBackend final : public ciface::InputBackend
{
public:
using ciface::InputBackend::InputBackend;
void PopulateDevices() override;
+ void HandleWindowChange() override;
};
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
@@ -78,6 +81,14 @@ std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* co
return std::make_unique<InputBackend>(controller_interface);
}
+void InputBackend::HandleWindowChange()
+{
+ GetControllerInterface().RemoveDevice(
+ [](const auto* dev) { return dev->GetSource() == SOURCE_NAME; }, true);
+
+ PopulateDevices();
+}
+
// This function will add zero or more KeyboardMouse objects to devices.
void InputBackend::PopulateDevices()
{
@@ -400,7 +411,7 @@ std::string KeyboardMouse::GetName() const
std::string KeyboardMouse::GetSource() const
{
- return "XInput2";
+ return std::string(SOURCE_NAME);
}
KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* keyboard)