is it possible to improve this for exit by pressing a specific combination of buttons from inside the game without entering the wiiu menu ?
With the Wii U Plugin menu one hooks into CafeOS API functions, running custom code there while the game does normal API calls.
So the simplest solution to this might probably to just hook into the input reading function(s, depending on the controllers used), then check for a button combo and react to it before the game itself processes the input.
Pro: That's simple and fast to implement with probably under 10 lines of code, so just a very small possible bug surface.
Contra: The plugin could only check for the button combo when the game wants to read the input. This might not always be the case (loading screens, for example), so the plugin might no longer work everywhere.
Another solution could be to hook into the game loading, starting a new thread there which processes the input completely independent of the game.
Pro: As said this would be independent of the game reading input, so would work even if the game froze (as long as CafeOS is still processing threads).
Contra: There can't be two codes asking CafeOS for input so this independent button combo checking thread should save the input values to RAM. Then the CafeOS API function to read the input should be completely replaced (that's possible with the plugin system) with a custom function just passing the saved RAM values to the game. This might cause input lag if not done correctly and might not be as simple as it sounds through, so needs a lot of clever coding, opening up a larger bug surface.
Note that I won't code any of this through. Just trying to brainstorm with you guys about what could be done.
//EDIT: Thinking more about this the first solution might be good enough and not reduce the working area of the plugin as it is now cause the wii u plugin config menu itself is dependant on the running app/game reading input. It's also dependant on the game/app running with a fixed framerate (ever tried to use the menu while NUSspli or some other app not drawing with a fixed framerate is running?) but that's another story.
//EDIT²: Looking at the readme of the plugin:
Also adds a button shortcut to close or restart to the HOME Menu.
So are you just requesting a feature that's implemented already? Let me check the codes... Yes, looks like you need to press X for the period of at least 60 frames to restart the game or less than 60 frames to close it. Both needs you to enable that function in settings first and how long 60 frames are hardly depends on the game (probably one second for many games (running at 60 FPS), 2 seconds for others (running at 30 FPS), 3 seconds for Nintendo 64 injects and some other stuff (running at 20 FPS), hours to days or even years for apps like NUSspli (don't draw with a fixed FPS but on demand).
//EDIT³: These plugins codes are so messy (why use OSDynload when WUPS/WUT did everything already so you can just call the functions directly, for example?) but it looks like FPS aren't FPS for them. What they call FPS is actually ICPS (input calls per second). Apps like NUSspli are indeed processing input at a fixed rate (and use this to decide if a new frame needs to get drawn), so the plugin should also work fine there.
//EDIT4: And I just found a minor bug in these messy codes: You can shorten the times by using multiple wii motes. So pressing X on two motes reduces the time from 60 to 30 ICPS. Pressing on 3 motes shorts it to 20 ICPS and so on...
//EDIT5: I just must give an example of these messy codes. So look at this:
https://github.com/Lynx64/CloseRestartGamePlugin/blob/v0.1/src/main.cpp#L61-L67
This codeblock could be replaced with a simple
SYSLaunchMenu();
or even better: Removing that whole function and calling SYSLaunchMenu() directly at the codepoints that function gets called now. Don't believe me? Then look at this as there it's done exactly as I told it could be done:
https://github.com/Lynx64/CloseRestartGamePlugin/blob/v0.1/src/config.cpp#L149
...So the plugin isn't even consistent about what way to call a simple cafeOS function...