-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a button to quickly swap between Memory<->Rumble Paks #509
Conversation
7917e39
to
d8de00a
Compare
libretro/libretro.c
Outdated
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) | ||
{ | ||
if (!strcmp(var.value, "no delay")) | ||
swap_pak_delay = 0; | ||
else if (!strcmp(var.value, "1s hold")) | ||
swap_pak_delay = 60; | ||
else if (!strcmp(var.value, "2s hold")) | ||
swap_pak_delay = 120; | ||
else if (!strcmp(var.value, "3s hold")) | ||
swap_pak_delay = 180; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The heck is that unit? Frames?
- If its Frames/VI, then this is not correct depending on Buffer Swap mode for GlideN & PAL/NTSC configurations
- atoi or sscanf, prefer not to have val and string mixed tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was supposed to be frames, I assumed 60fps and completely forgot about PAL 😓
A bit annoying since ROM_PARAMS
isn't initialized yet on the first update_variables()
pass so it returns 0 (NTSC) as region even with a PAL game...
Would that be OK as a workaround?
var.key = CORE_NAME "-pak-swap-delay";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
// If startup is true then ROM infos aren't ready yet and we don't know
// the region of the game yet, so we just keep the seconds for now
// and we'll calculate in frames a bit later in retro_load_game()
swap_pak_delay = atoi(var.value);
if (!startup)
swap_pak_delay *= retro_get_region() == RETRO_REGION_PAL ? 50 : 60;
}
then in retro_load_game() after we got the ROM infos:
// Now that we know the region, we can calculate the seconds in frames
// for the 'Memory/Rumble Pak Swap' button hold delay
swap_pak_delay *= retro_get_region() == RETRO_REGION_PAL ? 50 : 60;
and I changed the values in libretro_core_options.h to:
{"0", "0 second"},
{"1", "1 second"},
{"2", "2 seconds"},
{"3", "3 seconds"},
so even if it shouldn't have been an issue with atoi, there's no val/string mix.
As for the buffer swap I'm not sure how to handle that tbh 🤔
A bit of a bummer, looks more complicated than I expected for my very limited C/C++ skills :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes pushed, AFAICT it works fine with the correct hold duration for NTSC/PAL now.
Still not sure to understand your "buffer swap" comment, doesn't retro_run run 60 (or 50 for PAL) times per second no matter what? Because basically the only thing I'm doing is once per retro_run I'm increasing the frame count for how long the button to swap paks has been held.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different approach using clock()
from time.h so the duration of the button being held is calculated in actual seconds instead of relying on frames: bslenul@e2d0392
Otherwise I could simply drop the hold button feature and make the swap on button press only. I initially added the hold options to avoid misclicks, but if you think it's not worth I don't mind removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will think of smth
d8de00a
to
b2ef4be
Compare
This PR adds a button to quickly swap from Memory Pak to Rumble Pak and vice-versa (RetroPad Select by default, or R3 if "Independent C-button Controls" is enabled):
mupen_swap_btn.mp4
Very useful for games compatible with both Paks, going back and forth in the Quick Menu every time you want to change quickly becomes annoying...
Just select "memory/rumble (swappable)" for any of the "Player N Pak" core options and it will be enabled for that controller. Also added a core option to select if the swap should be done on press or on hold (1, 2 or 3 seconds).
I hope this is fine, if it is then it closes #502
Also removed the
update_controllers()
call here:mupen64plus-libretro-nx/libretro/libretro.c
Lines 1988 to 1991 in f1ad37c
update_variables()
just above.