Configure a Mux Input Controller

Configuring a mux (multiplexed) input controller allows you to combine one or more controllers into a single virtual controller.

This lets you control a machine from different locations, such as the web and a locally connected gamepad, or use multiple controllers as one device.

For example, you could use a joystick alongside a numpad.

Configuration

To combine multiple controlers into a mux controller, you must first configure each controller individually.

Navigate to the Config tab of your machine’s page in the Viam app. Click on the Components subtab and click Create component. Select the input_controller type, then select the mux model. Enter a name for your input controller and click Create.

An example configuration for a multiplexed input controller component in the Viam App config builder

Copy and paste the following attribute template into your input controller’s Attributes box. Then remove and fill in the attributes as applicable to your input controller, according to the table below.

{
  "sources": [
    "<your-gamepad-input-controller-name",
    "<your-other-gamepad-input-controller-name>"
  ]
}
{
  "sources": ["myGamepad", "WebGamepad"]
}

From the Depends On dropdown menu, select all of the source input controllers for your mux controller to combine.

{
  "components": [
    {
      "name": "<your-mux-input-controller-name>",
      "model": "mux",
      "type": "input_controller",
      "namespace": "rdk",
      "attributes": {
        "sources": [
          "<your-gamepad-input-controller-name",
          "<your-other-gamepad-input-controller-name>"
        ]
      },
      "depends_on": [
        "<your-gamepad-input-controller-name>",
        "<your-other-gamepad-input-controller-name>"
      ]
    }
    <...CONFIGS FOR THE INDIVIDUAL INPUT CONTROLLERS...>
  ]
}

The following example configuration combines a gamepad and a webgamepad controller:

{
  "components": [
    {
      "name": "my-combined-controller",
      "model": "mux",
      "type": "input_controller",
      "namespace": "rdk",
      "attributes": {
        "sources": ["myGamepad", "WebGamepad"]
      },
      "depends_on": ["myGamepad", "WebGamepad"]
    },
    {
      "name": "myGamepad",
      "model": "gamepad",
      "type": "input_controller",
      "namespace": "rdk",
      "attributes": {
        "auto_reconnect": true
      },
      "depends_on": []
    },
    {
      "name": "WebGamepad",
      "model": "webgamepad",
      "type": "input_controller",
      "namespace": "rdk",
      "attributes": {},
      "depends_on": []
    }
  ]
}

The following attributes are available for mux input controllers:

NameTypeInclusionDescription
sourcesarrayRequiredThe name of every controller component you wish to combine input from.

Test the input controller

After you configure your input controller, navigate to the Control tab and select the dropdown panel dedicated to the input controller. View the current value of each input on your controller.

The input controller component 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.



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.