mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-14 23:33:35 +00:00
Changes to desktop keyboard input
This commit is contained in:
3
KVMControl.Designer.cs
generated
3
KVMControl.Designer.cs
generated
@@ -38,6 +38,9 @@
|
|||||||
this.Name = "KVMControl";
|
this.Name = "KVMControl";
|
||||||
this.Size = new System.Drawing.Size(585, 364);
|
this.Size = new System.Drawing.Size(585, 364);
|
||||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.KVMControl_Paint);
|
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.MouseDown += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseDown);
|
||||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseMove);
|
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseMove);
|
||||||
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseUp);
|
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.KVMControl_MouseUp);
|
||||||
|
|||||||
@@ -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 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); } }
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,45 +51,46 @@ namespace MeshCentralRouter
|
|||||||
{
|
{
|
||||||
if (nCode >= 0)
|
if (nCode >= 0)
|
||||||
{
|
{
|
||||||
bool alt = (Control.ModifierKeys & Keys.Alt) != 0;
|
|
||||||
bool control = (Control.ModifierKeys & Keys.Control) != 0;
|
|
||||||
|
|
||||||
Keys key = (Keys)Marshal.ReadInt32(lParam);
|
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;
|
||||||
|
|
||||||
const int WM_KEYDOWN = 0x100;
|
const int WM_KEYDOWN = 0x100;
|
||||||
const int WM_KEYUP = 0x101;
|
const int WM_KEYUP = 0x101;
|
||||||
const int WM_SYSKEYDOWN = 0x104;
|
const int WM_SYSKEYDOWN = 0x104;
|
||||||
const int WM_SYSKEYUP = 0x105;
|
const int WM_SYSKEYUP = 0x105;
|
||||||
|
|
||||||
byte bkey = (byte)key;
|
byte bkey = (byte)key;
|
||||||
byte keyStatus;
|
byte keyStatus = 255;
|
||||||
switch ((int)wParam)
|
switch ((int)wParam)
|
||||||
{
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
keyStatus = 0;
|
|
||||||
break;
|
|
||||||
case WM_KEYUP:
|
|
||||||
keyStatus = 1;
|
|
||||||
break;
|
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
keyStatus = 4;
|
|
||||||
break;
|
|
||||||
case WM_SYSKEYUP:
|
|
||||||
keyStatus = 5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return KVMKeyboardHook.CallNextHookEx(_hook, nCode, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_callback != null)
|
|
||||||
{
|
{
|
||||||
_callback(bkey,keyStatus);
|
case WM_KEYDOWN:
|
||||||
return (IntPtr)1;
|
keyStatus = 0;
|
||||||
|
break;
|
||||||
|
case WM_KEYUP:
|
||||||
|
keyStatus = 1;
|
||||||
|
break;
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
//keyStatus = 0; // 4
|
||||||
|
break;
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
//keyStatus = 1; // 5
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return KVMKeyboardHook.CallNextHookEx(_hook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((_callback != null) && (keyStatus != 255))
|
||||||
|
{
|
||||||
|
_callback(bkey, keyStatus);
|
||||||
|
return (IntPtr)1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
return KVMKeyboardHook.CallNextHookEx(_hook, nCode, wParam, lParam);
|
return KVMKeyboardHook.CallNextHookEx(_hook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -743,7 +743,7 @@ namespace MeshCentralRouter
|
|||||||
readBufferLen = 0;
|
readBufferLen = 0;
|
||||||
Debug("Websocket TCP connected, doing TLS...");
|
Debug("Websocket TCP connected, doing TLS...");
|
||||||
wsstream = new SslStream(wsrawstream, false, VerifyServerCertificate, null);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user