summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/Quartz
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2024-03-11 01:31:30 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2024-03-11 03:05:52 -0500
commit498584ac777ac4fc452a83a4380889ef2c99d216 (patch)
tree85ae1be884ea2b7831d1b09dd15f9cfb6fa9b7ef /Source/Core/InputCommon/ControllerInterface/Quartz
parent9941c54911e8ab713aad1f156511bf6552ca4b3b (diff)
InputCommon: Add Quartz InputBackend class.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Quartz')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h5
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm20
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm1
3 files changed, 19 insertions, 7 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h
index 8818425344..34219e9828 100644
--- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h
+++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.h
@@ -3,8 +3,9 @@
#pragma once
+#include "InputCommon/ControllerInterface/InputBackend.h"
+
namespace ciface::Quartz
{
-void PopulateDevices(void* window);
-void DeInit();
+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..75054f08b9 100644
--- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
+++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
@@ -7,15 +7,25 @@
namespace ciface::Quartz
{
-void PopulateDevices(void* window)
+class InputBackend final : public ciface::InputBackend
{
- if (!window)
- return;
+public:
+ using ciface::InputBackend::InputBackend;
+ void PopulateDevices() override;
+};
- g_controller_interface.AddDevice(std::make_shared<KeyboardAndMouse>(window));
+std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
+{
+ return std::make_unique<InputBackend>(controller_interface);
}
-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..b21eb48ab4 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