From 4393455ebac4fd4c65febc5d5bf7dde862117978 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 25 Dec 2016 16:12:54 +0100 Subject: [PATCH] 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 --- doc/ReleaseNotes | 1 + panda/src/windisplay/winGraphicsWindow.cxx | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 3ad0ecd49b..cd6bdf2f4c 100644 --- a/doc/ReleaseNotes +++ b/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 ------------------------ diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 0f7e33dc75..7f949415fe 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/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;