diff --git a/source/client/main.qc b/source/client/main.qc index 800356f..f87f6f2 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -904,9 +904,15 @@ noref float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent float last_input_storage = last_input_was_gamepad; if (last_input_deviceid > 0) + { last_input_was_gamepad = TRUE; + setlocaluserinfo(0, "using_gamepad", "1"); + } else + { last_input_was_gamepad = FALSE; + setlocaluserinfo(0, "using_gamepad", "0"); + } if (current_menu != MENU_NONE) { diff --git a/source/server/player/player_core.qc b/source/server/player/player_core.qc index 9d24c36..195b21c 100644 --- a/source/server/player/player_core.qc +++ b/source/server/player/player_core.qc @@ -592,6 +592,9 @@ void() PlayerPostThink = // Network everything self.SendFlags = 1; + + // Used to tell which gun to fire for akimbo weapons + self.is_using_gamepad = stof(infokey(self, "using_gamepad")); // Obtain menu state from CSQC via infokeys. self.is_in_menu = stof(infokey(self, "in_menu")); diff --git a/source/server/weapons/weapon_core.qc b/source/server/weapons/weapon_core.qc index 4ce8137..26f163a 100644 --- a/source/server/weapons/weapon_core.qc +++ b/source/server/weapons/weapon_core.qc @@ -1912,9 +1912,20 @@ void() WeaponCore_FireButtonPressed = // to which click of the mouse you've provided, which is different behavior // to single-hand weapons, where left click fires its right-side. (Hooray // for ternaries!). + // For gamepads, we don't want this behavior, because the gun that + // fires will be the wrong side #ifdef FTE - (IsDualWeapon(self.weapon)) ? W_Fire(S_LEFT) : W_Fire(S_RIGHT); + if (self.is_using_gamepad) + { + // Gamepads always fire the right side + W_Fire(S_RIGHT); + } + else + { + // Otherwise, fire the side of the mouse click for akimbo weapons + (IsDualWeapon(self.weapon)) ? W_Fire(S_LEFT) : W_Fire(S_RIGHT); + } #else @@ -1959,8 +1970,17 @@ void() WeaponCore_AimButtonPressed = // fire our secondary as opposed to Aiming down the Sight. if (IsDualWeapon(self.weapon)) { #ifdef FTE + // On KBM this is the right click, so it should fire the right weapon. + // On gamepads, this is the left trigger, so it should fire the left weapon. - W_Fire(S_RIGHT); + if (self.is_using_gamepad) + { + W_Fire(S_LEFT); + } + else + { + W_Fire(S_RIGHT); + } #else diff --git a/source/shared/shared_defs.qc b/source/shared/shared_defs.qc index d215852..24477b3 100644 --- a/source/shared/shared_defs.qc +++ b/source/shared/shared_defs.qc @@ -316,6 +316,7 @@ float game_over; #ifdef FTE .float is_in_menu; +.float is_using_gamepad; #endif // FTE //