[Spice-commits] 4 commits - src/atKeynames.js src/utils.js

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 6 09:36:58 UTC 2019


 src/atKeynames.js |    2 
 src/utils.js      |  141 ++++++++++++++++++++++++++++--------------------------
 2 files changed, 76 insertions(+), 67 deletions(-)

New commits:
commit 61373be8eccb51ec689f884f23686e258e5f4999
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Mon Aug 5 14:27:07 2019 -0500

    Adjust the presentation of two byte scan codes.
    
    The previous implementation worked strictly due to a bug which would
    luckily generate roughly the right scan codes, although we would send
    more codes than required.
    
    For example, the old implementation would send 0xdf48e0 for 'up key down'
    and '0xdfc8e0' for 'up key up'.  The prepended 0xdf is incorrect; the
    correct values should be 0x48e0 and 0xc8e0.  Essentially, it stored
    the bytes in reverse order and had a bug while flipping them.
    
    This code stores them in the order we transmit them which simplifies
    the code.
    
    Signed-off-by: Jeremy White <jwhite at codeweavers.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/src/utils.js b/src/utils.js
index 79e3e5e..1013789 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -223,21 +223,21 @@ common_scanmap[19]                 = 101;// Break, XSpice only
    were grey on the original AT keyboard.  These are
    prefixed, as they were on the PS/2 controller, with an
    0xE0 byte to indicate that they are extended */
-common_scanmap[111]                = 0xE035; // KP_Divide
-common_scanmap[106]                = 0xE037; // KP_Multiply
-common_scanmap[36]                 = 0xE047; // Home
-common_scanmap[38]                 = 0xE048; // Up
-common_scanmap[33]                 = 0xE049; // PgUp
-common_scanmap[37]                 = 0xE04B; // Left
-common_scanmap[39]                 = 0xE04D; // Right
-common_scanmap[35]                 = 0xE04F; // End
-common_scanmap[40]                 = 0xE050; // Down
-common_scanmap[34]                 = 0xE051; // PgDown
-common_scanmap[45]                 = 0xE052; // Insert
-common_scanmap[46]                 = 0xE053; // Delete
-common_scanmap[91]                 = 0xE05B; //KeyNames.KEY_LMeta
-common_scanmap[92]                 = 0xE05C; //KeyNames.KEY_RMeta
-common_scanmap[93]                 = 0xE05D; //KeyNames.KEY_Menu
+common_scanmap[111]                = 0xE0 | (KeyNames.KEY_Slash << 8);// KP_Divide
+common_scanmap[106]                = 0xE0 | (KeyNames.KEY_KP_Multiply << 8); // KP_Multiply
+common_scanmap[36]                 = 0xE0 | (KeyNames.KEY_KP_7 << 8); // Home
+common_scanmap[38]                 = 0xE0 | (KeyNames.KEY_KP_8 << 8); // Up
+common_scanmap[33]                 = 0xE0 | (KeyNames.KEY_KP_9 << 8); // PgUp
+common_scanmap[37]                 = 0xE0 | (KeyNames.KEY_KP_4 << 8); // Left
+common_scanmap[39]                 = 0xE0 | (KeyNames.KEY_KP_6 << 8); // Right
+common_scanmap[35]                 = 0xE0 | (KeyNames.KEY_KP_1 << 8); // End
+common_scanmap[40]                 = 0xE0 | (KeyNames.KEY_KP_2 << 8); // Down
+common_scanmap[34]                 = 0xE0 | (KeyNames.KEY_KP_3 << 8); // PgDown
+common_scanmap[45]                 = 0xE0 | (KeyNames.KEY_KP_0 << 8); // Insert
+common_scanmap[46]                 = 0xE0 | (KeyNames.KEY_KP_Decimal << 8); // Delete
+common_scanmap[91]                 = 0xE0 | (0x5B << 8); //KeyNames.KEY_LMeta
+common_scanmap[92]                 = 0xE0 | (0x5C << 8); //KeyNames.KEY_RMeta
+common_scanmap[93]                 = 0xE0 | (0x5D << 8); //KeyNames.KEY_Menu
 
 /* Firefox/Mozilla codes */
 var firefox_scanmap = [];
@@ -273,11 +273,7 @@ function keycode_to_start_scan(code)
         return 0;
     }
 
-    if (scancode < 0x100) {
-        return scancode;
-    } else {
-        return 0xe0 | ((scancode - 0x100) << 8);
-    }
+    return scancode;
 }
 
 function keycode_to_end_scan(code)
@@ -289,7 +285,7 @@ function keycode_to_end_scan(code)
     if (scancode < 0x100) {
         return scancode | 0x80;
     } else {
-        return 0x80e0 | ((scancode - 0x100) << 8);
+        return scancode | 0x8000;
     }
 }
 
commit a14f8933a7262effcf27b258bcac1e2eecbb3bc0
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Mon Aug 5 14:27:06 2019 -0500

    Update the documentation and organization of the scancodes.
    
    The common scan codes were disjointed and logically belong together.
    
    Signed-off-by: Jeremy White <jwhite at codeweavers.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/src/utils.js b/src/utils.js
index 5059a5b..79e3e5e 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -114,14 +114,54 @@ function arraybuffer_to_str(buf) {
 }
 
 /*----------------------------------------------------------------------------
-** Converting keycodes to AT scancodes is very hard.
-** luckly there are some resources on the web and in the Xorg driver that help
-** us figure out what browser dependent keycodes match to what scancodes.
-**
-** This will most likely not work for non US keyboard and browsers other than
-** modern Chrome and FireFox.
+** Converting browser keycodes to AT scancodes is very hard.
+**  Spice transmits keys using the original AT scan codes, often
+**   described as 'Scan Code Set 1'.
+**  There is a confusion of other scan codes; Xorg synthesizes it's
+**   own in the same atKeynames.c file that has the XT codes.
+**  Scan code set 2 and 3 are more common, and use different values.
+** Further, there is no formal specification for keycodes
+**  returned by browsers, so we have done our mapping largely with
+**  empirical testing.
+** There has been little rigorous testing with International keyboards,
+**  and this would be an easy area for non English speakers to contribute.
 **--------------------------------------------------------------------------*/
 var common_scanmap = [];
+
+/* The following appear to be keycodes that work in most browsers */
+common_scanmap['1'.charCodeAt(0)]  = KeyNames.KEY_1;
+common_scanmap['2'.charCodeAt(0)]  = KeyNames.KEY_2;
+common_scanmap['3'.charCodeAt(0)]  = KeyNames.KEY_3;
+common_scanmap['4'.charCodeAt(0)]  = KeyNames.KEY_4;
+common_scanmap['5'.charCodeAt(0)]  = KeyNames.KEY_5;
+common_scanmap['6'.charCodeAt(0)]  = KeyNames.KEY_6;
+common_scanmap['7'.charCodeAt(0)]  = KeyNames.KEY_7;
+common_scanmap['8'.charCodeAt(0)]  = KeyNames.KEY_8;
+common_scanmap['9'.charCodeAt(0)]  = KeyNames.KEY_9;
+common_scanmap['0'.charCodeAt(0)]  = KeyNames.KEY_0;
+common_scanmap[145]                = KeyNames.KEY_ScrollLock;
+common_scanmap[103]                = KeyNames.KEY_KP_7;
+common_scanmap[104]                = KeyNames.KEY_KP_8;
+common_scanmap[105]                = KeyNames.KEY_KP_9;
+common_scanmap[100]                = KeyNames.KEY_KP_4;
+common_scanmap[101]                = KeyNames.KEY_KP_5;
+common_scanmap[102]                = KeyNames.KEY_KP_6;
+common_scanmap[107]                = KeyNames.KEY_KP_Plus;
+common_scanmap[97]                 = KeyNames.KEY_KP_1;
+common_scanmap[98]                 = KeyNames.KEY_KP_2;
+common_scanmap[99]                 = KeyNames.KEY_KP_3;
+common_scanmap[96]                 = KeyNames.KEY_KP_0;
+common_scanmap[109]                = KeyNames.KEY_Minus;
+common_scanmap[110]                = KeyNames.KEY_KP_Decimal;
+common_scanmap[191]                = KeyNames.KEY_Slash;
+common_scanmap[190]                = KeyNames.KEY_Period;
+common_scanmap[188]                = KeyNames.KEY_Comma;
+common_scanmap[220]                = KeyNames.KEY_BSlash;
+common_scanmap[192]                = KeyNames.KEY_Tilde;
+common_scanmap[222]                = KeyNames.KEY_Quote;
+common_scanmap[219]                = KeyNames.KEY_LBrace;
+common_scanmap[221]                = KeyNames.KEY_RBrace;
+
 common_scanmap['Q'.charCodeAt(0)]  = KeyNames.KEY_Q;
 common_scanmap['W'.charCodeAt(0)]  = KeyNames.KEY_W;
 common_scanmap['E'.charCodeAt(0)]  = KeyNames.KEY_E;
