Пример #1
0
def read (blocking=True):
	"""
		Reads all the Devices' device nodes for input.
		This will block until one of the devices has some input.
	"""
	global _allInputNodes
	devices = _allInputNodes
	if blocking:
		timeout = None
	else:
		timeout = 0
	readable, writable, exceptional = select.select(devices.keys(), [], [], timeout)
	events = []
	for dev in readable:
		events.extend(devices[dev].read(dev))
	
	return events
Пример #2
0
def read(blocking=True):
    """
		Reads all the Devices' device nodes for input.
		This will block until one of the devices has some input.
	"""
    global _allInputNodes
    devices = _allInputNodes
    if blocking:
        timeout = None
    else:
        timeout = 0
    readable, writable, exceptional = select.select(devices.keys(), [], [],
                                                    timeout)
    events = []
    for dev in readable:
        events.extend(devices[dev].read(dev))

    return events
Пример #3
0
def read (timeout=None):
	"""
		Reads all the Devices' device nodes for input.
		If the timeout parameter is None or absent, the read will block
		until it receives something. Otherwise it will block only for a
		maximum of the specified number of seconds. Use a timeout of 0 for
		an immediate return.
	"""
	global _allInputNodes
	devices = _allInputNodes
	try:
		readable, writable, exceptional = select.select(devices.keys(), [], [], timeout)
	except select.error:
		# Quite likely an interrupting signal
		readable, writable, exceptional = [], [], []
	
	events = []
	for dev in readable:
		events.extend(devices[dev].read(dev))
	
	return events
Пример #4
0
def read (timeout=None):
	"""
		Reads all the Devices' device nodes for input.
		If the timeout parameter is None or absent, the read will block
		until it receives something. Otherwise it will block only for a
		maximum of the specified number of seconds. Use a timeout of 0 for
		an immediate return.
	"""
	global _allInputNodes
	devices = _allInputNodes
	try:
		readable, writable, exceptional = select.select(devices.keys(), [], [], timeout)
	except select.error:
		# Quite likely an interrupting signal
		readable, writable, exceptional = [], [], []
	
	events = []
	for dev in readable:
		events.extend(devices[dev].read(dev))
	
	return events
Пример #5
0
    def process(self):
        """
			Relay queued-up input events to this Device's output object.
			Returns a list of the event objects which were sent.
		"""
        relay = self._relayCombo

        events = []
        for cycle, iterator in self._queue.items():
            if len(iterator.sequence) == 1:
                combo = iterator.next()

                if combo:
                    if cycle in self._starting:
                        # We haven't started with this key yet, or it has
                        # a specific value (eg. KEYUP!)
                        # Combo timings are only relevent to implicit KEYUPs
                        downCombo = self._removeComboDelays(combo)
                        value = combo.value
                        if value is None:
                            value = const.KEYDOWN
                        events.extend(relay(downCombo, value))

                    # This isn't an elif because, for example,
                    # remaps from EV_REL are instantaneous.
                    # We don't KEYUP if the combo has a specific value.
                    if combo.value is None and cycle in self._ending:
                        events.extend(
                            relay(tuple(reversed(combo)), const.KEYUP))

                    # These are done with, whatever
                    self._starting.discard(cycle)
                    self._ending.discard(cycle)

                # Unitary sequences don't repeat
                del (self._queue[cycle])

            else:
                # If a sequence is more than one element long, we loop it.
                try:
                    combo = iterator.next()
                except StopIteration:
                    # It's over. Let it go. Move on.
                    del (self._queue[cycle])
                    self._ending.discard(cycle)
                    continue

                if combo:
                    # combo (when it's not None) is a tuple of keypresses,
                    # Combo timings are only relevent to KEYUPs
                    downCombo = self._removeComboDelays(combo)
                    value = combo.value
                    if value is None:
                        value = const.KEYDOWN
                    events.extend(relay(downCombo, value))
                    if combo.value is None:
                        # Unvalued combos are KEYUPped
                        events.extend(
                            relay(tuple(reversed(combo)), const.KEYUP))

        return events
