diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-09-01 18:02:29 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-09-01 18:03:50 +0300 |
commit | 5194505407884f6375311f0ab4c5f8783646cb91 (patch) | |
tree | a3457cf11bdf0f3203d5e5313020ffba0e50ea1c /src/keycode.cpp | |
parent | 3e7957512bdb86acb3836c6c1df96e38e05efa3c (diff) | |
download | minetest-5194505407884f6375311f0ab4c5f8783646cb91.tar.gz minetest-5194505407884f6375311f0ab4c5f8783646cb91.tar.bz2 minetest-5194505407884f6375311f0ab4c5f8783646cb91.zip |
Fix GUIKeyChangeMenu so that '/' can be inserted on a finnish keyboard
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; } |