@@ -172,9 +212,17 @@ common_scanmap[121]                = KeyNames.KEY_F10;
 common_scanmap[122]                = KeyNames.KEY_F11;
 common_scanmap[123]                = KeyNames.KEY_F12;
 
-/* These extended scancodes do not line up with values from atKeynames */
-common_scanmap[42]                 = 99;
-common_scanmap[19]                 = 101;    // Break
+/* TODO:  Break and Print are complex scan codes.  XSpice cheats and
+   uses Xorg synthesized codes to simplify them.  Fixing this will
+   require XSpice to handle the scan codes correctly, and then
+   fix spice-html5 to send the complex scan codes. */
+common_scanmap[42]                 = 99; // Print, XSpice only
+common_scanmap[19]                 = 101;// Break, XSpice only
+
+/* Handle the so called 'GREY' keys, for the extended keys that
+   were grey on the original AT keyboard.  These are
+   prefixed, as they were on the PS/2 controller, with an
+   0xE0 byte to indicate that they are extended */
 common_scanmap[111]                = 0xE035; // KP_Divide
 common_scanmap[106]                = 0xE037; // KP_Multiply
 common_scanmap[36]                 = 0xE047; // Home
@@ -187,41 +235,6 @@ common_scanmap[40]                 = 0xE050; // Down
 common_scanmap[34]                 = 0xE051; // PgDown
 common_scanmap[45]                 = 0xE052; // Insert
 common_scanmap[46]                 = 0xE053; // Delete
-
-/* These are not common between ALL browsers but are between Firefox and DOM3 */
-common_scanmap['1'.charCodeAt(0)]  = KeyNames.KEY_1;
-common_scanmap['2'.charCodeAt(0)]  = KeyNames.KEY_2;
-common_scanmap['3'.charCodeAt(0)]  = KeyNames.KEY_3;
-common_scanmap['4'.charCodeAt(0)]  = KeyNames.KEY_4;
-common_scanmap['5'.charCodeAt(0)]  = KeyNames.KEY_5;
-common_scanmap['6'.charCodeAt(0)]  = KeyNames.KEY_6;
-common_scanmap['7'.charCodeAt(0)]  = KeyNames.KEY_7;
-common_scanmap['8'.charCodeAt(0)]  = KeyNames.KEY_8;
-common_scanmap['9'.charCodeAt(0)]  = KeyNames.KEY_9;
-common_scanmap['0'.charCodeAt(0)]  = KeyNames.KEY_0;
-common_scanmap[145]                = KeyNames.KEY_ScrollLock;
-common_scanmap[103]                = KeyNames.KEY_KP_7;
-common_scanmap[104]                = KeyNames.KEY_KP_8;
-common_scanmap[105]                = KeyNames.KEY_KP_9;
-common_scanmap[100]                = KeyNames.KEY_KP_4;
-common_scanmap[101]                = KeyNames.KEY_KP_5;
-common_scanmap[102]                = KeyNames.KEY_KP_6;
-common_scanmap[107]                = KeyNames.KEY_KP_Plus;
-common_scanmap[97]                 = KeyNames.KEY_KP_1;
-common_scanmap[98]                 = KeyNames.KEY_KP_2;
-common_scanmap[99]                 = KeyNames.KEY_KP_3;
-common_scanmap[96]                 = KeyNames.KEY_KP_0;
-common_scanmap[109]                = KeyNames.KEY_Minus;
-common_scanmap[110]                = KeyNames.KEY_KP_Decimal;
-common_scanmap[191]                = KeyNames.KEY_Slash;
-common_scanmap[190]                = KeyNames.KEY_Period;
-common_scanmap[188]                = KeyNames.KEY_Comma;
-common_scanmap[220]                = KeyNames.KEY_BSlash;
-common_scanmap[192]                = KeyNames.KEY_Tilde;
-common_scanmap[222]                = KeyNames.KEY_Quote;
-common_scanmap[219]                = KeyNames.KEY_LBrace;
-common_scanmap[221]                = KeyNames.KEY_RBrace;
-
 common_scanmap[91]                 = 0xE05B; //KeyNames.KEY_LMeta
 common_scanmap[92]                 = 0xE05C; //KeyNames.KEY_RMeta
 common_scanmap[93]                 = 0xE05D; //KeyNames.KEY_Menu
