# MonoGame Linux Mouse.SetPosition doesn't work!

Having a really weird issue, it seems that no matter what I do I cannot get the Mouse to lock to the center of the screen in MonoGame. I triple checked all the possible noob mistakes, and Mouse.SetPosition does get called. Weirder still, setting Game.IsMouseVisible to false does nothing as well.

        public override void Update(GameTime gt)
{
_lastmousestate = _mousestate;
_mousestate = Mouse.GetState();
if(LockMouse)
Mouse.SetPosition(100,100);
Point distance = new Point(_mousestate.X - _lastmousestate.X, _mousestate.Y - _lastmousestate.Y);
MouseEntity.Position = new Point(MouseEntity.Position.X - distance.X, MouseEntity.Position.Y - distance.Y);
}


I'm using Linux Mint 64-bit with Cinnamon.

• Then perhaps you should file a bug report. What exactly is the question? – petervaz May 22 '13 at 13:29
• Before a bug report, maybe someone on Windows could verify that this code works correctly in Microsoft XNA? – Katana314 May 22 '13 at 13:58
• @Katana314 I'm on it. – Grey May 22 '13 at 14:13
• It seems to work on Windows in my Linux Mono Game Project. It may be a bug. – Grey May 22 '13 at 14:17

http://monogame.codeplex.com/discussions/390201

In this thread the user is struggling with getting the mouse-position(Mouse.SetPosition) to work. Unfortunately it is a bug within MonoGame so it is going to have to take some internal editing. Please look at the code/instructions he has posted within the thread so you can solve your error. It seems like this error is Linux specific only.

I could not find anything on your IsMouseVisible = false not working. Perhaps if you make the following adjustments in the linked thread above, it might work.

EDIT:

The fixes are within two files: OpenTKGameWindow.cs and Mouse.cs

I would submit a bug report to OpenTK, however I am not sure if your bug report will be acknowledged. It's last release was on 2010-Oct-06. It seems like it is being neglected.

• Sad to hear, looks like I'll be going back to XNA on Windows. Turns out there is also no SpriteFOnt support meaning I can't port any of my games. >___> – redcodefinal May 22 '13 at 15:18
• @redcodefinal There actually is SpriteFont support. I have gotten it to work in my Linux MonoGame Project. Would you like me to link you to something that show you how to make it work? – Grey May 22 '13 at 15:54
• You could finish your ports if you help fix the bugs in MonoGame. Why don't you grab a copy of the source code and see if you can figure it out that way? – craftworkgames May 23 '13 at 0:14
• I didn't realise MonoGame was a living project, I'd love to submit bugs when I find them! Could you link me to the bug report site? – redcodefinal May 24 '13 at 2:54
• monogame.net/issues – Grey May 24 '13 at 13:53