-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix InputEvent
device id clash (reverted)
#97707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctly implemented
Makes sense. I have a little concern though. Is the former value for "all devices" stored somewhere? In that case, it'd be appropriate to leave |
The only place, where it is used to set something, is within the Editor.
I didn't find any indication, that this |
While the
Projects that are loaded with the change in its current state will interpret previous One option to work around this would be:
|
Why don't just leave |
Same problem, because |
So, being that the case, your proposed workaround seems to be the most sensible thing to do. |
85e0c9d
to
7db239a
Compare
7db239a
to
0cdc8af
Compare
586f614
to
c327824
Compare
It was necessary to add additional conversion code to |
c327824
to
6f8fb1d
Compare
@@ -508,6 +508,21 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) { | |||
} | |||
} | |||
} | |||
if (p_from_version <= 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to increment project version, otherwise this code will run every time.
godot/core/config/project_settings.h
Line 152 in 44fa552
static const int CONFIG_VERSION = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to unnecessarily increment the project version number.
This conversion can be implemented without incrementing the project version.
Before this PR, possible values of device id in the project file are: -1, 0, ..., 7
With this PR, possible values of device id in the project file are: -3, 0, ..., 7
So the conversion doesn't affect projects, that are saved with this PR. The conversion just makes sure, that all projects use -3 for "all devices" after they are loaded.
Also it is compatible with future project version increments.
The conversion happens only once during loading, so there shouldn't be any noticeable delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least wrap it in DISABLE_DEPRECATED check then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I wrap the section above also in a DISABLE_DEPRECATED
check?
godot/core/config/project_settings.cpp
Lines 497 to 509 in 44fa552
if (p_from_version <= 3) { | |
// Converts the actions from array to dictionary (array of events to dictionary with deadzone + events) | |
for (KeyValue<StringName, ProjectSettings::VariantContainer> &E : props) { | |
Variant value = E.value.variant; | |
if (String(E.key).begins_with("input/") && value.get_type() == Variant::ARRAY) { | |
Array array = value; | |
Dictionary action; | |
action["deadzone"] = Variant(0.5f); | |
action["events"] = array; | |
E.value.variant = action; | |
} | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh the other sections is irrelevant at this point. Version 5 is used since 4.0.
But yeah, it should be wrapped too.
6f8fb1d
to
b2ea0de
Compare
`InputMap::ALL_DEVICES` and `InputEvent::DEVICE_ID_EMULATION` have the same value `-1`. Change value of `InputMap::All_DEVICES` so that it's different from `InputEvent::DEVICE_ID_EMULATION`. `InputEvent::DEVICE_ID_EMULATION` is part of the API and can't be changed without potentially breaking projects. Gather all special device constants in a single location inside `InputEvent`. Add a converter to project settings, that takes care of adjusting project files during loading.
b2ea0de
to
916d480
Compare
5 approvals! 😃 |
Thanks! |
Hey, this change breaks compat 🙂 I'm storing keymaps in InputEvent resources because project settings aren't portable. Keyboard stopped working for me, had to figure out why and remap. Not a big deal, just fyi in case you want to add this to a list of breaking changes |
This also causes a pretty large change to the project.godot file (every action changes its device ID when you open a project and save it in 4.4-dev4). Might be worth calling out in the release notes as well. |
InputEvent
device id clashInputEvent
device id clash (reverted)
InputMap::ALL_DEVICES
andInputEvent::DEVICE_ID_EMULATION
have the same value-1
, but since both are used for device ids of input events, there could potentially be cases, where they are clashing.Change value of
InputMap::All_DEVICES
so that it's different fromInputEvent::DEVICE_ID_EMULATION
.InputEvent::DEVICE_ID_EMULATION
is part of the API and can't be changed without potentially breaking projects.Gather all special device constants in a single location inside
InputEvent
.Add a converter to project settings, that takes care of adjusting project files during loading.
Relevant PRs: