src/joystick/darwin/SDL_sysjoystick.c
changeset 475 429fe382fe4f
parent 427 027ae30b867f
child 495 4503f9475cf2
equal deleted inserted replaced
474:583a07ab5444 475:429fe382fe4f
    40 #include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
    40 #include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
    41 #endif
    41 #endif
    42 #include <IOKit/hid/IOHIDLib.h>
    42 #include <IOKit/hid/IOHIDLib.h>
    43 #include <IOKit/hid/IOHIDKeys.h>
    43 #include <IOKit/hid/IOHIDKeys.h>
    44 #include <CoreFoundation/CoreFoundation.h>
    44 #include <CoreFoundation/CoreFoundation.h>
       
    45 #include <Carbon/Carbon.h> /* for NewPtrClear, DisposePtr */
    45 
    46 
    46 #include "SDL_error.h"
    47 #include "SDL_error.h"
    47 #include "SDL_joystick.h"
    48 #include "SDL_joystick.h"
    48 #include "SDL_sysjoystick.h"
    49 #include "SDL_sysjoystick.h"
    49 #include "SDL_joystick_c.h"
    50 #include "SDL_joystick_c.h"
   593 	if ((hidMatchDictionary != NULL) && (usagePage) && (usage))
   594 	if ((hidMatchDictionary != NULL) && (usagePage) && (usage))
   594 	{
   595 	{
   595 		/* Add key for device type (joystick, in this case) to refine the matching dictionary. */
   596 		/* Add key for device type (joystick, in this case) to refine the matching dictionary. */
   596 		CFNumberRef refUsage = NULL, refUsagePage = NULL;
   597 		CFNumberRef refUsage = NULL, refUsagePage = NULL;
   597 
   598 
   598 		refUsage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usagePage);
   599 		refUsage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usage);
   599 		CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsageKey), refUsage);
   600 		CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsageKey), refUsage);
   600 		refUsagePage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usage);
   601 		refUsagePage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usagePage);
   601 		CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage);
   602 		CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage);
   602 	}
   603 	}
   603 	else
   604 	else
   604 	{
   605 	{
   605 		SDL_SetError("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching.");
   606 		SDL_SetError("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching.");