User Input > Gamepad


Read our guide on Gamepads before consulting this reference.


Gamepad

Map Button to Control

map button text to control control

Binds a physical button on the gamepad to a Stencyl control. Each model of controller has different names for its buttons, so you must either let the user configure their controls or discover those names.

Input.mapJoystickButton([TEXT], [CONTROL]);

Example (for XBox 360 Controller)

example

Read our guide on Gamepads for an explanation.


Unmap Button

unmap button text

Unbinds a gamepad button from its current control.

Input.unmapJoystickButton([TEXT]);

Unmap Control

unmap all buttons for control control

Unbinds all gamepad buttons for a given control.

Input.unmapJoystickFromControl([CONTROL]);

Set Analog Sensitivity

set analog sensitivity to number %

Sets the deadzone for an analog button (usually a joystick), so that a small tilt doesn't get interpreted as actions. Defaults to 0. Provide a value between [0-100], inclusive, where 0 means that any amount of tilt/press will be detected and 100 effectively disables the button.

Input.setJoySensitivity([NUMBER] / 100);

Get Pressure for Control

get pressure for control control

Gets the pressure for a given control as a value between 0 and 1, inclusive, where 0 means no tilt/press and 1 means full tilt/press. Assumes that said control is an analog control (such as joystick), not a digital control like a regular button.

Input.getButtonPressure([CONTROL])

Save / Load Gamepad Configuration

save gamepad configuration to text
load gamepad configuration from text

Players using a less common controller will need to manually configure their controller during the game. This block lets you save and load those mappings, so they don't have to repeat the process each time they play your game. The name provided is a virtual filename. For most cases, it doesn't matter what you put in.

Input.saveJoystickConfig([TEXT]);
Input.loadJoystickConfig([TEXT]);