shithub: choc

Download patch

ref: dc4eb0ba8d0bac8059c060b5965db13f5c86dd12
parent: 226a67f8bf8cb6de3b9f8cf81cd9c674ffbb5347
parent: 8c282de8f96d29384d515248d8a1cd63a3f53177
author: Simon Howard <fraggle+github@gmail.com>
date: Sat Nov 12 19:36:02 EST 2016

Merge pull request #805 from AXDOOMER/master

Fix number of joystick buttons so Chocolate-Setup doesn't crash

--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -68,7 +68,7 @@
 // Virtual to physical button joystick button mapping. By default this
 // is a straight mapping.
 static int joystick_physical_buttons[NUM_VIRTUAL_BUTTONS] = {
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
 };
 
 void I_ShutdownJoystick(void)
--- a/src/i_joystick.h
+++ b/src/i_joystick.h
@@ -22,7 +22,7 @@
 // Number of "virtual" joystick buttons defined in configuration files.
 // This needs to be at least as large as the number of different key
 // bindings supported by the higher-level game code (joyb* variables).
-#define NUM_VIRTUAL_BUTTONS 10
+#define NUM_VIRTUAL_BUTTONS 11
 
 // If this bit is set in a configuration file axis value, the axis is
 // not actually a joystick axis, but instead is a "button axis". This
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1033,6 +1033,13 @@
     CONFIG_VARIABLE_INT(joystick_physical_button9),
 
     //!
+    // The physical joystick button that corresponds to joystick
+    // virtual button #10.
+    //
+
+    CONFIG_VARIABLE_INT(joystick_physical_button10),
+
+    //!
     // Joystick virtual button to make the player strafe left.
     //
 
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -81,7 +81,7 @@
 
 // Virtual to physical mapping.
 int joystick_physical_buttons[NUM_VIRTUAL_BUTTONS] = {
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
 };
 
 static txt_button_t *joystick_button;
--- a/src/setup/txt_joybinput.c
+++ b/src/setup/txt_joybinput.c
@@ -44,7 +44,7 @@
 // button that the user wants to use for firing. We do this so that
 // the menus work (the game code is hard coded to interpret
 // button #0 = select menu item, button #1 = go back to previous menu).
-static int *all_joystick_buttons[] =
+static int *all_joystick_buttons[NUM_VIRTUAL_BUTTONS] =
 {
     &joybfire,
     &joybuse,
@@ -72,7 +72,7 @@
 }
 
 // Get the virtual button number for the given variable, ie. the
-// variable's index in all_joystick_buttons[].
+// variable's index in all_joystick_buttons[NUM_VIRTUAL_BUTTONS].
 static int VirtualButtonForVariable(int *variable)
 {
     int i;
@@ -91,7 +91,7 @@
 
 // Rearrange joystick button configuration to be in "canonical" form:
 // each joyb* variable should have a value equal to its index in
-// all_joystick_buttons[] above.
+// all_joystick_buttons[NUM_VIRTUAL_BUTTONS] above.
 static void CanonicalizeButtons(void)
 {
     int new_mapping[NUM_VIRTUAL_BUTTONS];