Beispiel #1
0
 def __init__(self, elementRef):
     # Check that we've been passed a valid IOHIDElement.
     assert elementRef
     assert cf.CFGetTypeID(elementRef) == iokit.IOHIDElementGetTypeID()
     _element_lookup[elementRef.value] = self
     self.elementRef = elementRef
     # Set element properties as attributes.
     self.cookie = iokit.IOHIDElementGetCookie(elementRef)
     self.type = iokit.IOHIDElementGetType(elementRef)
     if self.type == kIOHIDElementTypeCollection:
         self.collectionType = iokit.IOHIDElementGetCollectionType(
             elementRef)
     else:
         self.collectionType = None
     self.usagePage = iokit.IOHIDElementGetUsagePage(elementRef)
     self.usage = iokit.IOHIDElementGetUsage(elementRef)
     self.isVirtual = bool(iokit.IOHIDElementIsVirtual(elementRef))
     self.isRelative = bool(iokit.IOHIDElementIsRelative(elementRef))
     self.isWrapping = bool(iokit.IOHIDElementIsWrapping(elementRef))
     self.isArray = bool(iokit.IOHIDElementIsArray(elementRef))
     self.isNonLinear = bool(iokit.IOHIDElementIsNonLinear(elementRef))
     self.hasPreferredState = bool(
         iokit.IOHIDElementHasPreferredState(elementRef))
     self.hasNullState = bool(iokit.IOHIDElementHasNullState(elementRef))
     self.name = cftype_to_value(iokit.IOHIDElementGetName(elementRef))
     self.reportID = iokit.IOHIDElementGetReportID(elementRef)
     self.reportSize = iokit.IOHIDElementGetReportSize(elementRef)
     self.reportCount = iokit.IOHIDElementGetReportCount(elementRef)
     self.unit = iokit.IOHIDElementGetUnit(elementRef)
     self.unitExponent = iokit.IOHIDElementGetUnitExponent(elementRef)
     self.logicalMin = iokit.IOHIDElementGetLogicalMin(elementRef)
     self.logicalMax = iokit.IOHIDElementGetLogicalMax(elementRef)
     self.physicalMin = iokit.IOHIDElementGetPhysicalMin(elementRef)
     self.physicalMax = iokit.IOHIDElementGetPhysicalMax(elementRef)
Beispiel #2
0
 def get_property(self, name):
     cfname = CFSTR(name)
     cfvalue = c_void_p(iokit.IOHIDDeviceGetProperty(
         self.deviceRef, cfname))
     cf.CFRelease(cfname)
     return cftype_to_value(cfvalue)