From 95cc910349d0aa1e39d6c0786db577b8075eeb60 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 6 Apr 2013 15:48:31 +0000 Subject: Run I_ShutdownJoystick on exit (thanks Brad Harding). Subversion-branch: /branches/v2-branch Subversion-revision: 2591 --- src/i_joystick.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/i_joystick.c b/src/i_joystick.c index 7767c19d..4bc6a1e9 100644 --- a/src/i_joystick.c +++ b/src/i_joystick.c @@ -34,6 +34,7 @@ #include "doomtype.h" #include "d_event.h" #include "i_joystick.h" +#include "i_system.h" #include "m_config.h" @@ -66,6 +67,16 @@ static int joystick_x_invert = 0; static int joystick_y_axis = 1; static int joystick_y_invert = 0; +void I_ShutdownJoystick(void) +{ + if (joystick != NULL) + { + SDL_JoystickClose(joystick); + joystick = NULL; + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + } +} + void I_InitJoystick(void) { int num_axes; @@ -118,16 +129,8 @@ void I_InitJoystick(void) // Initialized okay! printf("I_InitJoystick: %s\n", SDL_JoystickName(joystick_index)); -} -void I_ShutdownJoystick(void) -{ - if (joystick != NULL) - { - SDL_JoystickClose(joystick); - joystick = NULL; - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } + I_AtExit(I_ShutdownJoystick, true); } // Get a bitmask of all currently-pressed buttons -- cgit v1.2.3