Skip to content
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

[3.x] Simplify InputDefault::joy_axis code by using float instead of struct JoyAxis #56239

Merged
merged 1 commit into from
Jan 14, 2022

Conversation

madmiraal
Copy link
Contributor

Backport of #56238.

Although the 3.x branch does not have issue #44178, the fix contains significant code simplification and the removal of the misleading struct JoyAxis, which I think would be advantageous for 3.x too.

@madmiraal madmiraal requested review from a team as code owners December 25, 2021 11:19
@YeldhamDev YeldhamDev added this to the 3.5 milestone Dec 25, 2021
Comment on lines +418 to +419
float value = *((float *)axes + (i + 1));
input->joy_axis(p_controller_id + 100, i, value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting that the code is different in the master branch (and thus not changed in #56238), I'm not sure if it means that either the 3.x or master version might be missing a follow-up fix? @dsnopek @Faless

In master it's:

                int *axes = godot_webxr_get_controller_axes(p_controller_id);
                if (axes) {
                        // TODO again just a temporary fix, split these between proper float and vector2 inputs
                        for (int i = 0; i < axes[0]; i++) {
                                char name[1024];
                                sprintf(name, "axis_%i", i);

                                float value = *((float *)axes + (i + 1));
                                ;
                                tracker->set_input(name, value);
                        }
                        free(axes);
                }

@akien-mga akien-mga merged commit d23f2b7 into godotengine:3.x Jan 14, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants