This commit is contained in:
Nayla Hanegan 2024-05-12 02:17:59 -04:00
commit 98c174edc4
520 changed files with 74815 additions and 58942 deletions

View file

@ -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

View file

@ -7,15 +7,40 @@
namespace ciface::Quartz
{
void PopulateDevices(void* window)
std::string GetSourceName()
{
if (!window)
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);
PopulateDevices();
}
void InputBackend::PopulateDevices()
{
const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo();
if (wsi.type != WindowSystemType::MacOS)
return;
g_controller_interface.AddDevice(std::make_shared<KeyboardAndMouse>(window));
GetControllerInterface().AddDevice(std::make_shared<KeyboardAndMouse>(wsi.render_window));
}
void DeInit()
{
}
} // namespace ciface::Quartz

View file

@ -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