Debian Codegraph @

Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm

raw
1 // Copyright 2016 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "InputCommon/ControllerInterface/Quartz/Quartz.h"
5
6 #include "InputCommon/ControllerInterface/ControllerInterface.h"
7 #include "InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h"
8
9 namespace ciface::Quartz
10 {
11 std::string GetSourceName()
12 {
13 return "Quartz";
14 }
15
16 class InputBackend final : public ciface::InputBackend
17 {
18 public:
19 using ciface::InputBackend::InputBackend;
20 void PopulateDevices() override;
21 void HandleWindowChange() override;
22 };
23
24 std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
25 {
26 return std::make_unique<InputBackend>(controller_interface);
27 }
28
29 void InputBackend::HandleWindowChange()
30 {
31 const std::string source_name = GetSourceName();
32 GetControllerInterface().RemoveDevice(
33 [&](const auto* dev) { return dev->GetSource() == source_name; }, true);
34
35 PopulateDevices();
36 }
37
38 void InputBackend::PopulateDevices()
39 {
40 const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo();
41 if (wsi.type != WindowSystemType::MacOS)
42 return;
43
44 GetControllerInterface().AddDevice(std::make_shared<KeyboardAndMouse>(wsi.render_window));
45 }
46
47 } // namespace ciface::Quartz