From 680a82a43160b911483ec6461161686b759f63e8 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 19 Nov 2020 12:15:09 -0800 Subject: [PATCH] Added support for unicode keys in desktop multiplexor. --- meshdesktopmultiplex.js | 19 +++++++++++-------- views/default.handlebars | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/meshdesktopmultiplex.js b/meshdesktopmultiplex.js index f7a195ad..1ec52962 100644 --- a/meshdesktopmultiplex.js +++ b/meshdesktopmultiplex.js @@ -452,15 +452,15 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) { var cmdsize = data.readUInt16BE(2); //console.log('ViewerData', data.length, command, cmdsize); switch (command) { - case 1:// Key Events, forward to agent + case 1: // Key Events, forward to agent //console.log('Viewer-Keys'); obj.sendToAgent(data); break; - case 2:// Mouse events, forward to agent + case 2: // Mouse events, forward to agent //console.log('Viewer-Mouse'); obj.sendToAgent(data); break; - case 5:// Compression + case 5: // Compression if (data.length < 10) return; //viewer.imageType = data[4]; // Always 1=JPEG viewer.imageCompression = data[5]; @@ -493,12 +493,12 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) { obj.sendToAgent(cmd); } break; - case 6:// Refresh, handle this on the server + case 6: // Refresh, handle this on the server //console.log('Viewer-Refresh'); viewer.dataPtr = obj.firstData; // Start over if (viewer.sending == false) { sendViewerNext(viewer); } break; - case 8:// Pause and unpause + case 8: // Pause and unpause if (data.length != 5) break; var pause = data[4]; // 0 = Unpause, 1 = Pause if (viewer.desktopPaused == (pause == 1)) break; @@ -513,13 +513,16 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) { obj.sendToAgent(data); } break; - case 10:// CTRL-ALT-DEL, forward to agent + case 10: // CTRL-ALT-DEL, forward to agent obj.sendToAgent(data); break; - case 12:// SET DISPLAY, forward to agent + case 12: // SET DISPLAY, forward to agent obj.sendToAgent(data); break; - case 14:// Touch setup + case 14: // Touch setup + break; + case 85: // Unicode Key Events, forward to agent + obj.sendToAgent(data); break; default: console.log('Un-handled viewer command: ' + command); diff --git a/views/default.handlebars b/views/default.handlebars index 0ab40ff7..1a1f07db 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1519,7 +1519,7 @@ } // Enable browser clipboard read if supported - QV('DeskClipboardInButton', navigator.clipboard.readText != null); + QV('DeskClipboardInButton', (navigator.clipboard != null) && (navigator.clipboard.readText != null)); // Session Refresh Timer if (sessionTime >= 10) { sessionRefreshTimer = setTimeout(refreshCookieSession, Math.round((sessionTime * 60000) * 0.8)); } @@ -2197,7 +2197,7 @@ if ((message.tag == 1) && (xxdialogTag == 'clipboard')) { Q('d2clipText').value = message.data; // Put remote clipboard data into dialog box } else if (message.tag == 2) { - navigator.clipboard.writeText(message.data).then(function() { console.log('ok'); }).catch(function(err) { console.log(err); }) // Put remote clipboard data into our clipboard + if (navigator.clipboard != null) { navigator.clipboard.writeText(message.data).then(function() { console.log('ok'); }).catch(function(err) { console.log(err); }) } // Put remote clipboard data into our clipboard } } else if ((message.type == 'setclip') && (xxdialogTag == 'clipboard') && (currentNode != null) && (currentNode._id == message.nodeid)) { // Display success/fail on the clipboard dialog box. @@ -6189,7 +6189,7 @@ } function deskClipboardOutFunction() { - if (navigator.clipboard.readText) { navigator.clipboard.readText().then(function(text) { meshserver.send({ action: 'msg', type: 'setclip', nodeid: currentNode._id, data: text }); }).catch(function(err) { }); } + if ((navigator.clipboard != null) && (navigator.clipboard.readText != null)) { navigator.clipboard.readText().then(function(text) { meshserver.send({ action: 'msg', type: 'setclip', nodeid: currentNode._id, data: text }); }).catch(function(err) { }); } } function deskRefreshFunction() {