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 - SDL_HapticEffect limits
Summary: SDL_HapticEffect limits
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: haptic (show other bugs)
Version: HG 2.0
Hardware: x86 All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-01 07:45 UTC by Ryan C. Gordon
Modified: 2018-10-01 16:44 UTC (History)
2 users (show)

See Also:


Attachments
Patch to fix Linux magnitude scaling, add FIXME (2.32 KB, patch)
2018-05-05 02:03 UTC, Ethan Lee
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.