Symbol wheel is much less likely to input incorrect characters

Input detection now has a buffer zone, where selections are only detected at
the extreme edges of the joystick range, but are deselected only after moving
through a larger range toward the centre. This creates a buffer zone where
selections are unlikely to happen by accident due to worn-out or limited
joystick ranges around the outside edge, and deselections are unlikely to
happen until the user actually releases the joystick. Phantom inputs are now
seemingly entirely eliminated.
This commit is contained in:
Jamie Greunbaum 2024-06-23 00:27:26 -04:00
parent 9a4c39c386
commit 3073485e92
2 changed files with 27 additions and 18 deletions

View File

@ -74,21 +74,15 @@ func _input(event:InputEvent) -> void:
var wheels_count : int = __wheels.size()
var index : int = -1
var index : int = __selected_wheel
var left_stick_vector : Vector2 = Input.get_vector(&"select_wheel_left", &"select_wheel_right", &"select_wheel_up", &"select_wheel_down", 0.95)
if left_stick_vector.length_squared() - 0.01 > 0.0:
if left_stick_vector.length() >= 0.95:
var stick_angle : float = ((Vector2.UP).rotated(left_stick_vector.angle() + (TAU / wheels_count / 2.0)).angle() + PI) / TAU
index = int(floor(stick_angle * wheels_count))
elif left_stick_vector.length() < 0.8:
index = -1
if index != __selected_wheel:
var old_selected_wheel : int = __selected_wheel
__selected_wheel = index
if old_selected_wheel >= 0:
__deselect_wheel(old_selected_wheel)
if __selected_wheel >= 0:
__select_wheel(__selected_wheel)
__new_wheel_selection(index)
func __select_wheel(selection:int) -> void:
@ -125,6 +119,19 @@ func __deselect_wheel(deselection:int) -> void:
wheel.deselect()
func __new_wheel_selection(new_selection:int) -> void:
if __selected_wheel == new_selection: return
var old_selected_wheel : int = __selected_wheel
__selected_wheel = new_selection
if old_selected_wheel >= 0:
__deselect_wheel(old_selected_wheel)
if __selected_wheel >= 0:
__select_wheel(__selected_wheel)
func __print_character(char:String) -> void:
new_character.emit(char)

View File

@ -41,11 +41,13 @@ func _input(event:InputEvent) -> void:
if not __selected: return
var symbols_count : int = __symbol_labels.size()
var index : int = -1
var right_stick_vector : Vector2 = Input.get_vector(&"select_symbol_left", &"select_symbol_right", &"select_symbol_up", &"select_symbol_down", 0.95)
if right_stick_vector.length_squared() - 0.01 > 0.0:
var index : int = __selected_label
var right_stick_vector : Vector2 = Input.get_vector(&"select_symbol_left", &"select_symbol_right", &"select_symbol_up", &"select_symbol_down")
if right_stick_vector.length() >= 0.95:
var stick_angle : float = ((Vector2.UP).rotated(right_stick_vector.angle() + (TAU / (symbols_count + symbols_count))).angle() + PI) / TAU
index = clamp(int(floor(stick_angle * symbols_count)), 0, symbols_count - 1)
elif right_stick_vector.length() < 0.8:
index = -1
__new_symbol_selection(index)
@ -148,13 +150,13 @@ func __spin_labels_around_centre() -> void:
func __initialise_input() -> void:
InputMap.add_action(&"select_symbol_up", 0.75)
InputMap.add_action(&"select_symbol_up", 0.0)
InputMap.action_add_event(&"select_symbol_up", joypad_symbol_up)
InputMap.add_action(&"select_symbol_down", 0.75)
InputMap.add_action(&"select_symbol_down", 0.0)
InputMap.action_add_event(&"select_symbol_down", joypad_symbol_down)
InputMap.add_action(&"select_symbol_left", 0.75)
InputMap.add_action(&"select_symbol_left", 0.0)
InputMap.action_add_event(&"select_symbol_left", joypad_symbol_left)
InputMap.add_action(&"select_symbol_right", 0.75)
InputMap.add_action(&"select_symbol_right", 0.0)
InputMap.action_add_event(&"select_symbol_right", joypad_symbol_right)
func __uninitialise_input() -> void: