X11 keyboard numpad and function keys corrupted by lookup in enigma::usermap with diff fix [u570]

Reporter: ssss  |  Status: closed  |  Last Modified: June 10, 2013, 03:34:00 PM

The value for special vk_ keys is looked up from X keysym in enigma::keymap. The array enigma::usermap is set in ENIGMAsystem/SHELL/Platforms/xlib/XLIBwindow.cpp line 367:
for (int i = 'a'; i <= 'z'; i++) // 'a' to 'z' wrap to 'A' to 'Z'
usermap[i] = i + 'A' - 'a';

In ENIGMAsystem/SHELL/Platforms/xlib/XLIBmain.cpp line 70 the result keycode should not be looked up through enigma::usermap because it changes lowercase to uppercase, corrupting the meaning of vk_ codes for numpad and function keys between vk_numpad1 = 97 and vk_f11 = 122. Diff fixes the problem:

--- a/ENIGMAsystem/SHELL/Platforms/xlib/XLIBmain.cpp
+++ b/ENIGMAsystem/SHELL/Platforms/xlib/XLIBmain.cpp
@@ -69,7 +69,8 @@ namespace enigma
return 0;

           if (!(gk & 0xFF00)) actualKey = enigma::usermap[gk];
  •          else actualKey = enigma::usermap[(int)enigma::keymap[gk & 0xFF]];
    
  •          else actualKey = (int)enigma::keymap[gk & 0xFF];
    
  •          //else actualKey = enigma::usermap[(int)enigma::keymap[gk & 0xFF]];
           { // Set keyboard_lastchar. Seems to work without 
               char str[1];
               int len = XLookupString(&e.xkey, str, 1, NULL, NULL);
    

    @@ -91,7 +92,8 @@ namespace enigma
    return 0;

         if (!(gk & 0xFF00)) actualKey = enigma::usermap[gk];
    
  •        else actualKey = enigma::usermap[(int)enigma::keymap[gk & 0xFF]];
    
  •        else actualKey = (int)enigma::keymap[gk & 0xFF];
    
         enigma::last_keybdstatus[actualKey]=enigma::keybdstatus[actualKey];
         enigma::keybdstatus[actualKey]=0;
    

Keys affected were:

vk_numpad1 = 97,
vk_numpad2 = 98,
vk_numpad3 = 99,
vk_numpad4 = 100,
vk_numpad5 = 101,
vk_numpad6 = 102,
vk_numpad7 = 103,
vk_numpad8 = 104,
vk_numpad9 = 105,
vk_multiply = 106,
vk_add = 107,
vk_subtract = 109,
vk_decimal = 110,
vk_divide = 111,
vk_f1 = 112,
vk_f2 = 113,
vk_f3 = 114,
vk_f4 = 115,
vk_f5 = 116,
vk_f6 = 117,
vk_f7 = 118,
vk_f8 = 119,
vk_f9 = 120,
vk_f10 = 121,
vk_f11 = 122,

ssss  
goddamn why did it screw up my text

ssss  

JUST READ IT HERE FORGET THE TRACKER TEXT
http://enigma-dev.org/forums/index.php?topic=1297.0

sssstest  

Different solution found by Josh
Fixed in my recent commit #197

Please sign in to post comments, or you can view this issue on GitHub.