Merge pull request #100 from Peter0x44/controller_akimbo_fire_correct_side

CLIENT/SERVER: Fire the correct akimbo weapon when using gamepads
This commit is contained in:
cypress 2024-12-30 23:20:08 -05:00 committed by GitHub
commit 77e8408394
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 2 deletions

View file

@ -892,9 +892,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)
{

View file

@ -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"));

View file

@ -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

View file

@ -316,6 +316,7 @@ float game_over;
#ifdef FTE
.float is_in_menu;
.float is_using_gamepad;
#endif // FTE
//