Files
MovementTests/tools/global_helpers.gd

21 lines
608 B
GDScript

extends Node
enum GamepadDetectionEvent {
GAMEPAD,
KEYBOARD,
IRRELEVANT
}
static func is_event_gamepad(event: InputEvent) -> GamepadDetectionEvent:
if event is InputEventKey || event is InputEventMouseButton:
return GamepadDetectionEvent.KEYBOARD
elif event is InputEventMouseMotion:
if not event.relative.is_zero_approx():
return GamepadDetectionEvent.KEYBOARD
elif event is InputEventJoypadMotion:
if abs(event.axis_value) > 0.5:
return GamepadDetectionEvent.GAMEPAD
elif event is InputEventJoypadButton:
return GamepadDetectionEvent.GAMEPAD
return GamepadDetectionEvent.IRRELEVANT