Configure a webgamepad

Configuring a webgamepad input controller allows you to use a web-based gamepad as a device to communicate with your robot.

Configuration

Use the following configuration for an input controller of model webgamepad:

What an example configuration for a web-based gamepad input controller component looks like in the Viam App config builder.
{
  "components": [
    {
      "name": "WebGamepad",
      "type": "input_controller",
      "model": "webgamepad",
      "attributes": {},
      "depends_on": []
    }
  ]
}

Usage

Connect your controller to your computer. Follow the instructions included with your gamepad to make this connection.

If you haven’t done so already, create a robot in the Viam app, and follow the instructions in the SETUP tab to start viam-server on your computer and connect to the robot.

Then, click on the robot’s CONFIG tab and configure an input_controller component of model webgamepad and name WebGamepad, as shown above. Save the config.

Next, navigate to the CONTROL tab. You should see a WebGamepad drop-down menu. Click on the drop-down menu to expand it. Click Enable, and press a button on your controller. Then, you should see the Controls on your input controller appear:

The dropdown as a table of controls available and their inputs in the Control tab of the Viam app. This is for a WebGamepad model.

You should now be able to see the row of control inputs respond to your button presses and stick toggles.

For example, this is how the row of Controls appears after pressing the circle (west) button on the button pad of the connected PS4 controller:

The dropdown as a table of controls available for a web-based gamepad and their inputs in the Control tab of the Viam app.

Troubleshooting

You can find additional assistance in the Troubleshooting section.

You can also ask questions in the Community Discord and we will be happy to help.