lukemols
lukemols

Reputation: 71

How to check if Mouse is available in XNA - Monogame

I'm using Monogame to develop an universal app for Windows Store and Windows Phone.

I know that is possible to check if a TouchPanel is available and I'm looking for a method that do the same thing with a mouse.

I can't ignore the fact that a mouse is not connected because instructions like this.IsMouseVisible = true; launch exceptions on Windows Phone.

Thank you all for your reply,

Luca.

Upvotes: 3

Views: 255

Answers (1)

ReMinoer
ReMinoer

Reputation: 402

You have various solutions, depends of what you want to do :

  1. You can add a try-catch around this.IsMouseVisible. If you get a exception, you know for sure that the mouse is unavailable.
  2. You have conditional compilation symbols with XNA. Use #if !WINDOWS_PHONE to prevent phones to check the mouse. I think you can consider that most of phones don't use mouse. (See MSDN documentation)

Upvotes: 1

Related Questions