public XnaInputManager(Game game, Core.IO.IGameDescriptor gameDesc) { _game = game; _width = gameDesc.Width; _height = gameDesc.Height; _window = game.Window; _mousePosition = new Core.Graphics.Point(); TouchPanel.EnableMouseGestures = true; TouchPanel.EnabledGestures = GestureType.Hold | GestureType.Tap; TouchPanel.EnableMouseTouchPoint = true; #if WINDOWS_UWP var view = SystemNavigationManager.GetForCurrentView(); view.BackRequested += HardwareButtons_BackPressed; bool isHardwareButtonsApiPresent = Windows.Foundation.Metadata.ApiInformation.IsTypePresent (typeof(Windows.Phone.UI.Input.HardwareButtons).FullName); if (isHardwareButtonsApiPresent) { Windows.Phone.UI.Input.HardwareButtons.CameraPressed += HardwareButtons_CameraPressed; } _inputPane = InputPane.GetForCurrentView(); _currentWindow = CoreWindow.GetForCurrentThread(); _currentWindow.KeyDown += XnaInputManager_KeyDown; _currentWindow.KeyUp += XnaInputManager_KeyUp; #endif }
private void UpdateMousePosition(Vector2 pos) { var rect = _game.Services.GetService <IGraphicsManager>().Bounds; if (rect.Width == 0 || rect.Height == 0) { return; } var scaleX = (float)_width / rect.Width; var scaleY = (float)_height / rect.Height; RealPosition = pos; _mousePosition = new Core.Graphics.Point((int)((pos.X - rect.Left) * scaleX), (int)((pos.Y - rect.Top) * scaleY)); }
private void UpdateMousePosition(Vector2 pos) { var rect = _game.Services.GetService<IGraphicsManager>().Bounds; if (rect.Width == 0 || rect.Height == 0) return; var scaleX = (float)_width / rect.Width; var scaleY = (float)_height / rect.Height; RealPosition = pos; _mousePosition = new Core.Graphics.Point((int)((pos.X - rect.Left) * scaleX), (int)((pos.Y - rect.Top) * scaleY)); }