controlling an unfocused godot stream overlay

I’ve added a media player to my stream overlay written in Godot, and I want to be able to control media playback while the application isn’t focused. I also want to control other things, like change what scene is being shown, while the application isn’t focused. So, I think I need to register a global key callback.

However, it appears that Godot doesn’t support global keyboard shortcuts yet. So, there are a few repositories here and there that implement it:

None of them appear to be used very much and many of them have various drawbacks. Have any of you used these repositories? Maybe there’s an alternate solution I’m not considering?

1 Like

I will say that controllers seem to be global input for Godot- probably not ideal but I do keep a controller plugged in to my streaming device as a sort of macro-pad. Other than that- I’d probably do some evil derranged thing of getting key inputs from some other app and sending it to Godot thru some form of IPC (web-socket usually).

2 Likes

it might not be too much help since you’re A.) not in unity and I imagine B.) you aren’t on windows, but I use this GitHub - elringus/unity-raw-input: Windows Raw Input wrapper for Unity game engine personally, which hooks into Windows Raw Input, but its setup in Unity.

Since there doesn’t seem to be a well used and maintained godot extension. Maybe the right approach would be to run a standalone keylogger, like this example linked from the background inputs demo, as a separate process (probably with OS.execute() in a dedicated thread, or OS.execute_with_pipe()) and reading the output to find the events you’re looking for. Possibly also filtering and/or massaging the output through a sed or similar command to make the job of parsing the output on the godot side easier.

2 Likes