Report 16-bit analog axis precision to the game instead of arbitrarily truncating it to ~14.3 bits.

git-svn-id: https://svn.eduke32.com/eduke32@7956 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2019-08-12 15:23:07 +00:00 committed by Christoph Oelckers
parent 44d5371ad3
commit 56998c4840
2 changed files with 9 additions and 8 deletions

View file

@ -2041,14 +2041,15 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
if (appactive && ev->jaxis.axis < joystick.numAxes) if (appactive && ev->jaxis.axis < joystick.numAxes)
{ {
joystick.pAxis[ev->jaxis.axis] = ev->jaxis.value * 10000 / 32767; joystick.pAxis[ev->jaxis.axis] = ev->jaxis.value;
if ((joystick.pAxis[ev->jaxis.axis] < joydead[ev->jaxis.axis]) && int32_t const scaledValue = ev->jaxis.value * 10000 / 32767;
(joystick.pAxis[ev->jaxis.axis] > -joydead[ev->jaxis.axis])) if ((scaledValue < joydead[ev->jaxis.axis]) &&
(scaledValue > -joydead[ev->jaxis.axis]))
joystick.pAxis[ev->jaxis.axis] = 0; joystick.pAxis[ev->jaxis.axis] = 0;
else if (joystick.pAxis[ev->jaxis.axis] >= joysatur[ev->jaxis.axis]) else if (scaledValue >= joysatur[ev->jaxis.axis])
joystick.pAxis[ev->jaxis.axis] = 10000; joystick.pAxis[ev->jaxis.axis] = 32767;
else if (joystick.pAxis[ev->jaxis.axis] <= -joysatur[ev->jaxis.axis]) else if (scaledValue <= -joysatur[ev->jaxis.axis])
joystick.pAxis[ev->jaxis.axis] = -10000; joystick.pAxis[ev->jaxis.axis] = -32767;
else else
joystick.pAxis[ev->jaxis.axis] = joystick.pAxis[ev->jaxis.axis] * 10000 / joysatur[ev->jaxis.axis]; joystick.pAxis[ev->jaxis.axis] = joystick.pAxis[ev->jaxis.axis] * 10000 / joysatur[ev->jaxis.axis];
} }

View file

@ -2946,7 +2946,7 @@ void P_GetInput(int const playerNum)
int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run)); int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
constexpr int const analogExtent = 10000; // KEEPINSYNC sdlayer.cpp constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
input_t input {}; input_t input {};