diff options
author | Simon Howard | 2007-06-13 19:12:13 +0000 |
---|---|---|
committer | Simon Howard | 2007-06-13 19:12:13 +0000 |
commit | e4127187e0e5de9c94a92301b4dc780bc9153fb8 (patch) | |
tree | b0c3c6205739d10d6c1c98c31d70d07f63314e2a | |
parent | 22d473c19cddb35c8ba90fbe52beb7dff8377688 (diff) | |
download | chocolate-doom-e4127187e0e5de9c94a92301b4dc780bc9153fb8.tar.gz chocolate-doom-e4127187e0e5de9c94a92301b4dc780bc9153fb8.tar.bz2 chocolate-doom-e4127187e0e5de9c94a92301b4dc780bc9153fb8.zip |
Working joystick code.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 903
-rw-r--r-- | setup/joystick.c | 14 | ||||
-rw-r--r-- | setup/txt_joybinput.c | 9 | ||||
-rw-r--r-- | src/i_joystick.c | 2 | ||||
-rw-r--r-- | src/i_video.c | 2 |
4 files changed, 26 insertions, 1 deletions
diff --git a/setup/joystick.c b/setup/joystick.c index 41c30067..d491aadf 100644 --- a/setup/joystick.c +++ b/setup/joystick.c @@ -79,6 +79,11 @@ static int OpenAllJoysticks(void) 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 @@ static int OpenAllJoysticks(void) free(all_joysticks); all_joysticks = NULL; } + else + { + SDL_JoystickEventState(SDL_ENABLE); + } return result; } @@ -125,6 +134,9 @@ static void CloseAllJoysticks(void) } } + SDL_JoystickEventState(SDL_DISABLE); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + free(all_joysticks); all_joysticks = NULL; } @@ -178,7 +190,7 @@ static void CalibrateAxis(int *axis_index, int *axis_invert) if (abs(axis_value) > best_value) { best_value = abs(axis_value); - best_invert = axis_value < 0; + best_invert = axis_value > 0; best_axis = i; } } diff --git a/setup/txt_joybinput.c b/setup/txt_joybinput.c index 56aaa47e..0f05eaf4 100644 --- a/setup/txt_joybinput.c +++ b/setup/txt_joybinput.c @@ -64,6 +64,8 @@ static void PromptWindowClosed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(joystick)) 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 @@ static void OpenPromptWindow(txt_joystick_input_t *joystick_input) 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 @@ static void OpenPromptWindow(txt_joystick_input_t *joystick_input) 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)) diff --git a/src/i_joystick.c b/src/i_joystick.c index 0e0f7590..3eb9069d 100644 --- a/src/i_joystick.c +++ b/src/i_joystick.c @@ -108,6 +108,8 @@ void I_InitJoystick(void) SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } + SDL_JoystickEventState(SDL_ENABLE); + // Initialised okay! printf("I_InitJoystick: %s\n", SDL_JoystickName(joystick_index)); diff --git a/src/i_video.c b/src/i_video.c index 39208ec3..0dfccfa3 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -555,6 +555,8 @@ void I_StartTic (void) { I_ReadMouse(); } + + I_UpdateJoystick(); } |