From: Holger Schemel Date: Wed, 4 Oct 2017 18:46:50 +0000 (+0200) Subject: removed old joystick calibration code X-Git-Tag: 4.0.1.1~47 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1f9ffbb0cc61dd3b7216d71141d047383d7700c8;p=rocksndiamonds.git removed old joystick calibration code --- diff --git a/src/screens.c b/src/screens.c index ce99012e..af53b7f8 100644 --- a/src/screens.c +++ b/src/screens.c @@ -6340,180 +6340,6 @@ void CustomizeKeyboard(int player_nr) DrawSetupScreen_Input(); } -#if 0 -static boolean OLD_CalibrateJoystickMain(int player_nr) -{ - int new_joystick_xleft = JOYSTICK_XMIDDLE; - int new_joystick_xright = JOYSTICK_XMIDDLE; - int new_joystick_yupper = JOYSTICK_YMIDDLE; - int new_joystick_ylower = JOYSTICK_YMIDDLE; - int new_joystick_xmiddle, new_joystick_ymiddle; - - char *device_name = setup.input[player_nr].joy.device_name; - int joystick_nr = getJoystickNrFromDeviceName(device_name); - boolean joystick_active = CheckJoystickOpened(joystick_nr); - - int x, y, last_x, last_y, xpos = 8, ypos = 3; - boolean check[3][3]; - int check_remaining = 3 * 3; - int joy_x, joy_y; - int joy_value; - int result = -1; - - if (joystick.status == JOYSTICK_NOT_AVAILABLE) - return FALSE; - - if (!joystick_active || !setup.input[player_nr].use_joystick) - return FALSE; - - FadeSetEnterMenu(); - FadeOut(REDRAW_FIELD); - - ClearField(); - - for (y = 0; y < 3; y++) - { - for (x = 0; x < 3; x++) - { - DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0); - check[x][y] = FALSE; - } - } - - DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick"); - DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions"); - DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls"); - DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,"); - DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick"); - DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and"); - DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!"); - - joy_value = JoystickExt(joystick_nr, TRUE); - last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0); - last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0); - - /* eventually uncalibrated center position (joystick could be uncentered) */ - if (!ReadJoystick(joystick_nr, &joy_x, &joy_y, NULL, NULL)) - return FALSE; - - new_joystick_xmiddle = joy_x; - new_joystick_ymiddle = joy_y; - - DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0); - - FadeIn(REDRAW_FIELD); - - /* wait for potentially still pressed button to be released */ - while (JoystickExt(joystick_nr, TRUE) & JOY_BUTTON); - - while (result < 0) - { - while (PendingEvent()) /* got event */ - { - Event event; - - NextEvent(&event); - - switch (event.type) - { - case EVENT_KEYPRESS: - switch (GetEventKey((KeyEvent *)&event, TRUE)) - { - case KSYM_Return: - if (check_remaining == 0) - result = 1; - break; - - case KSYM_Escape: - FadeSkipNextFadeIn(); - result = 0; - break; - - default: - break; - } - break; - - case EVENT_KEYRELEASE: - key_joystick_mapping = 0; - break; - - default: - HandleOtherEvents(&event); - break; - } - } - - if (!ReadJoystick(joystick_nr, &joy_x, &joy_y, NULL, NULL)) - return FALSE; - - new_joystick_xleft = MIN(new_joystick_xleft, joy_x); - new_joystick_xright = MAX(new_joystick_xright, joy_x); - new_joystick_yupper = MIN(new_joystick_yupper, joy_y); - new_joystick_ylower = MAX(new_joystick_ylower, joy_y); - - setup.input[player_nr].joy.xleft = new_joystick_xleft; - setup.input[player_nr].joy.yupper = new_joystick_yupper; - setup.input[player_nr].joy.xright = new_joystick_xright; - setup.input[player_nr].joy.ylower = new_joystick_ylower; - setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle; - setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle; - - CheckJoystickData(); - - joy_value = JoystickExt(joystick_nr, TRUE); - - if (joy_value & JOY_BUTTON && check_remaining == 0) - result = 1; - - x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0); - y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0); - - if (x != last_x || y != last_y) - { - DrawFixedGraphic(xpos + last_x, ypos + last_y, - IMG_MENU_CALIBRATE_YELLOW, 0); - DrawFixedGraphic(xpos + x, ypos + y, - IMG_MENU_CALIBRATE_RED, 0); - - last_x = x; - last_y = y; - - if (check_remaining > 0 && !check[x+1][y+1]) - { - check[x+1][y+1] = TRUE; - check_remaining--; - } - } - - BackToFront(); - } - - /* calibrated center position (joystick should now be centered) */ - if (!ReadJoystick(joystick_nr, &joy_x, &joy_y, NULL, NULL)) - return FALSE; - - new_joystick_xmiddle = joy_x; - new_joystick_ymiddle = joy_y; - - /* wait until the last pressed button was released */ - while (JoystickExt(joystick_nr, TRUE) & JOY_BUTTON) - { - if (PendingEvent()) /* got event */ - { - Event event; - - NextEvent(&event); - HandleOtherEvents(&event); - - BackToFront(); - } - } - - return TRUE; -} -#endif - /* game controller mapping generator by Gabriel Jacobo */ #define MARKER_BUTTON 1