shithub: choc

Download patch

ref: ec72b141f47cd1a5b061f9bc87c1a02e2722be59
parent: 6a1179122850be4da020b45f5dd1bf1c8c068b09
author: Simon Howard <fraggle@soulsphere.org>
date: Wed Apr 15 16:52:23 EDT 2015

setup: Remove "enable gamepad" checkbox.

This control seemed redundant, as we have the control below it that
selects the gamepad to use. So remove it and set the usejoystick
variable automatically based on whether joystick_index has been
configured to point to a valid device.

--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -568,7 +568,7 @@
 
     result = 0;
 
-    for (i=0; i<num_joysticks; ++i) 
+    for (i = 0; i < num_joysticks; ++i)
     {
         all_joysticks[i] = SDL_JoystickOpen(i);
 
@@ -604,7 +604,7 @@
 
     num_joysticks = SDL_NumJoysticks();
 
-    for (i=0; i<num_joysticks; ++i)
+    for (i = 0; i < num_joysticks; ++i)
     {
         if (all_joysticks[i] != NULL)
         {
@@ -635,6 +635,7 @@
     // At this point, we have a button press.
     // In the first "center" stage, we're just trying to work out which
     // joystick is being configured and which button the user is pressing.
+    usejoystick = 1;
     joystick_index = event->jbutton.which;
     calibrate_button = event->jbutton.button;
 
@@ -643,7 +644,6 @@
     if (IsKnownJoystick(joystick_index))
     {
         LoadKnownConfiguration();
-        usejoystick = 1;
         TXT_CloseWindow(calibration_window);
     }
     else
@@ -661,11 +661,12 @@
 
 static void NoJoystick(void)
 {
-    TXT_MessageBox(NULL, "No joysticks or gamepads could be found.\n\n"
+    TXT_MessageBox(NULL, "No gamepads or joysticks could be found.\n\n"
                          "Try configuring your controller from within\n"
                          "your OS first. Maybe you need to install\n"
                          "some drivers or otherwise configure it.");
 
+    usejoystick = 0;
     joystick_index = -1;
     SetJoystickButtonLabel();
 }
@@ -707,7 +708,7 @@
     TXT_SignalConnect(calibration_window, "closed", CalibrateWindowClosed, NULL);
 
     // Start calibration
-
+    usejoystick = 0;
     joystick_index = -1;
 }
 
@@ -736,7 +737,6 @@
     TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);
 
     TXT_AddWidgets(window,
-                   TXT_NewCheckBox("Enable gamepad/joystick", &usejoystick),
                    joystick_table = TXT_NewTable(2),
                    TXT_NewSeparator("Axes"),
                    axis_table = TXT_NewTable(2),
@@ -744,6 +744,13 @@
                    button_table = TXT_NewTable(4),
                    NULL);
 
+    TXT_SetColumnWidths(joystick_table, 13, 40);
+
+    TXT_AddWidgets(joystick_table,
+                   TXT_NewLabel("Controller"),
+                   joystick_button = TXT_NewButton("zzzz"),
+                   NULL);
+
     TXT_SetColumnWidths(axis_table, 20, 15);
 
     TXT_AddWidgets(axis_table,
@@ -759,13 +766,6 @@
                    TXT_NewJoystickAxis(&joystick_strafe_axis,
                                        &joystick_strafe_invert,
                                         JOYSTICK_AXIS_HORIZONTAL),
-                   NULL);
-
-    TXT_SetColumnWidths(joystick_table, 20, 15);
-
-    TXT_AddWidgets(joystick_table,
-                   TXT_NewLabel("Current controller"),
-                   joystick_button = TXT_NewButton("zzzz"),
                    NULL);
 
     TXT_SetColumnWidths(button_table, 16, 12, 14, 11);