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
This commit is contained in:
Eric Wasylishen 2018-02-05 06:37:50 +00:00
parent 3e2ee378b3
commit f910bae881
4 changed files with 24 additions and 15 deletions

View File

@ -158,6 +158,8 @@ these patched libSDL binaries may help.
<itemize> <itemize>
<item> Fixed a fog regression which was introduced in 0.93.0. <item> Fixed a fog regression which was introduced in 0.93.0.
<item> Fixed a crash (buffer overflow) with invalid vis data. <item> Fixed a crash (buffer overflow) with invalid vis data.
<item> Fixed buttons crushing players in 64-bit builds.
<item> Change controller movement to use cubic easing by default; added "joy_exponent_move" cvar.
</itemize> </itemize>
</p> </p>

View File

@ -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_sensitivity_pitch = { "joy_sensitivity_pitch", "150", CVAR_ARCHIVE };
cvar_t joy_invert = { "joy_invert", "0", CVAR_ARCHIVE }; cvar_t joy_invert = { "joy_invert", "0", CVAR_ARCHIVE };
cvar_t joy_exponent = { "joy_exponent", "3", 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_swapmovelook = { "joy_swapmovelook", "0", CVAR_ARCHIVE };
cvar_t joy_enable = { "joy_enable", "1", 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_deadzone_trigger);
Cvar_RegisterVariable(&joy_invert); Cvar_RegisterVariable(&joy_invert);
Cvar_RegisterVariable(&joy_exponent); Cvar_RegisterVariable(&joy_exponent);
Cvar_RegisterVariable(&joy_exponent_move);
Cvar_RegisterVariable(&joy_swapmovelook); Cvar_RegisterVariable(&joy_swapmovelook);
Cvar_RegisterVariable(&joy_enable); 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. 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. 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}; joyaxis_t result = {0};
vec_t eased_magnitude; vec_t eased_magnitude;
@ -462,21 +464,21 @@ static joyaxis_t IN_ApplyLookEasing(joyaxis_t axis, float exponent)
================ ================
IN_ApplyMoveEasing IN_ApplyMoveEasing
clamps coordinates to a square with coordinates +/- sqrt(2)/2, then scales them to +/- 1. same as IN_ApplyEasing, but scales the output by sqrt(2).
This wastes a bit of stick range, but gives the diagonals coordinates of (+/-1,+/-1), this gives diagonal stick inputs coordinates of (+/-1,+/-1).
so holding the stick on a diagonal gives the same speed boost as holding the forward and strafe keyboard keys.
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}; joyaxis_t result = IN_ApplyEasing(axis, exponent);
const float v = sqrtf(2.0f) / 2.0f; const float v = sqrtf(2.0f);
result.x = q_max(-v, q_min(v, axis.x)); result.x *= v;
result.y = q_max(-v, q_min(v, axis.y)); result.y *= v;
result.x /= v;
result.y /= v;
return result; return result;
} }
@ -671,8 +673,8 @@ void IN_JoyMove (usercmd_t *cmd)
moveDeadzone = IN_ApplyDeadzone(moveRaw, joy_deadzone.value); moveDeadzone = IN_ApplyDeadzone(moveRaw, joy_deadzone.value);
lookDeadzone = IN_ApplyDeadzone(lookRaw, joy_deadzone.value); lookDeadzone = IN_ApplyDeadzone(lookRaw, joy_deadzone.value);
moveEased = IN_ApplyMoveEasing(moveDeadzone); moveEased = IN_ApplyMoveEasing(moveDeadzone, joy_exponent_move.value);
lookEased = IN_ApplyLookEasing(lookDeadzone, joy_exponent.value); lookEased = IN_ApplyEasing(lookDeadzone, joy_exponent.value);
if ((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0)) if ((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
speed = cl_movespeedkey.value; speed = cl_movespeedkey.value;

View File

@ -252,6 +252,8 @@ these patched libSDL binaries may help.
<UL> <UL>
<LI> Fixed a fog regression which was introduced in 0.93.0.</LI> <LI> Fixed a fog regression which was introduced in 0.93.0.</LI>
<LI> Fixed a crash (buffer overflow) with invalid vis data.</LI> <LI> Fixed a crash (buffer overflow) with invalid vis data.</LI>
<LI> Fixed buttons crushing players in 64-bit builds.</LI>
<LI> Change controller movement to use cubic easing by default; added "joy_exponent_move" cvar.</LI>
</UL> </UL>
</P> </P>
<H2><A NAME="ss6.2">6.2</A> <A HREF="#toc6.2">Changes in 0.93.0</A> <H2><A NAME="ss6.2">6.2</A> <A HREF="#toc6.2">Changes in 0.93.0</A>

View File

@ -292,6 +292,9 @@
o Fixed a fog regression which was introduced in 0.93.0. o Fixed a fog regression which was introduced in 0.93.0.
o Fixed a crash (buffer overflow) with invalid vis data. 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 6.2. Changes in 0.93.0