BindJoystickButton
From Spheriki
Sets up scripts to run when a joystick button is pressed or released.
Contents |
[edit]
Usage
BindJoystickButton(joystick, button, on_button_down, on_button_up);
- joystick number, non-negative. Which joystick has the button you wish to bind.
- button number, non-negative. The button on the joystick to bind scripts to.
- on_button_down string, containing the JavaScript code to run when the button is pressed down.
- on_button_up string, containing the JavaScript code to run when the button is released.
[edit]
Examples
To set a variable run to the first button on the first joystick:
BindJoystickButton(0, 0, "run = true;", "run = false;");
[edit]
Notes
- The highest valid index for the
joystickparameter is GetNumJoysticks() - 1, while the highest valid index for thebuttonparameter is GetNumJoystickButtons(joystick) - 1.
- Most scripts in Sphere are checked when the engine starts up. However, the scripts in these strings will not be checked until they are encountered.
- To remove button script binding, use UnbindJoystickButton().
[edit]

