summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2013-04-06 15:48:31 +0000
committerSimon Howard2013-04-06 15:48:31 +0000
commit95cc910349d0aa1e39d6c0786db577b8075eeb60 (patch)
treee886b040a67ddda17bb9db9b28e779db8ff1f237
parentde482094992cf84425c5868b03abda4deea2306b (diff)
downloadchocolate-doom-95cc910349d0aa1e39d6c0786db577b8075eeb60.tar.gz
chocolate-doom-95cc910349d0aa1e39d6c0786db577b8075eeb60.tar.bz2
chocolate-doom-95cc910349d0aa1e39d6c0786db577b8075eeb60.zip
Run I_ShutdownJoystick on exit (thanks Brad Harding).
Subversion-branch: /branches/v2-branch Subversion-revision: 2591
-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