Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLIENT/SERVER: Fire the correct akimbo weapon when using gamepads #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/client/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions source/server/player/player_core.qc
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ void() PlayerPostThink =

// Network everything
self.SendFlags = 1;

// Used to tell which gun of the mustang and sally to shoot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revise this comment, there are more akimbo weapons than just the Mustang & Sally, and there should be further context here as to why this is relevant.

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"));
Expand Down
24 changes: 22 additions & 2 deletions source/server/weapons/weapon_core.qc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions source/shared/shared_defs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ float game_over;

#ifdef FTE
.float is_in_menu;
.float is_using_gamepad;
#endif // FTE

//
Expand Down