Note I posted about this in another thread but I realized this issue may not be the same reported by the original poster there, so I’m creating a new thread here for clarity.
On Windows 10, Mouse clicks and key pressed are not detected (or frequently missed) for all Monogame apps targeting Windows 8.1 and compiled with Visual Studio 2012/2013 (not sure about VS 2015 yet).
If confirmed, it’s a serious problem because it affects all apps out there, that are working fine on Windows 8/8.1, but fail when the user upgrades to Windws 10 (I just confirmed this for this game http://apps.microsoft.com/windows/app/4ad90094-406f-438a-8888-3e27f79bc419 apparently made with Monogame).
Reproducing the issue is easy. Using Visual Studio Express 2012 or 2013, create a default ‘MonoGame Windows Store Project’ called ‘MonoGameWindowsStoreProject13’ (if you use a different name you will need to change namespace name accordingly, at line 4 in Game1.cs, see below)
Replace the entire code in Game1.cs with the code below (change ‘namespace’ name at line 4 to match your project name if necessary).
This example is supposed to paint the screen Red while mouse button is pressed).
On Windows 10 (laptops/XBox) it appears to only detect clicks occasionally or not at all. It works fine on Windows 8.1.
I’m using the latest Monogame SDK. I updated Visual Studio to the latest patches from Microsoft.
Can anyone confirm? I tried on various laptops running Windows 10. A friend confirmed the issue on his XBox.
Doeas anyone know a fix?
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace MonoGameWindowsStoreProject13
{
///
/// This is the main type for your game.
///
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
Windows.UI.Core.CoreWindow _window = Windows.UI.Core.CoreWindow.GetForCurrentThread();
_window.PointerPressed += OnPointerPressed;
_window.PointerReleased += OnPointerReleased;
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
if (PointerButtonPressedLeft) GraphicsDevice.Clear(Color.Red);
else GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
bool PointerButtonPressedLeft = false;
void OnPointerPressed(object sender, Windows.UI.Core.PointerEventArgs args)
{
Windows.UI.Input.PointerPointProperties props = args.CurrentPoint.Properties;
if (props.IsLeftButtonPressed)
{
PointerButtonPressedLeft = true;
}
}
void OnPointerReleased(object sender, Windows.UI.Core.PointerEventArgs args)
{
Windows.UI.Input.PointerPointProperties props = args.CurrentPoint.Properties;
if (props.PointerUpdateKind == Windows.UI.Input.PointerUpdateKind.LeftButtonReleased)
{
PointerButtonPressedLeft = false;
}
}
}
}