Compatibility for July 12 dolphin src code
This commit is contained in:
@@ -4,15 +4,44 @@
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
//OpenEmu undefine the OSX settings
|
||||
#ifdef CIFACE_USE_OSX
|
||||
#undef CIFACE_USE_OSX
|
||||
#endif
|
||||
|
||||
//OpenEmu incluse OE input header
|
||||
#include "OpenEmuInput.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
|
||||
#include "OpenEmuInput.h"
|
||||
#ifdef CIFACE_USE_WIN32
|
||||
#include "InputCommon/ControllerInterface/Win32/Win32.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XLIB
|
||||
#include "InputCommon/ControllerInterface/Xlib/XInput2.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
#include "InputCommon/ControllerInterface/OSX/OSX.h"
|
||||
#include "InputCommon/ControllerInterface/Quartz/Quartz.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
#include "InputCommon/ControllerInterface/SDL/SDL.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_ANDROID
|
||||
#include "InputCommon/ControllerInterface/Android/Android.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_EVDEV
|
||||
#include "InputCommon/ControllerInterface/evdev/evdev.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_PIPES
|
||||
#include "InputCommon/ControllerInterface/Pipes/Pipes.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DUALSHOCKUDPCLIENT
|
||||
#include "InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.h"
|
||||
#endif
|
||||
|
||||
ControllerInterface g_controller_interface;
|
||||
|
||||
@@ -28,10 +57,39 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi)
|
||||
|
||||
m_is_populating_devices = true;
|
||||
|
||||
Input::Openemu_Input_Init();
|
||||
#ifdef CIFACE_USE_WIN32
|
||||
ciface::Win32::Init(wsi.render_window);
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XLIB
|
||||
// nothing needed
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
if (m_wsi.type == WindowSystemType::MacOS)
|
||||
ciface::OSX::Init(wsi.render_window);
|
||||
// nothing needed for Quartz
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
ciface::SDL::Init();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_ANDROID
|
||||
// nothing needed
|
||||
#endif
|
||||
#ifdef CIFACE_USE_EVDEV
|
||||
ciface::evdev::Init();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_PIPES
|
||||
// nothing needed
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DUALSHOCKUDPCLIENT
|
||||
ciface::DualShockUDPClient::Init();
|
||||
#endif
|
||||
|
||||
//OpenEmu initalize OpenEmu Input
|
||||
Input::Openemu_Input_Init();
|
||||
|
||||
RefreshDevices();
|
||||
|
||||
//OpenEmu set populating devices to false
|
||||
m_is_populating_devices = false;
|
||||
}
|
||||
|
||||
@@ -40,7 +98,8 @@ void ControllerInterface::ChangeWindow(void* hwnd)
|
||||
if (!m_is_init)
|
||||
return;
|
||||
|
||||
m_wsi.render_surface = hwnd;
|
||||
// This shouldn't use render_surface so no need to update it.
|
||||
m_wsi.render_window = hwnd;
|
||||
RefreshDevices();
|
||||
}
|
||||
|
||||
@@ -49,6 +108,49 @@ void ControllerInterface::RefreshDevices()
|
||||
if (!m_is_init)
|
||||
return;
|
||||
|
||||
//OpenEmu comment out this section so we can maintain our controller input
|
||||
// {
|
||||
// std::lock_guard lk(m_devices_mutex);
|
||||
// m_devices.clear();
|
||||
// }
|
||||
|
||||
m_is_populating_devices = true;
|
||||
|
||||
// Make sure shared_ptr<Device> objects are released before repopulating.
|
||||
InvokeDevicesChangedCallbacks();
|
||||
|
||||
#ifdef CIFACE_USE_WIN32
|
||||
ciface::Win32::PopulateDevices(m_wsi.render_window);
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XLIB
|
||||
if (m_wsi.type == WindowSystemType::X11)
|
||||
ciface::XInput2::PopulateDevices(m_wsi.render_window);
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
if (m_wsi.type == WindowSystemType::MacOS)
|
||||
{
|
||||
ciface::OSX::PopulateDevices(m_wsi.render_window);
|
||||
ciface::Quartz::PopulateDevices(m_wsi.render_window);
|
||||
}
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
ciface::SDL::PopulateDevices();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_ANDROID
|
||||
ciface::Android::PopulateDevices();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_EVDEV
|
||||
ciface::evdev::PopulateDevices();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_PIPES
|
||||
ciface::Pipes::PopulateDevices();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DUALSHOCKUDPCLIENT
|
||||
ciface::DualShockUDPClient::PopulateDevices();
|
||||
#endif
|
||||
|
||||
WiimoteReal::ProcessWiimotePool();
|
||||
|
||||
m_is_populating_devices = false;
|
||||
InvokeDevicesChangedCallbacks();
|
||||
}
|
||||
@@ -63,7 +165,7 @@ void ControllerInterface::Shutdown()
|
||||
m_is_init = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||
std::lock_guard lk(m_devices_mutex);
|
||||
|
||||
for (const auto& d : m_devices)
|
||||
{
|
||||
@@ -79,6 +181,28 @@ void ControllerInterface::Shutdown()
|
||||
// BEFORE we shutdown the backends.
|
||||
InvokeDevicesChangedCallbacks();
|
||||
|
||||
#ifdef CIFACE_USE_WIN32
|
||||
ciface::Win32::DeInit();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XLIB
|
||||
// nothing needed
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
ciface::OSX::DeInit();
|
||||
ciface::Quartz::DeInit();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
ciface::SDL::DeInit();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_ANDROID
|
||||
// nothing needed
|
||||
#endif
|
||||
#ifdef CIFACE_USE_EVDEV
|
||||
ciface::evdev::Shutdown();
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DUALSHOCKUDPCLIENT
|
||||
ciface::DualShockUDPClient::DeInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device)
|
||||
@@ -88,7 +212,7 @@ void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
|
||||
return;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||
std::lock_guard lk(m_devices_mutex);
|
||||
|
||||
const auto is_id_in_use = [&device, this](int id) {
|
||||
return std::any_of(m_devices.begin(), m_devices.end(), [&device, &id](const auto& d) {
|
||||
@@ -124,7 +248,7 @@ void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
|
||||
void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::Device*)> callback)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||
std::lock_guard lk(m_devices_mutex);
|
||||
auto it = std::remove_if(m_devices.begin(), m_devices.end(), [&callback](const auto& dev) {
|
||||
if (callback(dev.get()))
|
||||
{
|
||||
@@ -146,12 +270,27 @@ void ControllerInterface::UpdateInput()
|
||||
// Don't block the UI or CPU thread (to avoid a short but noticeable frame drop)
|
||||
if (m_devices_mutex.try_lock())
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_devices_mutex, std::adopt_lock);
|
||||
std::lock_guard lk(m_devices_mutex, std::adopt_lock);
|
||||
for (const auto& d : m_devices)
|
||||
d->UpdateInput();
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerInterface::SetAspectRatioAdjustment(float value)
|
||||
{
|
||||
m_aspect_ratio_adjustment = value;
|
||||
}
|
||||
|
||||
Common::Vec2 ControllerInterface::GetWindowInputScale() const
|
||||
{
|
||||
const auto ar = m_aspect_ratio_adjustment.load();
|
||||
|
||||
if (ar > 1)
|
||||
return {1.f, ar};
|
||||
else
|
||||
return {1 / ar, 1.f};
|
||||
}
|
||||
|
||||
// Register a callback to be called when a device is added or removed (as from the input backends'
|
||||
// hotplug thread), or when devices are refreshed
|
||||
// Returns a handle for later removing the callback.
|
||||
|
||||
Reference in New Issue
Block a user