Skip to content

Commit

Permalink
Improve input detection to fix dialogic-godot#1976
Browse files Browse the repository at this point in the history
  • Loading branch information
Jowan-Spooner committed Jun 25, 2024
1 parent de2b918 commit 51a40d6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions addons/dialogic/Modules/Core/subsystem_input.gd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func handle_input() -> void:

## Unhandled Input is used for all NON-Mouse based inputs.
func _unhandled_input(event:InputEvent) -> void:
if Input.is_action_just_pressed(ProjectSettings.get_setting(_SETTING_INPUT_ACTION, _SETTING_INPUT_ACTION_DEFAULT), true):
if is_input_pressed(event, true):
if event is InputEventMouse:
return
handle_input()
Expand All @@ -101,14 +101,18 @@ func _unhandled_input(event:InputEvent) -> void:
## Input is used for all mouse based inputs.
## If any DialogicInputNode is present this won't do anything (because that node handles MouseInput then).
func _input(event:InputEvent) -> void:
if Input.is_action_just_pressed(ProjectSettings.get_setting(_SETTING_INPUT_ACTION, _SETTING_INPUT_ACTION_DEFAULT)):

if is_input_pressed(event):
if not event is InputEventMouse or get_tree().get_nodes_in_group('dialogic_input').any(func(node):return node.is_visible_in_tree()):
return

handle_input()


func is_input_pressed(event: InputEvent, exact := false) -> bool:
var action := ProjectSettings.get_setting(_SETTING_INPUT_ACTION, _SETTING_INPUT_ACTION_DEFAULT)
return (event is InputEventAction and event.action == action) or Input.is_action_just_pressed(action, exact)


## This is called from the gui_input of the InputCatcher and DialogText nodes
func handle_node_gui_input(event:InputEvent) -> void:
if Input.is_action_just_pressed(ProjectSettings.get_setting(_SETTING_INPUT_ACTION, _SETTING_INPUT_ACTION_DEFAULT)):
Expand Down

0 comments on commit 51a40d6

Please sign in to comment.