MouseState position is relative to cursor position on start #1

Closed
jhauberg opened this Issue Jan 12, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@jhauberg
Contributor

jhauberg commented Jan 12, 2013

I have a problem where the position of the cursor has its origin ( 0, 0) set to where ever the cursor happens to be on the screen ( the entire screen) when i run my windowed subclass of GameWindow. I was expecting it to have its origin be at either the top-left or lower-left corner of the window.

All I do with the mouse is this, in a typical update loop:

MouseState ms = Mouse.GetState();

System.Diagnostics.Debug.WriteLine(
    String.Format("{0}, {1}", ms.X, ms.Y));

This is happening on Windows 8. I have not tested on OSX.

@andykorth

This comment has been minimized.

Show comment
Hide comment
@andykorth

andykorth Jan 15, 2013

Owner

I believe this is intended behavior by the original author:

"OpenTK.Input.Mouse, which provides low-level access to mouse motions. It is independent of windows/displays and provides raw (i.e. non-accelerated) values, if possible. Use this for games that require mouse motions not confined to the display, for instance first-person shooters and 3d games with mouse-controlled cameras."

Instead, if you want absolute (instead of delta) coordinates relative to the screen... I think instead you want this:

"GameWindow.Mouse* events, which are equivalent to WinForms/WPF/GTK# mouse events. The values are accelerated by the OS and are reported in window coordinates. Use this for menu/UI navigation and games that require absolute coordinates, for instance and 2d games."

From: http://www.opentk.com/doc/input

(Additionally, OpenTK.Input.Mouse x and y values aren't adjusted by your mouse acceleration curve, and at least on OS X, they don't even come close to corresponding with the screen. Numbers returned as deltas aren't close to pixels)

Owner

andykorth commented Jan 15, 2013

I believe this is intended behavior by the original author:

"OpenTK.Input.Mouse, which provides low-level access to mouse motions. It is independent of windows/displays and provides raw (i.e. non-accelerated) values, if possible. Use this for games that require mouse motions not confined to the display, for instance first-person shooters and 3d games with mouse-controlled cameras."

Instead, if you want absolute (instead of delta) coordinates relative to the screen... I think instead you want this:

"GameWindow.Mouse* events, which are equivalent to WinForms/WPF/GTK# mouse events. The values are accelerated by the OS and are reported in window coordinates. Use this for menu/UI navigation and games that require absolute coordinates, for instance and 2d games."

From: http://www.opentk.com/doc/input

(Additionally, OpenTK.Input.Mouse x and y values aren't adjusted by your mouse acceleration curve, and at least on OS X, they don't even come close to corresponding with the screen. Numbers returned as deltas aren't close to pixels)

@andykorth andykorth closed this Jan 15, 2013

@jhauberg

This comment has been minimized.

Show comment
Hide comment
@jhauberg

jhauberg Jan 15, 2013

Contributor

Wow, my bad. I should learn to read! It totally works as I wanted when using GameWindow.Mouse. Thanks for pointing this out!

Contributor

jhauberg commented Jan 15, 2013

Wow, my bad. I should learn to read! It totally works as I wanted when using GameWindow.Mouse. Thanks for pointing this out!

@andykorth

This comment has been minimized.

Show comment
Hide comment
@andykorth

andykorth Jan 15, 2013

Owner

No problem, it's quite unclear, I think it should be made more clear that Mouse.GetState().X are actually deltas.

I actually updated the wiki page a little bit to make it more clear a few days ago.. still easy to miss.

Owner

andykorth commented Jan 15, 2013

No problem, it's quite unclear, I think it should be made more clear that Mouse.GetState().X are actually deltas.

I actually updated the wiki page a little bit to make it more clear a few days ago.. still easy to miss.

andykorth added a commit that referenced this issue Mar 22, 2013

Merge pull request #1 from elisee/fix-client-rectangle-setter
Fix ClientRectangle setter on Windows (WinGL) & Linux (X11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment