From 038a317c213db41227beaa014100dc43b46e392c Mon Sep 17 00:00:00 2001 From: pecksin Date: Fri, 19 Mar 2021 16:25:44 -0400 Subject: user-configurable 'ctrl' keys for ctrl-leftclick in chat weblinks --- src/client/keycode.cpp | 9 +++++++++ src/client/keycode.h | 3 +++ 2 files changed, 12 insertions(+) (limited to 'src/client') 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); -- cgit v1.2.3