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 445

Summary: SDL Mouse acceleration fix for OS X
Product: SDL Reporter: Zachary J. Slater <zakk>
Component: videoAssignee: Sam Lantinga <slouken>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: API change    
Priority: P2 CC: amaranth72, ewasylishen
Version: HG 2.1   
Hardware: x86   
OS: Mac OS X (All)   
Attachments: First draft of OS X raw mouse support
raw mouse patch v2

Description Zachary J. Slater 2007-06-27 15:20:50 UTC
With SDL and, in fact, any program under OS X you get mouse acceleration if you want it or not. This is completely bad for FPS players or anything else where quick mouse positioning is important. The logical solution seems to be to offer an environment variable so this can be fixed one way globally instead of per-game in a multitude of methods.

There is an example "fix" here:
http://bugzilla.icculus.org/show_bug.cgi?id=3206

Please implement this in SDL 1.3 with the environment variable "SDL_FUCK_WITH_MOUSE_ACCEL"
Comment 1 Sam Lantinga 2007-07-04 23:21:40 UTC
Maybe this would be better implemented with an actual mouse acceleration API?  Maybe along the lines of the existing SDL 1.2 environment variable SDL_VIDEO_X11_MOUSEACCEL?
Comment 2 Gavin 2007-10-03 08:33:28 UTC
you can get around it by disabling mouse acceleration using the carbon api. I'm sure it would be feasable to put this in a future release of SDL.
Comment 3 Eric Wasylishen 2016-04-07 17:47:58 UTC
Created attachment 2408 [details]
First draft of OS X raw mouse support

Resurrecting this..  SDL_SetRelativeMouseMode on Windows and Linux (afaik) gives raw non-accelerated mouse events. Would be nice to do the same on OS X, for consistency.

The current OSX mouse input code is using NSEvent which are throttled to 60Hz and have acceleration applied.

The fix is to use the IOHID API's instead of NSEvent. SDL already uses these API's for accessing joysticks.

I wrote a draft implementation a while ago, attaching it here. I have a feeling it shouldn't use NSThread, and the CPU usage needs to be examined because I remember it being a bit high.

Related mailing list posts:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2014-October/096672.html
https://forums.libsdl.org/viewtopic.php?t=11838
Comment 4 Eric Wasylishen 2016-05-26 22:54:39 UTC
Created attachment 2466 [details]
raw mouse patch v2

New patch, rewritten from scratch.
- everything done on main thread now.
- uses IOHIDQueue API to receive raw mouse events. 
I believe IOHIDManagerRegisterInputValueCallback is broken on OS X 10.6 (some events get dropped with a 500Hz mouse), and using the IOHIDQueue API works around this because we can explicitly specify the event queue size.

Tested on OS X 10.6 and 10.11.