-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Your Godot version:
4.4.1
Issue description:
The InputMap
class description does not mention that the class behaves differently when it is accessed from the editor rather than from a running project, i.e. that in the editor it only deals with the input bindings of the editor itself. The short description currently only mentions the project's input map, as if that is all that the class manages.
There have been several summarily closed issues raised for the engine about this behavior as people believe it to be some kind of bug when, for example, a tool script running in the editor sees has_action()
return false for custom actions defined in the project settings. In the docs this behavior is currently mentioned only in a note under a single method, action_get_events()
, when to the best of my knowledge it applies to the entire class.
I am too new to this to try and edit the documentation myself, but I wrote a suggestion for a new class description, rewording and combining existing elements to clarify the distinction:
Description
A singleton that manages the InputEventActions for either the project or the editor, depending on which context it is accessed from.
The project's InputEventActions can be created and modified in the Project Settings menu (Project > Project Settings > Input Map), or in code by calling e.g.
add_action()
andaction_add_event()
from a running project.When called from the editor (e.g. from a tool script running in the editor, or from an EditorPlugin), the methods will target the input map used by the editor itself. For accessing the project's InputEventActions from the editor, see the
input/*
settings in ProjectSettings.
The note in action_get_events()
could then also be removed since the class description would have already explained the behavior.
Additionally, load_from_project_settings()
could probably use a warning, maybe along the lines of:
Warning: Not intended for use in the editor. Some of the built-in actions specific to the editor itself are not included in ProjectSettings, so they will be effectively removed, requiring them to be replaced or the editor to be restarted.
(That method was one of the things I personally tried when trying to make an editor script dealing with the project's input map, since it kind of sounded like what I wanted, and it of course caused a bunch of errors about missing actions instead.)
EDIT: Changed the wording of the warning to be a little stronger -- "not being intended for editor use" should be accurate, as far as I understand it, since I can't think of a reason one would want to mix up the two separate InputMaps like this. Feels like a bigger architectural issue that this is even possible to do (unless I'm missing something), but that's beyond the scope of the docs.
--
I'm not 100% confident in the precision of the language around all the programming/Godot concepts, but I figure this could be a good starting point, at least. The project vs. editor distinction might initially confuse anyone who hasn't come to grips with how all that works in Godot, but in my opinion it'd be best to own it up front.
URL to the documentation page (if already existing):
https://docs.godotengine.org/en/4.4/classes/class_inputmap.html