We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4120

Summary: SDL_HapticEffect limits
Product: SDL Reporter: Ryan C. Gordon <icculus>
Component: hapticAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: flibitijibibo, sezeroz
Version: HG 2.0   
Hardware: x86   
OS: All   
Attachments: Patch to fix Linux magnitude scaling, add FIXME

Description Ryan C. Gordon 2018-04-01 07:45:03 UTC
All SDL_HapticEffect fields are intended to max out at 0x7FFF, but test/testhaptic.c tries to pass 0xFFFF for several tests. It doesn't appear that SDL makes any attempt to clamp or check this. Not sure if we should fix the test program or SDL.

--ryan.
Comment 1 Ethan Lee 2018-05-05 02:03:27 UTC
Created attachment 3239 [details]
Patch to fix Linux magnitude scaling, add FIXME

Attached is a patch that at least makes the runtime output consistent, but it's honestly really hard to tell what should be clamped to what and when it should be clamped. Because of that the patch does not touch the test program, but it at least fixes the one platform that stuck out regarding what the magnitude range should be as of the current API.

We should probably take all the clamping that's done in the SYS functions (which all seems to be using a copypasted macro...?) and do it at the surface-level function to make it easier to read. But that's probably risky to do without extensive testing, so I didn't do that either. Will need to spend a day or two cleaning all that up!
Comment 2 Sam Lantinga 2018-10-01 16:44:41 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/44a639b5f1af

This should definitely be revisited for SDL 2.1.