🧪 Version 0.3.1 is our alpha release candidate. Please send us bug reports and suggestions!

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Reference for on_state_change

Set callback for when the state of a joystick trigger changes. This is part of the reference section.

Purpose

Register a callback for when the state of a "discrete input" on a joystick-like device changes. These "triggers" include hats and push buttons.

Snippet

Register a callback for when the state of a trigger changes on the first joystick.
def print_trigger(trigger):
print(trigger.get_name())

joysticks = sketch.get_joysticks()
first_joystick = joysticks[0]
button = first_joystick.get_trigger('button0')
button.on_state_change(print_trigger)

Parameters

  • callback: Function to call with the trigger when the state changes.

Availability

Not yet available. Planned for future release.

See also