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

[SDL3] Translate conditional effects direction instead of hardcoding it to 0 #12031

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

Lawstorant
Copy link
Contributor

Description

Previous code wrongly assumed that direction is not an important part of conditional effect. Moreover, if there's need to hardcode polar direction, the default should be 0x4000 (North).

For one axis affects, a direction of 0 means complete lack of force, if a FFB-enabled device takes direction into force calculation. A sine function graph can be used to represent the resulting forces where X is the input direction and Y is the force multiplier (360 degrees equals to 1).

This fixes conditional effect playback on Moza Racing devices, which do not ignore direction field.

@Lawstorant
Copy link
Contributor Author

Lawstorant commented Jan 20, 2025

Sine function graph for context which shows the issue with using direction = 0:

sine resized

Provious code wrongly assumed that direction is not an important part
of conditional effect. Moreover, if there's need to hardcode polar
direction, the default should be 0x4000 (north).

For one axis affects, a direction of 0 means complete lack of force, if
a FFB-enabled device takes direction into force calculation. A sine function
graph can be used to represent the resulting forces where X is the input
direction and Y is the force multiplier (360 degrees equals to 1).

This fixes conditional effect playback on Moza Racing devices, which do
not ignore direction field.
@Lawstorant Lawstorant force-pushed the fix-conditional-direction branch from 5422454 to bfe6b5b Compare January 20, 2025 22:37
@Lawstorant
Copy link
Contributor Author

I think the wrong value came from confusion between spherical and polar systems where in the former, the proper value indeed would be 0, but Linux API uses polar.

I see that the RUMBLE (LEFTRIGHT) effect is incorrectly initialised as well (again, direction = 0). Shall I add the fix to this PR or create a separate one?

@slouken
Copy link
Collaborator

slouken commented Jan 21, 2025

I think the wrong value came from confusion between spherical and polar systems where in the former, the proper value indeed would be 0, but Linux API uses polar.

I see that the RUMBLE (LEFTRIGHT) effect is incorrectly initialised as well (again, direction = 0). Shall I add the fix to this PR or create a separate one?

Feel free to add it to this PR.

Uses proper polar direction of 90 degrees. Previous value probably came from mistakenly using spherical system default.
@slouken slouken merged commit 10c9fbf into libsdl-org:main Jan 21, 2025
@slouken
Copy link
Collaborator

slouken commented Jan 21, 2025

Merged, thanks!

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

Successfully merging this pull request may close these issues.

2 participants