diff --git a/MapTP.App/MainWindow.xaml b/MapTP.App/MainWindow.xaml index 67b016f..391a21b 100644 --- a/MapTP.App/MainWindow.xaml +++ b/MapTP.App/MainWindow.xaml @@ -102,7 +102,10 @@ - + + + Turtle mode + diff --git a/MapTP.App/MainWindow.xaml.cs b/MapTP.App/MainWindow.xaml.cs index 7431aff..a26ad8a 100644 --- a/MapTP.App/MainWindow.xaml.cs +++ b/MapTP.App/MainWindow.xaml.cs @@ -440,7 +440,9 @@ private void OnWindowCloses(object sender, System.ComponentModel.CancelEventArgs return; } - + public bool Turtle; + private int nowTipSwitch=0; + /// /// This method is for processing touchpad inputs /// @@ -461,7 +463,6 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b { InputX = x.X; InputY = x.Y; - if (started) { try @@ -478,13 +479,16 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b : (int)Math.Floor((decimal)scey / ScreenSizeY * 65535) ) : (int)Math.Floor((decimal)scsy / ScreenSizeY * 65535) ); mouseProcessor.MoveCursor(X, Y); - + if (nowTipSwitch == 1 && x.TipSwitch == 0 && Turtle) mouseProcessor.MouseUp(); + if (nowTipSwitch == 0 && x.TipSwitch == 1 && Turtle) mouseProcessor.MouseDown(); } catch (Exception e) { HandyControl.Controls.MessageBox.Show(e.ToString()); } } + nowTipSwitch = x.TipSwitch; + } } diff --git a/MapTP.App/MapAreaWindow.xaml b/MapTP.App/MapAreaWindow.xaml index 1445823..d41535c 100644 --- a/MapTP.App/MapAreaWindow.xaml +++ b/MapTP.App/MapAreaWindow.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:MapTP.App" mc:Ignorable="d" Title="MapAreaWindow" Height="450" Width="800" WindowStyle="None" - AllowsTransparency="True" + AllowsTransparency="True" Topmost="True" Background="#00ffffff"> diff --git a/MapTP.App/MapAreaWindow.xaml.cs b/MapTP.App/MapAreaWindow.xaml.cs index cf9a06e..6b040e6 100644 --- a/MapTP.App/MapAreaWindow.xaml.cs +++ b/MapTP.App/MapAreaWindow.xaml.cs @@ -22,17 +22,7 @@ namespace MapTP.App /// public partial class MapAreaWindow : Window { - #region Win32 - private const int WS_EX_TRANSPARENT = 0x20; - - private const int GWL_EXSTYLE = -20; - - [DllImport("user32", EntryPoint = "SetWindowLong")] - private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong); - - [DllImport("user32", EntryPoint = "GetWindowLong")] - private static extern uint GetWindowLong(IntPtr hwnd, int nIndex); - #endregion + public delegate void SendArea(int scsx, int scsy, int scex, int scey); public SendArea sendArea; diff --git a/MapTP.App/MouseProcessor.cs b/MapTP.App/MouseProcessor.cs index 857dbec..1b12352 100644 --- a/MapTP.App/MouseProcessor.cs +++ b/MapTP.App/MouseProcessor.cs @@ -89,6 +89,51 @@ public void MoveCursor(int x, int y) return; } + + public void MouseDown() + { + INPUT[] _input = new INPUT[1]; + _input[0] = new INPUT + { + type = 0, // INPUT_MOUSE + mkhi = new MOUSEKEYBDHARDWAREINPUT + { + mi = new MOUSEINPUT + { + dx = 0, + dy = 0, + mouseData = 0, + dwFlags = 0x0002, // MOUSEEVENTF_LEFTDOWN + time = 0 // Windows will provide this + } + } + }; + SendInput((uint)1, _input, Marshal.SizeOf(typeof(INPUT))); + return; + } + + public void MouseUp() + { + INPUT[] _input = new INPUT[1]; + _input[0] = new INPUT + { + type = 0, // INPUT_MOUSE + mkhi = new MOUSEKEYBDHARDWAREINPUT + { + mi = new MOUSEINPUT + { + dx = 0, + dy = 0, + mouseData = 0, + dwFlags = 0x0004, // MOUSEEVENTF_LEFTUP + time = 0 // Windows will provide this + } + } + }; + SendInput((uint)1, _input, Marshal.SizeOf(typeof(INPUT))); + return; + } + public MouseProcessor() { } diff --git a/MapTP.App/Touchpad/Contact.cs b/MapTP.App/Touchpad/Contact.cs index ac492ac..19c442a 100644 --- a/MapTP.App/Touchpad/Contact.cs +++ b/MapTP.App/Touchpad/Contact.cs @@ -12,21 +12,22 @@ public struct TouchpadContact : IEquatable public int ContactId { get; } public int X { get; } public int Y { get; } + public int TipSwitch {get;} - public TouchpadContact(int contactId, int x, int y) => - (this.ContactId, this.X, this.Y) = (contactId, x, y); + public TouchpadContact(int contactId, int x, int y, int tipSwitch) => + (this.ContactId, this.X, this.Y, this.TipSwitch) = (contactId, x, y, tipSwitch); public override bool Equals(object obj) => (obj is TouchpadContact other) && Equals(other); public bool Equals(TouchpadContact other) => - (this.ContactId == other.ContactId) && (this.X == other.X) && (this.Y == other.Y); + (this.ContactId == other.ContactId) && (this.X == other.X) && (this.Y == other.Y) && (this.TipSwitch==other.TipSwitch); public static bool operator ==(TouchpadContact a, TouchpadContact b) => a.Equals(b); public static bool operator !=(TouchpadContact a, TouchpadContact b) => !(a == b); - public override int GetHashCode() => (this.ContactId, this.X, this.Y).GetHashCode(); + public override int GetHashCode() => (this.ContactId, this.X, this.Y, this.TipSwitch).GetHashCode(); - public override string ToString() => $"Contact ID:{ContactId} Point:{X},{Y}"; + public override string ToString() => $"Contact ID:{ContactId} Point:{X},{Y} Tip Switch:{TipSwitch}"; } internal class TouchpadContactCreator @@ -34,12 +35,13 @@ internal class TouchpadContactCreator public int? ContactId { get; set; } public int? X { get; set; } public int? Y { get; set; } + public int? TipSwitch { get; set; } public bool TryCreate(out TouchpadContact contact) { - if (ContactId.HasValue && X.HasValue && Y.HasValue) + if (ContactId.HasValue && X.HasValue && Y.HasValue && TipSwitch.HasValue) { - contact = new TouchpadContact(ContactId.Value, X.Value, Y.Value); + contact = new TouchpadContact(ContactId.Value, X.Value, Y.Value, TipSwitch.Value); return true; } contact = default; diff --git a/MapTP.App/Touchpad/Handler.cs b/MapTP.App/Touchpad/Handler.cs index bac4e06..afc1b9e 100644 --- a/MapTP.App/Touchpad/Handler.cs +++ b/MapTP.App/Touchpad/Handler.cs @@ -206,17 +206,6 @@ public static TouchpadContact[] ParseInput(IntPtr lParam) switch (valueCap.LinkCollection) { case 0: - /* - switch (valueCap.UsagePage, valueCap.Usage) - { - case (0x0D, 0x56): // Scan Time - scanTime = value; - break; - - case (0x0D, 0x54): // Contact Count - contactCount = value; - break; - }*/ if (valueCap.UsagePage == 0x0D) { switch (valueCap.Usage) @@ -235,21 +224,6 @@ public static TouchpadContact[] ParseInput(IntPtr lParam) break; default: - /* - switch (valueCap.UsagePage, valueCap.Usage) - { - case (0x0D, 0x51): // Contact ID - creator.ContactId = (int)value; - break; - - case (0x01, 0x30): // X - creator.X = (int)value; - break; - - case (0x01, 0x31): // Y - creator.Y = (int)value; - break; - }*/ if (valueCap.UsagePage == 0x0D) { if (valueCap.Usage == 0x51) @@ -268,7 +242,10 @@ public static TouchpadContact[] ParseInput(IntPtr lParam) creator.Y = (int)value; break; } - } + }else if(valueCap.UsagePage == 0x09 && valueCap.Usage == 0x42) + { + creator.TipSwitch = (int)value; + } break; }