OSX: Relative mousemode is accelerated, should be raw(?)

Hi,

I recently tried playing a FPS game using SDL2 on OSX, using a normal
mouse, and it was pretty bad: Aiming was almost impossible because the
mouse input is accelerated. (The common workaround currently seems to be
using thirdparty tools like to disable mouse acceleration system-wide.)
On Windows and Linux you get raw mouse input in relative mode, which
IMHO is the right thing to do - however “slime” of #SDL argued that when
using a trackpad, accelerated mouse input is preferable even in relative
mode.
Note however that the current behavior is inconsistent with Windows and
Linux and if raw mouse input on OSX were implemented, one could still
use SDL_HINT_MOUSE_RELATIVE_MODE_WARP to get the old/current behavior.

I found http://forums.libsdl.org/viewtopic.php?t=9969 which describes a
way to get raw mouse input on OSX, does anyone know why SDL2 doesn’t do
that? Does the approach have any problems or was it just not implemented
because no one got around to do it?

There’s also a really old bugreport:
https://bugzilla.libsdl.org/show_bug.cgi?id=445

Any thoughts on the topic? :slight_smile:

Cheers,
Daniel

Hi,
I agree completely, OS X relative mode should match Linux and Windows and
give raw input.
A way to opt-in to acceleration would be nice as well, but I think that
would be a separate new feature.

I sent a patch to the list a while ago with a first stab at implementing
this:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2014-October/096672.html

Haven’t looked at the patch since 2014. Maybe I should have filed it in the
bug tracker, oops.
Anyway, if there is interest I could try resurrecting and cleaning up this
patch.
Cheers,
EricOn Sun, Mar 13, 2016 at 5:35 PM, Daniel Gibson wrote:

Hi,

I recently tried playing a FPS game using SDL2 on OSX, using a normal
mouse, and it was pretty bad: Aiming was almost impossible because the
mouse input is accelerated. (The common workaround currently seems to be
using thirdparty tools like to disable mouse acceleration system-wide.)
On Windows and Linux you get raw mouse input in relative mode, which IMHO
is the right thing to do - however “slime” of #SDL argued that when using a
trackpad, accelerated mouse input is preferable even in relative mode.
Note however that the current behavior is inconsistent with Windows and
Linux and if raw mouse input on OSX were implemented, one could still use
SDL_HINT_MOUSE_RELATIVE_MODE_WARP to get the old/current behavior.

I found http://forums.libsdl.org/viewtopic.php?t=9969 which describes a
way to get raw mouse input on OSX, does anyone know why SDL2 doesn’t do
that? Does the approach have any problems or was it just not implemented
because no one got around to do it?

There’s also a really old bugreport:
https://bugzilla.libsdl.org/show_bug.cgi?id=445

Any thoughts on the topic? :slight_smile:

Cheers,
Daniel


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Oh cool, totally missed that patch!

Do you think there is a way to get raw input without spending 15% of the
CPU time in the raw mouse thread? It sounds a lot (even if it might be
tolerable if there is no other way).

Cheers,
DanielOn 03/14/2016 06:01 AM, Eric Wasylishen wrote:

Hi,
I agree completely, OS X relative mode should match Linux and Windows
and give raw input.
A way to opt-in to acceleration would be nice as well, but I think that
would be a separate new feature.

I sent a patch to the list a while ago with a first stab at implementing
this:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2014-October/096672.html

Haven’t looked at the patch since 2014. Maybe I should have filed it in
the bug tracker, oops.
Anyway, if there is interest I could try resurrecting and cleaning up
this patch.
Cheers,
Eric

On Sun, Mar 13, 2016 at 5:35 PM, Daniel Gibson <@Daniel_Gibson mailto:Daniel_Gibson> wrote:

Hi,

I recently tried playing a FPS game using SDL2 on OSX, using a
normal mouse, and it was pretty bad: Aiming was almost impossible
because the mouse input is accelerated. (The common workaround
currently seems to be using thirdparty tools like to disable mouse
acceleration system-wide.)
On Windows and Linux you get raw mouse input in relative mode, which
IMHO is the right thing to do - however "slime" of #SDL argued that
when using a trackpad, accelerated mouse input is preferable even in
relative mode.
Note however that the current behavior is inconsistent with Windows
and Linux and if raw mouse input on OSX were implemented, one could
still use SDL_HINT_MOUSE_RELATIVE_MODE_WARP to get the old/current
behavior.

I found http://forums.libsdl.org/viewtopic.php?t=9969 which
describes a way to get raw mouse input on OSX, does anyone know why
SDL2 doesn't do that? Does the approach have any problems or was it
just not implemented because no one got around to do it?

There's also a really old bugreport:
https://bugzilla.libsdl.org/show_bug.cgi?id=445

