X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fjoystick.c;h=d5a78a290465dfa71730ab29d00de1fe7ef23e92;hb=61c3da024802ecc0268bab42d7499fc0346e4fd3;hp=d9cad1289ddd7d9fbabd79f76219bb4be0c5e91d;hpb=74c0f7de91268e40d15948f473eac51a9760b9c0;p=rocksndiamonds.git diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index d9cad128..d5a78a29 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -1,7 +1,7 @@ /*********************************************************** * Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1995-2002 Artsoft Entertainment * +* (c) 1995-2006 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -26,6 +26,8 @@ #if defined(PLATFORM_UNIX) && !defined(TARGET_SDL) void UnixInitJoysticks() { + static boolean unix_joystick_subsystem_initialized = FALSE; + boolean print_warning = !unix_joystick_subsystem_initialized; int i; for (i = 0; i < MAX_PLAYERS; i++) @@ -44,18 +46,24 @@ void UnixInitJoysticks() if (access(device_name, R_OK) != 0) { - Error(ERR_WARN, "cannot access joystick device '%s'", device_name); + if (print_warning) + Error(ERR_WARN, "cannot access joystick device '%s'", device_name); + continue; } if ((joystick.fd[i] = open(device_name, O_RDONLY)) < 0) { - Error(ERR_WARN, "cannot open joystick device '%s'", device_name); + if (print_warning) + Error(ERR_WARN, "cannot open joystick device '%s'", device_name); + continue; } joystick.status = JOYSTICK_ACTIVATED; } + + unix_joystick_subsystem_initialized = TRUE; } boolean UnixReadJoystick(int fd, int *x, int *y, boolean *b1, boolean *b2) @@ -140,7 +148,7 @@ void translate_joyname(int *joysymbol, char **name, int mode) for (i = 0; i < 6; i++) { - if (strcmp(*name, translate_joy[i].name) == 0) + if (strEqual(*name, translate_joy[i].name)) { *joysymbol = translate_joy[i].joysymbol; break; @@ -200,7 +208,7 @@ char *getDeviceNameFromJoystickNr(int joystick_nr) static int JoystickPositionPercent(int center, int border, int actual) { - long range, position; + int range, position; int percent; if (border < center && actual > center)