X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fjoystick.c;h=14ba7d2c61ee9eace068f84767b5176096ea2314;hb=afad49f6ce2e58eeb41f680b8d05eed74455a1ab;hp=f092c11d677fa03a0beb7f868aff13efa41d903d;hpb=30eb586d06bc4d1ee7388dced1c20e530292aa93;p=rocksndiamonds.git diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index f092c11d..14ba7d2c 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -4,7 +4,7 @@ // (c) 1995-2014 by Artsoft Entertainment // Holger Schemel // info@artsoft.org -// http://www.artsoft.org/ +// https://www.artsoft.org/ // ---------------------------------------------------------------------------- // joystick.c // ============================================================================ @@ -17,74 +17,9 @@ #include "misc.h" -/* ========================================================================= */ -/* platform independent joystick functions */ -/* ========================================================================= */ - -#define TRANSLATE_JOYSYMBOL_TO_JOYNAME 0 -#define TRANSLATE_JOYNAME_TO_JOYSYMBOL 1 - -static void translate_joyname(int *joysymbol, char **name, int mode) -{ - static struct - { - int joysymbol; - char *name; - } translate_joy[] = - { - { JOY_LEFT, "joystick_left" }, - { JOY_RIGHT, "joystick_right" }, - { JOY_UP, "joystick_up" }, - { JOY_DOWN, "joystick_down" }, - { JOY_BUTTON_1, "joystick_button_1" }, - { JOY_BUTTON_2, "joystick_button_2" }, - }; - - int i; - - if (mode == TRANSLATE_JOYSYMBOL_TO_JOYNAME) - { - *name = "[undefined]"; - - for (i = 0; i < 6; i++) - { - if (*joysymbol == translate_joy[i].joysymbol) - { - *name = translate_joy[i].name; - break; - } - } - } - else if (mode == TRANSLATE_JOYNAME_TO_JOYSYMBOL) - { - *joysymbol = 0; - - for (i = 0; i < 6; i++) - { - if (strEqual(*name, translate_joy[i].name)) - { - *joysymbol = translate_joy[i].joysymbol; - break; - } - } - } -} - -char *getJoyNameFromJoySymbol(int joysymbol) -{ - char *name; - - translate_joyname(&joysymbol, &name, TRANSLATE_JOYSYMBOL_TO_JOYNAME); - return name; -} - -int getJoySymbolFromJoyName(char *name) -{ - int joysymbol; - - translate_joyname(&joysymbol, &name, TRANSLATE_JOYNAME_TO_JOYSYMBOL); - return joysymbol; -} +// ============================================================================ +// platform independent joystick functions +// ============================================================================ int getJoystickNrFromDeviceName(char *device_name) { @@ -173,25 +108,6 @@ static int JoystickPositionPercent(int center, int border, int actual) return percent; } -void CheckJoystickData(void) -{ - int i; - int distance = 100; - - for (i = 0; i < MAX_PLAYERS; i++) - { - if (setup.input[i].joy.xleft >= setup.input[i].joy.xmiddle) - setup.input[i].joy.xleft = setup.input[i].joy.xmiddle - distance; - if (setup.input[i].joy.xright <= setup.input[i].joy.xmiddle) - setup.input[i].joy.xright = setup.input[i].joy.xmiddle + distance; - - if (setup.input[i].joy.yupper >= setup.input[i].joy.ymiddle) - setup.input[i].joy.yupper = setup.input[i].joy.ymiddle - distance; - if (setup.input[i].joy.ylower <= setup.input[i].joy.ymiddle) - setup.input[i].joy.ylower = setup.input[i].joy.ymiddle + distance; - } -} - int JoystickExt(int player_nr, boolean use_as_joystick_nr) { int joystick_nr = joystick.nr[player_nr]; @@ -211,10 +127,11 @@ int JoystickExt(int player_nr, boolean use_as_joystick_nr) 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); + Warn("cannot read joystick device '%s'", + setup.input[player_nr].joy.device_name); joystick.status = JOYSTICK_NOT_AVAILABLE; + return JOY_NO_ACTION; } @@ -304,24 +221,3 @@ int AnyJoystickButton(void) return result; } - -void DeactivateJoystick(void) -{ - /* Temporarily deactivate joystick. This is needed for calibration - screens, where the player has to select a joystick device that - should be calibrated. If there is a totally uncalibrated joystick - active, it may be impossible (due to messed up input from joystick) - to select the joystick device to calibrate even when trying to use - the mouse or keyboard to select the device. */ - - if (joystick.status & JOYSTICK_AVAILABLE) - joystick.status &= ~JOYSTICK_ACTIVE; -} - -void ActivateJoystick(void) -{ - /* reactivate temporarily deactivated joystick */ - - if (joystick.status & JOYSTICK_AVAILABLE) - joystick.status |= JOYSTICK_ACTIVE; -}