finally cleaned up input method detection
This commit is contained in:
17
tools/global_helpers.gd
Normal file
17
tools/global_helpers.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
1
tools/global_helpers.gd.uid
Normal file
1
tools/global_helpers.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dqcm83o8e66a2
|
||||
Reference in New Issue
Block a user