Exemple #1
0
void SecPointerBase::assign(SecCFObject * p)
{
	if (p && !p->isNew())
	{
		CFRetain(p->operator CFTypeRef());
	}
	if (ptr)
	{
		CheckForRelease(ptr);
		CFRelease(ptr->operator CFTypeRef());
	}
	ptr = p;
}
Exemple #2
0
SecPointerBase& SecPointerBase::operator = (const SecPointerBase& p)
{
	if (p.ptr)
	{
		CFTypeRef tr = p.ptr->operator CFTypeRef();
		CFRetain(tr);
	}
	if (ptr)
	{
		CheckForRelease(ptr);
		CFRelease(ptr->operator CFTypeRef());
	}
	ptr = p.ptr;
	return *this;
}
Exemple #3
0
SecPointerBase::~SecPointerBase()
{
	if (ptr)
	{
		CheckForRelease(ptr);
		CFRelease(ptr->operator CFTypeRef());
	}
}
Exemple #4
0
SecPointerBase::SecPointerBase(SecCFObject *p)
{
	if (p && !p->isNew())
	{
		CFRetain(p->operator CFTypeRef());
	}
	ptr = p;
}
Exemple #5
0
SecPointerBase::SecPointerBase(const SecPointerBase& p)
{
	if (p.ptr)
	{
		CFRetain(p.ptr->operator CFTypeRef());
	}
	ptr = p.ptr;
}
Exemple #6
0
static void CheckForRelease(SecCFObject* ptr)
{
	CFTypeRef tr = ptr->operator CFTypeRef();
	CFIndex retainCount = CFGetRetainCount(tr);
	if (retainCount == 1 || retainCount == -1)
	{
		ptr->aboutToDestruct();
	}
}
Exemple #7
0
void SecPointerBase::copy(SecCFObject * p)
{
	if (ptr)
	{
		CheckForRelease(ptr);
		CFRelease(ptr->operator CFTypeRef());
	}
	
	ptr = p;
}
Exemple #8
0
Color::operator CGColorRef()
{
	return	(CGColorRef)operator CFTypeRef();
}
Exemple #9
0
static void HIDGetElementsCFArrayHandler (const void * value, void * parameter)
{
	if (CFGetTypeID (value) != CFDictionaryGetTypeID ())
      return;

   CFTypeRef refElement = CFTypeRef(value);
	long elementType, usagePage, usage;
	CFTypeRef refElementType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementTypeKey));
	CFTypeRef refUsagePage = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementUsagePageKey));
	CFTypeRef refUsage = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementUsageKey));
   bool isButton = false, isAxis = false;

   ControllerElement *theElement = NULL;
	if ((refElementType) && (CFNumberGetValue (refElementType, kCFNumberLongType, &elementType)))
	{
		/* look at types of interest */
		if ((elementType == kIOHIDElementTypeInput_Misc) || (elementType == kIOHIDElementTypeInput_Button) ||
			(elementType == kIOHIDElementTypeInput_Axis))
		{
			if (refUsagePage && CFNumberGetValue (refUsagePage, kCFNumberLongType, &usagePage) &&
				refUsage && CFNumberGetValue (refUsage, kCFNumberLongType, &usage))
			{
				switch (usagePage) /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */
				{
					case kHIDPage_GenericDesktop:
						{
							switch (usage) /* look at usage to determine function */
							{
								case kHIDUsage_GD_X:
                           theElement = gController.axes + AxisX;
                           break;
								case kHIDUsage_GD_Y:
                           theElement = gController.axes + AxisY;
                           break;
								case kHIDUsage_GD_Z:
                           theElement = gController.axes + AxisZ;
                           break;
								case kHIDUsage_GD_Rx:
                           theElement = gController.axes + AxisRx;
                           break;
								case kHIDUsage_GD_Ry:
                           theElement = gController.axes + AxisRy;
                           break;
								case kHIDUsage_GD_Rz:
                           theElement = gController.axes + AxisRz;
                           break;
								case kHIDUsage_GD_Slider:
                           theElement = gController.axes + AxisSlider0;
                           break;
								case kHIDUsage_GD_Dial:
								case kHIDUsage_GD_Wheel:
   								break;
							}							
						}
						break;
					case kHIDPage_Button:
                  {
                     ControllerElement e;
                     gController.buttons.push_back(e);
                     theElement = &gController.buttons.last();
                  }
						break;
					default:
						break;
				}
			}
		}
		else if (kIOHIDElementTypeCollection == elementType)
      {
         CFTypeRef refElementTop = CFDictionaryGetValue ((CFMutableDictionaryRef) refElement, CFSTR(kIOHIDElementKey));
         if (refElementTop)
         {
            CFTypeID type = CFGetTypeID (refElementTop);
            if (type == CFArrayGetTypeID()) /* if element is an array */
            {
               CFRange range = {0, CFArrayGetCount (refElementTop)};
               /* CountElementsCFArrayHandler called for each array member */
               CFArrayApplyFunction (refElementTop, range, HIDGetElementsCFArrayHandler, NULL);
            }
         }
      }
	}
	if (theElement) /* add to list */
	{
	   long number;
	   CFTypeRef refType;

	   refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementCookieKey));
	   if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number))
		   theElement->cookie = (IOHIDElementCookie) number;
	   refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementMinKey));
	   if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number))
		   theElement->minValue = number;

      refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementMaxKey));

	   if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number))
		   theElement->maxValue = number;
	  logprintf("Cookie = %d min = %d max = %d", theElement->cookie, theElement->minValue, theElement->maxValue);
	}
}