mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
ControllerInterface: Don't crash on non-X11 QPA
This commit is contained in:
@ -41,12 +41,12 @@ ControllerInterface g_controller_interface;
|
||||
//
|
||||
// Detect devices and inputs outputs / will make refresh function later
|
||||
//
|
||||
void ControllerInterface::Initialize(void* const hwnd)
|
||||
void ControllerInterface::Initialize(const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (m_is_init)
|
||||
return;
|
||||
|
||||
m_hwnd = hwnd;
|
||||
m_wsi = wsi;
|
||||
m_is_populating_devices = true;
|
||||
|
||||
#ifdef CIFACE_USE_DINPUT
|
||||
@ -59,7 +59,8 @@ void ControllerInterface::Initialize(void* const hwnd)
|
||||
// nothing needed
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
ciface::OSX::Init(hwnd);
|
||||
if (m_wsi.type == WindowSystemType::MacOS)
|
||||
ciface::OSX::Init(wsi.render_surface);
|
||||
// nothing needed for Quartz
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
@ -92,17 +93,22 @@ void ControllerInterface::RefreshDevices()
|
||||
m_is_populating_devices = true;
|
||||
|
||||
#ifdef CIFACE_USE_DINPUT
|
||||
ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_hwnd));
|
||||
if (m_wsi.type == WindowSystemType::Windows)
|
||||
ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_wsi.render_surface));
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XINPUT
|
||||
ciface::XInput::PopulateDevices();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XLIB
|
||||
ciface::XInput2::PopulateDevices(m_hwnd);
|
||||
if (m_wsi.type == WindowSystemType::X11)
|
||||
ciface::XInput2::PopulateDevices(m_wsi.render_surface);
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
ciface::OSX::PopulateDevices(m_hwnd);
|
||||
ciface::Quartz::PopulateDevices(m_hwnd);
|
||||
if (m_wsi.type == WindowSystemType::MacOS)
|
||||
{
|
||||
ciface::OSX::PopulateDevices(m_wsi.render_surface);
|
||||
ciface::Quartz::PopulateDevices(m_wsi.render_surface);
|
||||
}
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
ciface::SDL::PopulateDevices();
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
|
||||
// enable disable sources
|
||||
@ -39,8 +40,8 @@
|
||||
class ControllerInterface : public ciface::Core::DeviceContainer
|
||||
{
|
||||
public:
|
||||
ControllerInterface() : m_is_init(false), m_hwnd(nullptr) {}
|
||||
void Initialize(void* const hwnd);
|
||||
ControllerInterface() : m_is_init(false) {}
|
||||
void Initialize(const WindowSystemInfo& wsi);
|
||||
void RefreshDevices();
|
||||
void Shutdown();
|
||||
void AddDevice(std::shared_ptr<ciface::Core::Device> device);
|
||||
@ -56,7 +57,7 @@ private:
|
||||
mutable std::mutex m_callbacks_mutex;
|
||||
bool m_is_init;
|
||||
std::atomic<bool> m_is_populating_devices{false};
|
||||
void* m_hwnd;
|
||||
WindowSystemInfo m_wsi;
|
||||
};
|
||||
|
||||
extern ControllerInterface g_controller_interface;
|
||||
|
Reference in New Issue
Block a user