def __call__(self, event): """Executes the callback based on the event's content. Creates a Value object from the event and passes the two through the execution graph until every entry has run or it is aborted. """ if event.event_type in [ common.InputType.JoystickAxis, common.InputType.JoystickHat ]: value = actions.Value(event.value) elif event.event_type in [ common.InputType.JoystickButton, common.InputType.Keyboard, common.InputType.VirtualButton ]: value = actions.Value(event.is_pressed) else: raise error.GremlinError("Invalid event type") # Containers representing a virtual button get their individual # value instance, all others share one to propagate changes across shared_value = copy.deepcopy(value) if event == common.InputType.VirtualButton: # TODO: remove this at a future stage logging.getLogger("system").error( "Virtual button code path being used") else: self.execution_graph.process_event(event, shared_value)
def __call__(self, event): """Executes the container's content when called. :param event the event triggering the callback """ self._execution_graph.process_event(event, actions.Value(event.is_pressed))