Added KVM key state command support

This commit is contained in:
Ylian Saint-Hilaire 2022-02-28 09:52:35 -08:00
parent 97807e8209
commit bdb12ce7cc
2 changed files with 16 additions and 3 deletions

View File

@ -34,7 +34,7 @@ MNG_KVM_SET_DISPLAY = 12,
MNG_KVM_FRAME_RATE_TIMER = 13,
MNG_KVM_INIT_TOUCH = 14,
MNG_KVM_TOUCH = 15,
MNG_KVM_CONNECTCOUNT = 16,
MNG_KVM_KEYSTATE = 16,
MNG_KVM_MESSAGE = 17,
MNG_ECHO = 21,
MNG_JUMBO = 27,
@ -82,6 +82,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, id, func) {
obj.lastData = null; // Index in the images table of the last image in the table.
obj.lastDisplayInfoData = null; // Pointer to the last display information command from the agent (Number of displays).
obj.lastDisplayLocationData = null; // Pointer to the last display location and size command from the agent.
obj.lastKeyState = null; // Pointer to the last key state command from the agent.
obj.desktopPaused = true; // Current desktop pause state, it's true if all viewers are paused.
obj.imageType = 1; // Current image type, 1 = JPEG, 2 = PNG, 3 = TIFF, 4 = WebP
obj.imageCompression = 50; // Current image compression, this is the highest value of all viewers.
@ -178,7 +179,8 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, id, func) {
if (obj.lastDisplayInfoData != null) { obj.sendToViewer(peer, obj.lastDisplayInfoData); }
if (obj.lastDisplayLocationData != null) { obj.sendToViewer(peer, obj.lastDisplayLocationData); }
if (obj.lastConsoleMessage != null) { obj.sendToViewer(peer, obj.lastConsoleMessage); }
if (obj.lastKeyState != null) { obj.sendToViewer(peer, obj.lastKeyState); }
// Log joining the multiplex session
if (obj.startTime != null) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: peer.user ? peer.user._id : null, username: peer.user.name, msgid: 143, msgArgs: [obj.id], msg: "Joined desktop multiplex session \"" + obj.id + "\"", protocol: 2 };
@ -788,7 +790,10 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, id, func) {
break;
case 15: // KVM_TOUCH
break;
case 16: // MNG_KVM_CONNECTCOUNT
case 16: // MNG_KVM_KEYSTATE
// Store and send this to all viewers right away
obj.lastKeyState = data;
obj.sendToAllInputViewers(data);
break;
case 17: // MNG_KVM_MESSAGE
// Send this to all viewers right away

View File

@ -52,6 +52,10 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.onRemoteInputLockChanged = null;
obj.RemoteInputLock = null;
// Remote keyboard state
obj.onKeyboardStateChanged = null;
obj.KeyboardState = 0; // 1 = NumLock, 2 = ScrollLock, 4 = CapsLock
obj.ScreenWidth = 960;
obj.ScreenHeight = 701;
obj.width = 960;
@ -260,6 +264,10 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.TouchArray = {};
break;
case 16: // MNG_KVM_KEYSTATE
if ((cmdsize != 5) || (obj.KeyboardState == view[4])) break;
obj.KeyboardState = view[4]; // 1 = NumLock, 2 = ScrollLock, 4 = CapsLock
if (obj.onKeyboardStateChanged) { obj.onKeyboardStateChanged(obj, obj.KeyboardState); }
console.log('MNG_KVM_KEYSTATE:' + ((obj.KeyboardState & 1) ? ' NumLock' : '') + ((obj.KeyboardState & 2) ? ' ScrollLock' : '') + ((obj.KeyboardState & 4) ? ' CapsLock' : ''));
break;
case 17: // MNG_KVM_MESSAGE
var str = String.fromCharCode.apply(null, view.slice(4));