def from_xml(self, node): """Populates the object with data from an XML node. :param node the XML node to parse for data """ self.comparison = safe_read(node, "comparison") self.scan_code = safe_read(node, "scan_code", int) self.is_extended = profile.parse_bool(safe_read(node, "extended"))
def from_xml(self, node): """Populates the virtual button based on the node's data. :param node the node containing data for this instance """ self.lower_limit = safe_read(node, "lower-limit", float) self.upper_limit = safe_read(node, "upper-limit", float) self.direction = common.AxisButtonDirection.to_enum( safe_read(node, "direction", default_value="anywhere"))
def _parse_xml(self, node): """Reads the contents of an XML node to populate this instance. :param node the node whose content should be used to populate this instance """ self.axis = safe_read(node, "axis", default_value="x") self.min_speed = safe_read(node, "min-speed", int, 5) self.max_speed = safe_read(node, "max-speed", int, 5) self.acceleration = safe_read(node, "acceleration", float, 0.0)
def from_xml(self, node): """Extracts activation condition data from an XML node. :param node the XML node to parse """ self.rule = ActivationCondition.rule_lookup[safe_read(node, "rule")] for cond_node in node.findall("condition"): input_type = safe_read(cond_node, "input") condition = ActivationCondition.condition_lookup[input_type]() condition.from_xml(cond_node) self.conditions.append(condition)
def _parse_xml(self, node): """Populates the data storage with data from the XML node. :param node XML node with which to populate the storage """ try: if "axis" in node.attrib: self.input_type = InputType.JoystickAxis self.vjoy_input_id = safe_read(node, "axis", int) elif "button" in node.attrib: self.input_type = InputType.JoystickButton self.vjoy_input_id = safe_read(node, "button", int) elif "hat" in node.attrib: self.input_type = InputType.JoystickHat self.vjoy_input_id = safe_read(node, "hat", int) elif "keyboard" in node.attrib: self.input_type = InputType.Keyboard self.vjoy_input_id = safe_read(node, "button", int) else: raise gremlin.error.GremlinError( "Invalid remap type provided: {}".format(node.attrib)) self.vjoy_device_id = safe_read(node, "vjoy", int) if self.get_input_type() == InputType.JoystickAxis and \ self.input_type == InputType.JoystickAxis: self.axis_mode = safe_read(node, "axis-type", str, "absolute") self.axis_scaling = safe_read(node, "axis-scaling", float, 1.0) except ProfileError: self.vjoy_input_id = None self.vjoy_device_id = None
def _parse_xml(self, node): """Reads the contents of an XML node to populate this instance. :param node the node whose content should be used to populate this instance """ self.motion_input = read_bool(node, "motion_input", False) try: self.button_id = gremlin.common.MouseButton( safe_read(node, "button_id", int, 1)) except ValueError as e: logging.getLogger("system").warning( "Invalid mouse identifier in profile: {:}".format(e)) self.button_id = gremlin.common.MouseButton.Left self.direction = safe_read(node, "direction", int, 0) self.min_speed = safe_read(node, "min-speed", int, 5) self.max_speed = safe_read(node, "max-speed", int, 5) self.time_to_max_speed = safe_read(node, "time-to-max-speed", float, 0.0)
def from_xml(self, node): """Populates the object with data from an XML node. :param node the XML node to parse for data """ self.comparison = safe_read(node, "comparison") self.input_type = profile.tag_to_input_type(safe_read(node, "input")) self.input_id = safe_read(node, "id", int) self.device_id = safe_read(node, "device_id", int) self.windows_id = safe_read(node, "windows_id", int) self.device_name = safe_read(node, "device_name") if self.input_type == common.InputType.JoystickAxis: self.range = [ safe_read(node, "range_low", float), safe_read(node, "range_high", float) ]
def from_xml(self, node): """Populates the object with data from an XML node. :param node the XML node to parse for data """ self.comparison = safe_read(node, "comparison") self.input_type = common.InputType.to_enum(safe_read(node, "input")) self.input_id = safe_read(node, "id", int) self.device_guid = parse_guid(node.get("device-guid")) self.device_name = safe_read(node, "device-name") if self.input_type == common.InputType.JoystickAxis: self.range = [ safe_read(node, "range-low", float), safe_read(node, "range-high", float) ]
def from_xml(self, node): """Populates the object with data from an XML node. Parameters ========== node : ElementTree.Element XML node to parse for data """ self.comparison = safe_read(node, "comparison") self.input_type = common.InputType.to_enum(safe_read(node, "input")) self.input_id = safe_read(node, "id", int) self.vjoy_id = safe_read(node, "vjoy-id", int) if self.input_type == common.InputType.JoystickAxis: self.range = [ safe_read(node, "range-low", float), safe_read(node, "range-high", float) ]
def from_xml(self, node): """Populates the object with data from an XML node. :param node the XML node to parse for data """ self.comparison = safe_read(node, "comparison")
def _parse_xml(self, node): self.center_point = float(node.get("center-point")) self.device_low_vjoy_id = safe_read(node, "device-low-vjoy-id", int) self.device_high_vjoy_id = safe_read(node, "device-high-vjoy-id", int) self.device_low_axis = safe_read(node, "device-low-axis", int) self.device_high_axis = safe_read(node, "device-high-axis", int)