USB HID Joysticks and Gamepads

Hi, just found out about audacity and I love the program. I’d like to use a USB HID Joystick or Gamepad to control Audacity. For example, I’d like to program buttons for “play”, “record” and “play loop”, perhaps the direction pad for increasing or decreasing the selection for the current track. I know that I can perhaps bind the USB joystick to keyboard keys, but I’d like to do this natively so that the command is sent to audacity regardless of which program is selected?

For example, if I’m using audacity, but my currently selected program is an internet browser, if I press the space bar, the input is sent to the internet browser, not to audacity. I’d like for the USB joystick/gamepad controller to be bound to the focus of the audacity program.

Is this possible and where would I find resources/documentation to get started?


Audacity has no built in support for joysticks or gamepads but it does have comprehensive support for keyboard control:

I think that you would need to bind your HID to keyboard keys and/or mouse. See your HID documentation for this.

Can this be a feature that can be added in the future or something that can be done through a plugin? I don’t mind write one if this functionality is possible.


I’d like to contribute anyway I can. My background is in embedded hardware and software design and I have designed several USB devices. My website is at, with some of the projects that I’ve created. I discovered audacity while trying to improve my guitar playing. The goal is to make a device that can control audacity’s selection cursor, loop, play and record. These are very common controls for guitar pedals. I’d like to build a USB device that does all these things exclusively for audacity. I can make the hardware portion of the project as it is the area of my expertise, but I don’t even know if this is possible within audacity. Of course, binding this to audacity’s keyboard shortcuts is very easy to do, but I’d like to do this through a joystick drivers (such as hid.dll on Windows). This will of course allow you to record/play/loop even while looking at tabs or other reference material.

If this can be done with a plugin, or if some programming is required on the open source itself, I’d definitely would love to contribute.


I’m not a programmer, but I would think that it may be possible to add HID support with a “module”.
Have a look here:
In particular, have a look at mod-script-pipe

You will also find developer resources here:

You may also like to register on the developers mailing list so that you are “in the loop” for current development issues:

So the idea is that when Audacity is running, you can use any standard USB HID but it will only talk to Audacity? Or that the user must use your HID, which does nothing unless Audacity is running?

It seems to me we are not at the first step yet, which would be for Audacity to work with standards- based HID’s when it has focus. The current solution to that lack of support is of course to map keystrokes on the device using third-party software, or use an expensive DAW pedal like .

Would you want to write a patch that helps with the “first step”? If we achieve the first step, is another more extensible solution for Audacity to support global shortcuts (that work whatever app has focus) and keyboard media keys?

We know already that wxwidgets (the GUI toolkit that Audacity uses) only supports global shortcuts in Windows. Cross-platform issues might make your original idea difficult too. Do you have experience on Mac or Linux?



I’ve done projects on Windows mostly and some Linux, I unfortunately do not own a MAC machine. My priority would be to have this work on a Windows machine, though if it works on Linux, that would be a plus.

I can definitely look into creating a plugin that can bind HID buttons to Audacity functions. The focus issue would be nice to have, but it would be a low priority. I’d love to help, but documentation is a little scarce.

From a software perspective, the HID API can be accessed on Windows through hid.dll and on Linux through input.h. However, I wouldn’t even know where to start to invoke the functions in Audacity. If you can point to the direction for anything helpful, that would be great (especially an example). It seems like you have already pointed out that wxwidgets is the way to go as far as accessing functions within Audacity through a plugin. Is there an example of a plugin project that shows how functions are accessed? All I can find on the wiki is and some very scarce information about wxwidget (something about wxwidget still a proof-of-concept, source:


Did you look at mod-script-pipe?
The source code is in /lib-src/mod-script-pipe/

The full Audacity source code is available from svn:

I think the more generally applicable you can make your solution, the more chance the Audacity developers would be interested.

Have you looked at other open source media programs to see what solutions they have adopted?


Currently looking at the AutoHotKey program to send commands when Audacity is not in focus. It seems like Audacity ignores all keys or commands sent to it if the focus is not on the program. Is this an intentional behavior or is this due to wxWidgets? I have not yet looked at the source code yet, however, AutoHotKey covers just about every possible binding possible so if it can be made to work with Audacity, that would save a ton of programming.


As a side note, the out of focus command implementation of VLC is very nicely done. Perhaps such key binding for global variables can be implemented for Audacity in the future? This will allow keyboard bindings to send commands to Audacity without having the program selected.


The implementation uses two columns for key bindings, one for when the program is in focus, and another “global” column. The shortcuts under the global column automatically binds to a function, even when VLC is not in focus.

Also, it is confirmed that Audacity seems to consume the events sent to it when it is out of focus:
Another user of autohotkey has tried this before, same issue. There must be a line in the code, or some behavior, that is telling the events to be consumed when it is sent to Audacity.


But AutoHotKey is Windows only.
Linux has a program called “AutoKey”
I don’t know about OS X.

I’m not a programmer, but one issue that may be a problem with enabling global hot keys in Audacity is that it may conflict with screen reader support.

I’ll add the vote for global shortcuts.

Supported global shortcuts on Windows usually have the Windows key modifier, so at least should not interfere with default Audacity shortcuts.


Well the request is for global shortcuts. I think such a feature can benefit many people who are using the program, especially since it is possible to implement it from a cross-platform point of view, just like VLC. How the global shortcuts are used can be platform independent. I’ll take a look at the source when I have time to see why the events are being consumed when Audacity is not in focus or when it is minimized. Thanks.


I’ve looked a bit further into this. With the version of wxWidgets that we use (2.8.12) it’s still the case that global shortcut support is Windows only.

To get cross-platform support we would have to update to a 2.9 version of Widgets:

but unfortunately a great deal of housekeeping on the Audacity code is needed before we can update.

VLC moved to QT a long time ago: .


I see. QT or GTK+ would be much more mainstream, and perhaps a larger programmer base.

I’ve looked a bit into mod-pipe-script. It seems like using the “MenuCommand” might be the way to go. However, some of the commands such as “play/stop” implemented on the space button is is not listed on a menu (just to name one). How would such commands be invoked?


“Play” and “Stop” are listed (separately) in the Transport menu.