summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorMichael Maltese <michaeljosephmaltese@gmail.com>2017-04-15 19:23:19 -0700
committerMichael Maltese <michaeljosephmaltese@gmail.com>2017-04-15 19:34:42 -0700
commit5298328cb175a17eb9ea534a9d07dc57b42d2d42 (patch)
tree1a0bcdbc85ba3045cf0ff92fc7332ef9b15a5011 /Source/Core/InputCommon/ControllerInterface
parenta389ae0711142d8c5c996fda3d1e6c5731d71de3 (diff)
Add headless support on macOS
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm14
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm3
2 files changed, 14 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm
index 900fc29a70..948e2b85fa 100644
--- a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm
+++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm
@@ -173,13 +173,21 @@ static void DeviceMatchingCallback(void* inContext, IOReturn inResult, void* inS
// Add a device if it's of a type we want
if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard))
- g_controller_interface.AddDevice(std::make_shared<Keyboard>(inIOHIDDeviceRef, name, g_window));
+ {
+ if (g_window)
+ g_controller_interface.AddDevice(
+ std::make_shared<Keyboard>(inIOHIDDeviceRef, name, g_window));
+ }
#if 0
else if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse))
+ {
g_controller_interface.AddDevice(new Mouse(inIOHIDDeviceRef, name));
+ }
#endif
else
+ {
g_controller_interface.AddDevice(std::make_shared<Joystick>(inIOHIDDeviceRef, name));
+ }
NOTICE_LOG(SERIALINTERFACE, "Added device: %s", name.c_str());
g_controller_interface.InvokeHotplugCallbacks();
@@ -187,12 +195,12 @@ static void DeviceMatchingCallback(void* inContext, IOReturn inResult, void* inS
void Init(void* window)
{
+ g_window = window;
+
HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
if (!HIDManager)
ERROR_LOG(SERIALINTERFACE, "Failed to create HID Manager reference");
- g_window = window;
-
IOHIDManagerSetDeviceMatching(HIDManager, nullptr);
if (IOHIDManagerOpen(HIDManager, kIOHIDOptionsTypeNone) != kIOReturnSuccess)
ERROR_LOG(SERIALINTERFACE, "Failed to open HID Manager");
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
index a090b421a5..30802182a8 100644
--- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
+++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm
@@ -12,6 +12,9 @@ namespace Quartz
{
void PopulateDevices(void* window)
{
+ if (!window)
+ return;
+
g_controller_interface.AddDevice(std::make_shared<KeyboardAndMouse>(window));
}