diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c index 67c7d465..1bdce7f3 100644 --- a/Quake/in_sdl.c +++ b/Quake/in_sdl.c @@ -879,22 +879,60 @@ static void IN_JoyKeyEvent(qboolean wasdown, qboolean isdown, int key, double *t } } -static joyaxis_t IN_GetLookAxis (joyaxisstate_t *state) -{ +// Add a new control scheme option +#define JOY_SCHEME_DEFAULT 0 +#define JOY_SCHEME_SWAP 1 +#define JOY_SCHEME_LEGACY 2 + +static joyaxis_t IN_GetLookAxis(joyaxisstate_t *state) { joyaxis_t axis; - axis.x = state->axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_LEFTX : SDL_CONTROLLER_AXIS_RIGHTX]; - axis.y = state->axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_LEFTY : SDL_CONTROLLER_AXIS_RIGHTY]; + + switch ((int)joy_swapmovelook.value) { + case JOY_SCHEME_LEGACY: + // GoldenEye 1.1 setup: rotate and move forward/backward on the left stick, strafe and up/down look on the right stick + axis.x = state->axisvalue[SDL_CONTROLLER_AXIS_LEFTX]; + axis.y = state->axisvalue[SDL_CONTROLLER_AXIS_RIGHTY]; + break; + case JOY_SCHEME_SWAP: + // Swapped move/look configuration + axis.x = state->axisvalue[SDL_CONTROLLER_AXIS_LEFTX]; + axis.y = state->axisvalue[SDL_CONTROLLER_AXIS_LEFTY]; + break; + default: // JOY_SCHEME_DEFAULT + // Default configuration + axis.x = state->axisvalue[SDL_CONTROLLER_AXIS_RIGHTX]; + axis.y = state->axisvalue[SDL_CONTROLLER_AXIS_RIGHTY]; + break; + } + return axis; } -static joyaxis_t IN_GetMoveAxis (joyaxisstate_t *state) -{ +static joyaxis_t IN_GetMoveAxis(joyaxisstate_t *state) { joyaxis_t axis; - axis.x = state->axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_RIGHTX : SDL_CONTROLLER_AXIS_LEFTX]; - axis.y = state->axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_RIGHTY : SDL_CONTROLLER_AXIS_LEFTY]; + + switch ((int)joy_swapmovelook.value) { + case JOY_SCHEME_LEGACY: + // GoldenEye 1.1 setup: rotate and move forward/backward on the left stick, strafe and up/down look on the right stick + axis.x = state->axisvalue[SDL_CONTROLLER_AXIS_RIGHTX]; + axis.y = state->axisvalue[SDL_CONTROLLER_AXIS_LEFTY]; + break; + case JOY_SCHEME_SWAP: + // Swapped move/look configuration + axis.x = state->axisvalue[SDL_CONTROLLER_AXIS_RIGHTX]; + axis.y = state->axisvalue[SDL_CONTROLLER_AXIS_RIGHTY]; + break; + default: // JOY_SCHEME_DEFAULT + // Default configuration + axis.x = state->axisvalue[SDL_CONTROLLER_AXIS_LEFTX]; + axis.y = state->axisvalue[SDL_CONTROLLER_AXIS_LEFTY]; + break; + } + return axis; } + static qboolean IN_JoyActive (void) { return joy_active_controller != NULL && (joy_always_active.value || lastactivetype == KD_GAMEPAD); @@ -1496,7 +1534,7 @@ float IN_GetRawLookMagnitude (void) if (!joy_active_controller) return 0.f; - axis.x = joy_axisstate.axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_LEFTX : SDL_CONTROLLER_AXIS_RIGHTX]; + axis.x = joy_axisstate.axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_LEFTX : SDL_CONTROLLER_AXIS_RIGHTX ]; axis.y = joy_axisstate.axisvalue[joy_swapmovelook.value ? SDL_CONTROLLER_AXIS_LEFTY : SDL_CONTROLLER_AXIS_RIGHTY]; return IN_AxisMagnitude (axis); diff --git a/Quake/menu.c b/Quake/menu.c index bac40bcf..1e10c9b1 100644 --- a/Quake/menu.c +++ b/Quake/menu.c @@ -3927,7 +3927,7 @@ void M_AdjustSliders (int dir) Cvar_SetValueQuick (&joy_invert, !joy_invert.value); break; case GPAD_OPT_SWAP_MOVELOOK: - Cvar_SetValueQuick (&joy_swapmovelook, !joy_swapmovelook.value); + Cvar_SetValueQuick(&joy_swapmovelook, fmod(joy_swapmovelook.value + 1, 3)); break; case GPAD_OPT_EXPONENT_LOOK: Cvar_SetValueQuick (&joy_exponent, CLAMP (MIN_JOY_EXPONENT, joy_exponent.value + dir * 0.5f, MAX_JOY_EXPONENT)); @@ -4549,7 +4549,20 @@ static void M_Options_DrawItem (int y, int item) M_DrawCheckbox (x, y, joy_invert.value); break; case GPAD_OPT_SWAP_MOVELOOK: - M_Print (x, y, joy_swapmovelook.value ? "Left" : "Right"); + switch ((int)joy_swapmovelook.value) { + case 0: + M_Print(x, y, "Right"); + break; + case 1: + M_Print(x, y, "Left"); + break; + case 2: + M_Print(x, y, "Legacy"); + break; + default: + M_Print(x, y, "Unknown"); + break; + } break; case GPAD_OPT_EXPONENT_LOOK: r = (joy_exponent.value - MIN_JOY_EXPONENT) / (MAX_JOY_EXPONENT - MIN_JOY_EXPONENT); diff --git a/Quakespasm.html b/Quakespasm.html index 457957b6..4f6342fa 100644 --- a/Quakespasm.html +++ b/Quakespasm.html @@ -141,7 +141,9 @@