Win32 Relative Mouse Movement (attn Forest Hale!)

I wrote:

I’ve just tested out the win32 version of Patrick’s changes (sorry for
calling you Peter earlier!) and it seems to work well. The cursor
disappears correctly, I get the same movement as I did in 1.2, and
didn’t see anything wrong jump out.

I take that back, I had to back out the change. The relative mouse
works, but there’s some bug that seems to get the mouse buttons locked
down after a click. It doesn’t always happen for me, but often I’ll get
repeated mouse clicks (infinite repeated mouse clicks).

[>] Brian

I’ve just tested out the win32 version of Patrick’s changes (sorry for
calling you Peter earlier!) and it seems to work well. The cursor
disappears correctly, I get the same movement as I did in 1.2, and didn’t
see anything wrong jump out.

One thing I thought about later was multiple windows with relative mouse
movement. I think it should be OK, but I keep thinking that there might be
a chance that multiple SDL windows would cause events to not be reported. I
think I need to test if the focus will follow on a second window. Here’s
the scenario:

Two windows A & B created by SDL2:

  1. A is active.
  2. Relative mouse movement enabled, messages are reported when A has focus
    (I think?)
  3. User Alt+Tab’s to B
  4. Does relative mouse movement still work?

If this is a problem, the fix is absurdly trivial. Now I’m kind of
regretting not testing that. Hmm…

I think we should think about getting this into the trunk and getting more
testing.

It might be a little slower than the old one, though, but that’s what
mouse movement sliders are for :slight_smile:

I think that raw input is implemented on Win32 by directly reading the
device file using the HidP API. I think that means that any sort of
pre-applied software cursor acceleration wouldn’t be applied. This is
conjecture, I don’t actually have the Windows source code, but if you read
from the device directly using HidP, those are the sort of small values you
get.On Thu, Jun 7, 2012 at 12:32 PM, Brian Barnes wrote:

Note I only spent a couple minutes testing, but no problems in that time
(this was within my own 3D engine.)

[>] Brian

Heh, that sounds like a pretty bad problem. OK, let me look into that
tonight and get back to you guys. Off hand, I’m not sure why the mouse
events would be infinitely generated. Thanks for testing this.

PatrickOn Thu, Jun 7, 2012 at 2:39 PM, Brian Barnes wrote:

I wrote:

I’ve just tested out the win32 version of Patrick’s changes (sorry for

calling you Peter earlier!) and it seems to work well. The cursor
disappears correctly, I get the same movement as I did in 1.2, and
didn’t see anything wrong jump out.

I take that back, I had to back out the change. The relative mouse works,
but there’s some bug that seems to get the mouse buttons locked down after
a click. It doesn’t always happen for me, but often I’ll get repeated
mouse clicks (infinite repeated mouse clicks).

[>] Brian

You can test multiple windows using ./testrelative --windows 2On Thu, Jun 7, 2012 at 10:47 PM, Patrick Baggett <baggett.patrick at gmail.com> wrote:

Heh, that sounds like a pretty bad problem. OK, let me look into that
tonight and get back to you guys. Off hand, I’m not sure why the mouse
events would be infinitely generated. Thanks for testing this.

Patrick

On Thu, Jun 7, 2012 at 2:39 PM, Brian Barnes wrote:

I wrote:

I’ve just tested out the win32 version of Patrick’s changes (sorry for
calling you Peter earlier!) and it seems to work well. ?The cursor
disappears correctly, I get the same movement as I did in 1.2, and
didn’t see anything wrong jump out.

I take that back, I had to back out the change. ?The relative mouse works,
but there’s some bug that seems to get the mouse buttons locked down after a
click. ?It doesn’t always happen for me, but often I’ll get repeated mouse
clicks (infinite repeated mouse clicks).

[>] Brian


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

Ah nice, thanks a lot. :wink:

PatrickOn Thu, Jun 7, 2012 at 2:53 PM, Dimitris Zenios <dimitris.zenios at gmail.com>wrote:

You can test multiple windows using ./testrelative --windows 2

On Thu, Jun 7, 2012 at 10:47 PM, Patrick Baggett <@Patrick_Baggett> wrote:

