示例#1
0
    def invalidate(self):
        """Releases all resources claimed by this instance.

        Releases the lock on the vjoy device instance as well as terminating
        the keep alive timer.
        """
        if self.vjoy_id:
            self.reset()
            VJoyInterface.RelinquishVJD(self.vjoy_id)
            self.vjoy_id = None
            self._keep_alive_timer.cancel()
示例#2
0
def device_available(vjoy_id):
    """Returns whether or not a device is available, i.e. can be acquired.

    :param vjoy_id id of the vjoy device to check
    :return True if the device is available, False otherwise
    """
    dev_free = VJoyInterface.GetVJDStatus(vjoy_id) == VJoyState.Free.value
    dev_acquire = VJoyInterface.AcquireVJD(vjoy_id)
    VJoyInterface.RelinquishVJD(vjoy_id)

    return dev_free & dev_acquire