Disable controller input during startup
-
@mitu said in Disable controller input during startup:
What unwanted effects are you referring to ? Input handling is disabled during loading, it's enabled only after EmulationStation has finished starting and the system's list is displayed.
Sadly not in my case, for example if i press a menu button when emulationstation is loading, the menu appear when emulationstation is loaded. Can you confirm that you have not this problem?
-
Please post your system's details, as requested in https://retropie.org.uk/forum/topic/3/read-this-first.
What EmulationStation version are you using ? -
I've built the latest version of emulationstation present on https://github.com/RetroPie/EmulationStation/commits/master
And I'm using it on Pandora box 4 hardware that is an arm v7 board on jamma cabinet.
All works great except this small problems.
-
@apiso Actually, this happens also on the Pi4. May be an improvement opportunity in EmulationStation.
EDIT: what kind of controllers do you have connected to your system ?
-
The board is directly connected to a cabinet through the jamma interface that directly manage the controllers.
I think this could be a good improvement, for me it's a problem because in my board i can launch different configuration of emulationstation with different system in it pressing some button at startup.
-
@apiso said in Disable controller input during startup:
The board is directly connected to a cabinet through the jamma interface that directly manage the controllers.
Is this recognized as a keyboard or as a gamepad device ?
-
It's recognized as gamepad i think, I've noticed that in the code in the main function the sdl_joystik is already disabled for this purpose this is the code :
//dont generate joystick events while we're loading (hopefully fixes "automatically started emulator" bug)
SDL_JoystickEventState(SDL_DISABLE);Maybe joystick should be disabled first.
-
@apiso said in Disable controller input during startup:
Maybe joystick should be disabled first.
Yes, the gamepad input disable code could be added earlier, before the splashscreen/configuration load is started. Should be pretty easy to add.
-
@mitu said in Disable controller input during startup:
e gamepad input disable code could be added earlier, before the splashscreen/configura
I've added in the main.cpp a simple loop before the main loop , that clear the buffer input , it seems to work good even if a keep pressing a button.
I've inserted this code on row 396 of main.cpp:
SDL_Event event;
//Clean buffer input if some controller is touched before running
do
{} while(SDL_PollEvent(&event));
I'm not a c++ programmer so probably there is a better way to do so , maybe calling directly an sdl api that clear the input buffer but it works.
-
This diff should do the trick, clearing also any keyboard type controllers
diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 26faeb2..26bc328 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -320,6 +320,9 @@ int main(int argc, char* argv[]) bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress"); + //dont generate joystick events while we're loading (hopefully fixes "automatically started emulator" bug) + SDL_JoystickEventState(SDL_DISABLE); + if(!scrape_cmdline) { if(!window.init()) @@ -365,9 +368,6 @@ int main(int argc, char* argv[]) return run_scraper_cmdline(); } - //dont generate joystick events while we're loading (hopefully fixes "automatically started emulator" bug) - SDL_JoystickEventState(SDL_DISABLE); - // preload what we can right away instead of waiting for the user to select it // this makes for no delays when accessing content, but a longer startup time ViewController::get()->preload(); @@ -386,7 +386,10 @@ int main(int argc, char* argv[]) } } - //generate joystick events since we're done loading + //generate joystick events since we're done loading and clear the input event queue + SDL_PumpEvents(); + SDL_FlushEvent(SDL_KEYDOWN); + SDL_FlushEvent(SDL_KEYUP); SDL_JoystickEventState(SDL_ENABLE); int lastTime = SDL_GetTicks();
I don't think it's 100% correct, since any errors during startup would leave the joystick disabled, further testing is needed.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.