feat: register_custom_input_handler() API

This introduces a new API on `ESCInputsManager` that makes it
possible to inject custom logic for processing input events.

An example of how to use this API will be introduced in a
separate commit as part of
https://github.com/godot-escoria/escoria-demo-game/pull/503
via a new plugin, `addons/escoria-ui-keyboard-9verbs/`,
which shows how this can be used to add support for keyboard shortcuts
to select a specific verb.
This commit is contained in:
Michael Bolin authored and Julian Murgia committed 2022-03-08 14:06:18 +01:00
1 parent 641d630b10
commit 14cf1327fe
2 files changed
+54 -2

No files matched your search

@@ -82,8 +82,11 @@ func _ready():
#
# #### Parameters
# - event: Event received
func _unhandled_input(event) -> void:
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
func _unhandled_input(event: InputEvent) -> void:
var is_default_state = escoria.current_state == escoria.GAME_STATE.DEFAULT
if escoria.inputs_manager.try_custom_input_handler(event, is_default_state):
return
if not is_default_state:
return
if InputMap.has_action(escoria.inputs_manager.SWITCH_ACTION_VERB) \
and event.is_action_pressed(escoria.inputs_manager.SWITCH_ACTION_VERB):