Re: [X2Go-Dev] Patch for x2gohtmlclient

2024-08-20 Thread Mike Gabriel

Hi Dj ZU,

On  Di 20 Aug 2024 18:30:16 CEST, Dj ZU wrote:


Hi team,

Thank you for the development of X2go, I'm using Kdrive on the Windows
client on a daily basis and very happy with it!
I am also using the HTML client but faced limitations with the keyboard
that I could fix.
I made the changes directly on the compiled JS but it all happens in
[x2gohtmlclient.git] / src / x2gokdrivehtmlclient.js

CapsLock and AltGr modifier keys were not effective. Fix:
@@ -1419,10 +1691,17 @@ X2GoKDriveHTMLClient
 {
 v32[1] |= Mod4Mask;
 }
+ if (e.getModifierState("AltGraph")) {
+ v32[1] |= Mod5Mask;
+ }
+ if (e.getModifierState("CapsLock")) {
+ v32[1] |= LockMask;
+}

   v32[2] = this.web2pc105(e.keyCode);

//console.log(v32[1], v32[2]);

 e.preventDefault();
 e.stopPropagation();


Minor issue with parsing:
@@ -1249,7 +1249,7 @@ X2GoKDriveHTMLClient
 case 111 :
 return  106; ///
 case 106 :
-return  63; //*
+return  63; // * (putting a space before * here, so that
nano/gedit do not get confused with syntax highlighting)
 case 109 :
 return  82; //-


FYI, since I'm using a French keyboard, I also created a new keymap, but
this should probably be written differently and add a UI setting in the
HTML to choose the keyboard mapping.
-v32[2] = this.web2pc105(e.keyCode);
+v32[2] = this.web2pc105fr(e.keyCode);

@@ -1312,6 +1312,273 @@ X2GoKDriveHTMLClient
 return nativeCode;
 }

+web2pc105fr(nativeCode)
+{
+switch (nativeCode)
+{
+//1st row
+case 222:
+return 49; // ²
+case   49:
+return 10; //1
+case 50:
+return 11; //2
+case 51:
+return 12; //3
+case 52:
+return 13; //4
+case 53:
+return 14; //5
+case 54:
+return 15; //6
+case 55:
+return 16; //7
+case 56:
+return 17; //8
+case 57:
+return 18; //9
+case 48:
+return 19; //0
+case 169:
+return 20; //°
+case 61:
+return 21; //+
+case 8:
+return 22; //BSP
+
+//2 row
+case 9 :
+return 23; //TAB
+case 65:
+return 24; //a
+case 90:
+return 25; //z
+case 69 :
+return 26; //e
+case 82 :
+return 27; //r
+case 84 :
+return 28; //t
+case 89:
+return 29; //y
+case 85:
+return 30; //u
+case 73:
+return 31; //i
+case 79:
+return 32; //o
+case 80:
+return 33; //p
+case 160:
+return 34; //[
+case 164:
+return 35; //]
+case  13:
+return 36; //ENT
+
+//3 row
+case 20 :
+return  66; //CAPS
+case 81 :
+return  38; //q
+case 83 :
+return  39; //s
+case 68 :
+return  40; //d
+case 70 :
+return  41; //f
+case 71 :
+return  42; //g
+case 72 :
+return  43; //h
+case 74 :
+return  44; //j
+case 75 :
+return  45; //k
+case 76 :
+return  46; //l
+case 77 :
+return  47; //m
+case 165 :
+return  48; //ù
+case 170 :
+return  51; // *
+
+//4 row
+case 16 :
+return  50; //Shift Left
+case 60 :
+return  94; //<
+case 87 :
+return  52; //w
+case 88 :
+return  53; //x
+case 67 :
+return  54; //c
+case 86 :
+return  55; //v
+case 66 :
+return  56; //b
+case 78 :
+return  57; //n
+case 188 :
+return  58; //,
+case 59 :
+return  59; //;
+case 58 :
+return  60; //:
+case 161 :
+return  61; //!
+case 16 :
+return  62; //Shift Right
+
+
+//5 row
+case 17 :
+return  37; //LCTRL
+case 91 :
+return  133; //LMETA
+case 18 :
+return  64; //LALT
+case 32 :
+   

[X2Go-Dev] Patch for x2gohtmlclient

2024-08-20 Thread Dj ZU
Hi team,

Thank you for the development of X2go, I'm using Kdrive on the Windows
client on a daily basis and very happy with it!
I am also using the HTML client but faced limitations with the keyboard
that I could fix.
I made the changes directly on the compiled JS but it all happens in
[x2gohtmlclient.git] / src / x2gokdrivehtmlclient.js

CapsLock and AltGr modifier keys were not effective. Fix:
@@ -1419,10 +1691,17 @@ X2GoKDriveHTMLClient
 {
 v32[1] |= Mod4Mask;
 }
+ if (e.getModifierState("AltGraph")) {
+ v32[1] |= Mod5Mask;
+ }
+ if (e.getModifierState("CapsLock")) {
+ v32[1] |= LockMask;
+}

   v32[2] = this.web2pc105(e.keyCode);

//console.log(v32[1], v32[2]);

 e.preventDefault();
 e.stopPropagation();


Minor issue with parsing:
@@ -1249,7 +1249,7 @@ X2GoKDriveHTMLClient
 case 111 :
 return  106; ///
 case 106 :
-return  63; //*
+return  63; // * (putting a space before * here, so that
nano/gedit do not get confused with syntax highlighting)
 case 109 :
 return  82; //-


FYI, since I'm using a French keyboard, I also created a new keymap, but
this should probably be written differently and add a UI setting in the
HTML to choose the keyboard mapping.
-v32[2] = this.web2pc105(e.keyCode);
+v32[2] = this.web2pc105fr(e.keyCode);

@@ -1312,6 +1312,273 @@ X2GoKDriveHTMLClient
 return nativeCode;
 }

