From 8b53ce4cfe9ce8468494497f2abfabd0ea04f191 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 30 Aug 2021 21:57:31 +0200 Subject: [PATCH] Swap gamepad attack and throw button on dualwield weapons to make left trigger match left weapon etc --- src/Components/Modules/Gamepad.cpp | 15 +++++++++++++++ src/Game/Structs.hpp | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index c7679725..4e4adecb 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -831,6 +831,21 @@ namespace Components cmd->rightmove = ClampChar(cmd->rightmove + rightMove); cmd->forwardmove = ClampChar(cmd->forwardmove + forwardMove); + // Swap attack and throw buttons when using controller and akimbo to match "left trigger"="left weapon" and "right trigger"="right weapon" + if(gamePad.inUse && clientActive.snap.ps.weapCommon.lastWeaponHand == Game::WEAPON_HAND_LEFT) + { + auto oldButtons = cmd->buttons; + if (oldButtons & Game::CMD_BUTTON_ATTACK) + cmd->buttons |= Game::CMD_BUTTON_THROW; + else + cmd->buttons &= ~Game::CMD_BUTTON_THROW; + + if (oldButtons & Game::CMD_BUTTON_THROW) + cmd->buttons |= Game::CMD_BUTTON_ATTACK; + else + cmd->buttons &= ~Game::CMD_BUTTON_ATTACK; + } + // Check for frozen controls. Flag name should start with PMF_ if (CG_ShouldUpdateViewAngles(gamePadIndex) && (clientActive.snap.ps.pm_flags & 0x800) == 0) { diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index b4d31f06..18710994 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1296,6 +1296,15 @@ namespace Game CMD_BUTTON_ACTIVATE = 0x8, CMD_BUTTON_RELOAD = 0x10, CMD_BUTTON_USE_RELOAD = 0x20, + CMD_BUTTON_PRONE = 0x100, + CMD_BUTTON_CROUCH = 0x200, + CMD_BUTTON_UP = 0x400, + CMD_BUTTON_ADS = 0x800, + CMD_BUTTON_DOWN = 0x1000, + CMD_BUTTON_BREATH = 0x2000, + CMD_BUTTON_FRAG = 0x4000, + CMD_BUTTON_OFFHAND_SECONDARY = 0x8000, + CMD_BUTTON_THROW = 0x80000, }; #pragma pack(push, 4)