Any thoughts on the topic? :-)

Cheers,
Daniel
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Just a small update - I thought I would resurrect that bug report and
collect info there: https://bugzilla.libsdl.org/show_bug.cgi?id=445

My patch still applies and seems to work (yay!) but I didn’t get a chance
to look at the CPU usage yet.On Wed, Mar 16, 2016 at 1:45 PM, Daniel Gibson wrote:

Oh cool, totally missed that patch!

Do you think there is a way to get raw input without spending 15% of the
CPU time in the raw mouse thread? It sounds a lot (even if it might be
tolerable if there is no other way).

Cheers,
Daniel

On 03/14/2016 06:01 AM, Eric Wasylishen wrote:

Hi,
I agree completely, OS X relative mode should match Linux and Windows
and give raw input.
A way to opt-in to acceleration would be nice as well, but I think that
would be a separate new feature.

I sent a patch to the list a while ago with a first stab at implementing
this:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2014-October/096672.html

Haven’t looked at the patch since 2014. Maybe I should have filed it in
the bug tracker, oops.
Anyway, if there is interest I could try resurrecting and cleaning up
this patch.
Cheers,
Eric

On Sun, Mar 13, 2016 at 5:35 PM, Daniel Gibson <metalcaedes at gmail.com <mailto:metalcaedes at gmail.com>> wrote:

Hi,

I recently tried playing a FPS game using SDL2 on OSX, using a
normal mouse, and it was pretty bad: Aiming was almost impossible
because the mouse input is accelerated. (The common workaround
currently seems to be using thirdparty tools like to disable mouse
acceleration system-wide.)
On Windows and Linux you get raw mouse input in relative mode, which
IMHO is the right thing to do - however "slime" of #SDL argued that
when using a trackpad, accelerated mouse input is preferable even in
relative mode.
Note however that the current behavior is inconsistent with Windows
and Linux and if raw mouse input on OSX were implemented, one could
still use SDL_HINT_MOUSE_RELATIVE_MODE_WARP to get the old/current
behavior.

I found http://forums.libsdl.org/viewtopic.php?t=9969 which
describes a way to get raw mouse input on OSX, does anyone know why
SDL2 doesn't do that? Does the approach have any problems or was it
just not implemented because no one got around to do it?

There's also a really old bugreport:
https://bugzilla.libsdl.org/show_bug.cgi?id=445

Any thoughts on the topic? :-)

Cheers,
Daniel
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Actually I just stumbled upon a related bug (about raw events not working properly) when I just upgraded my game to SDL 2.0.4.

On my Macbook with OSX El Capitan (10.11), SDL_SetRelativeMouseMode(SDL_TRUE) breaks the SDL_MOUSEMOTION events completely, you don’t get any events - neither with the trackpad nor with a real USB mouse. Mousebutton events and keyboard events work fine.

Setting the additional SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, “1”) makes it work, but has the side-effect that if you jitter the mouse around a bit, OSX pop ups a mega-large mousepointer for a few seconds which SDL doesn’t seem to know how to hide. I guess as some kind of sight-impaired help…

Anyway, my interpretation is that the relative mouse mode seems to be broken on OSX 10.11 and SDL 2.0.4 as far as I can tell, when it tries to use raw events (which it should try without the hint set).

On Linux, the same code works fine with SDL 2.0.4 and SetRelativeMouseMode. Haven’t tried on Windows yet.

FYI tested the same code also on Windows (with 2.0.4 as shipped from libsdl.org) and it worked fine there as well. It’s only on the Mac it’s broken.

bjornw2 wrote:> Actually I just stumbled upon a related bug (about raw events not working properly) when I just upgraded my game to SDL 2.0.4.

On my Macbook with OSX El Capitan (10.11), SDL_SetRelativeMouseMode(SDL_TRUE) breaks the SDL_MOUSEMOTION events completely, you don’t get any events - neither with the trackpad nor with a real USB mouse. Mousebutton events and keyboard events work fine.

Setting the additional SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, “1”) makes it work, but has the side-effect that if you jitter the mouse around a bit, OSX pop ups a mega-large mousepointer for a few seconds which SDL doesn’t seem to know how to hide. I guess as some kind of sight-impaired help…

Anyway, my interpretation is that the relative mouse mode seems to be broken on OSX 10.11 and SDL 2.0.4 as far as I can tell, when it tries to use raw events (which it should try without the hint set).

On Linux, the same code works fine with SDL 2.0.4 and SetRelativeMouseMode. Haven’t tried on Windows yet.

As a reference in case anyone finds this, see https://bugzilla.libsdl.org/show_bug.cgi?id=3312 (was a problem in the 2.0.4 release, didn’t check if it was solved in the latest snapshot though)

