From 3d625d424779fc21c1d91d4241e83c24ad8465a3 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 5 Jul 2019 15:25:03 -0700 Subject: [PATCH] Fixed remote desktop problems with input keys. --- package.json | 2 +- public/scripts/agent-desktop-0.0.2.js | 27 +++++++++++++++++++++++++-- views/default-min.handlebars | 2 +- views/default-mobile-min.handlebars | 2 +- views/default.handlebars | 11 ++++++++--- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 94d7d350..99e4d8ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.7-g", + "version": "0.3.7-h", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/scripts/agent-desktop-0.0.2.js b/public/scripts/agent-desktop-0.0.2.js index 2eecfe7d..a0728b5c 100644 --- a/public/scripts/agent-desktop-0.0.2.js +++ b/public/scripts/agent-desktop-0.0.2.js @@ -32,6 +32,9 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) { obj.firstUpKeys = []; obj.stopInput = false; obj.localKeyMap = true; + obj.altPressed = false; + obj.ctrlPressed = false; + obj.shiftPressed = false; obj.sessionid = 0; obj.username; @@ -394,6 +397,8 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) { // Older browser support this. var kc = event.keyCode; if (kc == 0x3B) { kc = 0xBA; } // Fix the ';' key + else if (kc == 173) { kc = 189; } // Fix the '-' key for Firefox + else if (kc == 61) { kc = 187; } // Fix the '=' key for Firefox obj.SendKeyMsgKC(action, kc); } } @@ -531,9 +536,27 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) { if (obj.firstUpKeys.length < 5) { obj.firstUpKeys.push(e.keyCode); if ((obj.firstUpKeys.length == 5)) { var j = obj.firstUpKeys.join(','); if ((j == '16,17,91,91,16') || (j == '16,17,18,91,92')) { obj.stopInput = true; } } - } return obj.xxKeyUp(e); + } + if (e.keyCode == 16) { obj.shiftPressed = false; } + if (e.keyCode == 17) { obj.ctrlPressed = false; } + if (e.keyCode == 18) { obj.altPressed = false; } + return obj.xxKeyUp(e); + } + obj.handleKeyDown = function (e) { + if (obj.stopInput == true || desktop.State != 3) return false; + if (e.keyCode == 16) { obj.shiftPressed = true; } + if (e.keyCode == 17) { obj.ctrlPressed = true; } + if (e.keyCode == 18) { obj.altPressed = true; } + return obj.xxKeyDown(e); + } + + // Release the CTRL, ALT, SHIFT keys if they are pressed. + obj.handleReleaseKeys = function () { + if (obj.shiftPressed) { obj.SendKeyMsgKC(obj.KeyAction.UP, 16); } // Shift + if (obj.ctrlPressed) { obj.SendKeyMsgKC(obj.KeyAction.UP, 17); } // Ctrl + if (obj.altPressed) { obj.SendKeyMsgKC(obj.KeyAction.UP, 18); } // Alt + obj.shiftPressed = obj.ctrlPressed = obj.altPressed = false; } - obj.handleKeyDown = function (e) { if (obj.stopInput == true || desktop.State != 3) return false; return obj.xxKeyDown(e); } // Mouse handlers obj.mousedblclick = function (e) { if (obj.stopInput == true) return false; return obj.xxMouseDblClick(e); } diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 372db370..21f9a8a9 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index 180b2d79..b188f9bc 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/default.handlebars b/views/default.handlebars index 46ffc896..c4a1405e 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -473,7 +473,7 @@
-   +     @@ -944,7 +944,7 @@ var webPageFullScreen = true; var nightMode = (getstore('_nightMode', '0') == '1'); var sessionActivity = Date.now(); - + // Console Message Display Timers var p11DeskConsoleMsgTimer = null; var p12TermConsoleMsgTimer = null; @@ -1006,6 +1006,8 @@ document.onkeypress = ondockeypress; document.onkeydown = ondockeydown; document.onkeyup = ondockeyup; + //window.addEventListener("focus", ondocfocus, false); + window.addEventListener("blur", ondocblur, false); window.onresize = function () { masterUpdate(512); } setTimeout("masterUpdate(512)", 200); @@ -2164,6 +2166,9 @@ if (Q('viewselect').value == 3) { if ((e.keyCode === 8 && mapSearchFocus == 0) || e.keyCode === 27) { return haltEvent(e); } } } + //function ondocfocus() { } + function ondocblur() { if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) { return desktop.m.handleReleaseKeys(); } } + // Highlights the device being hovered function devMouseHover(element, over) { setSessionActivity(); @@ -4995,7 +5000,7 @@ function deskGetDisplayNumbers(e) { desktop.m.GetDisplayNumbers(); } var deskPreferedStickyDisplay = 0; - function deskSetDisplay(e) { desktop.m.SetDisplay(deskPreferedStickyDisplay = parseInt(Q('termdisplays').value)); } + function deskSetDisplay(e) { desktop.m.SetDisplay(deskPreferedStickyDisplay = parseInt(Q('termdisplays').value)); Q('termdisplays').blur(); } // Double click detection. This is important for MacOS. var dblClickDetectArgs = { t:0, x:0, y:0 };