summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2016-06-12 17:08:04 +0200
committerLéo Lam <leo@innovatetechnologi.es>2016-06-25 13:46:53 +0200
commitfd29e5c4cc26cd853a03ac7b0e08b367b7070c84 (patch)
tree5fdf3f210fc09344c829d1fa4b63baa4a423d97e /Source/Core/InputCommon/ControllerInterface
parent8a1bbaa56382b1bca3b95d79c716fc377c78e591 (diff)
ControllerInterface: Don't pass m_devices to the backends
Previously, the devices vector would be passed to all backends. They would then manually push_back to it to add new devices. This was fine but caused issues when trying to add synchronisation. Instead, backends now call AddDevice() to fill m_devices so that it is not accessible from the outside.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Android/Android.cpp13
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Android/Android.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp23
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.h1
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp10
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInput.h3
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp5
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp5
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/OSX/OSX.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm16
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp5
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp5
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDL.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/XInput/XInput.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp6
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp5
-rw-r--r--Source/Core/InputCommon/ControllerInterface/evdev/evdev.h4
24 files changed, 69 insertions, 72 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp
index 3d68be633f..f6957e3ca1 100644
--- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp
@@ -4,21 +4,16 @@
#include "InputCommon/ControllerInterface/Android/Android.h"
#include <sstream>
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
namespace ciface
{
namespace Android
{
-void Init(std::vector<Core::Device*>& devices)
+void Init()
{
- devices.push_back(new Touchscreen(0));
- devices.push_back(new Touchscreen(1));
- devices.push_back(new Touchscreen(2));
- devices.push_back(new Touchscreen(3));
- devices.push_back(new Touchscreen(4));
- devices.push_back(new Touchscreen(5));
- devices.push_back(new Touchscreen(6));
- devices.push_back(new Touchscreen(7));
+ for (int i = 0; i < 8; ++i)
+ g_controller_interface.AddDevice(new Touchscreen(i));
}
// Touchscreens and stuff
diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.h b/Source/Core/InputCommon/ControllerInterface/Android/Android.h
index 53b578f699..29cc16d7ef 100644
--- a/Source/Core/InputCommon/ControllerInterface/Android/Android.h
+++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.h
@@ -4,14 +4,14 @@
#pragma once
-#include "InputCommon/ControllerInterface/Device.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "jni/ButtonManager.h"
namespace ciface
{
namespace Android
{
-void Init(std::vector<Core::Device*>& devices);
+void Init();
class Touchscreen : public Core::Device
{
private:
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 55643ece5f..c139d3b787 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -55,31 +55,31 @@ void ControllerInterface::Initialize(void* const hwnd)
m_hwnd = hwnd;
#ifdef CIFACE_USE_DINPUT
- ciface::DInput::Init(m_devices, (HWND)hwnd);
+ ciface::DInput::Init((HWND)hwnd);
#endif
#ifdef CIFACE_USE_XINPUT
- ciface::XInput::Init(m_devices);
+ ciface::XInput::Init();
#endif
#ifdef CIFACE_USE_XLIB
- ciface::Xlib::Init(m_devices, hwnd);
+ ciface::Xlib::Init(hwnd);
#ifdef CIFACE_USE_X11_XINPUT2
- ciface::XInput2::Init(m_devices, hwnd);
+ ciface::XInput2::Init(hwnd);
#endif
#endif
#ifdef CIFACE_USE_OSX
- ciface::OSX::Init(m_devices, hwnd);
+ ciface::OSX::Init(hwnd);
#endif
#ifdef CIFACE_USE_SDL
- ciface::SDL::Init(m_devices);
+ ciface::SDL::Init();
#endif
#ifdef CIFACE_USE_ANDROID
- ciface::Android::Init(m_devices);
+ ciface::Android::Init();
#endif
#ifdef CIFACE_USE_EVDEV
- ciface::evdev::Init(m_devices);
+ ciface::evdev::Init();
#endif
#ifdef CIFACE_USE_PIPES
- ciface::Pipes::Init(m_devices);
+ ciface::Pipes::Init();
#endif
m_is_init = true;
@@ -139,6 +139,11 @@ void ControllerInterface::Shutdown()
m_is_init = false;
}
+void ControllerInterface::AddDevice(ciface::Core::Device* device)
+{
+ m_devices.push_back(device);
+}
+
//
// UpdateInput
//
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
index 25154ede40..3d1354dcc7 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
@@ -121,6 +121,7 @@ public:
void Initialize(void* const hwnd);
void Reinitialize();
void Shutdown();
+ void AddDevice(ciface::Core::Device* device);
bool IsInit() const { return m_is_init; }
void UpdateReference(ControlReference* control,
const ciface::Core::DeviceQualifier& default_device) const;
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
index 09227b5932..83394852af 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
@@ -2,9 +2,9 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
-#include "Common/StringUtil.h"
-
#include "InputCommon/ControllerInterface/DInput/DInput.h"
+#include "Common/StringUtil.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/DInput/DInputJoystick.h"
#include "InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h"
@@ -44,7 +44,7 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
return result;
}
-void Init(std::vector<Core::Device*>& devices, HWND hwnd)
+void Init(HWND hwnd)
{
IDirectInput8* idi8;
if (FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8,
@@ -53,8 +53,8 @@ void Init(std::vector<Core::Device*>& devices, HWND hwnd)
return;
}
- InitKeyboardMouse(idi8, devices, hwnd);
- InitJoystick(idi8, devices, hwnd);
+ InitKeyboardMouse(idi8, hwnd);
+ InitJoystick(idi8, hwnd);
idi8->Release();
}
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h
index 2f5e2f83a7..94e4cb4fe3 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h
@@ -10,7 +10,6 @@
#include <windows.h>
#include "InputCommon/ControllerInterface/DInput/DInput8.h"
-#include "InputCommon/ControllerInterface/Device.h"
namespace ciface
{
@@ -21,6 +20,6 @@ BOOL CALLBACK DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVO
BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device);
-void Init(std::vector<Core::Device*>& devices, HWND hwnd);
+void Init(HWND hwnd);
}
}
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
index bf2c1f3e7e..ea059fde73 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
@@ -6,6 +6,7 @@
#include <map>
#include <sstream>
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/DInput/DInput.h"
#include "InputCommon/ControllerInterface/DInput/DInputJoystick.h"
#include "InputCommon/ControllerInterface/DInput/XInputFilter.h"
@@ -16,7 +17,7 @@ namespace DInput
{
#define DATA_BUFFER_SIZE 32
-void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND hwnd)
+void InitJoystick(IDirectInput8* const idi8, HWND hwnd)
{
std::list<DIDEVICEINSTANCE> joysticks;
idi8->EnumDevices(DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks,
@@ -60,7 +61,7 @@ void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices
Joystick* js = new Joystick(/*&*i, */ js_device, name_counts[joystick.tszInstanceName]++);
// only add if it has some inputs/outputs
if (js->Inputs().size() || js->Outputs().size())
- devices.push_back(js);
+ g_controller_interface.AddDevice(js);
else
delete js;
}
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h
index 9a14e910de..d66c28cfba 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h
@@ -11,7 +11,7 @@ namespace ciface
{
namespace DInput
{
-void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND hwnd);
+void InitJoystick(IDirectInput8* const idi8, HWND hwnd);
class Joystick : public ForceFeedback::ForceFeedbackDevice
{
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
index 92c8514825..3d9b692ba0 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
@@ -4,6 +4,7 @@
#include <algorithm>
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/DInput/DInput.h"
#include "InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h"
@@ -31,7 +32,7 @@ static const struct
// lil silly
static HWND m_hwnd;
-void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND _hwnd)
+void InitKeyboardMouse(IDirectInput8* const idi8, HWND _hwnd)
{
m_hwnd = _hwnd;
@@ -56,7 +57,7 @@ void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<Core::Device*>& de
if (SUCCEEDED(
mo_device->SetCooperativeLevel(nullptr, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
{
- devices.push_back(new KeyboardMouse(kb_device, mo_device));
+ g_controller_interface.AddDevice(new KeyboardMouse(kb_device, mo_device));
return;
}
}
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h
index 1ba9022f9d..38de8e219d 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h
@@ -13,7 +13,7 @@ namespace ciface
{
namespace DInput
{
-void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND _hwnd);
+void InitKeyboardMouse(IDirectInput8* const idi8, HWND _hwnd);
class KeyboardMouse : public Core::Device
{
diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.h b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.h
index c257d7e8f4..c2104774b7 100644
--- a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.h
+++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.h
@@ -4,13 +4,11 @@
#pragma once
-#include "InputCommon/ControllerInterface/Device.h"
-
namespace ciface
{
namespace OSX
{
-void Init(std::vector<Core::Device*>& devices, void* window);
+void Init(void* window);
void DeInit();
void DeviceElementDebugPrint(const void*, void*);
diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm
index 1335b01967..ea9723c6b9 100644
--- a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm
+++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm
@@ -6,6 +6,7 @@
#include <Foundation/Foundation.h>
#include <IOKit/hid/IOHIDLib.h>
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/OSX/OSX.h"
#include "InputCommon/ControllerInterface/OSX/OSXJoystick.h"
#include "InputCommon/ControllerInterface/OSX/OSXKeyboard.h"
@@ -140,22 +141,21 @@ static void DeviceMatching_callback(void* inContext, IOReturn inResult, void* in
DeviceDebugPrint(inIOHIDDeviceRef);
- std::vector<Core::Device*>* devices = (std::vector<Core::Device*>*)inContext;
-
- // Add to the devices vector if it's of a type we want
+ // Add a device if it's of a type we want
if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard))
- devices->push_back(new Keyboard(inIOHIDDeviceRef, name, kbd_name_counts[name]++, g_window));
+ g_controller_interface.AddDevice(
+ new Keyboard(inIOHIDDeviceRef, name, kbd_name_counts[name]++, g_window));
#if 0
else if (IOHIDDeviceConformsTo(inIOHIDDeviceRef,
kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse))
- devices->push_back(new Mouse(inIOHIDDeviceRef,
+ g_controller_interface.AddDevice(new Mouse(inIOHIDDeviceRef,
name, mouse_name_counts[name]++));
#endif
else
- devices->push_back(new Joystick(inIOHIDDeviceRef, name, joy_name_counts[name]++));
+ g_controller_interface.AddDevice(new Joystick(inIOHIDDeviceRef, name, joy_name_counts[name]++));
}
-void Init(std::vector<Core::Device*>& devices, void* window)
+void Init(void* window)
{
HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
if (!HIDManager)
@@ -166,7 +166,7 @@ void Init(std::vector<Core::Device*>& devices, void* window)
IOHIDManagerSetDeviceMatching(HIDManager, nullptr);
// Callbacks for acquisition or loss of a matching device
- IOHIDManagerRegisterDeviceMatchingCallback(HIDManager, DeviceMatching_callback, (void*)&devices);
+ IOHIDManagerRegisterDeviceMatchingCallback(HIDManager, DeviceMatching_callback, nullptr);
// Match devices that are plugged in right now
IOHIDManagerScheduleWithRunLoop(HIDManager, CFRunLoopGetCurrent(), OurRunLoop);
diff --git a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
index 95bdcc4da2..fc89d8a1e6 100644
--- a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
@@ -17,6 +17,7 @@
#include "Common/FileUtil.h"
#include "Common/MathUtil.h"
#include "Common/StringUtil.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Pipes/Pipes.h"
namespace ciface
@@ -40,7 +41,7 @@ static double StringToDouble(const std::string& text)
return result;
}
-void Init(std::vector<Core::Device*>& devices)
+void Init()
{
// Search the Pipes directory for files that we can open in read-only,
// non-blocking mode. The device name is the virtual name of the file.
@@ -60,7 +61,7 @@ void Init(std::vector<Core::Device*>& devices)
int fd = open(child.physicalName.c_str(), O_RDONLY | O_NONBLOCK);
if (fd < 0)
continue;
- devices.push_back(new PipeDevice(fd, child.virtualName, found++));
+ g_controller_interface.AddDevice(new PipeDevice(fd, child.virtualName, found++));
}
}
diff --git a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h
index 855c45953b..66ce56ff1c 100644
--- a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h
+++ b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h
@@ -8,8 +8,6 @@
#include <string>
#include <vector>
-#include "InputCommon/ControllerInterface/Device.h"
-
namespace ciface
{
namespace Pipes
@@ -24,7 +22,7 @@ namespace Pipes
// SET {L, R} [0, 1]
// SET {MAIN, C} [0, 1] [0, 1]
-void Init(std::vector<Core::Device*>& devices);
+void Init();
class PipeDevice : public Core::Device
{
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
index 8b87261480..870f0387d7 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
@@ -7,6 +7,7 @@
#include <sstream>
#include "Common/StringUtil.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/SDL/SDL.h"
#ifdef _WIN32
@@ -32,7 +33,7 @@ static std::string GetJoystickName(int index)
#endif
}
-void Init(std::vector<Core::Device*>& devices)
+void Init()
{
// this is used to number the joysticks
// multiple joysticks with the same name shall get unique ids starting at 0
@@ -60,7 +61,7 @@ void Init(std::vector<Core::Device*>& devices)
Joystick* js = new Joystick(dev, i, name_counts[GetJoystickName(i)]++);
// only add if it has some inputs/outputs
if (js->Inputs().size() || js->Outputs().size())
- devices.push_back(js);
+ g_controller_interface.AddDevice(js);
else
delete js;
}
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h
index 10c3fab6ee..746eb20b8e 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h
@@ -8,8 +8,6 @@
#include <SDL.h>
-#include "InputCommon/ControllerInterface/Device.h"
-
#if SDL_VERSION_ATLEAST(1, 3, 0)
#define USE_SDL_HAPTIC
#endif
@@ -22,7 +20,7 @@ namespace ciface
{
namespace SDL
{
-void Init(std::vector<Core::Device*>& devices);
+void Init();
class Joystick : public Core::Device
{
diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
index d7ed3343a0..982764d4b4 100644
--- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
@@ -50,7 +50,7 @@ static XInputGetState_t PXInputGetState = nullptr;
static bool haveGuideButton = false;
-void Init(std::vector<Core::Device*>& devices)
+void Init()
{
if (!hXInput)
{
@@ -89,7 +89,7 @@ void Init(std::vector<Core::Device*>& devices)
XINPUT_CAPABILITIES caps;
for (int i = 0; i != 4; ++i)
if (ERROR_SUCCESS == PXInputGetCapabilities(i, 0, &caps))
- devices.push_back(new Device(caps, i));
+ g_controller_interface.AddDevice(new Device(caps, i));
}
void DeInit()
diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h
index 204b1ecf81..e4a047d53c 100644
--- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h
+++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h
@@ -12,7 +12,7 @@
#include <XInput.h>
#include <windows.h>
-#include "InputCommon/ControllerInterface/Device.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
#error You are building this module against the wrong version of DirectX. You probably need to remove DXSDK_DIR from your include path and/or _WIN32_WINNT is wrong.
@@ -22,7 +22,7 @@ namespace ciface
{
namespace XInput
{
-void Init(std::vector<Core::Device*>& devices);
+void Init();
void DeInit();
class Device : public Core::Device
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
index 79b86a487d..d46f1cf4f6 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
@@ -46,7 +46,7 @@ namespace ciface
namespace XInput2
{
// This function will add zero or more KeyboardMouse objects to devices.
-void Init(std::vector<Core::Device*>& devices, void* const hwnd)
+void Init(void* const hwnd)
{
Display* dpy = XOpenDisplay(nullptr);
@@ -78,8 +78,8 @@ void Init(std::vector<Core::Device*>& devices, void* const hwnd)
if (current_master->use == XIMasterPointer)
// Since current_master is a master pointer, its attachment must
// be a master keyboard.
- devices.push_back(new KeyboardMouse((Window)hwnd, xi_opcode, current_master->deviceid,
- current_master->attachment));
+ g_controller_interface.AddDevice(new KeyboardMouse(
+ (Window)hwnd, xi_opcode, current_master->deviceid, current_master->attachment));
}
XCloseDisplay(dpy);
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
index e8f2e2e06b..10499ea22c 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
@@ -12,13 +12,13 @@ extern "C" {
#include <X11/keysym.h>
}
-#include "InputCommon/ControllerInterface/Device.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
namespace ciface
{
namespace XInput2
{
-void Init(std::vector<Core::Device*>& devices, void* const hwnd);
+void Init(void* const hwnd);
class KeyboardMouse : public Core::Device
{
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.cpp
index 71269c74f7..a7d94bbcd0 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.cpp
@@ -11,9 +11,9 @@ namespace ciface
{
namespace Xlib
{
-void Init(std::vector<Core::Device*>& devices, void* const hwnd)
+void Init(void* const hwnd)
{
- devices.push_back(new KeyboardMouse((Window)hwnd));
+ g_controller_interface.AddDevice(new KeyboardMouse((Window)hwnd));
}
KeyboardMouse::KeyboardMouse(Window window) : m_window(window)
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.h b/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.h
index 94388211c0..18e5bad635 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.h
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/Xlib.h
@@ -7,13 +7,13 @@
#include <X11/Xlib.h>
#include <X11/keysym.h>
-#include "InputCommon/ControllerInterface/Device.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
namespace ciface
{
namespace Xlib
{
-void Init(std::vector<Core::Device*>& devices, void* const hwnd);
+void Init(void* const hwnd);
class KeyboardMouse : public Core::Device
{
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
index 7a6ba50713..5da77e585a 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
@@ -9,6 +9,7 @@
#include "Common/Assert.h"
#include "Common/Logging/Log.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/evdev/evdev.h"
namespace ciface
@@ -31,7 +32,7 @@ static std::string GetName(const std::string& devnode)
return res;
}
-void Init(std::vector<Core::Device*>& controllerDevices)
+void Init()
{
// this is used to number the joysticks
// multiple joysticks with the same name shall get unique ids starting at 0
@@ -71,7 +72,7 @@ void Init(std::vector<Core::Device*>& controllerDevices)
if (input->IsInteresting())
{
- controllerDevices.push_back(input);
+ g_controller_interface.AddDevice(input);
num_controllers++;
}
else
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
index ce7831bfdc..36c25cb42b 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
@@ -8,13 +8,11 @@
#include <string>
#include <vector>
-#include "InputCommon/ControllerInterface/Device.h"
-
namespace ciface
{
namespace evdev
{
-void Init(std::vector<Core::Device*>& devices);
+void Init();
class evdevDevice : public Core::Device
{