diff --git a/UI/ControllerInput/controller_input_select_wheel.gd b/UI/ControllerInput/controller_input_select_wheel.gd index 9e8fbf6..13ca5f9 100644 --- a/UI/ControllerInput/controller_input_select_wheel.gd +++ b/UI/ControllerInput/controller_input_select_wheel.gd @@ -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) diff --git a/UI/ControllerInput/controller_input_symbol_wheel.gd b/UI/ControllerInput/controller_input_symbol_wheel.gd index 4848a9f..7586dc9 100644 --- a/UI/ControllerInput/controller_input_symbol_wheel.gd +++ b/UI/ControllerInput/controller_input_symbol_wheel.gd @@ -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: