aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.RemoteDesktop/Input
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-04 21:32:42 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-04 21:32:42 +0200
commitf17d39f37cac50861467e07a7bee40534d20100a (patch)
tree1d6ba97191b866eee6ffc6ef904fe3803a84decd /Software/Visual_Studio/Tango.RemoteDesktop/Input
parent565e48de649d3d14e6b82012b6aa2e3819a3c82c (diff)
downloadTango-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')
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs79
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs80
2 files changed, 159 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs
new file mode 100644
index 000000000..832018dac
--- /dev/null
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using WindowsInput;
+using WindowsInput.Native;
+
+namespace Tango.RemoteDesktop.Input
+{
+ public static class KeyboardController
+ {
+ private static InputSimulator simulator;
+
+ static KeyboardController()
+ {
+ simulator = new InputSimulator();
+ }
+
+ public static void KeyDown(Key key, bool ctrlDown, bool shitDown, bool altDown)
+ {
+ VirtualKeyCode virtualKey = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(key);
+
+ if (ctrlDown || shitDown || altDown)
+ {
+ List<VirtualKeyCode> modifierKeys = new List<VirtualKeyCode>();
+
+ if (ctrlDown)
+ {
+ modifierKeys.Add(VirtualKeyCode.LCONTROL);
+ }
+ if (shitDown)
+ {
+ modifierKeys.Add(VirtualKeyCode.LSHIFT);
+ }
+ if (altDown)
+ {
+ modifierKeys.Add(VirtualKeyCode.MENU);
+ }
+
+ simulator.Keyboard.ModifiedKeyStroke(modifierKeys, virtualKey);
+ }
+ else
+ {
+ simulator.Keyboard.KeyDown(virtualKey);
+ }
+ }
+
+ public static void KeyUp(Key key, bool ctrlDown, bool shitDown, bool altDown)
+ {
+ VirtualKeyCode virtualKey = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(key);
+
+ if (ctrlDown || shitDown || altDown)
+ {
+ List<VirtualKeyCode> modifierKeys = new List<VirtualKeyCode>();
+
+ if (ctrlDown)
+ {
+ modifierKeys.Add(VirtualKeyCode.LCONTROL);
+ }
+ if (shitDown)
+ {
+ modifierKeys.Add(VirtualKeyCode.LSHIFT);
+ }
+ if (altDown)
+ {
+ modifierKeys.Add(VirtualKeyCode.MENU);
+ }
+
+ simulator.Keyboard.ModifiedKeyStroke(modifierKeys, virtualKey);
+ }
+ else
+ {
+ simulator.Keyboard.KeyUp(virtualKey);
+ }
+ }
+ }
+}
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;
+ }
+ }
+ }
+}