Skip to content

Instantly share code, notes, and snippets.

@mantognini
Created December 24, 2011 15:17
Show Gist options
  • Select an option

  • Save mantognini/1517542 to your computer and use it in GitHub Desktop.

Select an option

Save mantognini/1517542 to your computer and use it in GitHub Desktop.
SFML2 joysticks patch
diff --git a/src/SFML/Window/OSX/HIDJoystickManager.cpp b/src/SFML/Window/OSX/HIDJoystickManager.cpp
index fcb9730..0b6bb68 100644
--- a/src/SFML/Window/OSX/HIDJoystickManager.cpp
+++ b/src/SFML/Window/OSX/HIDJoystickManager.cpp
@@ -75,10 +75,23 @@ HIDJoystickManager::HIDJoystickManager()
{
myHIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
- CFDictionaryRef mask = HIDInputManager::CopyDevicesMask(kHIDPage_GenericDesktop,
- kHIDUsage_GD_Joystick);
- IOHIDManagerSetDeviceMatching(myHIDManager, mask);
+ CFDictionaryRef mask0 = HIDInputManager::CopyDevicesMask(kHIDPage_GenericDesktop,
+ kHIDUsage_GD_Joystick);
+
+ CFDictionaryRef mask1 = HIDInputManager::CopyDevicesMask(kHIDPage_GenericDesktop,
+ kHIDUsage_GD_GamePad);
+
+ CFDictionaryRef maskArray[2];
+ maskArray[0] = mask0;
+ maskArray[1] = mask1;
+
+ CFArrayRef mask = CFArrayCreate(NULL, (const void**)maskArray, 2, NULL);
+
+ IOHIDManagerSetDeviceMatchingMultiple(myHIDManager, mask);
CFRelease(mask);
+ CFRelease(mask1);
+ CFRelease(mask0);
+
IOHIDManagerRegisterDeviceMatchingCallback(myHIDManager, pluggedIn, this);
IOHIDManagerRegisterDeviceRemovalCallback(myHIDManager, pluggedOut, this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment