diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/keycode.cpp | 9 | ||||
-rw-r--r-- | src/client/keycode.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/client/keycode.cpp b/src/client/keycode.cpp index ce5214f54..08aff43ce 100644 --- a/src/client/keycode.cpp +++ b/src/client/keycode.cpp @@ -386,3 +386,12 @@ irr::EKEY_CODE keyname_to_keycode(const char *name) { return lookup_keyname(name).Key; } + +irr::EKEY_CODE keyname_to_keycode_safemode(const char *name) +{ + try { + return lookup_keyname(name).Key; + } catch (UnknownKeycode &e) { + return irr::KEY_KEY_CODES_COUNT; + } +} diff --git a/src/client/keycode.h b/src/client/keycode.h index 7036705d1..cb3114099 100644 --- a/src/client/keycode.h +++ b/src/client/keycode.h @@ -65,3 +65,6 @@ KeyPress getKeySetting(const char *settingname); void clearKeyCache(); irr::EKEY_CODE keyname_to_keycode(const char *name); + +// Now with internal exception handling. return irr::KEY_KEY_CODES_COUNT on fail +irr::EKEY_CODE keyname_to_keycode_safemode(const char *name); |