finally cleaned up input method detection
This commit is contained in:
@@ -31,7 +31,7 @@ class_name InputController
|
||||
@export var slam:GUIDEAction
|
||||
|
||||
signal input_device_changed(is_gamepad: bool)
|
||||
var _using_gamepad = false
|
||||
var current_input_method = GlobalHelpers.GamepadDetectionEvent.GAMEPAD
|
||||
|
||||
signal input_move(value: Vector3)
|
||||
signal input_rotate_y(value: float)
|
||||
@@ -104,19 +104,15 @@ func on_input_slide_ended():
|
||||
input_slide_ended.emit()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey:
|
||||
if _using_gamepad:
|
||||
_using_gamepad = false
|
||||
input_device_changed.emit(_using_gamepad)
|
||||
elif event is InputEventJoypadMotion:
|
||||
if !_using_gamepad:
|
||||
if abs(event.axis_value) > 0.5:
|
||||
_using_gamepad = true
|
||||
input_device_changed.emit(_using_gamepad)
|
||||
elif event is InputEventJoypadButton:
|
||||
if !_using_gamepad:
|
||||
_using_gamepad = true
|
||||
input_device_changed.emit(_using_gamepad)
|
||||
var event_gamepad = GlobalHelpers.is_event_gamepad(event)
|
||||
if event_gamepad == GlobalHelpers.GamepadDetectionEvent.IRRELEVANT:
|
||||
return
|
||||
|
||||
if current_input_method == event_gamepad:
|
||||
return
|
||||
|
||||
current_input_method = event_gamepad
|
||||
input_device_changed.emit(current_input_method == GlobalHelpers.GamepadDetectionEvent.GAMEPAD)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var value_horizontal = -move_left.value_axis_1d + move_right.value_axis_1d
|
||||
|
||||
Reference in New Issue
Block a user