ref: e4127187e0e5de9c94a92301b4dc780bc9153fb8
parent: 22d473c19cddb35c8ba90fbe52beb7dff8377688
author: Simon Howard <[email protected]>
date: Wed Jun 13 15:12:13 EDT 2007
Working joystick code. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 903
--- a/setup/joystick.c
+++ b/setup/joystick.c
@@ -79,6 +79,11 @@
int num_joysticks;
int result;
+ if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
+ {
+ return 0;
+ }
+
// SDL_JoystickOpen() all joysticks.
num_joysticks = SDL_NumJoysticks();
@@ -104,6 +109,10 @@
free(all_joysticks);
all_joysticks = NULL;
}
+ else
+ {
+ SDL_JoystickEventState(SDL_ENABLE);
+ }
return result;
}
@@ -125,6 +134,9 @@
}
}
+ SDL_JoystickEventState(SDL_DISABLE);
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
+
free(all_joysticks);
all_joysticks = NULL;
}
@@ -178,7 +190,7 @@
if (abs(axis_value) > best_value)
{
best_value = abs(axis_value);
- best_invert = axis_value < 0;
+ best_invert = axis_value > 0;
best_axis = i;
}
}
--- a/setup/txt_joybinput.c
+++ b/setup/txt_joybinput.c
@@ -64,6 +64,8 @@
SDL_JoystickClose(joystick);
TXT_SDL_SetEventCallback(NULL, NULL);
+ SDL_JoystickEventState(SDL_DISABLE);
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
static void OpenErrorWindow(void)
@@ -86,6 +88,11 @@
txt_label_t *label;
SDL_Joystick *joystick;
+ if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
+ {
+ return;
+ }
+
// Check the current joystick is valid
joystick = SDL_JoystickOpen(joystick_index);
@@ -111,6 +118,8 @@
TXT_SDL_SetEventCallback(EventCallback, joystick_input);
TXT_SignalConnect(window, "closed", PromptWindowClosed, joystick);
joystick_input->prompt_window = window;
+
+ SDL_JoystickEventState(SDL_ENABLE);
}
static void TXT_JoystickInputSizeCalc(TXT_UNCAST_ARG(joystick_input))
--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -108,6 +108,8 @@
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
+ SDL_JoystickEventState(SDL_ENABLE);
+
// Initialised okay!
printf("I_InitJoystick: %s\n", SDL_JoystickName(joystick_index));
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -555,6 +555,8 @@
{
I_ReadMouse();
}
+
+ I_UpdateJoystick();
}