diff --git a/projects/mtg/src/TranslateKeys.cpp b/projects/mtg/src/TranslateKeys.cpp index 2bda7e8e6..f604418f0 100644 --- a/projects/mtg/src/TranslateKeys.cpp +++ b/projects/mtg/src/TranslateKeys.cpp @@ -29,18 +29,39 @@ const KeyRep& translateKey(LocalKeySym key) { } #else #ifdef WIN32 + + const KeyRep& translateKey(LocalKeySym key) { { map::iterator res; if ((res = fattable.find(key)) != fattable.end()) - return *(res->second); + return (res->second); } + unsigned int sc = MapVirtualKey(key, 0); - /* I think the code should look like this ? - Documentation from : http://msdn.microsoft.com/en-us/library/ms171538.aspx + switch (key) + { + case VK_LEFT: case VK_UP: case VK_RIGHT: case VK_DOWN: // arrow keys + case VK_PRIOR: case VK_NEXT: // page up and page down + case VK_END: case VK_HOME: + case VK_INSERT: case VK_DELETE: + case VK_DIVIDE: // numpad slash + case VK_NUMLOCK: + { + sc |= 0x100; // set extended bit + break; + } + } + + + char buf[256]; + memset(buf, 0, 256); + + string s; + // Convert to ANSI string + if (GetKeyNameTextA(sc << 16, buf, 256) > 0) + s = buf; - Keys keyCode = (Keys)((int)key) & Keys::KeyCode; - string s = keyCode.ToString(); KeyRep k; if (0 == s.length()) { char*str = new char[11]; @@ -51,15 +72,6 @@ const KeyRep& translateKey(LocalKeySym key) { fattable[key] = k; return fattable[key]; - ... Instead of the following : - */ - - - char* str = new char[11]; - sprintf(str, "%d", key); - const KeyRep k = make_pair(str, static_cast(NULL)); - fattable[key] = k; - return fattable[key]; } #else // PSP