shithub: choc

Download patch

ref: db9aee2bebf410ed9e4d44b1fae35a27de40289f
parent: 3a0370f2762c1927d7819377e798393e5d55ddd8
author: Simon Howard <[email protected]>
date: Mon Apr 28 21:09:07 EDT 2014

setup: Allow backspace or del to clear controls.

Backspace or delete clears other input boxes; make it do the same for
keyboard, mouse and joystick inputs.

--- a/src/setup/txt_joybinput.c
+++ b/src/setup/txt_joybinput.c
@@ -161,11 +161,11 @@
 {
 }
 
-static int TXT_JoystickInputKeyPress(TXT_UNCAST_ARG(joystick_input), int joystick)
+static int TXT_JoystickInputKeyPress(TXT_UNCAST_ARG(joystick_input), int key)
 {
     TXT_CAST_ARG(txt_joystick_input_t, joystick_input);
 
-    if (joystick == KEY_ENTER)
+    if (key == KEY_ENTER)
     {
         // Open a window to prompt for the new joystick press
 
@@ -172,6 +172,11 @@
         OpenPromptWindow(joystick_input);
 
         return 1;
+    }
+
+    if (key == KEY_BACKSPACE || key == KEY_DEL)
+    {
+        *joystick_input->variable = -1;
     }
 
     return 0;
--- a/src/setup/txt_keyinput.c
+++ b/src/setup/txt_keyinput.c
@@ -146,6 +146,11 @@
         return 1;
     }
 
+    if (key == KEY_BACKSPACE || key == KEY_DEL)
+    {
+        *key_input->variable = 0;
+    }
+
     return 0;
 }
 
--- a/src/setup/txt_mouseinput.c
+++ b/src/setup/txt_mouseinput.c
@@ -125,11 +125,11 @@
 {
 }
 
-static int TXT_MouseInputKeyPress(TXT_UNCAST_ARG(mouse_input), int mouse)
+static int TXT_MouseInputKeyPress(TXT_UNCAST_ARG(mouse_input), int key)
 {
     TXT_CAST_ARG(txt_mouse_input_t, mouse_input);
 
-    if (mouse == KEY_ENTER)
+    if (key == KEY_ENTER)
     {
         // Open a window to prompt for the new mouse press
 
@@ -136,6 +136,11 @@
         OpenPromptWindow(mouse_input);
 
         return 1;
+    }
+
+    if (key == KEY_BACKSPACE || key == KEY_DEL)
+    {
+        *mouse_input->variable = -1;
     }
 
     return 0;