Using joystick buttons in Lua scripts

Hi all, I have been experimenting with Lua scripts and wanted a way to access the joystick buttons to trigger functionality.

Here is a way to create up to 4 “script buttons”. These buttons will keep track of how many times they have been pressed, and you can query the current state of the button and the number of button presses inside a Lua script. There’s an example Lua script to show how they work.

If this is generally useful I’ll submit a PR to continue the discussion. If there is a better way to access the joystick buttons, please let me know!

/Clyde

1 Like

Hi @clyde

That is great! I like it as is. Please open a PR =]

Cool, thx. Sub: Lua scripts can query joystick button state by clydemcqueen · Pull Request #24347 · ArduPilot/ardupilot · GitHub