Skip to content

Commit

Permalink
Reword a few comments and function names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arignir committed Oct 18, 2024
1 parent a54edaf commit 307c110
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/app/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void app_bindings_keyboard_binding_clear(struct app *app, struct keyboard_bindin
bool app_bindings_keyboard_binding_match(struct keyboard_binding const *, struct keyboard_binding const *);
char *app_bindings_keyboard_binding_to_str(struct keyboard_binding const *bind);
void app_bindings_controller_binding_clear(struct app *app, SDL_GameControllerButton btn);
void app_bindings_handle(struct app *app, enum bind_actions bind, bool pressed);
void app_bindings_process(struct app *app, enum bind_actions bind, bool pressed);

/* config.c */
void app_config_load(struct app *app);
Expand Down
10 changes: 5 additions & 5 deletions source/app/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ app_bindings_keyboard_binding_match(
** Return the user-printable name of the given bind.
** Eg: `Ctrl-Alt-P`.
**
** The return value must be freed.
** The return value should be passed to `free()`.
*/
char *
app_bindings_keyboard_binding_to_str(
Expand All @@ -141,7 +141,7 @@ app_bindings_keyboard_binding_to_str(
}

/*
** Clear any existing keyboard bindings matching the given key.
** Clear any existing keyboard bindings matching the one given in argument.
*/
void
app_bindings_keyboard_binding_clear(
Expand All @@ -162,7 +162,7 @@ app_bindings_keyboard_binding_clear(
}

/*
** Clear any existing controller bindings matching the given key.
** Clear any existing controller bindings matching the one given in argument.
*/
void
app_bindings_controller_binding_clear(
Expand All @@ -183,10 +183,10 @@ app_bindings_controller_binding_clear(
}

/*
** Handle a given binding.
** Process a given binding, doing the action it represents.
*/
void
app_bindings_handle(
app_bindings_process(
struct app *app,
enum bind_actions bind,
bool pressed
Expand Down
15 changes: 8 additions & 7 deletions source/app/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ app_emulator_process_all_notifs(
}

void
app_emulator_wait_for_notif(
app_emulator_wait_for_notification(
struct app *app,
enum notification_kind kind
) {
Expand Down Expand Up @@ -597,7 +597,7 @@ app_emulator_configure_and_run(

extension = strrchr(rom_path, '.');

// We consider anything that isn't ending with `.gba` or `.bin` as an archive.
// We consider anything that isn't ending with `.gba` or `.bin` an archive.
// XXX: Should we build a hard-coded list instead?
if (extension) {
basename_len = extension - rom_path;
Expand Down Expand Up @@ -696,17 +696,15 @@ app_emulator_configure_and_run(

memcpy(&event.config, app->emulation.launch_config, sizeof(event.config));

/*
** Process all notifications before sending the reset message to make sure the NOTIFICATION_RESET we will
** receive comes from the correct reset message.
*/
// Process all notifications before sending the reset message to make sure the NOTIFICATION_RESET we will
// receive comes from the correct reset message.

app_emulator_process_all_notifs(app);
channel_lock(&app->emulation.gba->channels.messages);
channel_push(&app->emulation.gba->channels.messages, &event.header);
channel_release(&app->emulation.gba->channels.messages);

app_emulator_wait_for_notif(app, NOTIFICATION_RESET);
app_emulator_wait_for_notification(app, NOTIFICATION_RESET);

app_config_push_recent_rom(app, rom_path);

Expand Down Expand Up @@ -790,6 +788,9 @@ app_emulator_pause(

/*
** Exit the emulation.
**
** NOTE: The emulator thread will stop and exit when processing this message.
** This message is used when shutting down Hades.
*/
void
app_emulator_exit(
Expand Down
16 changes: 8 additions & 8 deletions source/app/sdl/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ app_sdl_handle_events(
for (i = BIND_MIN; i < BIND_MAX; ++i) {
// Normal binds
if (app_bindings_keyboard_binding_match(&app->binds.keyboard[i], &bind)) {
app_bindings_handle(app, i, event.type == SDL_KEYDOWN);
app_bindings_process(app, i, event.type == SDL_KEYDOWN);
}

// Alternative binds
if (app_bindings_keyboard_binding_match(&app->binds.keyboard_alt[i], &bind)) {
app_bindings_handle(app, i, event.type == SDL_KEYDOWN);
app_bindings_process(app, i, event.type == SDL_KEYDOWN);
}
}

Expand All @@ -190,12 +190,12 @@ app_sdl_handle_events(
for (i = BIND_MIN; i < BIND_MAX; ++i) {
// Normal binds
if (app->binds.controller[i] == event.cbutton.button) {
app_bindings_handle(app, i, event.type == SDL_CONTROLLERBUTTONDOWN);
app_bindings_process(app, i, event.type == SDL_CONTROLLERBUTTONDOWN);
}

// Alternative binds
if (app->binds.controller_alt[i] == event.cbutton.button) {
app_bindings_handle(app, i, event.type == SDL_CONTROLLERBUTTONDOWN);
app_bindings_process(app, i, event.type == SDL_CONTROLLERBUTTONDOWN);
}
}
break;
Expand All @@ -213,16 +213,16 @@ app_sdl_handle_events(
state_b = (event.jaxis.value <= INT16_MIN / 2);
if (event.jaxis.axis == 0 && state_a != app->sdl.controller.joystick.right) {
app->sdl.controller.joystick.right = state_a;
app_bindings_handle(app, BIND_GBA_RIGHT, state_a);
app_bindings_process(app, BIND_GBA_RIGHT, state_a);
} else if (event.jaxis.axis == 0 && state_b != app->sdl.controller.joystick.left) {
app->sdl.controller.joystick.left = state_b;
app_bindings_handle(app, BIND_GBA_LEFT, state_b);
app_bindings_process(app, BIND_GBA_LEFT, state_b);
} else if (event.jaxis.axis == 1 && state_a != app->sdl.controller.joystick.down) {
app->sdl.controller.joystick.down = state_a;
app_bindings_handle(app, BIND_GBA_DOWN, state_a);
app_bindings_process(app, BIND_GBA_DOWN, state_a);
} else if (event.jaxis.axis == 1 && state_b != app->sdl.controller.joystick.up) {
app->sdl.controller.joystick.up = state_b;
app_bindings_handle(app, BIND_GBA_UP, state_b);
app_bindings_process(app, BIND_GBA_UP, state_b);
}
break;
}
Expand Down

0 comments on commit 307c110

Please sign in to comment.