mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 08:15:33 +01:00
InputCommon: Handle window change in Quartz.
This commit is contained in:
parent
3665f7abac
commit
8583b6751a
@ -128,7 +128,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason)
|
|||||||
// or removing them as we are populating them (causing missing or duplicate devices).
|
// or removing them as we are populating them (causing missing or duplicate devices).
|
||||||
std::lock_guard lk_population(m_devices_population_mutex);
|
std::lock_guard lk_population(m_devices_population_mutex);
|
||||||
|
|
||||||
#if defined(CIFACE_USE_WIN32) && !defined(CIFACE_USE_OSX)
|
|
||||||
// If only the window changed, avoid removing and re-adding all devices.
|
// If only the window changed, avoid removing and re-adding all devices.
|
||||||
// Instead only refresh devices that require the window handle.
|
// Instead only refresh devices that require the window handle.
|
||||||
if (reason == RefreshReason::WindowChangeOnly)
|
if (reason == RefreshReason::WindowChangeOnly)
|
||||||
@ -140,9 +139,9 @@ void ControllerInterface::RefreshDevices(RefreshReason reason)
|
|||||||
|
|
||||||
if (m_populating_devices_counter.fetch_sub(1) == 1)
|
if (m_populating_devices_counter.fetch_sub(1) == 1)
|
||||||
InvokeDevicesChangedCallbacks();
|
InvokeDevicesChangedCallbacks();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
m_populating_devices_counter.fetch_add(1);
|
m_populating_devices_counter.fetch_add(1);
|
||||||
|
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "InputCommon/ControllerInterface/InputBackend.h"
|
#include "InputCommon/ControllerInterface/InputBackend.h"
|
||||||
|
|
||||||
namespace ciface::Quartz
|
namespace ciface::Quartz
|
||||||
{
|
{
|
||||||
|
std::string GetSourceName();
|
||||||
|
|
||||||
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface);
|
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface);
|
||||||
} // namespace ciface::Quartz
|
} // namespace ciface::Quartz
|
||||||
|
@ -7,11 +7,17 @@
|
|||||||
|
|
||||||
namespace ciface::Quartz
|
namespace ciface::Quartz
|
||||||
{
|
{
|
||||||
|
std::string GetSourceName()
|
||||||
|
{
|
||||||
|
return "Quartz";
|
||||||
|
}
|
||||||
|
|
||||||
class InputBackend final : public ciface::InputBackend
|
class InputBackend final : public ciface::InputBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using ciface::InputBackend::InputBackend;
|
using ciface::InputBackend::InputBackend;
|
||||||
void PopulateDevices() override;
|
void PopulateDevices() override;
|
||||||
|
void HandleWindowChange() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
|
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
|
||||||
@ -19,6 +25,15 @@ std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* co
|
|||||||
return std::make_unique<InputBackend>(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()
|
void InputBackend::PopulateDevices()
|
||||||
{
|
{
|
||||||
const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo();
|
const WindowSystemInfo wsi = GetControllerInterface().GetWindowSystemInfo();
|
||||||
|
@ -280,7 +280,7 @@ std::string KeyboardAndMouse::GetName() const
|
|||||||
|
|
||||||
std::string KeyboardAndMouse::GetSource() const
|
std::string KeyboardAndMouse::GetSource() const
|
||||||
{
|
{
|
||||||
return "Quartz";
|
return Quartz::GetSourceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState KeyboardAndMouse::Cursor::GetState() const
|
ControlState KeyboardAndMouse::Cursor::GetState() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user