From 04e38b079bd4e14c0db8dc10d97a743906315965 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 23 Nov 2024 21:03:46 +0100 Subject: [PATCH] Added the mouse support --- InputPad.cs | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/InputPad.cs b/InputPad.cs index f05f5ad..f86aa0e 100644 --- a/InputPad.cs +++ b/InputPad.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; using System.Linq; +using Microsoft.Xna.Framework.Input; + //using Microsoft.Devices.Sensors; using Microsoft.Xna.Framework.Input.Touch; using WindowsPhoneSpeedyBlupi; @@ -39,7 +41,7 @@ namespace WindowsPhoneSpeedyBlupi private Def.ButtonGlygh buttonPressed; - private int totalTouch; + private int touchCount; private bool accelStarted; @@ -63,7 +65,7 @@ namespace WindowsPhoneSpeedyBlupi { get { - return totalTouch; + return touchCount; } } @@ -254,16 +256,37 @@ namespace WindowsPhoneSpeedyBlupi int num3 = 0; padPressed = false; Def.ButtonGlygh buttonGlygh = Def.ButtonGlygh.None; - TouchCollection state = TouchPanel.GetState(); - totalTouch = state.Count; - foreach (TouchLocation item in state) + TouchCollection touches = TouchPanel.GetState(); + touchCount = touches.Count; + List touchesOrClicks = new List(); + foreach (TouchLocation item in touches) { - if (item.State == TouchLocationState.Pressed || item.State == TouchLocationState.Moved) + if (item.State == TouchLocationState.Pressed || item.State == TouchLocationState.Moved) { + TinyPoint tinyPoint = default(TinyPoint); + tinyPoint.X = (int)item.Position.X; + tinyPoint.Y = (int)item.Position.Y; + touchesOrClicks.Add(tinyPoint); + } + } + + + MouseState mouseState = Mouse.GetState(); + if (mouseState.LeftButton == ButtonState.Pressed) + { + touchCount++; + TinyPoint click = new TinyPoint(); + click.X = mouseState.X; + click.Y = mouseState.Y; + touchesOrClicks.Add(click); + } + + + + foreach (TinyPoint touchOrClick in touchesOrClicks) + { + { - TinyPoint tinyPoint = default(TinyPoint); - tinyPoint.X = (int)item.Position.X; - tinyPoint.Y = (int)item.Position.Y; - TinyPoint tinyPoint2 = tinyPoint; + TinyPoint tinyPoint2 = touchOrClick; if (!accelStarted && Misc.IsInside(GetPadBounds(PadCenter, padSize), tinyPoint2)) { padPressed = true;