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

Haptic coding bugs and fixes for Windows and Mac OS: wrong handling of negative periodic magnitude #1617

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: All, x86_64

Comments on the original bug report:

On 2014-08-23 20:59:44 +0000, Elias Vanderstuyft wrote:

This is something funny, a feature of the Linux FF API that doesn't exist in Windows' and MacOS' FF APIs:
a negative periodic magnitude.
The periodic magnitude parameter of the SDL Haptic API is based on the Linux FF API, so it means they are not directly compatible:
'dwMagnitude' is a 'DWORD', which is unsigned.

First I fixed some typos about angle units in the Haptic API doc (first patch: "vanilla-rev1.diff").

Then I created a patch to solve the problem by adding 180 degrees phase shift when the magnitude is negative (second patch: "rev1-rev2.diff").
WARNING: this patch is UNTESTED (as is the compilation), since I don't have the necessary access to a Windows or MacOS machine. Please verify this patch before applying it!

Both patches are based on yesterday's hg snapshot: SDL-2.0.3-9108

In the second patch you can see I also edited "testhaptic.c" to test the patch's changes:
To a user, the direction of the force of "Effect0 - Sine" should remain the same before and after this patch, since a negative magnitude combined with a 180 degrees phase shift will cancel out and become a positive magnitude combined with a zero degrees phase shift.

Finally, I included some images to graphically visualize exactly how the force output of "testhaptic" should be:
"Effect0_Sine.png"
"Effect1_SawtoothUp.png"
"Effect2_Constant.png"
"Effect7_Ramp.png"
I should note here that the forces and directions are defined in the Linux FF sense: the direction in which the force is applied by the joystick; not the direction where the force comes from!

On 2014-08-23 21:01:13 +0000, Elias Vanderstuyft wrote:

Created attachment 1841
Fix some typos about angle units in the Haptic API doc

On 2014-08-23 21:04:42 +0000, Elias Vanderstuyft wrote:

Created attachment 1842
A negative periodic magnitude doesn't exist in Windows' and MacOS' FF APIs

The periodic magnitude parameter of the SDL Haptic API is based on the Linux FF API, so it means they are not directly compatible:
'dwMagnitude' is a 'DWORD', which is unsigned.

WARNING: this patch is UNTESTED (as is the compilation)

On 2014-08-23 21:06:26 +0000, Elias Vanderstuyft wrote:

Created attachment 1843
Effect0_Sine.png

testhaptic.c: effect[0]: Sine

The forces and directions are defined in the Linux FF sense: the direction in which the force is applied by the joystick; not the direction where the force comes from!

On 2014-08-23 21:06:55 +0000, Elias Vanderstuyft wrote:

Created attachment 1844
Effect1_SawtoothUp.png

testhaptic.c: effect[1]: SawtoothUp

The forces and directions are defined in the Linux FF sense: the direction in which the force is applied by the joystick; not the direction where the force comes from!

On 2014-08-23 21:07:20 +0000, Elias Vanderstuyft wrote:

Created attachment 1845
Effect2_Constant.png

testhaptic.c: effect[2]: Constant

The forces and directions are defined in the Linux FF sense: the direction in which the force is applied by the joystick; not the direction where the force comes from!

On 2014-08-23 21:07:45 +0000, Elias Vanderstuyft wrote:

Created attachment 1846
Effect7_Ramp.png

testhaptic.c: effect[7]: Ramp

The forces and directions are defined in the Linux FF sense: the direction in which the force is applied by the joystick; not the direction where the force comes from!

On 2014-09-17 18:52:17 +0000, Ryan C. Gordon wrote:

These patches are in revision control now, thanks!

https://hg.libsdl.org/SDL/rev/dbef1f283c3f
https://hg.libsdl.org/SDL/rev/6bf589c8d549

--ryan.

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

No branches or pull requests

1 participant