How to | Connect a Gamepad or Other Device to the Wolfram System
All of the devices detected by the Wolfram System are listed in the output of ControllerInformation. There are several built-in devices here in addition to a Logitech Dual Action gamepad that is connected via USB:
By default, gamepads and other controllers can be used with Wolfram Language functions like Manipulate and Graphics3D. For instance, you can use a connected gamepad to adjust Manipulate controls or rotate 3D graphics with no additional configuration. For more information, see How to: Use Built-in Gamepad Support.
Devices from different manufacturers often use different names for controls. The Wolfram System attempts to standardize these names to "X", "Y", "X2", "Y2", and so on for one-dimensional analog controls, and "B1", "B2", and so on for buttons.
To see how the Wolfram System maps its standardized names onto the hardware names, use "Mapping" with the controller name in ControllerState. Short is used here to display only a few lines of this mapping:
If you wrap this input with Dynamic, the output will update continuously, thus letting you view the state of each axis in real time.
If ControllerState does not immediately respond to your controller, you may need to adjust the ControllerPath option. Similar to the way the Wolfram System searches the directories in $Path when it looks for files, ControllerState searches for available controllers based on the ControllerPath setting.
The default setting for ControllerPath is to use gamepads, if any are present:
Because of this, you can omit "Logitech Dual Action" as the first argument to ControllerState and get the same result:
If there are no gamepads connected, then ControllerState by default will fall back to other joystick devices, 3D mice, and finally other controller devices, including infrared controllers and digitizers.
Here, a preference for the sudden motion sensor that is built into some portable computers is specified in ControllerPath: