Another OS X mouse issue

Relative mousemove events don’t work correctly on OS X if:

  1. You have the input grabbed w/ the cursor hidden and
  2. you are fullscreen.

It seems that it’s just not grabbing the cursor at all, so when you hit
the edge of the window, the relative motion is 0. This is expected
behaviour for when the cursor is showing, but not when it’s hidden.
Windowed mode works correctly with the hidden cursor/grabbed input
combination.

Quickest example is to use SDL12/test/threadwin and add a
SDL_WM_GrabInput(SDL_GRAB_ON) right before the SetVideoMode call. In
windowed mode, the cursor sits in the middle of the window (hmmm, that’s
not right, either…) and relative motion events are correct. Run it with
the -fullscreen option, and it doesn’t grab the cursor. Calling
SDL_ShowCursor(0) doesn’t change the relative motion behaviour.

So in windowed mode, the mouse is grabbed a little too much, and in
fullscreen, not quite enough. :slight_smile:

Seriously, the fullscreen thing makes it hard to do FPS games, since you
can’t spin all the way around with the mouse.

Darrell, can I get your expert touch on this one if I promise to stop
nagging you about the mouse after this? :slight_smile:

Thanks,
–ryan.

Message: 21

Relative mousemove events don’t work correctly on OS X if:

  1. You have the input grabbed w/ the cursor hidden and
  2. you are fullscreen.

It seems that it’s just not grabbing the cursor at all, so when you hit
the edge of the window, the relative motion is 0. This is expected
behaviour for when the cursor is showing, but not when it’s hidden.
Windowed mode works correctly with the hidden cursor/grabbed input
combination.

Quickest example is to use SDL12/test/threadwin and add a
SDL_WM_GrabInput(SDL_GRAB_ON) right before the SetVideoMode call. In
windowed mode, the cursor sits in the middle of the window (hmmm,
that’s
not right, either…) and relative motion events are correct. Run it
with
the -fullscreen option, and it doesn’t grab the cursor. Calling
SDL_ShowCursor(0) doesn’t change the relative motion behaviour.

So in windowed mode, the mouse is grabbed a little too much, and in
fullscreen, not quite enough. :slight_smile:

Yeah, the cursor isn’t grabbed at all in fullscreen mode. When I wrote
the code I was trying for the minimal implementation of “Mouse is
constrained to SDL window”. In fullscreen mode, I don’t do a real grab
because I don’t have to (based on the definition I was working with).

In windowed mode, the cursor is frozen in the center of the screen
(essentially, the cursor has been detached from the mouse). But it’s
grabbed “too much” in that the hardware cursor is frozen and basically
useless.

Seriously, the fullscreen thing makes it hard to do FPS games, since
you
can’t spin all the way around with the mouse.

Would you be in favor of a full grab in fullscreen mode as well? This
will fix your FPS issue, and it’s a quick fix. It doesn’t fix the “too
much” problem though.

Maybe “just right” would warp the cursor to the opposite side of the
window/screen when it went over the edge. How do other platforms
constrain the mouse to the window (X11, Win32)?

Darrell, can I get your expert touch on this one if I promise to stop
nagging you about the mouse after this?

It’s no bother (yet), so feel free to keep nagging. The mouse movement
code has had lots of bugs/quirks since the beginning and I don’t expect
that to end anytime soon ;-)On Tuesday, December 17, 2002, at 03:01 PM, sdl-request at libsdl.org wrote:

Date: Tue, 17 Dec 2002 02:54:49 -0500 (EST)
From: “Ryan C. Gordon”
To:
Subject: [SDL] Another OS X mouse issue…
Reply-To: sdl at libsdl.org

Maybe “just right” would warp the cursor to the opposite side of the
window/screen when it went over the edge. How do other platforms
constrain the mouse to the window (X11, Win32)?

This is how X11 does it…it warps the cursor to the center if the cursor
is hidden and input is grabbed, so that relative motion remains accurate.

–ryan.

Message: 3

Maybe “just right” would warp the cursor to the opposite side of the
window/screen when it went over the edge. How do other platforms
constrain the mouse to the window (X11, Win32)?

This is how X11 does it…it warps the cursor to the center if the
cursor
is hidden and input is grabbed, so that relative motion remains
accurate.

What does X11 do when the cursor is grabbed but not hidden?On Wednesday, December 18, 2002, at 03:01 PM, sdl-request at libsdl.org wrote:

Date: Tue, 17 Dec 2002 16:46:21 -0500 (EST)
From: “Ryan C. Gordon”
To: “sdl at libsdl.org
Subject: Re: [SDL] Another OS X mouse issue…
Reply-To: sdl at libsdl.org

What does X11 do when the cursor is grabbed but not hidden?

Then the cursor is limited to the window. In fullscreen, this means the
cursor has a full range of the monitor, and stops at the edges (and
reports no relative motion when you try to move past the edge).

When hidden, the X11 cursor is still moving, we just warp it back to the
center when it hits an edge so we keep giving relative motion to the
application…obviously querying the position with SDL_GetMouseState() in
this mode is not possible.

–ryan.