From: Holger Schemel Date: Mon, 3 Jul 2017 20:07:06 +0000 (+0200) Subject: fixed joystick naming convention from file descriptor to joystick number X-Git-Tag: 4.0.1.0~29 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cea8726203188984c5d94dc15934d1e186d18c37;p=rocksndiamonds.git fixed joystick naming convention from file descriptor to joystick number --- diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index a6a065cd..61d0a113 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -161,22 +161,22 @@ void CheckJoystickData() int JoystickExt(int player_nr, boolean use_as_joystick_nr) { - int joystick_fd = joystick.fd[player_nr]; + int joystick_nr = joystick.nr[player_nr]; int js_x, js_y; boolean js_b1, js_b2; int left, right, up, down; int result = JOY_NO_ACTION; if (use_as_joystick_nr) - joystick_fd = player_nr; + joystick_nr = player_nr; if (joystick.status != JOYSTICK_ACTIVATED) return JOY_NO_ACTION; - if (joystick_fd < 0) + if (joystick_nr < 0) return JOY_NO_ACTION; - if (!ReadJoystick(joystick_fd, &js_x, &js_y, &js_b1, &js_b2)) + if (!ReadJoystick(joystick_nr, &js_x, &js_y, &js_b1, &js_b2)) { Error(ERR_WARN, "cannot read joystick device '%s'", setup.input[player_nr].joy.device_name); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index ee43dc05..04a098cd 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2913,8 +2913,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) */ diff --git a/src/libgame/system.c b/src/libgame/system.c index de59d77a..5ccf3fb3 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -1620,7 +1620,7 @@ void InitJoysticks() /* always start with reliable default values */ joystick.status = JOYSTICK_NOT_AVAILABLE; for (i = 0; i < MAX_PLAYERS; i++) - joystick.fd[i] = -1; /* joystick device closed */ + joystick.nr[i] = -1; /* no joystick configured */ SDLInitJoysticks(); } diff --git a/src/libgame/system.h b/src/libgame/system.h index 72a0754e..ca25b287 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -947,7 +947,7 @@ struct OverlayInfo struct JoystickInfo { int status; - int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */ + int nr[MAX_PLAYERS]; /* joystick number for each player */ }; struct SetupJoystickInfo