shithub: wipeout

Download patch

ref: 24b6efd3ea9d12661a96bfbed6bc86241e30aa70
parent: 0e3422d345124535296317815d84b6516d782af7
author: Dominic Szablewski <dominic@phoboslab.org>
date: Tue Aug 15 19:35:02 EDT 2023

Fix input problems when rebinding input

--- a/src/input.c
+++ b/src/input.c
@@ -200,15 +200,14 @@
 void input_set_button_state(button_t button, float state) {
 	error_if(button < 0 || button >= INPUT_BUTTON_MAX, "Invalid input button %d", button);
 
+	input_set_layer_button_state(INPUT_LAYER_SYSTEM, button, state);
+	input_set_layer_button_state(INPUT_LAYER_USER, button, state);
+
 	if (capture_callback) {
-		if (state) {
+		if (state > INPUT_DEADZONE_CAPTURE) {
 			capture_callback(capture_user, button, 0);
 		}
-		return;
 	}
-
-	input_set_layer_button_state(INPUT_LAYER_SYSTEM, button, state);
-	input_set_layer_button_state(INPUT_LAYER_USER, button, state);
 }
 
 void input_set_mouse_pos(int32_t x, int32_t y) {
@@ -219,12 +218,12 @@
 void input_capture(input_capture_callback_t cb, void *user) {
 	capture_callback = cb;
 	capture_user = user;
-	clear(actions_state);
+	input_clear();
 }
 
 void input_textinput(int32_t ascii_char) {
 	if (capture_callback) {
-		capture_callback(capture_user, 0, ascii_char);
+		capture_callback(capture_user, INPUT_INVALID, ascii_char);
 	}
 }
 
@@ -233,6 +232,7 @@
 	error_if(action < 0 || action >= INPUT_ACTION_MAX, "Invalid input action %d", action);
 	error_if(layer < 0 || layer >= INPUT_LAYER_MAX, "Invalid input layer %d", layer);
 
+	actions_state[action] = 0;
 	bindings[layer][button] = action;
 }
 
--- a/src/input.h
+++ b/src/input.h
@@ -184,6 +184,7 @@
 #define INPUT_ACTION_COMMAND 31
 #define INPUT_ACTION_MAX 32
 #define INPUT_DEADZONE 0.1
+#define INPUT_DEADZONE_CAPTURE 0.5
 #define INPUT_ACTION_NONE 255
 #define INPUT_BUTTON_NONE 0