commit bd96ebe0a9b0e4f0cf4970a8c92cc3915af22048
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Mon Aug 5 14:27:05 2019 -0500

    Support the keypad minus key in Chrome.
    
    The keypad minus key at 109 is common between at least Chrome and Firefox.
    
    Signed-off-by: Jeremy White <jwhite at codeweavers.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/src/utils.js b/src/utils.js
index f12edf9..5059a5b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -211,6 +211,7 @@ common_scanmap[97]                 = KeyNames.KEY_KP_1;
 common_scanmap[98]                 = KeyNames.KEY_KP_2;
 common_scanmap[99]                 = KeyNames.KEY_KP_3;
 common_scanmap[96]                 = KeyNames.KEY_KP_0;
+common_scanmap[109]                = KeyNames.KEY_Minus;
 common_scanmap[110]                = KeyNames.KEY_KP_Decimal;
 common_scanmap[191]                = KeyNames.KEY_Slash;
 common_scanmap[190]                = KeyNames.KEY_Period;
@@ -228,7 +229,6 @@ common_scanmap[93]                 = 0xE05D; //KeyNames.KEY_Menu
 /* Firefox/Mozilla codes */
 var firefox_scanmap = [];
 firefox_scanmap[173]                = KeyNames.KEY_Minus;
-firefox_scanmap[109]                = KeyNames.KEY_Minus;
 firefox_scanmap[61]                 = KeyNames.KEY_Equal;
 firefox_scanmap[59]                 = KeyNames.KEY_SemiColon;
 
commit c4e5fd1c3eb7dd468cbaea8b268130c20206fba8
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Mon Aug 5 14:27:04 2019 -0500

    Use a named constant from atKeynames.js for the PrintScreen/SysRq key.
    
    Correct a typo from the upstream atKeynames.js at the same time.
    
    Signed-off-by: Jeremy White <jwhite at codeweavers.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/src/atKeynames.js b/src/atKeynames.js
index 110e9e9..767e78b 100644
--- a/src/atKeynames.js
+++ b/src/atKeynames.js
@@ -174,7 +174,7 @@ var KeyNames = {
   KEY_KP_3        :/* 3           PgDown    0x51  */   81,
   KEY_KP_0        :/* 0           Insert    0x52  */   82,
   KEY_KP_Decimal  :/* . (Decimal) Delete    0x53  */   83,
-  KEY_SysReqest   :/* SysReqest             0x54  */   84,
+  KEY_SysRequest  :/* SysRequest            0x54  */   84,
                    /* NOTUSED               0x55  */
   KEY_Less        :/* < (Less)   >(Greater) 0x56  */   86,
   KEY_F11         :/* F11                   0x57  */   87,
diff --git a/src/utils.js b/src/utils.js
index 1874e97..f12edf9 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -157,6 +157,7 @@ common_scanmap[16]                 = KeyNames.KEY_ShiftL;
 common_scanmap[17]                 = KeyNames.KEY_LCtrl;
 common_scanmap[18]                 = KeyNames.KEY_Alt;
 common_scanmap[20]                 = KeyNames.KEY_CapsLock;
+common_scanmap[44]                 = KeyNames.KEY_SysReqest;
 common_scanmap[144]                = KeyNames.KEY_NumLock;
 common_scanmap[112]                = KeyNames.KEY_F1;
 common_scanmap[113]                = KeyNames.KEY_F2;
@@ -186,7 +187,6 @@ common_scanmap[40]                 = 0xE050; // Down
 common_scanmap[34]                 = 0xE051; // PgDown
 common_scanmap[45]                 = 0xE052; // Insert
 common_scanmap[46]                 = 0xE053; // Delete
-common_scanmap[44]                 = 0x2A37; // Print
 
 /* These are not common between ALL browsers but are between Firefox and DOM3 */
 common_scanmap['1'.charCodeAt(0)]  = KeyNames.KEY_1;


More information about the Spice-commits mailing list