summaryrefslogtreecommitdiff
path: root/src/i_joystick.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/i_joystick.c')
-rw-r--r--src/i_joystick.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/src/i_joystick.c b/src/i_joystick.c
index d48e8409..4bc6a1e9 100644
--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -31,11 +31,12 @@
#include <stdio.h>
#include <string.h>
-#include "doomdef.h"
#include "doomtype.h"
#include "d_event.h"
-#include "d_main.h"
#include "i_joystick.h"
+#include "i_system.h"
+
+#include "m_config.h"
// When an axis is within the dead zone, it is set to zero.
// This is 5% of the full range:
@@ -48,23 +49,33 @@ static SDL_Joystick *joystick = NULL;
// Standard default.cfg Joystick enable/disable
-extern int usejoystick;
+static int usejoystick = 0;
// Joystick to use, as an SDL joystick index:
-int joystick_index = -1;
+static int joystick_index = -1;
// Which joystick axis to use for horizontal movement, and whether to
// invert the direction:
-int joystick_x_axis = 0;
-int joystick_x_invert = 0;
+static int joystick_x_axis = 0;
+static int joystick_x_invert = 0;
// Which joystick axis to use for vertical movement, and whether to
// invert the direction:
-int joystick_y_axis = 1;
-int joystick_y_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)
{
@@ -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
@@ -186,3 +189,13 @@ void I_UpdateJoystick(void)
}
}
+void I_BindJoystickVariables(void)
+{
+ M_BindVariable("use_joystick", &usejoystick);
+ M_BindVariable("joystick_index", &joystick_index);
+ M_BindVariable("joystick_x_axis", &joystick_x_axis);
+ M_BindVariable("joystick_y_axis", &joystick_y_axis);
+ M_BindVariable("joystick_x_invert", &joystick_x_invert);
+ M_BindVariable("joystick_y_invert", &joystick_y_invert);
+}
+