Heh, that sounds like a pretty bad problem. OK, let me look into that
tonight and get back to you guys. Off hand, I’m not sure why the mouse
events would be infinitely generated. Thanks for testing this.

Patrick

On Thu, Jun 7, 2012 at 2:39 PM, Brian Barnes wrote:

I wrote:

I’ve just tested out the win32 version of Patrick’s changes (sorry for
calling you Peter earlier!) and it seems to work well. The cursor
disappears correctly, I get the same movement as I did in 1.2, and
didn’t see anything wrong jump out.

I take that back, I had to back out the change. The relative mouse
works,

but there’s some bug that seems to get the mouse buttons locked down
after a

click. It doesn’t always happen for me, but often I’ll get repeated
mouse

clicks (infinite repeated mouse clicks).

[>] Brian


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


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

In X11 relative mouse events do not hold a reference for the window.
(As per the documentation of X11 “Since raw events do not have target
windows they are delivered exclusively to all root windows.”).

Once relative mouse motion event is received its send to the event
queue without a window parameter.If someone wants to limit mouse
motion only inside once window its better to grab the mouseOn Thu, Jun 7, 2012 at 10:56 PM, Patrick Baggett <baggett.patrick at gmail.com> wrote:

Ah nice, thanks a lot. :wink:

Patrick

On Thu, Jun 7, 2012 at 2:53 PM, Dimitris Zenios <@Dimitris_Zenios> wrote:

You can test multiple windows using ./testrelative --windows 2

On Thu, Jun 7, 2012 at 10:47 PM, Patrick Baggett <baggett.patrick at gmail.com> wrote:

Heh, that sounds like a pretty bad problem. OK, let me look into that
tonight and get back to you guys. Off hand, I’m not sure why the mouse
events would be infinitely generated. Thanks for testing this.

Patrick

On Thu, Jun 7, 2012 at 2:39 PM, Brian Barnes wrote:

I wrote:

I’ve just tested out the win32 version of Patrick’s changes (sorry for
calling you Peter earlier!) and it seems to work well. ?The cursor
disappears correctly, I get the same movement as I did in 1.2, and
didn’t see anything wrong jump out.

I take that back, I had to back out the change. ?The relative mouse
works,
but there’s some bug that seems to get the mouse buttons locked down
after a
click. ?It doesn’t always happen for me, but often I’ll get repeated
mouse
clicks (infinite repeated mouse clicks).

[>] Brian


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


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


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

In X11 relative mouse events do not hold a reference for the window.
(As per the documentation of X11 “Since raw events do not have target
windows they are delivered exclusively to all root windows.”).

In Win32, they don’t necessarily have to be associated with a window, you
can choose to:

a) only get raw input messages on the window that enabled it when that
window has focus (single window mode)
b) always get raw input messages on the window has focus, regardless of who
initialized it (window with focus mode)
c) always get messages even if minimized and no focus (“input sink” mode).

b) is likely the best answer, even if you set the SDL_event’s window
parameter to NULL.

Once relative mouse motion event is received its send to the event
queue without a window parameter.If someone wants to limit mouse
motion only inside once window its better to grab the mouse

This makes me sound like relative mouse movement allows the cursor to leave
the window and various other issues listed below.

Maybe someone could point to documentation for the desired behavior? My
understanding of this feature is that it:
a) makes the cursor disappear
b) doesn’t allow the cursor to leave the SDL window with focus
c) reports relative mouse movements directly from the hardware (since the
cursor “ceases to exist” as such)

The typical use-case of this would be something like a FPS where you want
mouse look but don’t want the look ability to abruptly halt when it leaves
the window, nor clicks to unfocus your game window (if running in window
mode).

If you don’t enable relative mouse movement, you can still get relative
mouse coordinates since SDL will track the cursor position and compute
deltas, but:
a) the cursor is visible
b) the cursor can leave the application window in window mode
c) if the cursor reaches the edge of the screen, relative movements can’t
happen since they are tracked based on delta cursor position and not
reading the mouse HW.

PatrickOn Thu, Jun 7, 2012 at 3:04 PM, Dimitris Zenios <dimitris.zenios at gmail.com>wrote:

Now SDL_SetRelativeMouseMotion only sets the cursor to hidden but it
does allow for the mouse to leave the window.Maybe we can create a
standard on how relative mouse motion should behave and try to
implement it that way on all video drivers (X11,Windows etc)On Thu, Jun 7, 2012 at 11:24 PM, Patrick Baggett <baggett.patrick at gmail.com> wrote:

On Thu, Jun 7, 2012 at 3:04 PM, Dimitris Zenios <@Dimitris_Zenios> wrote:

In X11 relative mouse events do not hold a reference for the window.
(As per the documentation of X11 “Since raw events do not have target
windows they are delivered exclusively to all root windows.”).

In Win32, they don’t necessarily have to be associated with a window, you
can choose to:

a) only get raw input messages on the window that enabled it when that
window has focus (single window mode)
b) always get raw input messages on the window has focus, regardless of who
initialized it (window with focus mode)
c) always get messages even if minimized and no focus (“input sink” mode).

b) is likely the best answer, even if you set the SDL_event’s window
parameter to NULL.

Once relative mouse motion event is received its send to the event
queue without a window parameter.If someone wants to limit mouse
motion only inside once window its better to grab the mouse

This makes me sound like relative mouse movement allows the cursor to leave
the window and various other issues listed below.

Maybe someone could point to documentation for the desired behavior? My
understanding of this feature is that it:
a) makes the cursor disappear
b) doesn’t allow the cursor to leave the SDL window with focus
c) reports relative mouse movements directly from the hardware (since the
cursor “ceases to exist” as such)

The typical use-case of this would be something like a FPS where you want
mouse look but don’t want the look ability to abruptly halt when it leaves
the window, nor clicks to unfocus your game window (if running in window
mode).

If you don’t enable relative mouse movement, you can still get relative
mouse coordinates since SDL will track the cursor position and compute
deltas, but:
a) the cursor is visible
b) the cursor can leave the application window in window mode
c) if the cursor reaches the edge of the screen, relative movements can’t
happen since they are tracked based on delta cursor position and not reading
the mouse HW.

Patrick


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

Now SDL_SetRelativeMouseMotion only sets the cursor to hidden but it
does allow for the mouse to leave the window.Maybe we can create a
standard on how relative mouse motion should behave and try to
implement it that way on all video drivers (X11,Windows etc)

Conceptually, I think the “relative mouse mode” should be for those who
don’t need the “cursor” as such (e.g. games) – they are only interested in
the mouse’s relative movements which are usually translated into some
relative movement within the game itself. Considering that you have to
enable it and that you can otherwise get relative mouse information from
computing the deltas between cursor positions (as SDL currently does), the
only reason to opt-in for it is when you need something other than just
relative mouse movements. The fact that one of the already-documented
behaviors is that the cursor disappears strongly points to the fact that
the original design was to have a sort of “game mode” that ignored the
window system entirely and treated it as if you were polling the hardware.

Because of this, I vote for this behavior:

On SDL windows –

  1. Cursor is hidden
  2. Cursor cannot leave the window
  3. Clicks will not cause the SDL window to lose focus (follows from #2)
  4. When a SDL window doesn’t have focus, normal mouse operations occur
    (cursor visible, able to move normally, click to focus any other window,
    etc.)
  5. When the SDL app exits, it has no permanent effect on the
    cursor/windowing system, even if crashing/killed (so, no atexit()-style
    behaviors). Consider: Xf86DGA can leave mouse unconnected, XInput2 can
    reconfigure master devices.

PatrickOn Thu, Jun 7, 2012 at 3:28 PM, Dimitris Zenios <dimitris.zenios at gmail.com>wrote:

Yes, this is the correct behavior, as listed below. It should match the
SDL 1.2 relative mouse mode behavior.

Cheers!On Thu, Jun 7, 2012 at 5:31 PM, Patrick Baggett <baggett.patrick at gmail.com>wrote:

On Thu, Jun 7, 2012 at 3:28 PM, Dimitris Zenios <dimitris.zenios at gmail.com wrote:

Now SDL_SetRelativeMouseMotion only sets the cursor to hidden but it
does allow for the mouse to leave the window.Maybe we can create a
standard on how relative mouse motion should behave and try to
implement it that way on all video drivers (X11,Windows etc)

Conceptually, I think the “relative mouse mode” should be for those who
don’t need the “cursor” as such (e.g. games) – they are only interested in
the mouse’s relative movements which are usually translated into some
relative movement within the game itself. Considering that you have to
enable it and that you can otherwise get relative mouse information from
computing the deltas between cursor positions (as SDL currently does), the
only reason to opt-in for it is when you need something other than just
relative mouse movements. The fact that one of the already-documented
behaviors is that the cursor disappears strongly points to the fact that
the original design was to have a sort of “game mode” that ignored the
window system entirely and treated it as if you were polling the hardware.

Because of this, I vote for this behavior:

On SDL windows –

  1. Cursor is hidden
  2. Cursor cannot leave the window
  3. Clicks will not cause the SDL window to lose focus (follows from #2)
  4. When a SDL window doesn’t have focus, normal mouse operations occur
    (cursor visible, able to move normally, click to focus any other window,
    etc.)
  5. When the SDL app exits, it has no permanent effect on the
    cursor/windowing system, even if crashing/killed (so, no atexit()-style
    behaviors). Consider: Xf86DGA can leave mouse unconnected, XInput2 can
    reconfigure master devices.

Patrick


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

Err, there are two behaviors below, one by Dimitris and one by myself. Can
you be explicit (never used 1.2’s relative mouse)?

PatrickOn Sun, Jun 10, 2012 at 11:48 PM, Sam Lantinga wrote:

Yes, this is the correct behavior, as listed below. It should match the
SDL 1.2 relative mouse mode behavior.

Cheers!

On Thu, Jun 7, 2012 at 5:31 PM, Patrick Baggett <@Patrick_Baggett wrote:

On Thu, Jun 7, 2012 at 3:28 PM, Dimitris Zenios < dimitris.zenios at gmail.com> wrote:

Now SDL_SetRelativeMouseMotion only sets the cursor to hidden but it
does allow for the mouse to leave the window.Maybe we can create a
standard on how relative mouse motion should behave and try to
implement it that way on all video drivers (X11,Windows etc)

Conceptually, I think the “relative mouse mode” should be for those who
don’t need the “cursor” as such (e.g. games) – they are only interested in
the mouse’s relative movements which are usually translated into some
relative movement within the game itself. Considering that you have to
enable it and that you can otherwise get relative mouse information from
computing the deltas between cursor positions (as SDL currently does), the
only reason to opt-in for it is when you need something other than just
relative mouse movements. The fact that one of the already-documented
behaviors is that the cursor disappears strongly points to the fact that
the original design was to have a sort of “game mode” that ignored the
window system entirely and treated it as if you were polling the hardware.

Because of this, I vote for this behavior:

On SDL windows –

  1. Cursor is hidden
  2. Cursor cannot leave the window
  3. Clicks will not cause the SDL window to lose focus (follows from #2)
  4. When a SDL window doesn’t have focus, normal mouse operations occur
    (cursor visible, able to move normally, click to focus any other window,
    etc.)
  5. When the SDL app exits, it has no permanent effect on the
    cursor/windowing system, even if crashing/killed (so, no atexit()-style
    behaviors). Consider: Xf86DGA can leave mouse unconnected, XInput2 can
    reconfigure master devices.

Patrick


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


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

The part that says Cursor cannot leave the window does not specify
which window.With SDL 2.0 we can have many windows.That why I didn’t
lock the mouse inside a windowOn Wed, Jun 20, 2012 at 12:19 AM, Patrick Baggett <baggett.patrick at gmail.com> wrote:

Err, there are two behaviors below, one by Dimitris and one by myself. Can
you be explicit (never used 1.2’s relative mouse)?

Patrick

On Sun, Jun 10, 2012 at 11:48 PM, Sam Lantinga wrote:

Yes, this is the correct behavior, as listed below. ?It should match the
SDL 1.2 relative mouse mode behavior.

Cheers!

On Thu, Jun 7, 2012 at 5:31 PM, Patrick Baggett <baggett.patrick at gmail.com> wrote:

On Thu, Jun 7, 2012 at 3:28 PM, Dimitris Zenios <@Dimitris_Zenios> wrote:

Now SDL_SetRelativeMouseMotion only sets the cursor to hidden but it
does allow for the mouse to leave the window.Maybe we can create a
standard on how relative mouse motion should behave and try to
implement it that way on all video drivers (X11,Windows etc)

Conceptually, I think the “relative mouse mode” should be for those who
don’t need the “cursor” as such (e.g. games) – they are only interested in
the mouse’s relative movements which are usually translated into some
relative movement within the game itself. Considering that you have to
enable it and that you can otherwise get relative mouse information from
computing the deltas between cursor positions (as SDL currently does), the
only reason to opt-in for it is when you need something other than just
relative mouse movements. The fact that one of the already-documented
behaviors is that the cursor disappears strongly points to the fact that the
original design was to have a sort of “game mode” that ignored the window
system entirely and treated it as if you were polling the hardware.

Because of this, I vote for this behavior:

On SDL windows –

  1. Cursor is hidden
  2. Cursor cannot leave the window
  3. Clicks will not cause the SDL window to lose focus (follows from #2)
  4. When a SDL window doesn’t have focus, normal mouse operations occur
    (cursor visible, able to move normally, click to focus any other window,
    etc.)
  5. When the SDL app exits, it has no permanent effect on the
    cursor/windowing system, even if crashing/killed (so, no atexit()-style
    behaviors). Consider: Xf86DGA can leave mouse unconnected, XInput2 can
    reconfigure master devices.

Patrick


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


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


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

I just used the focus [SDL_]window as the window that the mouse could not
leave. I think that makes the most sense, and I’d be genuinely surprised if
there were many (any?) apps that would make use of relative mouse stuff
with >= 2 windows – though I guess we can test it too.

PatrickOn Wed, Jun 20, 2012 at 4:02 AM, Dimitris Zenios <dimitris.zenios at gmail.com>wrote:

The part that says Cursor cannot leave the window does not specify
which window.With SDL 2.0 we can have many windows.That why I didn’t
lock the mouse inside a window

On Wed, Jun 20, 2012 at 12:19 AM, Patrick Baggett <@Patrick_Baggett> wrote:

Err, there are two behaviors below, one by Dimitris and one by myself.
Can
you be explicit (never used 1.2’s relative mouse)?

Patrick

On Sun, Jun 10, 2012 at 11:48 PM, Sam Lantinga wrote:

Yes, this is the correct behavior, as listed below. It should match the
SDL 1.2 relative mouse mode behavior.

Cheers!

On Thu, Jun 7, 2012 at 5:31 PM, Patrick Baggett <@Patrick_Baggett> wrote:

On Thu, Jun 7, 2012 at 3:28 PM, Dimitris Zenios <dimitris.zenios at gmail.com> wrote:

Now SDL_SetRelativeMouseMotion only sets the cursor to hidden but it
does allow for the mouse to leave the window.Maybe we can create a
standard on how relative mouse motion should behave and try to
implement it that way on all video drivers (X11,Windows etc)

Conceptually, I think the “relative mouse mode” should be for those who
don’t need the “cursor” as such (e.g. games) – they are only
interested in

the mouse’s relative movements which are usually translated into some
relative movement within the game itself. Considering that you have to
enable it and that you can otherwise get relative mouse information
from

computing the deltas between cursor positions (as SDL currently does),
the

only reason to opt-in for it is when you need something other than just
relative mouse movements. The fact that one of the already-documented
behaviors is that the cursor disappears strongly points to the fact
that the

original design was to have a sort of “game mode” that ignored the
window

system entirely and treated it as if you were polling the hardware.

Because of this, I vote for this behavior:

On SDL windows –

  1. Cursor is hidden
  2. Cursor cannot leave the window
  3. Clicks will not cause the SDL window to lose focus (follows from #2)
  4. When a SDL window doesn’t have focus, normal mouse operations occur
    (cursor visible, able to move normally, click to focus any other
    window,

etc.)
5) When the SDL app exits, it has no permanent effect on the
cursor/windowing system, even if crashing/killed (so, no atexit()-style
behaviors). Consider: Xf86DGA can leave mouse unconnected, XInput2 can
reconfigure master devices.

Patrick


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


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


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


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