Skip to content

Commit

Permalink
hexen/g_game.c: Include miscellaneous mouse functionality
Browse files Browse the repository at this point in the history
Strafe left, strafe right, and move backward mouse commands work.
'Double click acts as "use"' option works, where previously it was
always enabled.

Fix for #813
  • Loading branch information
CapnClever committed Nov 20, 2016
1 parent dc4eb0b commit 84a2e9f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 43 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
* Fixed an issue where the game crashed while killing the
Wraithverge in 64-bit builds. (thanks J.Benaim)
* Added unlimited demo/savegame support. (thanks CapnClever)
* Mouse buttons for strafe left/right and move backward, as well as
'Double click acts as "use"' mouse option, now function properly.
(thanks CapnClever)

### Strife
* Support added for automatic loading of the IWAD from the GOG.com
Expand Down
95 changes: 52 additions & 43 deletions src/hexen/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)
{
forward -= forwardmove[pClass][speed];
}
if (gamekeydown[key_straferight] || joystrafemove > 0
|| joybuttons[joybstraferight])
if (gamekeydown[key_straferight] || mousebuttons[mousebstraferight]
|| joystrafemove > 0 || joybuttons[joybstraferight])
{
side += sidemove[pClass][speed];
}
if (gamekeydown[key_strafeleft] || joystrafemove < 0
|| joybuttons[joybstrafeleft])
if (gamekeydown[key_strafeleft] || mousebuttons[mousebstrafeleft]
|| joystrafemove < 0 || joybuttons[joybstrafeleft])
{
side -= sidemove[pClass][speed];
}
Expand Down Expand Up @@ -504,57 +504,66 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)
{
forward += forwardmove[pClass][speed];
}
if (mousebuttons[mousebbackward])
{
forward -= forwardmove[pClass][speed];
}

//
// forward double click
//
if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1)
// Double click to use can be disabled

if (dclick_use)
{
dclickstate = mousebuttons[mousebforward];
if (dclickstate)
dclicks++;
if (dclicks == 2)
//
// forward double click
//
if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1)
{
cmd->buttons |= BT_USE;
dclicks = 0;
dclickstate = mousebuttons[mousebforward];
if (dclickstate)
dclicks++;
if (dclicks == 2)
{
cmd->buttons |= BT_USE;
dclicks = 0;
}
else
dclicktime = 0;
}
else
dclicktime = 0;
}
else
{
dclicktime += ticdup;
if (dclicktime > 20)
{
dclicks = 0;
dclickstate = 0;
dclicktime += ticdup;
if (dclicktime > 20)
{
dclicks = 0;
dclickstate = 0;
}
}
}

//
// strafe double click
//
bstrafe = mousebuttons[mousebstrafe] || joybuttons[joybstrafe];
if (bstrafe != dclickstate2 && dclicktime2 > 1)
{
dclickstate2 = bstrafe;
if (dclickstate2)
dclicks2++;
if (dclicks2 == 2)
//
// strafe double click
//
bstrafe = mousebuttons[mousebstrafe] || joybuttons[joybstrafe];
if (bstrafe != dclickstate2 && dclicktime2 > 1)
{
cmd->buttons |= BT_USE;
dclicks2 = 0;
dclickstate2 = bstrafe;
if (dclickstate2)
dclicks2++;
if (dclicks2 == 2)
{
cmd->buttons |= BT_USE;
dclicks2 = 0;
}
else
dclicktime2 = 0;
}
else
dclicktime2 = 0;
}
else
{
dclicktime2 += ticdup;
if (dclicktime2 > 20)
{
dclicks2 = 0;
dclickstate2 = 0;
dclicktime2 += ticdup;
if (dclicktime2 > 20)
{
dclicks2 = 0;
dclickstate2 = 0;
}
}
}

Expand Down

0 comments on commit 84a2e9f

Please sign in to comment.