bjornw2 wrote:> FYI tested the same code also on Windows (with 2.0.4 as shipped from libsdl.org) and it worked fine there as well. It’s only on the Mac it’s broken.

bjornw2 wrote:

Actually I just stumbled upon a related bug (about raw events not working properly) when I just upgraded my game to SDL 2.0.4.

On my Macbook with OSX El Capitan (10.11), SDL_SetRelativeMouseMode(SDL_TRUE) breaks the SDL_MOUSEMOTION events completely, you don’t get any events - neither with the trackpad nor with a real USB mouse. Mousebutton events and keyboard events work fine.

Setting the additional SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, “1”) makes it work, but has the side-effect that if you jitter the mouse around a bit, OSX pop ups a mega-large mousepointer for a few seconds which SDL doesn’t seem to know how to hide. I guess as some kind of sight-impaired help…

Anyway, my interpretation is that the relative mouse mode seems to be broken on OSX 10.11 and SDL 2.0.4 as far as I can tell, when it tries to use raw events (which it should try without the hint set).

On Linux, the same code works fine with SDL 2.0.4 and SetRelativeMouseMode. Haven’t tried on Windows yet.

Thanks for pointing this out - I posted another fix on the bugzilla page: https://bugzilla.libsdl.org/show_bug.cgi?id=3312

Hi,
I just uploaded a new patch I’ve been working for OSX raw mouse support:
https://bugzilla.libsdl.org/show_bug.cgi?id=445

pretty excited about this, it’s a lot better than my first effort imho. :slight_smile:

  • no danger of threading bugs since everything happens on the main thread.
  • cleanly handles enabling/disabling relative mouse mode, as well as mice
    being added/removed
  • tested on 10.6 and 10.11, various mice (macbook trackpad, logitech g400,
    MS wireless keyboard/mouse, a wacom tablet)
  • CPU usage seems about the same in ‘testrelative’ with our without the
    patch, I get in the 7-8% CPU range according to Activity Monitor

The main concern I have is, currently there is no allowance for falling
back to the old NSMouseMoved implementation if the IOHID* API’s fail
somehow.

Appreciate any testing or feedback anyone can contribute!
Thanks,
EricOn Thu, Apr 7, 2016 at 12:03 PM, Eric Wasylishen <@Eric_Wasylishen> wrote:

Just a small update - I thought I would resurrect that bug report and
collect info there: https://bugzilla.libsdl.org/show_bug.cgi?id=445

My patch still applies and seems to work (yay!) but I didn’t get a chance
to look at the CPU usage yet.

On Wed, Mar 16, 2016 at 1:45 PM, Daniel Gibson wrote:

Oh cool, totally missed that patch!

Do you think there is a way to get raw input without spending 15% of the
CPU time in the raw mouse thread? It sounds a lot (even if it might be
tolerable if there is no other way).

Cheers,
Daniel

On 03/14/2016 06:01 AM, Eric Wasylishen wrote:

Hi,
I agree completely, OS X relative mode should match Linux and Windows
and give raw input.
A way to opt-in to acceleration would be nice as well, but I think that
would be a separate new feature.

I sent a patch to the list a while ago with a first stab at implementing
this:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2014-October/096672.html

Haven’t looked at the patch since 2014. Maybe I should have filed it in
the bug tracker, oops.
Anyway, if there is interest I could try resurrecting and cleaning up
this patch.
Cheers,
Eric

On Sun, Mar 13, 2016 at 5:35 PM, Daniel Gibson <metalcaedes at gmail.com <mailto:metalcaedes at gmail.com>> wrote:

Hi,

I recently tried playing a FPS game using SDL2 on OSX, using a
normal mouse, and it was pretty bad: Aiming was almost impossible
because the mouse input is accelerated. (The common workaround
currently seems to be using thirdparty tools like to disable mouse
acceleration system-wide.)
On Windows and Linux you get raw mouse input in relative mode, which
IMHO is the right thing to do - however "slime" of #SDL argued that
when using a trackpad, accelerated mouse input is preferable even in
relative mode.
Note however that the current behavior is inconsistent with Windows
and Linux and if raw mouse input on OSX were implemented, one could
still use SDL_HINT_MOUSE_RELATIVE_MODE_WARP to get the old/current
behavior.

I found http://forums.libsdl.org/viewtopic.php?t=9969 which
describes a way to get raw mouse input on OSX, does anyone know why
SDL2 doesn't do that? Does the approach have any problems or was it
just not implemented because no one got around to do it?

There's also a really old bugreport:
https://bugzilla.libsdl.org/show_bug.cgi?id=445

Any thoughts on the topic? :-)

Cheers,
Daniel
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org