Skip to content

Commit

Permalink
Slightly change the way the maximum speed binding work.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arignir committed Dec 11, 2023
1 parent 4f02773 commit 8dc68bd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
4 changes: 2 additions & 2 deletions include/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ enum bind_actions {
BIND_GBA_START,
BIND_GBA_SELECT,

BIND_EMULATOR_SPEED_MAX,
BIND_EMULATOR_SPEED_X1,
BIND_EMULATOR_SPEED_X2,
BIND_EMULATOR_SPEED_X3,
BIND_EMULATOR_SPEED_X4,
BIND_EMULATOR_SPEED_X5,
BIND_EMULATOR_SPEED_MAX_TOGGLE,
BIND_EMULATOR_SPEED_MAX_HOLD,
BIND_EMULATOR_SCREENSHOT,
BIND_EMULATOR_QUICKSAVE,
Expand All @@ -81,7 +81,7 @@ enum bind_actions {

BIND_GBA_MIN = BIND_GBA_A,
BIND_GBA_MAX = BIND_GBA_SELECT,
BIND_EMULATOR_MIN = BIND_EMULATOR_SPEED_X1,
BIND_EMULATOR_MIN = BIND_EMULATOR_SPEED_MAX,
BIND_EMULATOR_MAX = BIND_EMULATOR_RESET,
};

Expand Down
14 changes: 5 additions & 9 deletions source/gui/sdl/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ gui_sdl_setup_default_binds(
app->binds.keyboard[BIND_EMULATOR_SPEED_X3] = SDL_GetKeyFromName("3");
app->binds.keyboard[BIND_EMULATOR_SPEED_X4] = SDL_GetKeyFromName("4");
app->binds.keyboard[BIND_EMULATOR_SPEED_X5] = SDL_GetKeyFromName("5");
app->binds.keyboard[BIND_EMULATOR_SPEED_MAX_TOGGLE] = SDL_GetKeyFromName("F1");
app->binds.keyboard[BIND_EMULATOR_SPEED_MAX] = SDL_GetKeyFromName("0");
app->binds.keyboard[BIND_EMULATOR_SPEED_MAX_HOLD] = SDL_GetKeyFromName("Space");
app->binds.keyboard[BIND_EMULATOR_SCREENSHOT] = SDL_GetKeyFromName("F2");
app->binds.keyboard[BIND_EMULATOR_QUICKSAVE] = SDL_GetKeyFromName("F5");
Expand All @@ -72,7 +72,7 @@ gui_sdl_setup_default_binds(
app->binds.controller[BIND_EMULATOR_SPEED_X1] = SDL_CONTROLLER_BUTTON_LEFTSTICK;
app->binds.controller[BIND_EMULATOR_SPEED_X2] = SDL_CONTROLLER_BUTTON_RIGHTSTICK;
#if SDL_VERSION_ATLEAST(2, 0, 14)
app->binds.controller[BIND_EMULATOR_SPEED_MAX_TOGGLE] = SDL_CONTROLLER_BUTTON_TOUCHPAD;
app->binds.controller[BIND_EMULATOR_SPEED_MAX_HOLD] = SDL_CONTROLLER_BUTTON_TOUCHPAD;
#endif

app->binds.controller_alt[BIND_GBA_A] = SDL_CONTROLLER_BUTTON_Y;
Expand Down Expand Up @@ -155,19 +155,15 @@ gui_sdl_handle_bind(
}

switch (bind) {
case BIND_EMULATOR_SPEED_MAX:
case BIND_EMULATOR_SPEED_X1:
case BIND_EMULATOR_SPEED_X2:
case BIND_EMULATOR_SPEED_X3:
case BIND_EMULATOR_SPEED_X4:
case BIND_EMULATOR_SPEED_X5: {
app->emulation.unbounded = false;
app->emulation.speed = 1 + (bind - BIND_EMULATOR_SPEED_X1);
app_game_speed(app, app->emulation.speed * !app->emulation.unbounded);
break;
};
case BIND_EMULATOR_SPEED_MAX_TOGGLE: {
app->emulation.unbounded ^= true;
app_game_speed(app, app->emulation.speed * !app->emulation.unbounded);
app->emulation.speed = bind - BIND_EMULATOR_SPEED_MAX;
app_game_speed(app, app->emulation.speed);
break;
};
case BIND_EMULATOR_SCREENSHOT: app_game_screenshot(app); break;
Expand Down
4 changes: 2 additions & 2 deletions source/gui/windows/keybinds.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ char const * const binds_pretty_name[] = {
[BIND_EMULATOR_SPEED_X3] = "Speed x3",
[BIND_EMULATOR_SPEED_X4] = "Speed x4",
[BIND_EMULATOR_SPEED_X5] = "Speed x5",
[BIND_EMULATOR_SPEED_MAX_TOGGLE] = "Speed Max (Toggle)",
[BIND_EMULATOR_SPEED_MAX] = "Speed Max",
[BIND_EMULATOR_SPEED_MAX_HOLD] = "Speed Max (Hold)",
[BIND_EMULATOR_SCREENSHOT] = "Screenshot",
[BIND_EMULATOR_QUICKSAVE] = "Quicksave",
Expand All @@ -56,7 +56,7 @@ char const * const binds_slug[] = {
[BIND_EMULATOR_SPEED_X3] = "speed_x3",
[BIND_EMULATOR_SPEED_X4] = "speed_x4",
[BIND_EMULATOR_SPEED_X5] = "speed_x5",
[BIND_EMULATOR_SPEED_MAX_TOGGLE] = "speed_max_toggle",
[BIND_EMULATOR_SPEED_MAX] = "speed_max",
[BIND_EMULATOR_SPEED_MAX_HOLD] = "speed_max_hold",
[BIND_EMULATOR_SCREENSHOT] = "screenshot",
[BIND_EMULATOR_QUICKSAVE] = "quicksave",
Expand Down
23 changes: 10 additions & 13 deletions source/gui/windows/menubar.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,21 @@ gui_win_menubar_emulation(
"x2",
"x3",
"x4",
"x5"
"x5",
};

for (x = 0; x <= 5; ++x) {
if (!x) {
char const *bind;
char const *bind;

bind = SDL_GetKeyName(app->binds.keyboard[BIND_EMULATOR_SPEED_MAX_TOGGLE]);
if (igMenuItemBool(speed[x], bind ? bind : "", app->emulation.unbounded, true)) {
app->emulation.unbounded ^= 1;
app_game_speed(app, app->emulation.speed * !app->emulation.unbounded);
}
bind = SDL_GetKeyName(app->binds.keyboard[BIND_EMULATOR_SPEED_MAX + x]);
if (igMenuItemBool(speed[x], bind ?: "", app->emulation.speed == x, true)) {
app->emulation.unbounded = false;
app->emulation.speed = x;
app_game_speed(app, app->emulation.speed);
}

if (!x) {
igSeparator();
} else {
if (igMenuItemBool(speed[x], NULL, app->emulation.speed == x, !app->emulation.unbounded)) {
app->emulation.speed = x;
app_game_speed(app, app->emulation.speed * !app->emulation.unbounded);
}
}
}

Expand Down

0 comments on commit 8dc68bd

Please sign in to comment.