User Input > Gamepad


Read our guide on Gamepads before consulting this reference.


Gamepad

Enable Gamepad

enable-gamepad-block

Turns on the gamepad framework. Must be used before any gamepad functionality will work.

Input.enableJoystick();

Map Button to Control

map-gamepad-block

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.


Set Analog Sensitivity

analog-gamepad-block

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

pressure-gamepad-block

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

saveload-gamepad-block

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]);