Reference for on_state_change
Set callback for when the state of a joystick trigger changes. This is part of the reference section.
Arc
Buffer
Data
Dialog
Ellipse
Geo Utils
Image
Joystick (future)
on_state_change
Keyboard
Line
Mouse / Touchscreen
Pixel
Rectangle
Renderers
Shape
Sound (future)
Style
System
Text
Transform
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.