diff --git a/include/app/app.h b/include/app/app.h index 8aefceb..b6f1065 100644 --- a/include/app/app.h +++ b/include/app/app.h @@ -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); diff --git a/source/app/bindings.c b/source/app/bindings.c index a717c38..67cfbcf 100644 --- a/source/app/bindings.c +++ b/source/app/bindings.c @@ -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( @@ -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( @@ -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( @@ -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 diff --git a/source/app/emulator.c b/source/app/emulator.c index eb03769..f7f6d56 100644 --- a/source/app/emulator.c +++ b/source/app/emulator.c @@ -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 ) { @@ -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; @@ -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); @@ -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( diff --git a/source/app/sdl/event.c b/source/app/sdl/event.c index 0527460..4ec2e07 100644 --- a/source/app/sdl/event.c +++ b/source/app/sdl/event.c @@ -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); } } @@ -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; @@ -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; }