Pages

Thursday, February 14, 2013

CFDictionary in a CFArray

Hi all.

 

I'm trying to follow the HIDManager documentation to setup some Joystick/Gampage code to my app.

In my obj-c class I have started two methods (see below).

 

The first is incomplete as I have hit a warning that I don't understand and wish to get rid of this :

 

Passing 'CFArrayRef' (aka 'const struct__CFArray *') to parameter of type 'CFMutableArrayRef' ( 'const struct__CFArray *') discards qualifiers.

 

What's that exactly mean and how would I rectify my code to remove the warning?

 

Cheers

Steve

 

 

- (void) openHardwareConnection

{

   

    HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);

 

    CFArrayRef matchingCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);

   

    CFDictionaryRef matchingCFDictRef = [self buildDeviceMatchingCFDictionaryRef : kHIDPage_GenericDesktop : kHIDUsage_GD_Joystick];

   

    CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);    // WARNING HERE

   

    matchingCFDictRef = [self buildDeviceMatchingCFDictionaryRef : kHIDPage_GenericDesktop : kHIDUsage_GD_GamePad];

   

    CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);    // WARNING HERE

       

    CFRelease(matchingCFDictRef);

   

    //...... more hid stuff to follow

   

   

}

 

 

 

- (CFMutableDictionaryRef) buildDeviceMatchingCFDictionaryRef : (UInt32) inUsagePage : (UInt32) inUsage

{

    // Create a dictionary to add usage page/usages to

   

    CFMutableDictionaryRef HIDDeviceMatchingCFDictionaryRef = CFDictionaryCreateMutable( kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );

   

    CFNumberRef pageCFNumberRef = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &inUsagePage );

           

    CFDictionarySetValue( HIDDeviceMatchingCFDictionaryRef, CFSTR(kIOHIDDeviceUsagePageKey), pageCFNumberRef );

               

    CFRelease(pageCFNumberRef);

 

    CFNumberRef usageCFNumberRef = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &inUsage );

                   

    CFDictionarySetValue(HIDDeviceMatchingCFDictionaryRef, CFSTR(kIOHIDDeviceUsageKey), usageCFNumberRef);

                       

    CFRelease(usageCFNumberRef);

                 

    return HIDDeviceMatchingCFDictionaryRef;

}


View the original article here

0 comments:

Post a Comment