aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs
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/KeyboardController.cs
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/KeyboardController.cs')
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs79
1 files changed, 79 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);
+ }
+ }
+ }
+}