summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2014-04-30 01:00:28 -0400
committerSimon Howard2014-04-30 01:00:28 -0400
commitea90460a261fb602af273041f3b226f2b723ebd2 (patch)
tree27777c49208ddf9f369807912ce169af59989ebe /src
parent3bc4cfcf875fe4648e2d29e4b949a58a9a707fe7 (diff)
downloadchocolate-doom-ea90460a261fb602af273041f3b226f2b723ebd2.tar.gz
chocolate-doom-ea90460a261fb602af273041f3b226f2b723ebd2.tar.bz2
chocolate-doom-ea90460a261fb602af273041f3b226f2b723ebd2.zip
joystick: Mask out bits for button axis buttons.
When a "button" is actually used as part of a button axis, don't include presses on the button as part of the buttons field posted in joystick events. This avoids situations where button 1 or 2 are part of a D-pad, breaking menu navigation (related to #389).
Diffstat (limited to 'src')
-rw-r--r--src/i_joystick.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/i_joystick.c b/src/i_joystick.c
index 8822f288..de10fa08 100644
--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -159,6 +159,29 @@ void I_InitJoystick(void)
I_AtExit(I_ShutdownJoystick, true);
}
+static int ButtonAxisMask(void)
+{
+ int result = 0;
+
+ if (IS_BUTTON_AXIS(joystick_x_axis))
+ {
+ result |= 1 << BUTTON_AXIS_NEG(joystick_x_axis);
+ result |= 1 << BUTTON_AXIS_POS(joystick_x_axis);
+ }
+ if (IS_BUTTON_AXIS(joystick_y_axis))
+ {
+ result |= 1 << BUTTON_AXIS_NEG(joystick_y_axis);
+ result |= 1 << BUTTON_AXIS_POS(joystick_y_axis);
+ }
+ if (IS_BUTTON_AXIS(joystick_strafe_axis))
+ {
+ result |= 1 << BUTTON_AXIS_NEG(joystick_strafe_axis);
+ result |= 1 << BUTTON_AXIS_POS(joystick_strafe_axis);
+ }
+
+ return result;
+}
+
// Get a bitmask of all currently-pressed buttons
static int GetButtonState(void)
@@ -176,6 +199,9 @@ static int GetButtonState(void)
}
}
+ // Mask out any buttons that are actually used in axes.
+ result &= ~ButtonAxisMask();
+
return result;
}