Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL Mouse acceleration fix for OS X #67

Open
SDLBugzilla opened this issue Feb 10, 2021 · 3 comments
Open

SDL Mouse acceleration fix for OS X #67

SDLBugzilla opened this issue Feb 10, 2021 · 3 comments
Assignees
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: Mac OS X (All), x86

Comments on the original bug report:

On 2007-06-27 15:20:50 +0000, Zachary J. Slater wrote:

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"

On 2007-07-04 23:21:40 +0000, Sam Lantinga wrote:

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?

On 2007-10-03 08:33:28 +0000, Gavin wrote:

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.

On 2016-04-07 17:47:58 +0000, Eric Wasylishen wrote:

Created attachment 2408
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

On 2016-05-26 22:54:39 +0000, Eric Wasylishen wrote:

Created attachment 2466
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.

@sezero
Copy link
Contributor

sezero commented Jul 28, 2021

I wish @ericwa re-worked this for current SDL2

@slouken slouken self-assigned this Jul 28, 2021
@slouken slouken added this to the 2.0.16 milestone Jul 28, 2021
@ericwa
Copy link
Contributor

ericwa commented Jul 28, 2021

I left some comments on Discourse in 2017 from testing my patch, I believe the "raw mouse patch v2" above is the latest version of it.

It seems like on macOS 10.12, trackpads (at least my 2012 15" rMBP) no longer produce any events through the IOHIDManager API.

I guess this might be related to trackpads becoming natively touch devices (is that how it works on modern macOS?)

So the upshot was: with my patch, once inside relative mouse mode in SDL, only external USB mice generate relative motion events, not the trackpad. Hopefully it's a solvable problem.

Another question: I wonder if it's worth using libhidapi now, over IOHIDManagerRef, since SDL is already using that on macOS.

Lastly I guess we should double check if there is a new macOS API for this - afaik in 2017, last time I looked at it, IOHIDManagerRef was the best bet.

@slouken slouken modified the milestones: 2.0.16, 2.0.18 Jul 28, 2021
@slouken slouken removed this from the 2.0.18 milestone Oct 1, 2021
@slouken slouken removed the bug label May 11, 2022
@Blackflexxy
Copy link

HI, maybe this api can help for raw mouse input?

@slouken slouken added this to the 3.2.0 milestone Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants