dborth / snes9xgx

Snes9x GX - Port of Snes9x for Wii
http://wiibrew.org/wiki/Snes9x_GX
Other
435 stars 64 forks source link

Fix default game selection menu "jump" upon startup w/classic controller #1035

Closed InfiniteBlueGX closed 1 year ago

InfiniteBlueGX commented 1 year ago

(Marking as a draft for now until clarification)

When booting Snes9xGX with a classic controller, the game browser would highlight the previous game played like normal, then "jump" 40-60 games up the list as soon as the classic controller initialized (blue light for port 1 on the wiimote turns on). This did not happen with the GCN controller or solo wiimote. This was a regression introduced in commit https://github.com/dborth/snes9xgx/commit/05b4abce9812760e57bc86de33b8896b70216617

Reverting the commit eliminates the "jump", but I'm not aware of the controller issue the commit was originally trying to solve. I also don't have a 3rd party controller to test with if those were affected.

@dborth could you elaborate on the reasoning behind removing the if statement to fix controllers with bad calibration data?

Alternatively, adding a usleep for 2 seconds after WPAD_Init in the place indicated below seems to give the controller enough time to initialize before the menu appears, but it's not exactly an elegant solution. However, if you think this is preferable to reverting the commit, please let me know and I'll update accordingly.

This would fix issue https://github.com/dborth/snes9xgx/issues/936.

dborth commented 1 year ago

It's been awhile, but it looks like the min/max check was put in place to prevent controllers that return invalid values from causing the menu to continuously scroll. ie: min = max makes no sense at all and any position returned we can't even check properly, so return 0 so that it appears the analog stick isn't been used.

I added handling for this in libogc itself - as the controller initializes, proper defaults are now set:

https://github.com/devkitPro/libogc/commit/dc2451fd85f2943738bb106b08e648b645542336

...but there's a small delay I suppose in doing so, and during that delay the values have been loaded but the proper defaults haven't been set. I think it's reasonable to restore the lines now like you did to work around this.

InfiniteBlueGX commented 1 year ago

Awesome, thanks for the reply! I'll go ahead with it then.