midori-school/gamepad.gd
2024-08-16 13:54:37 -07:00

16 lines
623 B
GDScript

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
elif Global.gamepad == 0 && str(Input.get_joy_name(0)).is_empty():
Global.gamepad = 1
if event is InputEventMouse:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)