diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2024-03-11 02:28:18 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2024-03-11 03:25:31 -0500 |
| commit | 8583b6751abe08334329c7cae99c83df82683ce2 (patch) | |
| tree | 5d7ab219a07d6de98374a713511d532bd27b85c0 /Source/Core/InputCommon/ControllerInterface/Quartz | |
| parent | 3665f7abac4d5c93936f0325fe40bba73703813d (diff) | |
InputCommon: Handle window change in Quartz.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Quartz')
3 files changed, 20 insertions, 1 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h index 34219e9828..b2c6906e42 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h @@ -3,9 +3,13 @@ #pragma once +#include <string> + #include "InputCommon/ControllerInterface/InputBackend.h" namespace ciface::Quartz { +std::string GetSourceName(); + std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface); } // namespace ciface::Quartz diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm index 75054f08b9..5d52595835 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm @@ -7,11 +7,17 @@ namespace ciface::Quartz { +std::string GetSourceName() +{ + return "Quartz"; +} + 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) @@ -19,6 +25,15 @@ std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* co return std::make_unique<InputBackend>(controller_interface); } +void InputBackend::HandleWindowChange() +{ + const std::string source_name = GetSourceName(); + GetControllerInterface().RemoveDevice( + [&](const auto* dev) { return dev->GetSource() == source_name; }, true); + + PopulateDevices(); +} + void InputBackend::PopulateDevices() { const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo(); diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index b21eb48ab4..55f212900d 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -280,7 +280,7 @@ std::string KeyboardAndMouse::GetName() const std::string KeyboardAndMouse::GetSource() const { - return "Quartz"; + return Quartz::GetSourceName(); } ControlState KeyboardAndMouse::Cursor::GetState() const |
