C#/XNA get hardware mouse position
Posted
by
Sunder
on Game Development
See other posts from Game Development
or by Sunder
Published on 2012-12-13T10:39:11Z
Indexed on
2012/12/13
11:21 UTC
Read the original article
Hit count: 389
I'm using C# and trying to get hardware mouse position. First thing I tryed was simple XNA functionality that is simple to use
Vector2 position = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
After that i do the drawing of mouse as well, and comparing to windows hardware mouse, this new mouse with xna provided coordinates is "slacking off". By that i mean, that it is behind by few frames. For example if game is runing at 600 fps, of curse it will be responsive, but at 60 fps software mouse delay is no longer acceptable. Therefore I tried using what I thought was a hardware mouse,
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out POINT lpPoint);
but the result was exactly the same. I also tried geting Windows form cursor, and that was a dead end as well - worked, but with the same delay. Messing around with xna functionality:
GraphicsDeviceManager.SynchronizeWithVerticalRetrace = true/false
Game.IsFixedTimeStep = true/fale
did change the delay time for somewhat obvious reasons, but the bottom line is that regardless it still was behind default Windows mouse. I'v seen in some games, that they provide option for hardware acelerated mouse, and in others(I think) it is already by default. Can anyone give some lead on how to achieve that.
© Game Development or respective owner