Configure a Linux-supported Gamepad
Configuring a gamepad
input controller allows you to use a Linux-supported gamepad as a device to communicate with your machine.
Linux supports most standard gamepads, such as PlayStation or Xbox type game controllers, as well as many joysticks, racing wheels, and more.
To be able to test your gamepad as you configure it, physically connect your gamepad to your machine’s computer and turn both on. Then, configure the controller:
Navigate to the CONFIGURE tab of your machine’s page in the Viam app.
Click the + icon next to your machine part in the left-hand menu and select Component.
Select the input_controller
type, then select the gamepad
model.
Enter a name or use the suggested name for your input controller and click Create.
Edit the attributes as applicable to your input controller, according to the table below.
{
"components": [
{
"name": "<your-gamepad-input-controller>",
"model": "gamepad",
"type": "input_controller",
"namespace": "rdk",
"attributes": {
"dev_file": "<string>",
"auto_reconnect": <boolean>
}
}
]
}
The following attributes are available for gamepad
input controllers:
Name | Type | Required? | Description |
---|---|---|---|
dev_file | string | Optional | If dev_file is left blank or not included, viam-server will search and use the first gamepad it finds that’s connected to the computer controlling your machine. If you want to specify a device, give the absolute path to the input device event file. For example: /dev/input/event42 . |
auto_reconnect | boolean | Optional | Applies to both remote (gRPC) and local (bluetooth or direct USB connected) devices. If set to true , viam-server tries to (re)connect the device automatically. It waits for a device to connect during a machine’s start-up. If set to false (default) then start-up fails if a device is not already connected. |
Test the input controller
After you configure your input controller, open the input controller’s TEST panel on the CONFIGURE or CONTROL tabs. View the current value of each input on your controller.
Work in progress models
Mappings are currently available for a wired XBox 360 controller, and wireless XBox Series X|S, along with the 8bitdo Pro 2 bluetooth gamepad (which works great with the Raspberry Pi).
The XBox controllers emulate an XBox 360 gamepad when in wired mode, as does the 8bitdo.
Because of that, any unknown gamepad is mapped as an XBox 360.
If you have another controller that you want to use to control your machine, feel free to submit a PR on GitHub with new mappings.
Troubleshooting
If your input controller is not working as expected, follow these steps:
- Check your machine logs on the LOGS tab to check for errors.
- Review this input controller model’s documentation to ensure you have configured all required attributes.
- Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the input controller there.
If none of these steps work, reach out to us on the Community Discord and we will be happy to help.
Next steps
For more configuration and usage info, see:
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!