X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=8751f1b999dfa4de510e8eacf78aee61a9684e11;hp=ee43dc05b0c1b1795328b129d1ca0a563f0398e2;hb=6746a99c1d7348748c06d457f8496b4253bb7c84;hpb=aa77ac7ad31e0a9ab20bb85b51e429cd45f12455 diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index ee43dc05..8751f1b9 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2603,7 +2603,7 @@ static boolean sdl_is_controller[MAX_PLAYERS]; static boolean SDLOpenJoystick(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return FALSE; #if defined(TARGET_SDL2) @@ -2631,7 +2631,7 @@ static boolean SDLOpenJoystick(int nr) static void SDLCloseJoystick(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return; #if 1 @@ -2659,7 +2659,7 @@ static void SDLCloseJoystick(int nr) boolean SDLCheckJoystickOpened(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return FALSE; #if defined(TARGET_SDL2) @@ -2680,6 +2680,9 @@ static void setJoystickAxis(int nr, int axis_id_raw, int axis_value) int axis_id = axis_id_raw % 2; #endif + if (nr < 0 || nr >= MAX_PLAYERS) + return; + if (axis_id == -1) return; @@ -2723,6 +2726,9 @@ static void setJoystickButton(int nr, int button_id_raw, int button_state) int button_id = button_id_raw % 2; #endif + if (nr < 0 || nr >= MAX_PLAYERS) + return; + if (button_id == -1) return; @@ -2913,8 +2919,8 @@ void SDLInitJoysticks() joystick_nr = -1; } - /* misuse joystick file descriptor variable to store joystick number */ - joystick.fd[i] = joystick_nr; + /* store configured joystick number for each player */ + joystick.nr[i] = joystick_nr; } /* now open all connected joysticks (regardless if configured or not) */ @@ -2960,11 +2966,12 @@ static void DrawTouchInputOverlay() static int alpha_step = 5; static int alpha_last = 0; static int alpha = 0; + boolean active = (overlay.enabled && overlay.active); - if (!overlay.active && deactivated) + if (!active && deactivated) return; - if (overlay.active) + if (active) { if (alpha < alpha_max) alpha = MIN(alpha + alpha_step, alpha_max);