Hi guys
I am having an issue with trying to get the Mouse.GetState(). It’s always returning 0,0
I tried just the usual way of getting the Mouse.GetState() through MouseState mousestate = Mouse.GetState(); at the Update()
Then assigning mousestate.X and mousestate.Y to a Vector2 that’s declared outside as static. I am always getting 0,0 when trying to debug. I even just tried to dump mousestate.X and mousestate.Y at the Draw() at Window.title and still is 0,0.
I am running the game in a border-less Windows. Now, what I found is that at the beginning of the game (Initialize), both Mouse.WindowHandle and Window.Handle are the same value.
BUT in Update(), Mouse.WindowHandle = Window.Handle are different.
As far as I know, Mouse.WindowHandle {set} is not implemented in Monogame
Any remote idea what this is ? I’ve tried with monogame 3.7.1 and happens the same.
The mouse is just a regular USB mouse, I tried on a laptop and happens the same with the Touchpad.
Yes, it’s a Windows DX project (not UWP), using monogame 3.6. But as said in the description, the problem is that GetState() was using a different handle rather than the window Handle.
GetState() uses Mouse.WindowHandle and in my case, both Mouse.WindowHandle and Window.Handle are different at the moment of the Update()
The solution was simply passing Window to the GetState(), so:
Hi Nkast, thanks for your answer. Best solution I found was passing window to the getstate(), so:
MouseState mousestate = Mouse.GetState(Window);
This fixed the issue, as it passes the Window handle.
Another solution would be upgrading to 3.7.1 which, as far as I read, implemented {set} for Mouse.WindowHandle, so at the initialize part could be just used:
I think my solution is good, I couldn’t find it anywhere here on the forums, nor somewhere else. I mean, it’s an alternative as well for those not wanting to use 3.7.1 nor wanting to recompile monogame.