1
0
Fork 0
ExampleProject/FullscreenToggler.gd

30 lines
1.4 KiB
GDScript

extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
#InputMap.action_get_events()
var hotkey = ProjectSettings.get_setting("input/HotKey_ToggleFullscreen")
print(InputMap.action_get_events("character_forwards"))
print(InputMap.action_get_events("HotKey_ToggleFullscreen"))
if hotkey == null:
print("PLEASE GO Project->Project Settings... , Input Map, and add HotKey_ToggleFullscreen")
InputMap.add_action("HotKey_ToggleFullscreen")
#InputMap.action_add_event()
print(hotkey)
var temporarl_deadzone : float = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#Returns true when the user has started pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user pressed down the button.
#This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
if Input.is_action_just_pressed("HotKey_ToggleFullscreen") and temporarl_deadzone <= 0.0:
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
temporarl_deadzone = 0.5
if temporarl_deadzone > 0.0:
temporarl_deadzone -= delta