Sfoglia il codice sorgente

Merge pull request #461 from bslack/next

Next
Sean Paul Taylor 13 anni fa
parent
commit
756a0ebbc0
1 ha cambiato i file con 13 aggiunte e 4 eliminazioni
  1. 13 4
      gameplay/src/PlatformMacOSX.mm

+ 13 - 4
gameplay/src/PlatformMacOSX.mm

@@ -362,7 +362,8 @@ double getMachTimeInMilliseconds()
 }
 - (NSNumber*)locationID
 {
-    return (NSNumber*)IOHIDDeviceGetProperty([self rawDevice], CFSTR(kIOHIDLocationIDKey));
+    NSNumber *n = (NSNumber*)IOHIDDeviceGetProperty([self rawDevice], CFSTR(kIOHIDLocationIDKey));
+    return [NSNumber numberWithUnsignedInt:[n unsignedIntValue]];
 }
 
 - (void)initializeGamepadElements
@@ -1280,9 +1281,17 @@ Platform::Platform(Game* game)
     IOHIDManagerRegisterDeviceMatchingCallback(__hidManagerRef, hidDeviceDiscoveredCallback, NULL);
     IOHIDManagerRegisterDeviceRemovalCallback(__hidManagerRef, hidDeviceRemovalCallback, NULL);
     
-    CFDictionaryRef matchingCFDictRef = IOHIDCreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
-    if (matchingCFDictRef) IOHIDManagerSetDeviceMatching(__hidManagerRef, matchingCFDictRef);
-    CFRelease(matchingCFDictRef);
+    CFDictionaryRef matchingJoystickCFDictRef = IOHIDCreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
+    CFDictionaryRef matchingGamepadCFDictRef = IOHIDCreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
+    CFMutableArrayRef matchingDicts = CFArrayCreateMutable(kCFAllocatorDefault, 2, NULL);
+    CFArrayAppendValue(matchingDicts, matchingJoystickCFDictRef);
+    CFArrayAppendValue(matchingDicts, matchingGamepadCFDictRef);
+
+    if (matchingDicts) IOHIDManagerSetDeviceMatchingMultiple(__hidManagerRef, matchingDicts);
+    
+    CFRelease(matchingJoystickCFDictRef);
+    CFRelease(matchingGamepadCFDictRef);
+    CFRelease(matchingDicts);
     
     IOHIDManagerScheduleWithRunLoop(__hidManagerRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     IOReturn kr = IOHIDManagerOpen(__hidManagerRef, kIOHIDOptionsTypeNone);