Pārlūkot izejas kodu

Fix get_keyboard_map on Czech (and other) layouts
Now reports proper Unicode name, and doesn't omit keys that don't have a recognised mapping by Panda
https://bugs.launchpad.net/panda3d/+bug/1652145

rdb 9 gadi atpakaļ
vecāks
revīzija
4393455eba
2 mainītis faili ar 9 papildinājumiem un 7 dzēšanām
  1. 1 0
      doc/ReleaseNotes
  2. 8 7
      panda/src/windisplay/winGraphicsWindow.cxx

+ 1 - 0
doc/ReleaseNotes

@@ -52,6 +52,7 @@ This issue fixes several bugs that were still found in 1.9.2.
 * Now tries to preserve refresh rate when switching fullscreen on Windows
 * Fix back-to-front sorting when gl-coordinate-system is changed
 * Now also compiles on older Linux distros (eg. CentOS 5 / manylinux1)
+* get_keyboard_map now includes keys on layouts with special characters
 
 ------------------------  RELEASE 1.9.2  ------------------------
 

+ 8 - 7
panda/src/windisplay/winGraphicsWindow.cxx

@@ -2721,7 +2721,7 @@ ButtonMap *WinGraphicsWindow::
 get_keyboard_map() const {
   ButtonMap *map = new ButtonMap;
 
-  char text[256];
+  wchar_t text[256];
   UINT vsc = 0;
   unsigned short ex_vsc[] = {0x57, 0x58,
     0x011c, 0x011d, 0x0135, 0x0137, 0x0138, 0x0145, 0x0147, 0x0148, 0x0149, 0x014b, 0x014d, 0x014f, 0x0150, 0x0151, 0x0152, 0x0153, 0x015b, 0x015c, 0x015d};
@@ -2759,14 +2759,15 @@ get_keyboard_map() const {
 
       UINT vk = MapVirtualKeyA(vsc, MAPVK_VSC_TO_VK_EX);
       button = lookup_key(vk);
-      if (button == ButtonHandle::none()) {
-        continue;
-      }
+      //if (button == ButtonHandle::none()) {
+      //  continue;
+      //}
     }
 
-    int len = GetKeyNameTextA(lparam, text, 256);
-    string label (text, len);
-    map->map_button(raw_button, button, label);
+    int len = GetKeyNameTextW(lparam, text, 256);
+    TextEncoder enc;
+    enc.set_wtext(wstring(text, len));
+    map->map_button(raw_button, button, enc.get_text());
   }
 
   return map;