Example #1
0
def test_addRemoveInputDevice(application):
    controller = Controller(application)
    input_device = InputDevice()
    input_device.setPluginId("input_device")
    controller.addInputDevice(input_device)
    controller.addInputDevice(input_device) # Doing it twice shouldn't cause issues.
    assert controller.getInputDevice("input_device") == input_device
    assert controller.getInputDevice("OMGZOMG") is None  # This device isn't added
    controller.removeInputDevice("input_device")
    assert controller.getInputDevice("input_device") is None
    controller.removeInputDevice("input_device") #Removing it again shouldn't cause issues.
Example #2
0
 def addInputDevice(self, device: InputDevice) -> None:
     name = device.getPluginId()
     if name not in self._input_devices:
         self._input_devices[name] = device
         device.event.connect(self.event)
     else:
         Logger.log("w", "%s was already added to input device list. Unable to add it again." % name)
Example #3
0
 def addInputDevice(self, device: InputDevice) -> None:
     name = device.getPluginId()
     if name not in self._input_devices:
         self._input_devices[name] = device
         device.event.connect(self.event)
     else:
         Logger.log("w", "%s was already added to input device list. Unable to add it again." % name)
Example #4
0
def test_addRemoveInputDevice(application):
    controller = Controller(application)

    input_device = InputDevice()
    input_device.setPluginId("input_device")

    controller.addInputDevice(input_device)
    controller.addInputDevice(input_device) # Doing it twice shouldn't cause issues.

    assert controller.getInputDevice("input_device") == input_device
    assert controller.getInputDevice("OMGZOMG") is None  # This device isn't added

    controller.removeInputDevice("input_device")
    assert controller.getInputDevice("input_device") is None

    controller.removeInputDevice("input_device") #Removing it again shouldn't cause issues.
Example #5
0
    def addInputDevice(self, device: InputDevice) -> None:
        """Add an input device (e.g. mouse, keyboard, etc) if it's not already added.

        :param device: The input device to be added
        """

        name = device.getId()
        if name not in self._input_devices:
            self._input_devices[name] = device
            device.event.connect(self.event)
        else:
            Logger.log("w", "%s was already added to input device list. Unable to add it again." % name)