Cockpit Actions for joysticks

Hey,

Is it possible to have Cockpit Actions for joysticks? So we can make a certain movement on a joystick axis do something in an extension for example? We are not sure if this is possible currently because it seems like only buttons support Cockpit Actions at this point.

Kind regards,
Rutger

Hey @rutger-seascape!

Currently the Actions are directly supported only by buttons, as you noticed, but you can make them work with axis as well. What you have to do is:

  1. Create a data-lake variable of type number (from /menu/tools/data-lake)
  2. Go to /menu/settings/joystick and assign an axis to that variable
  3. Go back to the data-lake tools menu, look for the variable and actuate your joystick. You will notice that the variable now reflects the movement of the axis
  4. Go to /menu/settings/actions and create your Action. All the 3 types accept in one way or another the usage of a variable value, using the {{ mustache }} syntax. MAVLink Actions accept them as parameter values, JavaScript Actions accept them using the window.cockpit.getDataLakeVariableData('variable-id') syntax and the HTTP Actions accept them in both the URL, params or body.
  5. Once you create the Action, you can setup an Automatic Trigger for that Action (link icon in the Action entry in /menu/settings/actions), linking it to the variable. That way the actions is called in intervals or when the variable changes its value.

If you need to manipulate the value of the axis (instead of using the bare -1 to +1 floating values), you can just create a Compound Variable (also in /menu/tools/data-lake) that uses the {{ mustache }} syntax to create a new reactive value (it changes whenever the source variable changes).

Let us know if you have any questions. We know its not the most straightforward process yet.

As a minor addition, if you want to continue using the joystick axes for motion control, but also want to use their positions/values as inputs and/or triggers for custom actions, that is not yet possible but should be soon :slight_smile:

@rafael.lehmkuhl Thanks for the detailed answer! This should be enough to get us started.

@EliotBR That’s cool, good to know!