Gamepad
Read gamepads and joysticks plugged into the computer ARCx runs on: the sticks and triggers as axes, the buttons, the hat (d-pad), motion sensors and battery, and make them rumble. Controller 0 is the first one plugged in. Standard names such as "LeftX" or "A" work for gamepads; the raw commands read any joystick by number.
Where to find it: type Gamepad. in a Python script, or open the ARCx API view of the script editor and expand Gamepad
Commands
| Command | What it does |
|---|---|
| Gamepad.GetAccelerometer | [x, y, z] in m/s², gravity included. |
| Gamepad.GetAxis | Sticks -1 to 1 (up and left are negative), triggers 0 to 1 |
| Gamepad.GetAxisNames | Lists the axis names the axis commands accept: the X and Y of each stick and the two triggers. |
| Gamepad.GetBattery | 0 to 100, or -1 when the controller does not say |
| Gamepad.GetButton | True while the button is held |
| Gamepad.GetButtonNames | Lists the button names the button commands accept. |
| Gamepad.GetControllerType | "Xbox", "PS5", "Switch Pro", "Joystick" and so on |
| Gamepad.GetCount | How many controllers are connected |
| Gamepad.GetGyro | [x, y, z] in radians per second. |
| Gamepad.GetHat | "Centered", "Up", "UpRight", "Right", "DownRight", "Down", "DownLeft", "Left" or "UpLeft" |
| Gamepad.GetHatCount | Gets how many hats (the 8-way thumb switches on joysticks) the first controller has. |
| Gamepad.GetName | Gets the name of the first controller. |
| Gamepad.GetNames | The names of the connected controllers, in index order |
| Gamepad.GetRawAxis | -1 to 1 |
| Gamepad.GetRawAxisCount | Gets how many raw axes the first controller has. |
| Gamepad.GetRawButton | Checks whether a raw button on the first controller is held down, by number. |
| Gamepad.GetRawButtonCount | Gets how many raw buttons the first controller has. |
| Gamepad.IsConnected | Checks whether the first controller is plugged in. |
| Gamepad.IsGamepad | False for flight sticks, wheels and unrecognized controllers, which only have raw axes and buttons |
| Gamepad.Rumble | Rumble at a strength of 0 to 1 for the milliseconds given |
| Gamepad.RumbleMotors | Rumble the heavy (low) and light (high) motors separately, 0 to 1 each. |
| Gamepad.SetLED | Set the light bar colour (0 to 255 each) on controllers that have one |
| Gamepad.StopRumble | Stops the first controller rumbling straight away. |
| Gamepad.WaitForButton | Wait for the button to be pressed. |
Details
Gamepad.GetAccelerometer
[x, y, z] in m/s², gravity included. Turns the sensors on at the first call
Gamepad.GetAccelerometer()
Gamepad.GetAccelerometer(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: list[float]. [x, y, z] for the first controller. Zeros on the very first read, or when it is not plugged in or has no motion sensors.
Gamepad.GetAxis
Sticks -1 to 1 (up and left are negative), triggers 0 to 1
Gamepad.GetAxis(axisName)
Gamepad.GetAxis(axisName, index)
| Value | Type | What it is |
|---|---|---|
axisName |
str | The axis name, such as LeftX, LeftY, RightX, RightY, LeftTrigger or RightTrigger. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: float. The axis value on the first controller, or 0 when it is not plugged in.
Gamepad.GetAxisNames
Lists the axis names the axis commands accept: the X and Y of each stick and the two triggers. Trigger aliases such as LT, R2 and ZR work too.
Gamepad.GetAxisNames()
Gives back: list[str]. The axis names.
Gamepad.GetBattery
0 to 100, or -1 when the controller does not say
Gamepad.GetBattery()
Gamepad.GetBattery(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: int. The first controller's battery percent, or -1 when unknown or not plugged in.
Gamepad.GetButton
True while the button is held
Gamepad.GetButton(buttonName)
Gamepad.GetButton(buttonName, index)
| Value | Type | What it is |
|---|---|---|
buttonName |
str | The button name, such as A, B, South, LB, Start or DPadUp. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the button is held down on the first controller; not when it is not plugged in.
Gamepad.GetButtonNames
Lists the button names the button commands accept. The Xbox letters and common aliases such as A, LB and Up work too.
Gamepad.GetButtonNames()
Gives back: list[str]. The button names.
Gamepad.GetControllerType
"Xbox", "PS5", "Switch Pro", "Joystick" and so on
Gamepad.GetControllerType()
Gamepad.GetControllerType(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: str. The type of the first controller, or empty text when it is not plugged in.
Gamepad.GetCount
How many controllers are connected
Gamepad.GetCount()
Gives back: int. The number of controllers plugged in.
Gamepad.GetGyro
[x, y, z] in radians per second. Turns the sensors on at the first call
Gamepad.GetGyro()
Gamepad.GetGyro(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: list[float]. [x, y, z] for the first controller. Zeros on the very first read, or when it is not plugged in or has no motion sensors.
Gamepad.GetHat
"Centered", "Up", "UpRight", "Right", "DownRight", "Down", "DownLeft", "Left" or "UpLeft"
Gamepad.GetHat(hatIndex)
Gamepad.GetHat(hatIndex, index)
| Value | Type | What it is |
|---|---|---|
hatIndex |
int | Which hat, counting from 0. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: str. The direction the hat on the first controller is pushed, or Centered when the hat or controller does not exist.
Gamepad.GetHatCount
Gets how many hats (the 8-way thumb switches on joysticks) the first controller has.
Gamepad.GetHatCount()
Gamepad.GetHatCount(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: int. The number of hats, or 0 when it is not plugged in.
Gamepad.GetName
Gets the name of the first controller. Empty when no controller is plugged in.
Gamepad.GetName()
Gamepad.GetName(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: str. The controller name, or empty text.
Gamepad.GetNames
The names of the connected controllers, in index order
Gamepad.GetNames()
Gives back: list[str]. The controller names, one per connected controller.
Gamepad.GetRawAxis
-1 to 1
Gamepad.GetRawAxis(axisIndex)
Gamepad.GetRawAxis(axisIndex, index)
| Value | Type | What it is |
|---|---|---|
axisIndex |
int | Which raw axis, counting from 0. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: float. The axis value on the first controller, or 0 when the axis or controller does not exist.
Gamepad.GetRawAxisCount
Gets how many raw axes the first controller has. Raw inputs are for joysticks and other controllers that are not recognized gamepads.
Gamepad.GetRawAxisCount()
Gamepad.GetRawAxisCount(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: int. The number of raw axes, or 0 when it is not plugged in.
Gamepad.GetRawButton
Checks whether a raw button on the first controller is held down, by number. For joysticks and other controllers without named buttons.
Gamepad.GetRawButton(buttonIndex)
Gamepad.GetRawButton(buttonIndex, index)
| Value | Type | What it is |
|---|---|---|
buttonIndex |
int | Which raw button, counting from 0. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the button is held; not when the button or controller does not exist.
Gamepad.GetRawButtonCount
Gets how many raw buttons the first controller has.
Gamepad.GetRawButtonCount()
Gamepad.GetRawButtonCount(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: int. The number of raw buttons, or 0 when it is not plugged in.
Gamepad.IsConnected
Checks whether the first controller is plugged in. Other commands read 0 or nothing from a missing controller instead of failing, so check this when it matters.
Gamepad.IsConnected()
Gamepad.IsConnected(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the controller is connected.
Gamepad.IsGamepad
False for flight sticks, wheels and unrecognized controllers, which only have raw axes and buttons
Gamepad.IsGamepad()
Gamepad.IsGamepad(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the first controller is a recognized gamepad with named sticks and buttons.
Gamepad.Rumble
Rumble at a strength of 0 to 1 for the milliseconds given
Gamepad.Rumble(strength, durationMs)
Gamepad.Rumble(strength, durationMs, index)
| Value | Type | What it is |
|---|---|---|
strength |
float | How strong, from 0 (off) to 1 (full). |
durationMs |
int | How long to rumble in milliseconds, up to 60000. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the first controller started rumbling; not when it is not plugged in or cannot rumble.
Gamepad.RumbleMotors
Rumble the heavy (low) and light (high) motors separately, 0 to 1 each. Its own name rather than a Rumble() overload, because rumble(0.5, 0.5, 300) would otherwise mean strength 0.5 for half a millisecond on controller 300
Gamepad.RumbleMotors(lowStrength, highStrength, durationMs)
Gamepad.RumbleMotors(lowStrength, highStrength, durationMs, index)
| Value | Type | What it is |
|---|---|---|
lowStrength |
float | Strength of the heavy (low) motor, from 0 to 1. |
highStrength |
float | Strength of the light (high) motor, from 0 to 1. |
durationMs |
int | How long to rumble in milliseconds, up to 60000. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the first controller started rumbling; not when it is not plugged in or cannot rumble.
Gamepad.SetLED
Set the light bar colour (0 to 255 each) on controllers that have one
Gamepad.SetLED(red, green, blue)
Gamepad.SetLED(red, green, blue, index)
| Value | Type | What it is |
|---|---|---|
red |
int | Red brightness, 0 to 255. |
green |
int | Green brightness, 0 to 255. |
blue |
int | Blue brightness, 0 to 255. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the colour was set on the first controller; not when it is not plugged in or has no light.
Gamepad.StopRumble
Stops the first controller rumbling straight away.
Gamepad.StopRumble()
Gamepad.StopRumble(index)
| Value | Type | What it is |
|---|---|---|
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether it worked; not when the controller is not plugged in or cannot rumble.
Gamepad.WaitForButton
Wait for the button to be pressed. True when it was, false on timeout or disconnect. A button already held does not count until it is pressed again
Gamepad.WaitForButton(buttonName)
Gamepad.WaitForButton(buttonName, timeoutMs)
Gamepad.WaitForButton(buttonName, timeoutMs, index)
| Value | Type | What it is |
|---|---|---|
buttonName |
str | The button name, such as A, B, South, LB, Start or DPadUp. |
timeoutMs |
int | Optional. The longest to wait in milliseconds. 0 or less waits with no limit. |
index |
int | Optional. Which controller, 0 being the first one plugged in. |
Gives back: bool. Whether the button on the first controller was pressed. Waits with no time limit.