Joysticks

Introduced in 1.1.0

Simulation of a multi-mode joystick. There are three modes each applying a different constraint to the joystick movement displayed. they are -

  • 'X0' : stick can move in any direction (360°).
  • 'X4' : stick is constrained to the 4 main compass directions (N, E, S, W).
  • 'X4' : stick is constrained to the 8 main compass directions (N, NE, E, SE, S, SW, W, NW).
mode(md) Sets the joystick mode. Valid values are 'X0', 'X4' and 'X8', any other value is ignored.
If there is no parameter value then the current mode is returned.
thumbSize(size) Sets the thumb diameter for this joystick.

Unlike most of the other controls the joystick has no persistant value because the 'stick' will return to the rest state (centered) when released. To test for the current state the user should provide their own action-method using setAction.

When the joystick is moved with the mouse or touch event the current state is sent to the action-method so it can be processed by the sketch code. In the example below the table shows all the current state information available to the action-method.