Пример #6
0
	def process (self, target=None):
		"""
			Relay queued-up input events to another device object, either
			the passed-in target parameter, or the output object specified
			on init.
			Returns a list of the event objects which were sent.
		"""
		relay = self._relayCombo
		
		if target is None:
			target = self._outputNode
		
		events = []
		for cycle, iterator in self._queue.items():
			if len(iterator.sequence) == 1:
				combo = iterator.next()
				
				if combo:
					value = combo.value
					
					if cycle in self._starting:
						# We haven't started with this key yet
						# Combo timings are only relevent to KEYUPs
						downCombo = self._removeComboDelays(combo)
						if value is None:
							value = const.KEYDOWN
						events.extend(relay(downCombo, value, target))
						self._starting.discard(cycle)
						
						# So we can immediately KEYUP if we need to
						value = None
					
					# This isn't an elif because, for example,
					# remaps from EV_REL are instantaneous.
					# We don't KEYUP if the combo has a specific value.
					if not value and cycle in self._ending:
						# This combo is done with
						## We shouldn't do this for ->ABS remappings.
						## Nor for REL, but that doesn't matter so much.
						events.extend(relay(tuple(reversed(combo)), const.KEYUP, target))
						self._ending.discard(cycle)
						
					
				
				# Unitary sequences don't repeat
				del(self._queue[cycle])
				
			else:
				# If a sequence is more than one element long, we loop it.
				try:
					combo = iterator.next()
				except StopIteration:
					# It's over. Let it go. Move on.
					del(self._queue[cycle])
					self._ending.discard(cycle)
					continue
				
				if combo:
					# combo (when it's not None) is a tuple of keypresses,
					# Combo timings are only relevent to KEYUPs
					downCombo = self._removeComboDelays(combo)
					value = combo.value
					if value is None:
						value = const.KEYDOWN
					events.extend(relay(downCombo, value, target))
					if value is not None:
						events.extend(relay(tuple(reversed(combo)), const.KEYUP, target))
					
			
		return events
Пример #7
0
	def process (self):
		"""
			Relay queued-up input events to this Device's output object.
			Returns a list of the event objects which were sent.
		"""
		relay = self._relayCombo
		
		events = []
		for cycle, iterator in self._queue.items():
			if len(iterator.sequence) == 1:
				combo = iterator.next()
				
				if combo:
					if cycle in self._starting:
						# We haven't started with this key yet, or it has
						# a specific value (eg. KEYUP!)
						# Combo timings are only relevent to implicit KEYUPs
						downCombo = self._removeComboDelays(combo)
						value = combo.value
						if value is None:
							value = const.KEYDOWN
						events.extend(relay(downCombo, value))
						
					
					# This isn't an elif because, for example,
					# remaps from EV_REL are instantaneous.
					# We don't KEYUP if the combo has a specific value.
					if combo.value is None and cycle in self._ending:
						events.extend(relay(tuple(reversed(combo)), const.KEYUP))
					
					# These are done with, whatever
					self._starting.discard(cycle)
					self._ending.discard(cycle)
					
				
				# Unitary sequences don't repeat
				del(self._queue[cycle])
				
			else:
				# If a sequence is more than one element long, we loop it.
				try:
					combo = iterator.next()
				except StopIteration:
					# It's over. Let it go. Move on.
					del(self._queue[cycle])
					self._ending.discard(cycle)
					continue
				
				if combo:
					# combo (when it's not None) is a tuple of keypresses,
					# Combo timings are only relevent to KEYUPs
					downCombo = self._removeComboDelays(combo)
					value = combo.value
					if value is None:
						value = const.KEYDOWN
					events.extend(relay(downCombo, value))
					if combo.value is None:
						# Unvalued combos are KEYUPped
						events.extend(relay(tuple(reversed(combo)), const.KEYUP))
					
			
		return events
Пример #8
0
    def process(self, target=None):
        """
			Relay queued-up input events to another device object, either
			the passed-in target parameter, or the output object specified
			on init.
			Returns a list of the event objects which were sent.
		"""
        relay = self._relayCombo

        if target is None:
            target = self._outputNode

        events = []
        for cycle, iterator in self._queue.items():
            if len(iterator.sequence) == 1:
                combo = iterator.next()

                if combo:
                    value = combo.value

                    if cycle in self._starting:
                        # We haven't started with this key yet
                        # Combo timings are only relevent to KEYUPs
                        downCombo = self._removeComboDelays(combo)
                        if value is None:
                            value = const.KEYDOWN
                        events.extend(relay(downCombo, value, target))
                        self._starting.discard(cycle)

                        # So we can immediately KEYUP if we need to
                        value = None

                    # This isn't an elif because, for example,
                    # remaps from EV_REL are instantaneous.
                    # We don't KEYUP if the combo has a specific value.
                    if not value and cycle in self._ending:
                        # This combo is done with
                        ## We shouldn't do this for ->ABS remappings.
                        ## Nor for REL, but that doesn't matter so much.
                        events.extend(
                            relay(tuple(reversed(combo)), const.KEYUP, target))
                        self._ending.discard(cycle)

                # Unitary sequences don't repeat
                del (self._queue[cycle])

            else:
                # If a sequence is more than one element long, we loop it.
                try:
                    combo = iterator.next()
                except StopIteration:
                    # It's over. Let it go. Move on.
                    del (self._queue[cycle])
                    self._ending.discard(cycle)
                    continue

                if combo:
                    # combo (when it's not None) is a tuple of keypresses,
                    # Combo timings are only relevent to KEYUPs
                    downCombo = self._removeComboDelays(combo)
                    value = combo.value
                    if value is None:
                        value = const.KEYDOWN
                    events.extend(relay(downCombo, value, target))
                    if value is not None:
                        events.extend(
                            relay(tuple(reversed(combo)), const.KEYUP, target))

        return events