Allow the user to use their keyboard even if the gamepad is plugged in

This commit is contained in:
rackover 2021-05-04 15:54:12 +02:00
parent b3adacb71d
commit 1df84f7536

View File

@ -104,8 +104,11 @@ namespace Components
float viewStickX = abs(xiState->Gamepad.sThumbRX) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ? xiState->Gamepad.sThumbRX / (float)std::numeric_limits<SHORT>().max() : .0f; float viewStickX = abs(xiState->Gamepad.sThumbRX) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ? xiState->Gamepad.sThumbRX / (float)std::numeric_limits<SHORT>().max() : .0f;
float viewStickY = abs(xiState->Gamepad.sThumbRY) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ? xiState->Gamepad.sThumbRY / (float)std::numeric_limits<SHORT>().max() : .0f; float viewStickY = abs(xiState->Gamepad.sThumbRY) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ? xiState->Gamepad.sThumbRY / (float)std::numeric_limits<SHORT>().max() : .0f;
if (moveStickX != 0 || moveStickY != 0) {
// We check for 0:0 again so we don't overwrite keyboard input in case the user doesn't feel like using their gamepad, even though its plugged in
cmd->rightmove = moveStickX * std::numeric_limits<char>().max(); cmd->rightmove = moveStickX * std::numeric_limits<char>().max();
cmd->forwardmove = moveStickY * std::numeric_limits<char>().max(); cmd->forwardmove = moveStickY * std::numeric_limits<char>().max();
}
// Gamepad horizontal acceleration on view // Gamepad horizontal acceleration on view
if (abs(viewStickX) > 0.9f) { if (abs(viewStickX) > 0.9f) {