This function can be used to set the "dead zone" of the joystick axis. You specify the device slot to set, and then set a value from 0 to 1 and if the input amount is lower than the given value, the joystick axis is considered to be at 0. Note that this is a global setting that will affect all axis of all joysticks connected to the device slot specified.
Using this function does not mean that the axis value will start from the deadzone value, as the function gamepad_axis_value() will always return a normalised value between -1 and 0 or 0 and 1. For example, setting the deadzone to 0.2 will mean that pushing the stick right will only start returning a value from 0 - 1 when the raw axis value is over 0.2 - so when the raw value is 0.2, the return value will be 0, when the raw value is at 0.5, the return value will be 0.375, or if the raw value is 0.9, then the return value would be 0.875.
gamepad_set_axis_deadzone(device, deadzone);
| Argument | Type | Description |
|---|---|---|
| device | Real | Which gamepad device "slot" to check. |
| deadzone | Real | The dead zone value from 0 to 1. |
N/A
if (async_load[? "event_type"] == "gamepad discovered")
{
var _pad = async_load[? "pad_index"];
gamepad_set_axis_deadzone(_pad, 0.2);
array_push(gamepads, _pad);
}
The above code runs in the Async System event and when a gamepad is discovered, it takes the pad index, sets its deadzone to 20% and pushes the pad index into an array.
This follows the Gamepad Movement example on Movement And Controls where the gamepads array is set up.