MrEliptik / game_launcher

A simple game launcher made with Godot for developers to showcase their games
MIT License
55 stars 7 forks source link

Shortcut to kill currently running game #5

Open MrEliptik opened 5 months ago

MrEliptik commented 5 months ago

I added ctrl-c as a shortcut to kill the game but Godot won't receive inputs when not focused. It could probably be done with OS specific functions. If anyone want to help on that, let me know.

MrEliptik commented 5 months ago

It seems using hooks on Windows (is there something like that on Linux and Mac?) could work but it's low level so we would need to compile a module to access it: https://learn.microsoft.com/en-us/windows/win32/winmsg/using-hooks.

Another solution could be to integrate a simple python script, which doesn't require compiling a module. If python is not available on the platform, it would simply not be used. https://github.com/boppreh/keyboard

There is a proposal about including that in Godot but I don't think it's being worked on: https://github.com/godotengine/godot-proposals/issues/1919

naturally-intelligent commented 4 months ago

Godot by its nature is restricted to minimal OS-level features...

This is a bit of a problem for an application like this... if you dont fully trust the games running properly or leaving it unattended.

Perhaps a batch file wrapper around the whole Godot game launcher? This would handle the OS-level stuff and Godot would be just one step in the batch file to pick what process to launch next. Or Python instead of batch file? I'm not really great with Windows, so not sure what the best solution would be.

Another idea: a batch file that's running in a loop, querying Godot Game Launcher. If the game launcher responds that it wants focus, the batch file could ask the OS to give it focus.

MrEliptik commented 4 months ago

Honestly this feature is just a bonus. The application already watches the PID that was launched so I won't get stuck if the game crashes or something. It would just make life easier if we could force kill the game without going back to the launcher to hit the kill button.

I think I'll go with the python version. This app is aimed at developer showcasing their games so we can assume they have python or at least know how to get it if they want to use this feature.

naturally-intelligent commented 3 months ago

I'm part of a local nonprofit group that is making an arcade machine to showcase local games and for game jams.

Eventually the machine will need to be left unattended for long periods so being crash-resilient will be a priority

Planning on trying your launcher for this purpose .... so I may be a lot more active here lol