From 29e175c12ed93f65c11a94bb9f5ec171e017f72c Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 22 Dec 2021 16:56:40 -0800 Subject: [PATCH] Added KVM 4bit color mode. --- amt-desktop-0.0.2.js | 11 +++++++-- index.html | 53 ++++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/amt-desktop-0.0.2.js b/amt-desktop-0.0.2.js index b31ad7e..51a43b9 100644 --- a/amt-desktop-0.0.2.js +++ b/amt-desktop-0.0.2.js @@ -49,6 +49,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { obj.useZLib = false; obj.decimation = false; obj.graymode = false; + obj.lowcolor = true; // ###END###{DesktopInband} obj.mNagleTimer = null; // Mouse motion slowdown timer @@ -178,8 +179,11 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { } else { // Gray scale modes if (obj.bpp == 2) { obj.bpp = 1; } - if (obj.bpp == 1) obj.send(String.fromCharCode(0, 0, 0, 0, 8, 8, 0, 1) + ShortToStr(255) + ShortToStr(0) + ShortToStr(0) + String.fromCharCode(0, 0, 0, 0, 0, 0)); // Setup 8 bit black and white RGB800 - //if (obj.bpp == 1) obj.send(String.fromCharCode(0, 0, 0, 0, 8, 8, 0, 1) + ShortToStr(15) + ShortToStr(0) + ShortToStr(0) + String.fromCharCode(0, 0, 0, 0, 0, 0)); // Setup 4 bit black and white RGB400 + if (obj.lowcolor == false) { + obj.send(String.fromCharCode(0, 0, 0, 0, 8, 8, 0, 1) + ShortToStr(255) + ShortToStr(0) + ShortToStr(0) + String.fromCharCode(0, 0, 0, 0, 0, 0)); // Setup 8 bit black and white RGB800 + } else { + obj.send(String.fromCharCode(0, 0, 0, 0, 8, 4, 0, 1) + ShortToStr(15) + ShortToStr(0) + ShortToStr(0) + String.fromCharCode(0, 0, 0, 0, 0, 0)); // Setup 4 bit black and white RGB400 + } } obj.state = 4; @@ -327,6 +331,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { // Solid color tile if (obj.graymode) { v = data[ptr++]; + if (obj.lowcolor) { v = v << 4; } obj.canvas.fillStyle = 'rgb(' + v + ',' + v + ',' + v + ')'; } else { v = data[ptr++] + ((obj.bpp == 2) ? (data[ptr++] << 8) : 0); @@ -470,6 +475,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { // ###END###{DesktopRotation} if (obj.graymode) { + if (obj.lowcolor) { v = v << 4; } obj.spare.data[pp] = obj.spare.data[pp + 1] = obj.spare.data[pp + 2] = v; } else { obj.spare.data[pp] = v & 224; @@ -499,6 +505,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { function _setPixel8run(v, p, run) { if (obj.graymode) { var pp = (p << 2); + if (obj.lowcolor) { v = v << 4; } while (--run >= 0) { obj.spare.data[pp] = obj.spare.data[pp + 1] = obj.spare.data[pp + 2] = v; pp += 4; } } else { var pp = (p << 2), r = (v & 224), g = ((v & 28) << 3), b = (_fixColor((v & 3) << 6)); diff --git a/index.html b/index.html index 98187a3..8fd3eb3 100644 --- a/index.html +++ b/index.html @@ -1364,17 +1364,7 @@

- +
Image Encoding
@@ -8354,14 +8344,16 @@ if ((skipConsent !== true) && (amtversion > 5) && (amtsysstate != null) && (amtsysstate['IPS_OptInService'] != null) && (amtsysstate['IPS_OptInService'].response != undefined) && (amtsysstate['IPS_OptInService'].response['OptInRequired'] == 0xFFFFFFFF)) { connectDesktopConsent = true; amtstack.Get('IPS_OptInService', powerActionResponse0, 0, 1); return; // User consent always required, ask for it before KVM. } - // Encoding Flags: 1 = RLE, 2 = 16bit, 4 = Gray, 8 = ZLib, 16 = Decimation + // Encoding Flags: 1 = RLE, 2 = 16bit, 4 = Gray, 8 = ZLib, 16 = 4bit Color desktop.m.useRLE = ((desktopsettings.encflags & 1) != 0); desktop.m.bpp = (desktopsettings.encflags & 2) ? 2 : 1; if ((amtversion > 15) && (amtsysstate != null) && (amtsysstate['IPS_KVMRedirectionSettingData'] != null) && (amtsysstate['IPS_KVMRedirectionSettingData'].response)) { + desktop.m.lowcolor = amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported'] && ((desktopsettings.encflags & 16) != 0); desktop.m.graymode = amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported'] && ((desktopsettings.encflags & 4) != 0); desktop.m.useZLib = amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported'] && ((desktopsettings.encflags & 8) != 0); desktop.m.decimation = amtsysstate['IPS_KVMRedirectionSettingData'].response['InitialDecimationModeForLowRes'] && desktopsettings.decimation; } else { + desktop.m.lowcolor = false; desktop.m.graymode = false; desktop.m.useZLib = false; desktop.m.decimation = false; @@ -8647,23 +8639,36 @@ if (desktopsettings.scaling) { d7bitmapscaling.value = desktopsettings.scaling; } QV('d7softkvmsettings', amtversion >= 12); // ###END###{DesktopInband} - var encflags = desktopsettings.encflags; // Flags: 1 = RLE, 2 = 16bit, 4 = Gray, 8 = ZLib + var encflags = desktopsettings.encflags; // Flags: 1 = RLE, 2 = 16bit, 4 = Gray, 8 = ZLib, 16 = 4bit Color + + var x = ''; if ((amtversion > 15) && (amtsysstate != null) && (amtsysstate['IPS_KVMRedirectionSettingData'] != null) && (amtsysstate['IPS_KVMRedirectionSettingData'].response)) { - if (!amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported']) { encflags = encflags & 11; } // Remove grayscale - if (!amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported']) { encflags = encflags & 7; } // Remove zlib - QV('d7exm1', amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported']); - QV('d7exm2', amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported'] && amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported']); - QV('d7exm3', amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported']); - QV('d7exm4', amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported']); + if (!amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported']) { encflags = encflags & 11; } // Remove grayscale and lowcolor + if (!amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported']) { encflags = encflags & 23; } // Remove zlib + if (amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported']) { + x += ''; + x += ''; + } + x += ''; + x += ''; + if (amtsysstate['IPS_KVMRedirectionSettingData'].response['ZlibControlSupported']) { + if (amtsysstate['IPS_KVMRedirectionSettingData'].response['GrayscalePixelFormatSupported']) { + x += ''; + x += ''; + } + x += ''; + x += ''; + } QV('d7decimationspan', amtsysstate['IPS_KVMRedirectionSettingData'].response['InitialDecimationModeForLowRes'] > 0); } else { encflags = encflags & 3; // Remove gray & zlib flags (4 and 8), keep 1 & 2 - QV('d7exm1', false); - QV('d7exm2', false); - QV('d7exm3', false); - QV('d7exm4', false); - QV('d7decimationspan', false) + x += ''; + x += ''; + QV('d7decimationspan', false); } + x += ''; + x += ''; + QH('idx_d7desktopmode', x); idx_d7desktopmode.value = encflags; // ###BEGIN###{DesktopFocus} QV('idx_deskFocusBtn', desktopsettings.showfocus);