From f9af363e24b18510554c54950ce1f5d142419c0c Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 20 May 2005 22:25:22 +0000 Subject: added the ability to use keycode in keys file --- src/Keys.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Keys.cc b/src/Keys.cc index 0d3eecd..e817374 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -201,9 +201,27 @@ bool Keys::addBinding(const std::string &linebuffer) { if(tmpmod) mod |= tmpmod; //If it's a modifier else { - key = FbTk::KeyUtil::getKey(val[argc].c_str()); // else get the key + // keycode covers the following three two-byte cases: + // 0x - hex + // +[1-9] - number between +1 and +9 + // numbers 10 and above + // + if (val[argc].size() > 1 && (isdigit(val[argc][0]) && + (isdigit(val[argc][1]) || val[argc][1] == 'x') || + val[argc][0] == '+' && isdigit(val[argc][1])) ) { + + key = strtoul(val[argc].c_str(), NULL, 0); + + if (errno == EINVAL || errno == ERANGE) + key = 0; + + } else // convert from string symbol + key = FbTk::KeyUtil::getKey(val[argc].c_str()); + if (key == 0) { - cerr<<_FBTEXT(Keys, InvalidKeyMod, "Keys: Invalid key/modifier on line", "A bad key/modifier string was found on line (number following)")<<" "<< + cerr<<_FBTEXT(Keys, InvalidKeyMod, + "Keys: Invalid key/modifier on line", + "A bad key/modifier string was found on line (number following)")<<" "<< m_current_line<<"): "<