diff --git a/SDL/gui.c b/SDL/gui.c index c32eec4..ed9f357 100644 --- a/SDL/gui.c +++ b/SDL/gui.c @@ -721,8 +721,7 @@ joypad_axis_t get_joypad_axis(uint8_t physical_axis) } -extern void set_filename(const char *new_filename, bool new_should_free); -void run_gui(bool is_running) +void connect_joypad(void) { if (joystick && !SDL_NumJoysticks()) { if (controller) { @@ -743,6 +742,13 @@ void run_gui(bool is_running) joystick = SDL_JoystickOpen(0); } } +} + +extern void set_filename(const char *new_filename, bool new_should_free); +void run_gui(bool is_running) +{ + connect_joypad(); + /* Draw the background screen */ static SDL_Surface *converted_background = NULL; if (!converted_background) { diff --git a/SDL/gui.h b/SDL/gui.h index 9893eb6..4d10614 100644 --- a/SDL/gui.h +++ b/SDL/gui.h @@ -92,6 +92,7 @@ extern configuration_t configuration; void update_viewport(void); void run_gui(bool is_running); void render_texture(void *pixels, void *previous); +void connect_joypad(void); joypad_button_t get_joypad_button(uint8_t physical_button); joypad_axis_t get_joypad_axis(uint8_t physical_axis); diff --git a/SDL/main.c b/SDL/main.c index 7db59be..99facf8 100755 --- a/SDL/main.c +++ b/SDL/main.c @@ -616,6 +616,9 @@ int main(int argc, char **argv) if (filename == NULL) { run_gui(false); } + else { + connect_joypad(); + } SDL_PauseAudioDevice(device_id, 0); run(); // Never returns return 0;