Previous
gpio
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.
To combine multiple controllers into a mux
controller, you must first configure each controller individually.
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 mux
model.
Enter a name or use the suggested name for your input controller and click Create.
Enter the name of each source input controller in sources
.
Also, select each of the source input controllers in the Depends on dropdown menu.
{
"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:
Name | Type | Required? | Description |
---|---|---|---|
sources | array | Required | The name of every controller component you wish to combine input from. |
You must put each controller’s name
that you add in sources
in depends_on
.
This tells the program loading the config to fully load the source components first.
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.
If your input controller is not working as expected, follow these steps:
If none of these steps work, reach out to us on the Community Discord and we will be happy to help.
For more configuration and usage info, see:
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!