summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/Quartz
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Quartz')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h9
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm35
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm3
3 files changed, 39 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h
index 8818425344..b2c6906e42 100644
--- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h
+++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h
@@ -3,8 +3,13 @@
#pragma once
+#include <string>
+
+#include "InputCommon/ControllerInterface/InputBackend.h"
+
namespace ciface::Quartz
{
-void PopulateDevices(void* window);
-void DeInit();
+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 22dc4074d9..5d52595835 100644
--- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
+++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
@@ -7,15 +7,40 @@
namespace ciface::Quartz
{
-void PopulateDevices(void* window)
+std::string GetSourceName()
{
- if (!window)
- return;
+ 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)
+{
+ 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);
- g_controller_interface.AddDevice(std::make_shared<KeyboardAndMouse>(window));
+ PopulateDevices();
}
-void DeInit()
+void InputBackend::PopulateDevices()
{
+ const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo();
+ if (wsi.type != WindowSystemType::MacOS)
+ return;
+
+ GetControllerInterface().AddDevice(std::make_shared<KeyboardAndMouse>(wsi.render_window));
}
+
} // namespace ciface::Quartz
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm
index e41c370edf..55f212900d 100644
--- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm
+++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm
@@ -12,6 +12,7 @@
#include "Core/Host.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
+#include "InputCommon/ControllerInterface/Quartz/Quartz.h"
/// Helper class to get window position data from threads other than the main thread
@interface DolWindowPositionObserver : NSObject
@@ -279,7 +280,7 @@ std::string KeyboardAndMouse::GetName() const
std::string KeyboardAndMouse::GetSource() const
{
- return "Quartz";
+ return Quartz::GetSourceName();
}
ControlState KeyboardAndMouse::Cursor::GetState() const