ControllerState["c"]
gives the state of the control c for the first connected controller device on which it is supported.
ControllerState[{"c1","c2",…}]
gives the states of several controls.
ControllerState[id,"c"]
gives the state of control c for controller devices with the specified identifier.
ControllerState[id,{"c1","c2",…}]
gives the states of several controls for several controller devices.
ControllerState
ControllerState["c"]
gives the state of the control c for the first connected controller device on which it is supported.
ControllerState[{"c1","c2",…}]
gives the states of several controls.
ControllerState[id,"c"]
gives the state of control c for controller devices with the specified identifier.
ControllerState[id,{"c1","c2",…}]
gives the states of several controls for several controller devices.
Details and Options
- Dynamic[ControllerState[…]] gives continually updated current controller states.
- Typical control names include:
-
"X" or "X1" x primary
value "Y" or "Y1" y primary
value"Z" or "Z1" z primary
value"XY" or "XY1" {x,y} primary 2-axis controller value "XYZ" or "XYZ1" {x,y,z} primary 3-axis controller value "X2", "Y2", "XY2", etc. x, y, {x,y}, etc. values from a secondary controller "B1", "B2", etc. b1, b2, etc. button states - The following special control names are also possible:
-
"Axes" a list of all supported axis-like controls "Buttons" a list of all supported button-like controls "Controls" a list of all supported controls "Hardware" information on the controller device hardware "Mapping" rules for Wolfram System mappings of controls "Rules" rules for the settings of all controls - ControllerState always gives absolute instantaneous control states; it does not give relative or cyclic control states of the type available in Manipulate.
- If no explicit controller identifier id is given, the controller used will be the first one found on the list specified by the option ControllerPath that supports all the controls "ci" requested.
- Identifiers for controllers can be the following:
-
"name" device name from ControllerInformation "class" device class specifier n raw device index from ControllerInformation All all devices supporting the requested controls - Possible device class identifiers include:
-
"Gamepad" controller typically including two analog controls "Joystick" controller typically including one primary analog control "Detachable" controller not built into a computer "BuiltIn" controller built into a computer - If a requested control value is not available, ControllerState returns $Failed for that value.
Examples
open all close allBasic Examples (1)
Scope (3)
Acquire a list of all button controls supported by the device:
ControllerState["Buttons"]Specify which controller type should be used:
Dynamic[ControllerState["Gamepad", "B1"]]If no device of that type is attached, $Failed is returned:
Dynamic[ControllerState["Joystick", "B1"]]Get multiple values at once for a given controller type:
ControllerState["Joystick", {"X1", "X2", "X3"}]Options (1)
ControllerPath (1)
If multiple controllers are attached, specify the order of control sampling:
Dynamic[ControllerState["B1", ControllerPath -> {"Gamepad", "Joystick"}]]By default, controls are sampled in the following order:
Dynamic[ControllerState["B1", ControllerPath -> {"Gamepad", "Joystick", "Detachable", 1}]]Properties & Relations (3)
The controls for Manipulate are automatically linked to a controller:
Manipulate[Graphics[{Thick, If[c, Red, Blue], Cases[Plot[a * Sin[b * x], {x, 0, 2Pi}, PlotRange -> {-2, 2}], _Line, Infinity]}], {a, 1, 3}, {b, 1, 4}, {c, {True, False}}]Bind x to the X controller when your selection contains the output:
Dynamic[If[CurrentValue["SelectionOver"], x = ControllerState["X"]];x]ControllerInformation can be used to find a device name:
ControllerInformation[]Dynamic[ControllerState["Logitech Dual Action", "B1"]]Tech Notes
Related Workflows
- Control Interactive Content with a Gamepad
History
Text
Wolfram Research (2007), ControllerState, Wolfram Language function, https://reference.wolfram.com/language/ref/ControllerState.html.
CMS
Wolfram Language. 2007. "ControllerState." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ControllerState.html.
APA
Wolfram Language. (2007). ControllerState. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ControllerState.html
BibTeX
@misc{reference.wolfram_2026_controllerstate, author="Wolfram Research", title="{ControllerState}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/ControllerState.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_controllerstate, organization={Wolfram Research}, title={ControllerState}, year={2007}, url={https://reference.wolfram.com/language/ref/ControllerState.html}, note=[Accessed: 13-June-2026]}