diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c index 30704cc..bf93e25 100644 --- a/src/libsuperderpy.c +++ b/src/libsuperderpy.c @@ -359,8 +359,8 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* al_init_user_event_source(&(game->event_source)); - game->_priv.event_queue = al_create_event_queue(); - if (!game->_priv.event_queue) { + game->event_queue = al_create_event_queue(); + if (!game->event_queue) { FatalError(game, true, "Failed to create event queue."); al_destroy_display(game->display); return NULL; @@ -408,28 +408,28 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* static void ProgressStub(struct Game* game) {} SYMBOL_EXPORT int libsuperderpy_start(struct Game* game) { - al_register_event_source(game->_priv.event_queue, al_get_display_event_source(game->display)); - al_register_event_source(game->_priv.event_queue, al_get_keyboard_event_source()); + al_register_event_source(game->event_queue, al_get_display_event_source(game->display)); + al_register_event_source(game->event_queue, al_get_keyboard_event_source()); if (game->input.available.mouse) { - al_register_event_source(game->_priv.event_queue, al_get_mouse_event_source()); + al_register_event_source(game->event_queue, al_get_mouse_event_source()); } if (game->input.available.joystick) { - al_register_event_source(game->_priv.event_queue, al_get_joystick_event_source()); + al_register_event_source(game->event_queue, al_get_joystick_event_source()); } if (game->input.available.touch) { - al_register_event_source(game->_priv.event_queue, al_get_touch_input_event_source()); + al_register_event_source(game->event_queue, al_get_touch_input_event_source()); #ifdef LIBSUPERDERPY_MOUSE_EMULATION - al_register_event_source(game->_priv.event_queue, al_get_touch_input_mouse_emulation_event_source()); + al_register_event_source(game->event_queue, al_get_touch_input_mouse_emulation_event_source()); #endif } - al_register_event_source(game->_priv.event_queue, &(game->event_source)); + al_register_event_source(game->event_queue, &(game->event_source)); // HACK: some backends correct the window size only after the display has been already created. // if we start loading with wrong size, it won't be corrected until the main loop is entered back, // so the loading screen will stay at the wrong size. // Turns out SDL/Wayland needs some help with emitting the resize event before it's too late. ALLEGRO_EVENT event; - al_peek_next_event(game->_priv.event_queue, &event); + al_peek_next_event(game->event_queue, &event); ClearScreen(game); al_flip_display(); @@ -612,7 +612,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) { Console_Unload(game); al_destroy_display(game->display); al_destroy_user_event_source(&(game->event_source)); - al_destroy_event_queue(game->_priv.event_queue); + al_destroy_event_queue(game->event_queue); al_restore_default_mixer(); al_destroy_mixer(game->audio.fx); al_destroy_mixer(game->audio.music); diff --git a/src/libsuperderpy.h b/src/libsuperderpy.h index 6aa2535..ef900b2 100644 --- a/src/libsuperderpy.h +++ b/src/libsuperderpy.h @@ -153,6 +153,7 @@ struct Params { struct Game { ALLEGRO_DISPLAY* display; /*!< Main Allegro display. */ ALLEGRO_EVENT_SOURCE event_source; /*!< Event source for user events. */ + ALLEGRO_EVENT_QUEUE* event_queue; /*!< Main event queue. */ struct { ALLEGRO_VOICE* v; /*!< Main voice used by the game. */ ALLEGRO_MIXER* mixer; /*!< Main mixer of the game. */ @@ -216,7 +217,6 @@ struct Game { ALLEGRO_FONT* font_bsod; /*!< Font used in Blue Screens of Derp. */ char console[5][1024]; unsigned int console_pos; - ALLEGRO_EVENT_QUEUE* event_queue; /*!< Main event queue. */ bool show_timeline; double speed; /*!< Speed of the game */ diff --git a/src/mainloop.c b/src/mainloop.c index 4fb151a..0050932 100644 --- a/src/mainloop.c +++ b/src/mainloop.c @@ -226,8 +226,8 @@ static inline bool MainloopEvents(struct Game* game) { if (game->_priv.paused && !IS_EMSCRIPTEN) { // there's no frame flipping when paused, so avoid pointless busylooping - al_wait_for_event(game->_priv.event_queue, &ev); - } else if (!al_get_next_event(game->_priv.event_queue, &ev)) { + al_wait_for_event(game->event_queue, &ev); + } else if (!al_get_next_event(game->event_queue, &ev)) { break; } @@ -281,7 +281,7 @@ static inline bool MainloopEvents(struct Game* game) { al_unref_user_event(&ev.user); } - } while (!al_is_event_queue_empty(game->_priv.event_queue)); + } while (!al_is_event_queue_empty(game->event_queue)); return true; }