From f910bae8814725ffa0f1f0359edba12f12069bfa Mon Sep 17 00:00:00 2001
From: Eric Wasylishen
Date: Mon, 5 Feb 2018 06:37:50 +0000
Subject: [PATCH] in_sdl: Change controller movement to use cubic easing by
default; added "joy_exponent_move" cvar.
Previously movement was linear.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1556 af15c1b1-3010-417e-b628-4374ebc0bcbd
---
Linux/sgml/Quakespasm.sgml | 2 ++
Quake/in_sdl.c | 32 +++++++++++++++++---------------
Quakespasm.html | 2 ++
Quakespasm.txt | 3 +++
4 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/Linux/sgml/Quakespasm.sgml b/Linux/sgml/Quakespasm.sgml
index be90a243..7fcc52b7 100644
--- a/Linux/sgml/Quakespasm.sgml
+++ b/Linux/sgml/Quakespasm.sgml
@@ -158,6 +158,8 @@ these patched libSDL binaries may help.
- Fixed a fog regression which was introduced in 0.93.0.
- Fixed a crash (buffer overflow) with invalid vis data.
+
- Fixed buttons crushing players in 64-bit builds.
+
- Change controller movement to use cubic easing by default; added "joy_exponent_move" cvar.
diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c
index 5e114138..bc8b55bf 100644
--- a/Quake/in_sdl.c
+++ b/Quake/in_sdl.c
@@ -55,6 +55,7 @@ cvar_t joy_sensitivity_yaw = { "joy_sensitivity_yaw", "300", CVAR_ARCHIVE };
cvar_t joy_sensitivity_pitch = { "joy_sensitivity_pitch", "150", CVAR_ARCHIVE };
cvar_t joy_invert = { "joy_invert", "0", CVAR_ARCHIVE };
cvar_t joy_exponent = { "joy_exponent", "3", CVAR_ARCHIVE };
+cvar_t joy_exponent_move = { "joy_exponent_move", "3", CVAR_ARCHIVE };
cvar_t joy_swapmovelook = { "joy_swapmovelook", "0", CVAR_ARCHIVE };
cvar_t joy_enable = { "joy_enable", "1", CVAR_ARCHIVE };
@@ -370,6 +371,7 @@ void IN_Init (void)
Cvar_RegisterVariable(&joy_deadzone_trigger);
Cvar_RegisterVariable(&joy_invert);
Cvar_RegisterVariable(&joy_exponent);
+ Cvar_RegisterVariable(&joy_exponent_move);
Cvar_RegisterVariable(&joy_swapmovelook);
Cvar_RegisterVariable(&joy_enable);
@@ -436,13 +438,13 @@ static vec_t IN_AxisMagnitude(joyaxis_t axis)
/*
================
-IN_ApplyLookEasing
+IN_ApplyEasing
assumes axis values are in [-1, 1] and the vector magnitude has been clamped at 1.
Raises the axis values to the given exponent, keeping signs.
================
*/
-static joyaxis_t IN_ApplyLookEasing(joyaxis_t axis, float exponent)
+static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent)
{
joyaxis_t result = {0};
vec_t eased_magnitude;
@@ -462,21 +464,21 @@ static joyaxis_t IN_ApplyLookEasing(joyaxis_t axis, float exponent)
================
IN_ApplyMoveEasing
-clamps coordinates to a square with coordinates +/- sqrt(2)/2, then scales them to +/- 1.
-This wastes a bit of stick range, but gives the diagonals coordinates of (+/-1,+/-1),
-so holding the stick on a diagonal gives the same speed boost as holding the forward and strafe keyboard keys.
+same as IN_ApplyEasing, but scales the output by sqrt(2).
+this gives diagonal stick inputs coordinates of (+/-1,+/-1).
+
+forward/back/left/right will return +/- 1.41; this shouldn't be a problem because
+you can pull back on the stick to go slower (and the final speed is clamped
+by sv_maxspeed).
================
*/
-static joyaxis_t IN_ApplyMoveEasing(joyaxis_t axis)
+static joyaxis_t IN_ApplyMoveEasing(joyaxis_t axis, float exponent)
{
- joyaxis_t result = {0};
- const float v = sqrtf(2.0f) / 2.0f;
+ joyaxis_t result = IN_ApplyEasing(axis, exponent);
+ const float v = sqrtf(2.0f);
- result.x = q_max(-v, q_min(v, axis.x));
- result.y = q_max(-v, q_min(v, axis.y));
-
- result.x /= v;
- result.y /= v;
+ result.x *= v;
+ result.y *= v;
return result;
}
@@ -671,8 +673,8 @@ void IN_JoyMove (usercmd_t *cmd)
moveDeadzone = IN_ApplyDeadzone(moveRaw, joy_deadzone.value);
lookDeadzone = IN_ApplyDeadzone(lookRaw, joy_deadzone.value);
- moveEased = IN_ApplyMoveEasing(moveDeadzone);
- lookEased = IN_ApplyLookEasing(lookDeadzone, joy_exponent.value);
+ moveEased = IN_ApplyMoveEasing(moveDeadzone, joy_exponent_move.value);
+ lookEased = IN_ApplyEasing(lookDeadzone, joy_exponent.value);
if ((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
speed = cl_movespeedkey.value;
diff --git a/Quakespasm.html b/Quakespasm.html
index 70e38a4b..790f7319 100644
--- a/Quakespasm.html
+++ b/Quakespasm.html
@@ -252,6 +252,8 @@ these patched libSDL binaries may help.
- Fixed a fog regression which was introduced in 0.93.0.
- Fixed a crash (buffer overflow) with invalid vis data.
+- Fixed buttons crushing players in 64-bit builds.
+- Change controller movement to use cubic easing by default; added "joy_exponent_move" cvar.
6.2 Changes in 0.93.0
diff --git a/Quakespasm.txt b/Quakespasm.txt
index 066de9d9..a94a6190 100644
--- a/Quakespasm.txt
+++ b/Quakespasm.txt
@@ -292,6 +292,9 @@
o Fixed a fog regression which was introduced in 0.93.0.
o Fixed a crash (buffer overflow) with invalid vis data.
+ o Fixed buttons crushing players in 64-bit builds.
+ o Change controller movement to use cubic easing by default; added
+ "joy_exponent_move" cvar.
6.2. Changes in 0.93.0