summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/i_joystick.c21
1 files changed, 12 insertions, 9 deletions
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