2016-08-09 22:48:22 +00:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-08-08 16:38:22 +00:00
|
|
|
|
|
|
|
#include "InputCommon/ControllerInterface/Quartz/Quartz.h"
|
2016-08-10 00:23:30 +00:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2016-08-08 16:38:22 +00:00
|
|
|
#include "InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h"
|
|
|
|
|
2019-06-17 20:39:24 +00:00
|
|
|
namespace ciface::Quartz
|
2016-08-08 16:38:22 +00:00
|
|
|
{
|
2024-03-11 07:28:18 +00:00
|
|
|
std::string GetSourceName()
|
|
|
|
{
|
|
|
|
return "Quartz";
|
|
|
|
}
|
|
|
|
|
2024-03-11 06:31:30 +00:00
|
|
|
class InputBackend final : public ciface::InputBackend
|
2016-08-08 16:38:22 +00:00
|
|
|
{
|
2024-03-11 06:31:30 +00:00
|
|
|
public:
|
|
|
|
using ciface::InputBackend::InputBackend;
|
|
|
|
void PopulateDevices() override;
|
2024-03-11 07:28:18 +00:00
|
|
|
void HandleWindowChange() override;
|
2024-03-11 06:31:30 +00:00
|
|
|
};
|
2017-04-16 02:23:19 +00:00
|
|
|
|
2024-03-11 06:31:30 +00:00
|
|
|
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
|
|
|
|
{
|
|
|
|
return std::make_unique<InputBackend>(controller_interface);
|
2016-08-08 16:38:22 +00:00
|
|
|
}
|
|
|
|
|
2024-03-11 07:28:18 +00:00
|
|
|
void InputBackend::HandleWindowChange()
|
|
|
|
{
|
|
|
|
const std::string source_name = GetSourceName();
|
|
|
|
GetControllerInterface().RemoveDevice(
|
|
|
|
[&](const auto* dev) { return dev->GetSource() == source_name; }, true);
|
|
|
|
|
|
|
|
PopulateDevices();
|
|
|
|
}
|
|
|
|
|
2024-03-11 06:31:30 +00:00
|
|
|
void InputBackend::PopulateDevices()
|
2016-08-08 16:38:22 +00:00
|
|
|
{
|
2024-03-11 06:31:30 +00:00
|
|
|
const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo();
|
|
|
|
if (wsi.type != WindowSystemType::MacOS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetControllerInterface().AddDevice(std::make_shared<KeyboardAndMouse>(wsi.render_window));
|
2016-08-08 16:38:22 +00:00
|
|
|
}
|
2024-03-11 06:31:30 +00:00
|
|
|
|
2019-06-17 20:39:24 +00:00
|
|
|
} // namespace ciface::Quartz
|