summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/OSX
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/OSX
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/OSX')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/OSX/OSX.h4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm16
2 files changed, 9 insertions, 11 deletions
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);