diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-04 21:32:42 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-04 21:32:42 +0200 |
| commit | f17d39f37cac50861467e07a7bee40534d20100a (patch) | |
| tree | 1d6ba97191b866eee6ffc6ef904fe3803a84decd /Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs | |
| parent | 565e48de649d3d14e6b82012b6aa2e3819a3c82c (diff) | |
| download | Tango-f17d39f37cac50861467e07a7bee40534d20100a.tar.gz Tango-f17d39f37cac50861467e07a7bee40534d20100a.zip | |
Improved "Notify Continuous Requests About Disconnection".
Integrated FSE/PPC Remote Desktop.
Implemented RemoteDesktopService / RemoteDesktopProvider.
Implemented Mouse/Keyboard gestures.
Diffstat (limited to 'Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs new file mode 100644 index 000000000..ec556f88c --- /dev/null +++ b/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.RemoteDesktop.Input +{ + public static class MouseController + { + [Flags] + public enum MouseEventFlags + { + LeftDown = 0x00000002, + LeftUp = 0x00000004, + MiddleDown = 0x00000020, + MiddleUp = 0x00000040, + Move = 0x00000001, + Absolute = 0x00008000, + RightDown = 0x00000008, + RightUp = 0x00000010 + } + + [DllImport("user32.dll", EntryPoint = "SetCursorPos")] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool SetCursorPos(int x, int y); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool GetCursorPos(out MousePoint lpMousePoint); + + [DllImport("user32.dll")] + private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); + + public static void SetCursorPosition(int x, int y) + { + SetCursorPos(x, y); + } + + public static void SetCursorPosition(MousePoint point) + { + SetCursorPos(point.X, point.Y); + } + + public static MousePoint GetCursorPosition() + { + MousePoint currentMousePoint; + var gotPoint = GetCursorPos(out currentMousePoint); + if (!gotPoint) { currentMousePoint = new MousePoint(0, 0); } + return currentMousePoint; + } + + public static void MouseEvent(MouseEventFlags value) + { + MousePoint position = GetCursorPosition(); + + mouse_event + ((int)value, + position.X, + position.Y, + 0, + 0) + ; + } + + [StructLayout(LayoutKind.Sequential)] + public struct MousePoint + { + public int X; + public int Y; + + public MousePoint(int x, int y) + { + X = x; + Y = y; + } + } + } +} |
