18 lines
487 B
GDScript
18 lines
487 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 InputEventJoypadMotion:
|
|
if abs(event.axis_value) > 0.5:
|
|
return GamepadDetectionEvent.GAMEPAD
|
|
elif event is InputEventJoypadButton:
|
|
return GamepadDetectionEvent.GAMEPAD
|
|
return GamepadDetectionEvent.IRRELEVANT
|