summaryrefslogtreecommitdiff
path: root/setup
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
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')
-rw-r--r--setup/configfile.c5
-rw-r--r--setup/joystick.c28
-rw-r--r--setup/joystick.h2
-rw-r--r--setup/mouse.c60
-rw-r--r--setup/mouse.h5
-rw-r--r--setup/txt_joybinput.c4
-rw-r--r--setup/txt_mouseinput.c4
7 files changed, 81 insertions, 27 deletions
diff --git a/setup/configfile.c b/setup/configfile.c
index 0a1e9e5f..d9b17af2 100644
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -272,6 +272,11 @@ static default_t extra_defaults_list[] =
{"joystick_x_invert", &joystick_x_invert, DEFAULT_INT, 0, 0},
{"joystick_y_axis", &joystick_y_axis, DEFAULT_INT, 0, 0},
{"joystick_y_invert", &joystick_y_invert, DEFAULT_INT, 0, 0},
+ {"joyb_strafeleft", &joybstrafeleft, DEFAULT_INT, 0, 0},
+ {"joyb_straferight", &joybstraferight, DEFAULT_INT, 0, 0},
+ {"dclick_use", &dclick_use, DEFAULT_INT, 0, 0},
+ {"mouseb_strafeleft", &mousebstrafeleft, DEFAULT_INT, 0, 0},
+ {"mouseb_straferight", &mousebstraferight, DEFAULT_INT, 0, 0},
};
static default_collection_t extra_defaults =
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();
diff --git a/setup/joystick.h b/setup/joystick.h
index 30b568ad..39cf0bf4 100644
--- a/setup/joystick.h
+++ b/setup/joystick.h
@@ -27,6 +27,8 @@ extern int joybfire;
extern int joybstrafe;
extern int joybuse;
extern int joybspeed;
+extern int joybstrafeleft;
+extern int joybstraferight;
extern int joystick_index;
extern int joystick_x_axis;
diff --git a/setup/mouse.c b/setup/mouse.c
index c2d7e155..bafccc87 100644
--- a/setup/mouse.c
+++ b/setup/mouse.c
@@ -39,9 +39,22 @@ int grabmouse = 1;
int mousebfire = 0;
int mousebforward = 1;
int mousebstrafe = 2;
-
-static int *all_mouse_buttons[] = {&mousebfire, &mousebstrafe,
- &mousebforward};
+int mousebstrafeleft = -1;
+int mousebstraferight = -1;
+int mousebbackward = -1;
+int mousebuse = -1;
+
+int dclick_use = 1;
+
+static int *all_mouse_buttons[] = {
+ &mousebfire,
+ &mousebstrafe,
+ &mousebforward,
+ &mousebstrafeleft,
+ &mousebstraferight,
+ &mousebbackward,
+ &mousebuse,
+};
static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
{
@@ -73,11 +86,31 @@ static void AddMouseControl(txt_table_t *table, char *label, int *var)
TXT_SignalConnect(mouse_input, "set", MouseSetCallback, var);
}
+static void ConfigExtraButtons(void)
+{
+ txt_window_t *window;
+ txt_table_t *buttons_table;
+
+ window = TXT_NewWindow("Additional mouse buttons");
+
+ TXT_AddWidgets(window,
+ buttons_table = TXT_NewTable(2),
+ NULL);
+
+ TXT_SetColumnWidths(buttons_table, 29, 5);
+
+ AddMouseControl(buttons_table, "Move backward", &mousebbackward);
+ AddMouseControl(buttons_table, "Use", &mousebuse);
+ AddMouseControl(buttons_table, "Strafe left", &mousebstrafeleft);
+ AddMouseControl(buttons_table, "Strafe right", &mousebstraferight);
+}
+
void ConfigMouse(void)
{
txt_window_t *window;
txt_table_t *motion_table;
- txt_table_t *button_table;
+ txt_table_t *buttons_table;
+ txt_button_t *more_buttons;
window = TXT_NewWindow("Mouse configuration");
@@ -86,14 +119,17 @@ void ConfigMouse(void)
TXT_NewInvertedCheckBox("Allow vertical mouse movement",
&novert),
TXT_NewCheckBox("Grab mouse in windowed mode",
- &grabmouse),
+ &grabmouse),
+ TXT_NewCheckBox("Double click acts as \"use\"",
+ &dclick_use),
TXT_NewSeparator("Mouse motion"),
motion_table = TXT_NewTable(2),
- TXT_NewSeparator("Mouse buttons"),
+ TXT_NewSeparator("Buttons"),
+ buttons_table = TXT_NewTable(2),
+ more_buttons = TXT_NewButton("More buttons..."),
- button_table = TXT_NewTable(2),
NULL);
TXT_SetColumnWidths(motion_table, 27, 5);
@@ -107,12 +143,14 @@ void ConfigMouse(void)
TXT_NewSpinControl(&mouse_threshold, 0, 32),
NULL);
- TXT_SetColumnWidths(button_table, 27, 5);
+ TXT_SetColumnWidths(buttons_table, 27, 5);
- AddMouseControl(button_table, "Fire weapon", &mousebfire);
- AddMouseControl(button_table, "Move forward", &mousebforward);
- AddMouseControl(button_table, "Strafe on", &mousebstrafe);
+ AddMouseControl(buttons_table, "Move forward", &mousebforward);
+ AddMouseControl(buttons_table, "Strafe on", &mousebstrafe);
+ AddMouseControl(buttons_table, "Fire weapon", &mousebfire);
TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
+
+ TXT_SignalConnect(more_buttons, "pressed", ConfigExtraButtons, NULL);
}
diff --git a/setup/mouse.h b/setup/mouse.h
index 445a50c7..f0a39ade 100644
--- a/setup/mouse.h
+++ b/setup/mouse.h
@@ -32,6 +32,11 @@ extern int grabmouse;
extern int mousebfire;
extern int mousebforward;
extern int mousebstrafe;
+extern int mousebstrafeleft;
+extern int mousebstraferight;
+extern int mousebbackward;
+extern int mousebuse;
+extern int dclick_use;
void ConfigMouse(void);
diff --git a/setup/txt_joybinput.c b/setup/txt_joybinput.c
index 0f05eaf4..7a94a996 100644
--- a/setup/txt_joybinput.c
+++ b/setup/txt_joybinput.c
@@ -143,9 +143,9 @@ static void TXT_JoystickInputDrawer(TXT_UNCAST_ARG(joystick_input), int selected
char buf[20];
int i;
- if (*joystick_input->variable == -1)
+ if (*joystick_input->variable < 0)
{
- strcpy(buf, "");
+ strcpy(buf, "(none)");
}
else
{
diff --git a/setup/txt_mouseinput.c b/setup/txt_mouseinput.c
index 4e8cf2f3..6b70d110 100644
--- a/setup/txt_mouseinput.c
+++ b/setup/txt_mouseinput.c
@@ -117,9 +117,9 @@ static void TXT_MouseInputDrawer(TXT_UNCAST_ARG(mouse_input), int selected)
char buf[20];
int i;
- if (*mouse_input->variable == -1)
+ if (*mouse_input->variable < 0)
{
- strcpy(buf, "");
+ strcpy(buf, "(none)");
}
else
{