From bc3448e958df32f5ed49542ee68f48bd51aa9bf6 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 23 Jul 2009 05:37:03 +0000 Subject: [PATCH] - Removed specific Button_Speed handling from the controllers' AddAxes() methods. Analog axes now respond Button_Speed and cl_run in exactly the same way as digital buttons do. - Changed rounding slightly for analog axis -> integer in G_BuildTiccmd(). - Fixed: FXInputController::ProcessThumbstick() was slightly off when it converted to the range [-1.0,+1.0]. SVN r1733 (trunk) --- docs/rh-log.txt | 6 ++++++ src/g_game.cpp | 20 ++++++++++++++++---- src/win32/i_dijoy.cpp | 8 +------- src/win32/i_rawps2.cpp | 12 ++---------- src/win32/i_xinput.cpp | 14 +++----------- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 7c7599eb5..07f26b2ec 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ July 22, 2009 +- Removed specific Button_Speed handling from the controllers' AddAxes() + methods. Analog axes now respond Button_Speed and cl_run in exactly the + same way as digital buttons do. +- Changed rounding slightly for analog axis -> integer in G_BuildTiccmd(). +- Fixed: FXInputController::ProcessThumbstick() was slightly off when it + converted to the range [-1.0,+1.0]. - Added default bindings for the Xbox 360 controller buttons. - Fixed: Redefining an existing skill would set that skills ACSReturn to be the same as the next new skill defined, if neither definition explicitly set diff --git a/src/g_game.cpp b/src/g_game.cpp index 6f0636ddb..6231f318a 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -458,6 +458,18 @@ CCMD (select) who->player->inventorytics = 5*TICRATE; } +static inline int joyint(double val) +{ + if (val >= 0) + { + return int(ceil(val)); + } + else + { + return int(floor(val)); + } +} + // // G_BuildTiccmd // Builds a ticcmd from all of the available inputs @@ -605,10 +617,10 @@ void G_BuildTiccmd (ticcmd_t *cmd) LocalKeyboardTurner = true; } - side -= int(MAXPLMOVE * joyaxes[JOYAXIS_Side]); - forward += int(joyaxes[JOYAXIS_Forward] * MAXPLMOVE); - fly += int(joyaxes[JOYAXIS_Up] * 2048); - + side -= joyint(sidemove[speed] * joyaxes[JOYAXIS_Side]); + forward += joyint(joyaxes[JOYAXIS_Forward] * forwardmove[speed]); + fly += joyint(joyaxes[JOYAXIS_Up] * 2048); +Printf("%d %d %.9f %.9f\n", forward, side, joyaxes[JOYAXIS_Forward], joyaxes[JOYAXIS_Side]); // Handle mice. if (!Button_Mlook.bDown && !freelook) { diff --git a/src/win32/i_dijoy.cpp b/src/win32/i_dijoy.cpp index be035c22f..ca0fe9dfc 100644 --- a/src/win32/i_dijoy.cpp +++ b/src/win32/i_dijoy.cpp @@ -458,16 +458,10 @@ void FDInputJoystick::ProcessInput() void FDInputJoystick::AddAxes(float axes[NUM_JOYAXIS]) { - float mul = Multiplier; - if (Button_Speed.bDown) - { - mul *= 0.5f; - } - for (unsigned i = 0; i < Axes.Size(); ++i) { // Add to the game axis. - axes[Axes[i].GameAxis] -= float(Axes[i].Value * mul * Axes[i].Multiplier); + axes[Axes[i].GameAxis] -= float(Axes[i].Value * Multiplier * Axes[i].Multiplier); } } diff --git a/src/win32/i_rawps2.cpp b/src/win32/i_rawps2.cpp index 64034cbbe..625a1cff9 100644 --- a/src/win32/i_rawps2.cpp +++ b/src/win32/i_rawps2.cpp @@ -593,18 +593,10 @@ void FRawPS2Controller::NeutralInput() void FRawPS2Controller::AddAxes(float axes[NUM_JOYAXIS]) { - float mul = Multiplier; - int i; - - if (Button_Speed.bDown) - { - mul *= 0.5f; - } - // Add to game axes. - for (i = 0; i < NUM_AXES; ++i) + for (int i = 0; i < NUM_AXES; ++i) { - axes[Axes[i].GameAxis] -= float(Axes[i].Value * mul * Axes[i].Multiplier); + axes[Axes[i].GameAxis] -= float(Axes[i].Value * Multiplier * Axes[i].Multiplier); } } diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp index 2a1767089..d38c5372b 100644 --- a/src/win32/i_xinput.cpp +++ b/src/win32/i_xinput.cpp @@ -267,7 +267,7 @@ void FXInputController::ProcessThumbstick(int value, AxisInfo *axis, int base) BYTE buttonstate; double axisval; - axisval = (value - SHRT_MIN) * 2.0 / (SHRT_MAX - SHRT_MIN) - 1.0; + axisval = (value - SHRT_MIN) * 2.0 / 65536 - 1.0; axisval = Joy_RemoveDeadZone(axisval, axis->DeadZone, &buttonstate); Joy_GenerateButtonEvents(axis->ButtonValue, buttonstate, 2, base); axis->ButtonValue = buttonstate; @@ -354,18 +354,10 @@ void FXInputController::Detached() void FXInputController::AddAxes(float axes[NUM_JOYAXIS]) { - float mul = Multiplier; - int i; - - if (Button_Speed.bDown) - { - mul *= 0.5f; - } - // Add to game axes. - for (i = 0; i < NUM_AXES; ++i) + for (int i = 0; i < NUM_AXES; ++i) { - axes[Axes[i].GameAxis] -= float(Axes[i].Value * mul * Axes[i].Multiplier); + axes[Axes[i].GameAxis] -= float(Axes[i].Value * Multiplier * Axes[i].Multiplier); } }