diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 808d074..84eb327 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -386,6 +386,10 @@ namespace Microsoft.Xna.Framework.Graphics // Set up the OpenGL Device. Loads entry points. GLDevice = new OpenGLDevice(PresentationParameters); + // The mouse needs to know this for faux-backbuffer mouse scaling. + Input.Mouse.INTERNAL_BackBufferWidth = PresentationParameters.BackBufferWidth; + Input.Mouse.INTERNAL_BackBufferHeight = PresentationParameters.BackBufferHeight; + // Force set the default render states. BlendState = BlendState.Opaque; DepthStencilState = DepthStencilState.Default; @@ -634,6 +638,10 @@ namespace Microsoft.Xna.Framework.Graphics RenderTargetCount > 0 ); + // The mouse needs to know this for faux-backbuffer mouse scaling. + Input.Mouse.INTERNAL_BackBufferWidth = PresentationParameters.BackBufferWidth; + Input.Mouse.INTERNAL_BackBufferHeight = PresentationParameters.BackBufferHeight; + #if WIIU_GAMEPAD wiiuPixelData = new byte[ PresentationParameters.BackBufferWidth * diff --git a/src/Input/Mouse.cs b/src/Input/Mouse.cs index cfde819..29baec4 100644 --- a/src/Input/Mouse.cs +++ b/src/Input/Mouse.cs @@ -30,8 +30,10 @@ namespace Microsoft.Xna.Framework.Input #region Internal Variables - internal static int INTERNAL_WindowWidth = 800; - internal static int INTERNAL_WindowHeight = 600; + internal static int INTERNAL_WindowWidth = GraphicsDeviceManager.DefaultBackBufferWidth; + internal static int INTERNAL_WindowHeight = GraphicsDeviceManager.DefaultBackBufferHeight; + internal static int INTERNAL_BackBufferWidth = GraphicsDeviceManager.DefaultBackBufferWidth; + internal static int INTERNAL_BackBufferHeight = GraphicsDeviceManager.DefaultBackBufferHeight; internal static int INTERNAL_MouseWheel = 0; @@ -73,8 +75,8 @@ namespace Microsoft.Xna.Framework.Input else { // Scale the mouse coordinates for the faux-backbuffer - x = (int) ((double) x * Game.Instance.GraphicsDevice.GLDevice.Backbuffer.Width / INTERNAL_WindowWidth); - y = (int) ((double) y * Game.Instance.GraphicsDevice.GLDevice.Backbuffer.Height / INTERNAL_WindowHeight); + x = (int) ((double) x * INTERNAL_BackBufferWidth / INTERNAL_WindowWidth); + y = (int) ((double) y * INTERNAL_BackBufferHeight / INTERNAL_WindowHeight); } return new MouseState( @@ -101,8 +103,8 @@ namespace Microsoft.Xna.Framework.Input INTERNAL_warpY = y; // Scale the mouse coordinates for the faux-backbuffer - x = (int) ((double) x * INTERNAL_WindowWidth / Game.Instance.GraphicsDevice.GLDevice.Backbuffer.Width); - y = (int) ((double) y * INTERNAL_WindowHeight / Game.Instance.GraphicsDevice.GLDevice.Backbuffer.Height); + x = (int) ((double) x * INTERNAL_WindowWidth / INTERNAL_BackBufferWidth); + y = (int) ((double) y * INTERNAL_WindowHeight / INTERNAL_BackBufferHeight); FNAPlatform.SetMousePosition(WindowHandle, x, y); INTERNAL_IsWarped = true;