def _create_control(properties): type = get_property(properties, 'Type') if type not in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis, kIOHIDElementTypeInput_Button): return cookie = get_property(properties, 'ElementCookie') usage_page = get_property(properties, 'UsagePage') usage = get_property(properties, 'Usage') raw_name = get_property(properties, 'Name') if not raw_name: raw_name = '%d:%d' % (usage_page, usage) if type in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis): name = _axis_names.get((usage_page, usage)) relative = get_property(properties, 'IsRelative') if relative: control = RelativeAxis(name, raw_name) else: min = get_property(properties, 'Min') max = get_property(properties, 'Max') control = AbsoluteAxis(name, min, max, raw_name) elif type == kIOHIDElementTypeInput_Button: name = _button_names.get((usage_page, usage)) control = Button(name, raw_name) else: return control._cookie = cookie return control
def _create_control(properties): type = get_property(properties, 'Type') if type not in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis, kIOHIDElementTypeInput_Button): return cookie = get_property(properties, 'ElementCookie') usage_page = get_property(properties, 'UsagePage') usage = get_property(properties, 'Usage') raw_name = get_property(properties, 'Name') if not raw_name: raw_name = '%d:%d' % (usage_page, usage) if type in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis): name = _axis_names.get((usage_page, usage)) relative = get_property(properties, 'IsRelative') if relative: control = RelativeAxis(name, raw_name) else: min = get_property(properties, 'Min') max = get_property(properties, 'Max') control = AbsoluteAxis(name, min, max, raw_name) elif type == kIOHIDElementTypeInput_Button: name = _button_names.get((usage_page, usage)) control = Button(name, raw_name) else: return control._cookie = cookie return control
def _create_control(properties): type = get_property(properties, "Type") if type not in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis, kIOHIDElementTypeInput_Button): return cookie = get_property(properties, "ElementCookie") usage_page = get_property(properties, "UsagePage") usage = get_property(properties, "Usage") raw_name = get_property(properties, "Name") if not raw_name: raw_name = "%d:%d" % (usage_page, usage) if type in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis): name = _axis_names.get((usage_page, usage)) relative = get_property(properties, "IsRelative") if relative: control = RelativeAxis(name, raw_name) else: min = get_property(properties, "Min") max = get_property(properties, "Max") control = AbsoluteAxis(name, min, max, raw_name) elif type == kIOHIDElementTypeInput_Button: name = _button_names.get((usage_page, usage)) control = Button(name, raw_name) else: return control._cookie = cookie return control
def _create_controls(self): self._controls = {} for element in self.device.elements: raw_name = element.name or "0x%x:%x" % (element.usagePage, element.usage) if element.type in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis): name = _axis_names.get((element.usagePage, element.usage)) if element.isRelative: control = RelativeAxis(name, raw_name) else: control = AbsoluteAxis(name, element.logicalMin, element.logicalMax, raw_name) elif element.type == kIOHIDElementTypeInput_Button: name = _button_names.get((element.usagePage, element.usage)) control = Button(name, raw_name) else: continue control._cookie = element.cookie self._controls[control._cookie] = control
def _create_controls(self): self._controls = {} for element in self.device.elements: raw_name = element.name or '0x%x:%x' % (element.usagePage, element.usage) if element.type in (kIOHIDElementTypeInput_Misc, kIOHIDElementTypeInput_Axis): name = _axis_names.get((element.usagePage, element.usage)) if element.isRelative: control = RelativeAxis(name, raw_name) else: control = AbsoluteAxis(name, element.logicalMin, element.logicalMax, raw_name) elif element.type == kIOHIDElementTypeInput_Button: name = _button_names.get((element.usagePage, element.usage)) control = Button(name, raw_name) else: continue control._cookie = element.cookie self._controls[control._cookie] = control