1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix GUIKeyChangeMenu so that '/' can be inserted on a finnish keyboard

This commit is contained in:
Perttu Ahola 2012-09-01 18:02:29 +03:00
parent 3e7957512b
commit 5194505407
4 changed files with 35 additions and 6 deletions

View file

@ -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;
}