1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-15 07:43:38 +00:00

Changes to desktop keyboard input

This commit is contained in:
Ylian Saint-Hilaire
2020-09-22 11:39:34 -07:00
parent 6a79908605
commit dc03e06324
4 changed files with 77 additions and 34 deletions

View File

@@ -38,6 +38,9 @@
this.Name = "KVMControl";
this.Size = new System.Drawing.Size(585, 364);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.KVMControl_Paint);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KVMControl_KeyDown);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.KVMControl_KeyPress);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.KVMControl_KeyUp);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseUp);

View File

@@ -629,5 +629,44 @@ namespace MeshCentralRouter
public static byte[] GetByteArray() { lock (ByteArrayRecycleList) { if (ByteArrayRecycleList.Count == 0) ByteArrayRecycleListCount++; return (ByteArrayRecycleList.Count == 0) ? new byte[65535] : ByteArrayRecycleList.Pop(); } }
public static void RecycleByteArray(byte[] obj) { lock (ByteArrayRecycleList) { if (obj != null) ByteArrayRecycleList.Push(obj); } }
private void KVMControl_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.LWin) || (e.KeyCode == Keys.RWin)) return; // Don't process the Windows key
SendKey(e, 0);
e.Handled = true;
}
private void KVMControl_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
private void KVMControl_KeyUp(object sender, KeyEventArgs e)
{
SendKey(e, 1);
e.Handled = true;
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
// Tab keys
if (msg.Msg == WM_KEYDOWN && msg.WParam.ToInt32() == 9)
{
SendKey((byte)msg.WParam.ToInt32(), 0);
return true;
}
// Handle arrow keys
if (((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN)) && msg.WParam.ToInt32() >= 37 && msg.WParam.ToInt32() <= 40)
{
SendKey((byte)msg.WParam.ToInt32(), 0);
return true;
}
return false;
}
}
}

View File

@@ -51,18 +51,18 @@ namespace MeshCentralRouter
{
if (nCode >= 0)
{
Keys key = (Keys)Marshal.ReadInt32(lParam);
if ((key == Keys.LWin) || (key == Keys.RWin)) {
bool alt = (Control.ModifierKeys & Keys.Alt) != 0;
bool control = (Control.ModifierKeys & Keys.Control) != 0;
Keys key = (Keys)Marshal.ReadInt32(lParam);
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
const int WM_SYSKEYDOWN = 0x104;
const int WM_SYSKEYUP = 0x105;
byte bkey = (byte)key;
byte keyStatus;
byte keyStatus = 255;
switch ((int)wParam)
{
case WM_KEYDOWN:
@@ -72,10 +72,10 @@ namespace MeshCentralRouter
keyStatus = 1;
break;
case WM_SYSKEYDOWN:
keyStatus = 4;
//keyStatus = 0; // 4
break;
case WM_SYSKEYUP:
keyStatus = 5;
//keyStatus = 1; // 5
break;
default:
return KVMKeyboardHook.CallNextHookEx(_hook, nCode, wParam, lParam);
@@ -83,7 +83,7 @@ namespace MeshCentralRouter
try
{
if (_callback != null)
if ((_callback != null) && (keyStatus != 255))
{
_callback(bkey, keyStatus);
return (IntPtr)1;
@@ -91,6 +91,7 @@ namespace MeshCentralRouter
}
catch { }
}
}
return KVMKeyboardHook.CallNextHookEx(_hook, nCode, wParam, lParam);
}
}

View File

@@ -743,7 +743,7 @@ namespace MeshCentralRouter
readBufferLen = 0;
Debug("Websocket TCP connected, doing TLS...");
wsstream = new SslStream(wsrawstream, false, VerifyServerCertificate, null);
wsstream.BeginAuthenticateAsClient(url.Host, null, System.Security.Authentication.SslProtocols.Tls12, false, new AsyncCallback(OnTlsSetupSink), this);
wsstream.BeginAuthenticateAsClient(url.Host, null, System.Security.Authentication.SslProtocols.Default, false, new AsyncCallback(OnTlsSetupSink), this);
}
else
{