diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 7c7599eb5b..07f26b2ecd 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 6f0636ddbc..6231f318a8 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 be035c22fa..ca0fe9dfc1 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 64034cbbec..625a1cff98 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 2a17670899..d38c5372b7 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); } }