midori-school/gamepad.gd

16 lines
601 B
GDScript3
Raw Permalink Normal View History

2024-08-16 22:54:37 +02:00
extends Node
var file
func _init(event):
if event is InputEventKey || event is InputEventMouse:
Global.gamepad = 0
elif str(Input.get_joy_name(0)).begins_with("Nintendo Switch"):
Global.gamepad = 2
elif str(Input.get_joy_name(0)).begins_with("Sony Computer Entertainment") || str(Input.get_joy_name(0)).begins_with("PS4") || str(Input.get_joy_name(0)).begins_with("PS5"):
Global.gamepad = 3
2024-09-07 18:25:58 +02:00
elif !str(Input.get_joy_name(0)).is_empty():
2024-08-16 22:54:37 +02:00
Global.gamepad = 1
if event is InputEventMouse:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)