diff options
Diffstat (limited to 'src/keycode.cpp')
-rw-r--r-- | src/keycode.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/keycode.cpp b/src/keycode.cpp index 5a8df0db4..cdf3c6062 100644 --- a/src/keycode.cpp +++ b/src/keycode.cpp @@ -288,16 +288,27 @@ KeyPress::KeyPress(const char *name) m_name = name[0]; } -KeyPress::KeyPress(const irr::SEvent::SKeyInput &in) +KeyPress::KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character) { Key = in.Key; Char = in.Char; + + if(prefer_character){ + m_name.resize(MB_CUR_MAX+1, '\0'); + int written = wctomb(&m_name[0], Char); + if(written > 0){ + infostream<<"KeyPress: Preferring character for "<<m_name<<std::endl; + Key = irr::KEY_KEY_CODES_COUNT; + return; + } + } + if (valid_kcode(Key)) { m_name = KeyNames[Key]; } else { m_name.resize(MB_CUR_MAX+1, '\0'); int written = wctomb(&m_name[0], Char); - if(written >= 0){ + if(written < 0){ std::string hexstr = hex_encode((const char*)&Char, sizeof(Char)); errorstream<<"KeyPress: Unexpected multibyte character "<<hexstr<<std::endl; } |