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