diff --git a/addons/controller_icons/ControllerIcons.gd b/addons/controller_icons/ControllerIcons.gd index 6730b6f5..8585cee5 100644 --- a/addons/controller_icons/ControllerIcons.gd +++ b/addons/controller_icons/ControllerIcons.gd @@ -26,6 +26,29 @@ func _enter_tree(): _parse_input_actions() func _parse_input_actions(): + # Default actions will be the builtin editor actions when + # the script is at editor ("tool") level. To pickup more + # actions available, these have to be queried manually + var keys := [ + "input/ui_accept", + "input/ui_cancel", + "input/ui_down", + "input/ui_end", + "input/ui_focus_next", + "input/ui_focus_prev", + "input/ui_home", + "input/ui_left", + "input/ui_page_down", + "input/ui_page_up", + "input/ui_right", + "input/ui_select", + "input/ui_up" + ] + for key in keys: + var data : Dictionary = ProjectSettings.get_setting(key) + if not data.empty() and data.has("events") and data["events"] is Array: + _add_custom_input_action((key as String).trim_prefix("input/"), data) + # A script running at editor ("tool") level only has # the default mappings. The way to get around this is # manually parsing the project file and adding the diff --git a/addons/controller_icons/Mapper.gd b/addons/controller_icons/Mapper.gd index 97f7ffd2..01a0b230 100644 --- a/addons/controller_icons/Mapper.gd +++ b/addons/controller_icons/Mapper.gd @@ -31,6 +31,11 @@ func _convert_joypad_path(path: String, fallback) -> String: return "" func _get_joypad_type(fallback): + # If on editor, default to fallback always, to avoid editing scene + # files on controller reload + if Engine.is_editor_hint(): + return fallback + var controller_name = Input.get_joy_name(0) if "Luna Controller" in controller_name: return ControllerSettings.Devices.LUNA @@ -297,4 +302,4 @@ func _convert_joypad_to_steamdeck(path: String): "share": return path.replace("/share", "/dots") _: - return path \ No newline at end of file + return path diff --git a/addons/controller_icons/plugin.cfg b/addons/controller_icons/plugin.cfg index cd050a90..3dc36a5f 100644 --- a/addons/controller_icons/plugin.cfg +++ b/addons/controller_icons/plugin.cfg @@ -3,5 +3,5 @@ name="Controller Icons" description="Provides icons for all major controllers and keyboard, with automatic icon remapping." author="rsubtil" -version="1.1.3" +version="1.1.4" script="plugin.gd"