Commit 34a52528 authored by Sam Lantinga's avatar Sam Lantinga

Date: Thu, 12 Sep 2002 20:35:51 -0400

From: Darrell Walisser
Subject: Jag joystick fix (take 2)

This patch enables all HID devices, not just joysticks. This quell
complaints about gamepads not working, though I don't have I gamepad to
verify this theory.

Before, only joysticks were recognized. Now, all HID devices except the
keyboard and mouse will be recognized.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40496
parent d81041f4
...@@ -571,8 +571,6 @@ int SDL_SYS_JoystickInit(void) ...@@ -571,8 +571,6 @@ int SDL_SYS_JoystickInit(void)
CFMutableDictionaryRef hidMatchDictionary = NULL; CFMutableDictionaryRef hidMatchDictionary = NULL;
recDevice *device, *lastDevice; recDevice *device, *lastDevice;
io_object_t ioHIDDeviceObject = NULL; io_object_t ioHIDDeviceObject = NULL;
UInt32 usagePage = kHIDPage_GenericDesktop;
UInt32 usage = kHIDUsage_GD_Joystick; /* We probably also should check for gamepads? */
SDL_numjoysticks = 0; SDL_numjoysticks = 0;
...@@ -591,15 +589,20 @@ int SDL_SYS_JoystickInit(void) ...@@ -591,15 +589,20 @@ int SDL_SYS_JoystickInit(void)
/* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */ /* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */
hidMatchDictionary = IOServiceMatching (kIOHIDDeviceKey); hidMatchDictionary = IOServiceMatching (kIOHIDDeviceKey);
if ((hidMatchDictionary != NULL) && (usagePage) && (usage)) if ((hidMatchDictionary != NULL))
{ {
/* Add key for device type (joystick, in this case) to refine the matching dictionary. */ /* Add key for device type (joystick, in this case) to refine the matching dictionary. */
/* NOTE: we now perform this filtering later
UInt32 usagePage = kHIDPage_GenericDesktop;
UInt32 usage = kHIDUsage_GD_Joystick;
CFNumberRef refUsage = NULL, refUsagePage = NULL; CFNumberRef refUsage = NULL, refUsagePage = NULL;
refUsage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usage); refUsage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usage);
CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsageKey), refUsage); CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsageKey), refUsage);
refUsagePage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usagePage); refUsagePage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usagePage);
CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage); CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage);
*/
} }
else else
{ {
...@@ -638,6 +641,18 @@ int SDL_SYS_JoystickInit(void) ...@@ -638,6 +641,18 @@ int SDL_SYS_JoystickInit(void)
result = IOObjectRelease (ioHIDDeviceObject); result = IOObjectRelease (ioHIDDeviceObject);
// if (KERN_SUCCESS != result) // if (KERN_SUCCESS != result)
// HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result); // HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
/* Filter device list to non-keyboard/mouse stuff */
if ( device->usagePage == kHIDPage_GenericDesktop &&
(device->usage == kHIDUsage_GD_Keyboard ||
device->usage == kHIDUsage_GD_Mouse)) {
/* release memory for the device */
HIDDisposeDevice (&device);
DisposePtr((Ptr)device);
continue;
}
/* Add device to the end of the list */ /* Add device to the end of the list */
if (lastDevice) if (lastDevice)
lastDevice->pNext = device; lastDevice->pNext = device;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment