Ejemplo n.º 1
0
 def stop_input(self, device_name=None):
     """Stop reading from the input device."""
     if device_name:
         for d in readers.devices():
             if d.name == device_name:
                 d.close()
     else:
         for d in readers.devices():
             d.close()
Ejemplo n.º 2
0
    def start_input(self, device_name, config_name=None):
        """
        Start reading input from the device with name device_name using config
        config_name. Returns True if device supports mapping, otherwise False
        """
        try:
            #device_id = self._available_devices[device_name]
            # Check if we supplied a new map, if not use the preferred one
            for d in readers.devices():
                if d.name == device_name:
                    self._input_device = d
                    if not config_name:
                        config_name = self.get_saved_device_mapping(
                            device_name)
                    self.set_input_map(device_name, config_name)
                    self._input_device.open()
                    self._input_device.input_map = self._input_map
                    self._input_device.input_map_name = config_name
                    self._selected_mux.add_device(self._input_device, None)
                    # Update the UI with the limiting for this device
                    self.limiting_updated.call(self._input_device.limit_rp,
                                               self._input_device.limit_yaw,
                                               self._input_device.limit_thrust)
                    self._read_timer.start()
                    return self._input_device.supports_mapping
        except Exception:
            self.device_error.call(
                "Error while opening/initializing  input device\n\n%s" %
                (traceback.format_exc()))

        if not self._input_device:
            self.device_error.call(
                "Could not find device {}".format(device_name))
        return False
Ejemplo n.º 3
0
    def available_devices(self):
        """List all available and approved input devices.
        This function will filter available devices by using the
        blacklist configuration and only return approved devices."""
        devs = readers.devices()
        devs += interfaces.devices()
        approved_devs = []

        for dev in devs:
            if ((not self._dev_blacklist)
                    or (self._dev_blacklist
                        and not self._dev_blacklist.match(dev.name))):
                approved_devs.append(dev)

        return approved_devs
Ejemplo n.º 4
0
    def enableRawReading(self, device_name):
        """
        Enable raw reading of the input device with id deviceId. This is used
        to get raw values for setting up of input devices. Values are read
        without using a mapping.
        """
        if self._input_device:
            self._input_device.close()
            self._input_device = None

        for d in readers.devices():
            if d.name == device_name:
                self._input_device = d

        # Set the mapping to None to get raw values
        self._input_device.input_map = None
        self._input_device.open()