[OSX] Raw input still gives acceleration (proposed solution)


No matter if I use relative mouse mode or not on OSX (10.9) I still get acceleration, rendering gaming useless on OSX.
There has been hacks to get around this, for instance by saving current Acceleration curve and then applying 0.0 or -1.0 as curve to enable linear response, but it works differently across OSX versions and doesn’t seem stable.

Now I talked to Forest Hale (LordHavoc) about this, mentioning that fodquake (http://fodquake.net (use latest repo code), code is in in_osx.c) directly parses HID messages from USB and therefor can access the raw data without acceleration applied. He mentioned an email from John Carmack with a link to a tech note from Apple about how to do this, I’ll paste the conversation

20:50 <@LordHavoc> you’re reminding me of an email from John Carmack now when I was working on QuakeLive
20:50 <@LordHavoc> yes, there is a way to get raw mouse, but you have to use the HID subsystem on OSX to get the raw USB packets and parse them yourself
20:51 < dimman> That sounds exactly like what he’s doing
20:51 <@LordHavoc> almost certainly, yes
20:51 <@LordHavoc> it was an API that was never documented properly
20:52 <@LordHavoc> dimman: here’s the tech note - https://developer.apple.com/library/mac/technotes/tn2187/_index.html
20:52 <@LordHavoc> dimman: I’d go ahead and put it in, then start a thread on the SDL mailing list (or forum - the two are linked) about raw mouse on OSX, it’s a worthwhile subject
20:54 <@LordHavoc> dimman: but this should be brought to attention
20:54 <@LordHavoc> dimman: this sort of platform-specific code (and especially driver-level stuff like USB HID parsing) is what belongs in SDL2 itself

Any comments? Interesting?

Sry, the file should be in_macosx.c

I implemented (a hopefully temporary) solution in my client. It only cares about X/Y values from mouse input. No acceleration.

(Creds to fodquake devs whose code I based it on)

Just want to +1 this… it’s really crucial for FPS games to have no mouse acceleration. It would be great if SDL_SetRelativeMouseMode(SDL_TRUE) also disabled acceleration.

I am using the IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) hack in Quakespasm, borrowed from ioquake3 (see:
https://github.com/ariya/ioquake3/blob/master/code/sdl/sdl_input.c#L417 ). It’s been working fine for me for a few years now. The only real issue is that your app has to remember the desktop’s acceleration value and restore it upon quitting, so if the game crashes, you’re left with no mouse acceleration on the Mac desktop, and have to go into System Preferences and adjust the mouse sensitivity to restore the acceleration back to normal.