| Summary: | Haptic coding bugs and fixes for Windows and Mac OS: wrong handling of negative periodic magnitude | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Elias Vanderstuyft <Elias.vds> |
| Component: | haptic | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | Elias.vds |
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | All | ||
| Attachments: |
Fix some typos about angle units in the Haptic API doc
A negative periodic magnitude doesn't exist in Windows' and MacOS' FF APIs Effect0_Sine.png Effect1_SawtoothUp.png Effect2_Constant.png Effect7_Ramp.png |
||
Created attachment 1841 [details]
Fix some typos about angle units in the Haptic API doc
Created attachment 1842 [details]
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)
Created attachment 1843 [details]
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!
Created attachment 1844 [details]
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!
Created attachment 1845 [details]
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!
Created attachment 1846 [details]
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!
These patches are in revision control now, thanks!
https://hg.libsdl.org/SDL/rev/dbef1f283c3f
https://hg.libsdl.org/SDL/rev/6bf589c8d549
--ryan.
|
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!