summaryrefslogtreecommitdiff
path: root/setup/joystick.c
diff options
context:
space:
mode:
authorSimon Howard2007-06-20 00:37:40 +0000
committerSimon Howard2007-06-20 00:37:40 +0000
commit856eebe52624ba5d780436feb349ea5ff2ee46b4 (patch)
treeaea6417f30dc26af06650457e1032bbaccdf5d94 /setup/joystick.c
parentd004976261747a47389b14eaf0d695a14fa0f497 (diff)
downloadchocolate-doom-856eebe52624ba5d780436feb349ea5ff2ee46b4.tar.gz
chocolate-doom-856eebe52624ba5d780436feb349ea5ff2ee46b4.tar.bz2
chocolate-doom-856eebe52624ba5d780436feb349ea5ff2ee46b4.zip
Add new configuration options for the mouse and joystick for controls
that are available through the keyboard. Justification: this is already possible through advanced mouse drivers and programs like js2x, so there might as well be a proper interface for it. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 918
Diffstat (limited to 'setup/joystick.c')
-rw-r--r--setup/joystick.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/setup/joystick.c b/setup/joystick.c
index d491aadf..eb7f9bfa 100644
--- a/setup/joystick.c
+++ b/setup/joystick.c
@@ -43,6 +43,8 @@ int joybfire = 0;
int joybstrafe = 1;
int joybuse = 2;
int joybspeed = 3;
+int joybstrafeleft = -1;
+int joybstraferight = -1;
// Joystick to use, as an SDL joystick index:
@@ -325,6 +327,12 @@ static void SetJoystickButtonLabel(void)
TXT_SetButtonLabel(joystick_button, name);
}
+static void AddJoystickControl(txt_table_t *table, char *label, int *var)
+{
+ TXT_AddWidget(table, TXT_NewLabel(label));
+ TXT_AddWidget(table, TXT_NewJoystickInput(var));
+}
+
void ConfigJoystick(void)
{
txt_window_t *window;
@@ -351,14 +359,8 @@ void ConfigJoystick(void)
TXT_SetColumnWidths(button_table, 20, 15);
- TXT_AddWidgets(button_table,
- TXT_NewLabel("Fire"),
- TXT_NewJoystickInput(&joybfire),
- TXT_NewLabel("Use"),
- TXT_NewJoystickInput(&joybuse),
- TXT_NewLabel("Strafe"),
- TXT_NewJoystickInput(&joybstrafe),
- NULL);
+ AddJoystickControl(button_table, "Fire", &joybfire);
+ AddJoystickControl(button_table, "Use", &joybuse);
// High values of joybspeed are used to activate the "always run mode"
// trick in Vanilla Doom. If this has been enabled, not only is the
@@ -366,12 +368,14 @@ void ConfigJoystick(void)
if (joybspeed < 20)
{
- TXT_AddWidgets(button_table,
- TXT_NewLabel("Speed"),
- TXT_NewJoystickInput(&joybspeed),
- NULL);
+ AddJoystickControl(button_table, "Speed", &joybspeed);
}
+ AddJoystickControl(button_table, "Strafe", &joybstrafe);
+
+ AddJoystickControl(button_table, "Strafe Left", &joybstrafeleft);
+ AddJoystickControl(button_table, "Strafe Right", &joybstraferight);
+
TXT_SignalConnect(joystick_button, "pressed", CalibrateJoystick, NULL);
SetJoystickButtonLabel();