({{, (RefLink[ControllerState, paclet:ref/ControllerState])["c"]
gives the state of the control c for the first connected controller device on which it is supported.}, {, (RefLink[ControllerState, paclet:ref/ControllerState])[{"(Subscript[c, 1])","(Subscript[c, 2])",…}]
gives the states of several controls.}, {, (RefLink[ControllerState, paclet:ref/ControllerState])[id,"c"]
gives the state of control c for controller devices with the specified identifier.}, {, (RefLink[ControllerState, paclet:ref/ControllerState])[id,{"(Subscript[c, 1])","(Subscript[c, 2])",…}]
gives the states of several controls for several controller devices.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[Dynamic, paclet:ref/Dynamic])[ControllerState[…]] gives continually updated current controller states.

Typical control names include:

The following special control names are also possible:

(RefLink[ControllerState, paclet:ref/ControllerState]) always gives absolute instantaneous control states; it does not give relative or cyclic control states of the type available in (RefLink[Manipulate, paclet:ref/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 (RefLink[ControllerPath, paclet:ref/ControllerPath]) that supports all the controls "(Subscript[c, i])" requested.

Identifiers for controllers can be the following:

Possible device class identifiers include:

If a requested control value is not available, (RefLink[ControllerState, paclet:ref/ControllerState]) returns (RefLink[$Failed, paclet:ref/$Failed]) for that value.

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Check the state of button 1:

Dynamic[ControllerState["B1"]]

Check multiple values at once:

Dynamic[ControllerState[{"XY","B1"}]]

OpenersExampleSection1(Spacer1)Scope  (2)

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, (RefLink[$Failed, paclet:ref/$Failed]) is returned:

Dynamic[ControllerState["Joystick","B1"]]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)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}]]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

The controls for (RefLink[Manipulate, paclet:ref/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]

(RefLink[ControllerInformation, paclet:ref/ControllerInformation]) can be used to find a device name:

ControllerInformation[]

Dynamic[ControllerState["Logitech Dual Action","B1"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ControllerInformation, paclet:ref/ControllerInformation])  ▪  (RefLink[MousePosition, paclet:ref/MousePosition])  ▪  (RefLink[ControllerManipulate, paclet:ref/ControllerManipulate])  ▪  (RefLink[Manipulate, paclet:ref/Manipulate])  ▪  (RefLink[CurrentValue, paclet:ref/CurrentValue])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Introduction to Dynamic, paclet:tutorial/IntroductionToDynamic])}, {▪(RefLinkPlain[Advanced Dynamic Functionality, paclet:tutorial/AdvancedDynamicFunctionality])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Gamepad & Device Interface, paclet:guide/GamepadAndDeviceInterface])}, {▪(RefLinkPlain[Low-Level Interface Control, paclet:guide/LowLevelInterfaceControl])}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}, {▪(RefLinkPlain[Control Objects, paclet:guide/ControlObjects])}, {▪(RefLinkPlain[Custom Interface Construction, paclet:guide/CustomInterfaceConstruction])}, {▪(RefLinkPlain[Standalone Interfaces, paclet:guide/StandAloneInterfaces])}, {▪(RefLinkPlain[Dynamic Visualization, paclet:guide/DynamicVisualization])}, {▪(RefLinkPlain[Click-Interactive Panels, paclet:guide/ClickInteractivePanels])}})}})