+web2pc105fr(nativeCode)
+{
+switch (nativeCode)
+{
+//1st row
+case 222:
+return 49; // ²
+case   49:
+return 10; //1
+case 50:
+return 11; //2
+case 51:
+return 12; //3
+case 52:
+return 13; //4
+case 53:
+return 14; //5
+case 54:
+return 15; //6
+case 55:
+return 16; //7
+case 56:
+return 17; //8
+case 57:
+return 18; //9
+case 48:
+return 19; //0
+case 169:
+return 20; //°
+case 61:
+return 21; //+
+case 8:
+return 22; //BSP
+
+//2 row
+case 9 :
+return 23; //TAB
+case 65:
+return 24; //a
+case 90:
+return 25; //z
+case 69 :
+return 26; //e
+case 82 :
+return 27; //r
+case 84 :
+return 28; //t
+case 89:
+return 29; //y
+case 85:
+return 30; //u
+case 73:
+return 31; //i
+case 79:
+return 32; //o
+case 80:
+return 33; //p
+case 160:
+return 34; //[
+case 164:
+return 35; //]
+case  13:
+return 36; //ENT
+
+//3 row
+case 20 :
+return  66; //CAPS
+case 81 :
+return  38; //q
+case 83 :
+return  39; //s
+case 68 :
+return  40; //d
+case 70 :
+return  41; //f
+case 71 :
+return  42; //g
+case 72 :
+return  43; //h
+case 74 :
+return  44; //j
+case 75 :
+return  45; //k
+case 76 :
+return  46; //l
+case 77 :
+return  47; //m
+case 165 :
+return  48; //ù
+case 170 :
+return  51; // *
+
+//4 row
+case 16 :
+return  50; //Shift Left
+case 60 :
+return  94; //<
+case 87 :
+return  52; //w
+case 88 :
+return  53; //x
+case 67 :
+return  54; //c
+case 86 :
+return  55; //v
+case 66 :
+return  56; //b
+case 78 :
+return  57; //n
+case 188 :
+return  58; //,
+case 59 :
+return  59; //;
+case 58 :
+return  60; //:
+case 161 :
+return  61; //!
+case 16 :
+return  62; //Shift Right
+
+
+//5 row
+case 17 :
+return  37; //LCTRL
+case 91 :
+return  133; //LMETA
+case 18 :
+return  64; //LALT
+case 32 :
+return  65; //SPACE
+case 18 :
+