/* ======================== idKeyInput::LocalizedKeyName ======================== */ const char* idKeyInput::LocalizedKeyName( keyNum_t keynum ) { // RB #if defined(_WIN32) // DG TODO: move this into a win32 Sys_GetKeyName() if( keynum < K_JOY1 ) { // On the PC, we want to turn the scan code in to a key label that matches the currently selected keyboard layout unsigned char keystate[256] = { 0 }; WCHAR temp[5]; int scancode = ( int )keynum; int vkey = MapVirtualKey( keynum, MAPVK_VSC_TO_VK_EX ); int result = -1; while( result < 0 ) { result = ToUnicode( vkey, scancode, keystate, temp, sizeof( temp ) / sizeof( temp[0] ), 0 ); } if( result > 0 && temp[0] > ' ' && iswprint( temp[0] ) ) { static idStr bindStr; bindStr.Empty(); bindStr.AppendUTF8Char( temp[0] ); return bindStr; } } #else // DG: for !Windows I introduced Sys_GetKeyName() to get key label for current keyboard layout const char* ret = nullptr; if( keynum < K_JOY1 ) // only for keyboard keys, not joystick or mouse { ret = Sys_GetKeyName( keynum ); } if( ret != NULL ) { return ret; } #endif // check for a key string for( keyname_t* kn = keynames; kn->name; kn++ ) { if( keynum == kn->keynum ) { return idLocalization::GetString( kn->strId ); } } return "????"; // RB/DG end }
/* ======================== idKeyInput::LocalizedKeyName ======================== */ const char* idKeyInput::LocalizedKeyName( keyNum_t keynum ) { // RB: FIXME #if defined(_WIN32) if( keynum < K_JOY1 ) { // On the PC, we want to turn the scan code in to a key label that matches the currently selected keyboard layout unsigned char keystate[256] = { 0 }; WCHAR temp[5]; int scancode = ( int )keynum; int vkey = MapVirtualKey( keynum, MAPVK_VSC_TO_VK_EX ); int result = -1; while( result < 0 ) { result = ToUnicode( vkey, scancode, keystate, temp, sizeof( temp ) / sizeof( temp[0] ), 0 ); } if( result > 0 && temp[0] > ' ' && iswprint( temp[0] ) ) { static idStr bindStr; bindStr.Empty(); bindStr.AppendUTF8Char( temp[0] ); return bindStr; } } // check for a key string for( keyname_t* kn = keynames; kn->name; kn++ ) { if( keynum == kn->keynum ) { return idLocalization::GetString( kn->strId ); } } return "????"; #else return KeyNumToString( keynum ); #endif // RB end }