Get input from headphones

Godot Version

4.3

Question

Is there any way to respond to input from headphones? Wired headphone often have a button that can be used to pause/mute or answer/hangup calls. Bluetooth headphones can also have extras such as volume controls.

How can I get an event in godot to respond to these button pushes?

I expect this may need to be broken into two parts, bluetooth headphones and wired headphones.

I have found GodotAndroidBluetoothPlugin which appears to need updating for godot 4. Looks like Oppodelldog has done an update which I haven’t got built yet.

1 Like

I think this feature is very hardware specific and falling out of trend, as well as Apple has its own resister values for the headphone jack control that may also confuse users.(Apple doest really promote their wired headphones anyway as the headphone jack itself is going out of style). I dont think its very common for wired headphone control to be supporting this feature anymore. Especially with the advent of bluetooth headphones.

If its usb on the other hand that’s probably a different story.

Id be curious if bt commands just works in godot, have you tried? I guess it could be sending OS commands that would not translate to input though, but bt is standardized.

Update: ah do you know what I think the input type is filtered based on the designation of the input device. i.e. only gamepads, keyboards, mice, and stylus are picked up. you could try recompiling the engine to allow more types of input.

3 Likes

I agree with Penny, but I also have a question.

Why though?

Seriously, why would you ever need gdscript/C# input functionality for infrequently used headphone buttons?

If you want to pause, mute, hang up, etc, you’d just used the device the headphones are connected to. Which already have working input functions.

And headphones without a device are called earmuffs.

The only semi-useful headphone hardware extention is a volume wheel. But we also have a volume button too.

I see no practical use for getting headphone button responses.

If you want to learn more about CTIA or OMTP standard check this out.

I will say my laptop has an intel hda soundcard. But its specification does not say it supports wired ctia/omtp headphone control. My desktop doesnt have a 4 pin jack. And my phone is bt only.

While my use case is focused on the mobile platform, there are also many desktop keyboards which have media control keys as well. I think all platforms should respond to these type of events.

The device specs has the event info I can use to update android events.

Even if games were the only apps you made, then these events would still be useful, it is easier and quicker to press the headphone button than to go into settings and mute the audio, unless you want to litter your ui space with a mute button that a small percentage of your users would use.

I have a personal (non-game) app running to play media (lectures) and having to pick up the phone, unlock the screen to mute the audio is the only thing stopping me from using it. It uses http api calls to get media info and download media files, having to manually download files and create playlists is frustrating. And godot is a much easier way to get an app running on a mobile device.

Even for a desktop game, while you have many unused keys to assign mute to, having your game respond to the mute button on the keyboard makes sense.

I do understand your perspective, I really do. But I’ve got to address your points with some fearless feedback.


To address this point, if a player was playing a game, they would use the volume controls on their hardware (computer, phone, tv, etc) first before the game settings.

Why would any game need a dedicated mute button? Why is that even considered? The hardware the game is already running on has multiple near-instant options. Plus, if an instant mute button was a thing, it would be built into the headphones (a piece of hardware the communicates with software), NOT the game.


I’m glad you have your own app, but the solution to your muting-unlock inconvenience is NOT through highly specialized headphone hardware-to-software communication that, very likely, only you will use.

Most video/audio streaming apps (YouTube, Spotify, etc) have features that are built into the phone’s notification window. Meaning you just have to tap your power button once, scroll from the top of your phone, then tap the play/pause button.

I want to clarify that your questions and concerns are valid, but there are so many better and easier solutions.

Instead of taking the (tons of) time to create a Godot plugin that can communicate between very specific hardware, you could instead download your lectures and upload them privately on YouTube.

BOOM. Instant and free access to the lecture on any device at any time. You can use YouTube’s mobile pause button on your phone’s notification menu, download them for offline viewing, AND make playlists easily; solving all the grievances you mentioned.


Yeah, you could do that. I and anybody else won’t stop you. But again, why though! If you really want a game to have a dedicated mute button (for whatever reason), you can program a hotkey outside the game. BOOM. This mute function now works for any game and application. Plus, many keyboards and laptops already have dedicated mute buttons.


No offense, but developing this app seems like a not-so-worthwhile endeavor considering what you want to use it for. It seems like a better idea to spend time focusing on the lectures themselves. Not the medium they play through. That’s just my opinion, however. You do you.

This is true, but you can get exception for google certification. Or the product just doesnt get google certified. So it may not really guarantee that the hardware/driver supports the feature.

I would hope these could still work in godot? as keyboards are accepted input devices for godot?

Unless the shortcuts that media keys are filtered by the OS which has always been the case?

Godot has mapings for mediakeys

So maybe godot isnt asking the os for those events. Or somehow they get filter out. I dont see any issues on github. You could make one