From f8212328b16d8c24a6915e77bab47cd19446a033 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Sun, 23 Jun 2024 02:29:49 -0400 Subject: [PATCH] Added a delay timer to prevent faulty joystick inputs on the symbol wheel. --- UI/ControllerInput/controller_input_symbol_wheel.gd | 5 ++++- UI/ControllerInput/controller_input_symbol_wheel.tscn | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UI/ControllerInput/controller_input_symbol_wheel.gd b/UI/ControllerInput/controller_input_symbol_wheel.gd index 7586dc9..b16bff8 100644 --- a/UI/ControllerInput/controller_input_symbol_wheel.gd +++ b/UI/ControllerInput/controller_input_symbol_wheel.gd @@ -19,6 +19,8 @@ extends Control @export var joypad_symbol_left : InputEventJoypadMotion @export var joypad_symbol_right : InputEventJoypadMotion +@onready var __joystick_flick_timer : Timer = $JoystickFlickTimer + signal new_character(char:String) var __symbol_labels : Array = [] @@ -73,13 +75,14 @@ func deselect() -> void: func __new_symbol_selection(new_selection:int) -> void: if __selected_label == new_selection: return - if new_selection < 0: + if new_selection < 0 and __joystick_flick_timer.is_stopped(): var send_char : String = wheel_characters[__selected_label] if not send_char.is_empty(): if send_char == "␣": new_character.emit(" ") else: new_character.emit(send_char) + __joystick_flick_timer.start() if __selected_label >= 0: __deselect_symbol(__selected_label) diff --git a/UI/ControllerInput/controller_input_symbol_wheel.tscn b/UI/ControllerInput/controller_input_symbol_wheel.tscn index 0b6fb4e..0295ceb 100644 --- a/UI/ControllerInput/controller_input_symbol_wheel.tscn +++ b/UI/ControllerInput/controller_input_symbol_wheel.tscn @@ -53,3 +53,7 @@ grow_vertical = 2 scale = Vector2(0.85, 0.85) pivot_offset = Vector2(175, 175) color = Color(0.303233, 0.303233, 0.303233, 1) + +[node name="JoystickFlickTimer" type="Timer" parent="."] +wait_time = 0.05 +one_shot = true