private void handleIndirectPointer(UITouch touch, UIEventButtonMask buttonMask, Vector2 location) { PendingInputs.Enqueue(new MousePositionAbsoluteInput { Position = location }); // Indirect pointer means the touch came from a mouse cursor, and wasn't a physical touch on the screen switch (touch.Phase) { case UITouchPhase.Began: case UITouchPhase.Moved: // only one button can be in a "down" state at once. all previous buttons are automatically released. // we need to handle this assumption at our end. if (lastButtonMask != null && lastButtonMask != buttonMask) { PendingInputs.Enqueue(new MouseButtonInput(buttonFromMask(lastButtonMask.Value), false)); } PendingInputs.Enqueue(new MouseButtonInput(buttonFromMask(buttonMask), true)); lastButtonMask = buttonMask; break; case UITouchPhase.Cancelled: case UITouchPhase.Ended: Debug.Assert(lastButtonMask != null); PendingInputs.Enqueue(new MouseButtonInput(buttonFromMask(lastButtonMask.Value), false)); lastButtonMask = null; break; } }
private MouseButton buttonFromMask(UIEventButtonMask buttonMask) { Debug.Assert(indirectPointerSupported); switch (buttonMask) { default: return(MouseButton.Left); case UIEventButtonMask.Secondary: return(MouseButton.Right); } }