diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index d10aa2164..e5144511b 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1431,21 +1431,21 @@ unsigned int CRCInput::convertDigitToKey(const unsigned int digit) } /************************************************************************** -* getUnicodeValue - return unicode value of the key or -1 +* getUnicodeValue - return unicode value of the key or \0 * **************************************************************************/ #define UNICODE_VALUE_SIZE 58 -static const int unicode_value[UNICODE_VALUE_SIZE] = {-1 , -1 , '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', -1 , -1 , - 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', -1 , -1 , 'A', 'S', - 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', -1 /* FIXME */, -1 /* FIXME */, -1 , '\\', 'Z', 'X', 'C', 'V', - 'B', 'N', 'M', ',', '.', '/', -1, -1, -1, ' '}; +static const char unicode_value[UNICODE_VALUE_SIZE * 2] = + "\0\0" "\0\0" "1\0" "2\0" "3\0" "4\0" "5\0" "6\0" "7\0" "8\0" "9\0" "0\0" "-\0" "=\0" "\0\0" "\0\0" + "Q\0" "W\0" "E\0" "R\0" "T\0" "Y\0" "U\0" "I\0" "O\0" "P\0" "{\0" "}\0" "\0\0" "\0\0" "A\0" "S\0" + "D\0" "F\0" "G\0" "H\0" "J\0" "K\0" "L\0" ";\0" "'\0" "\140\0" "\0\0" "\\\0" "Z\0" "X\0" "C\0" "V\0" + "B\0" "N\0" "M\0" "\0\0" ".\0" "/\0" "\0\0" "\0\0" "\0\0" " "; -int CRCInput::getUnicodeValue(const neutrino_msg_t key) +const char *CRCInput::getUnicodeValue(const neutrino_msg_t key) { if (key < UNICODE_VALUE_SIZE) - return unicode_value[key]; - else - return -1; + return unicode_value + key * 2; + return ""; } /************************************************************************** @@ -1584,16 +1584,10 @@ std::string CRCInput::getKeyName(const unsigned int key) const char *CRCInput::getKeyNameC(const unsigned int key) { - int lunicode_value = getUnicodeValue(key); - if (lunicode_value == -1) - return getSpecialKeyName(key); - else - { - static char tmp[2]; - tmp[0] = lunicode_value; - tmp[1] = 0; - return tmp; - } + const char *lunicode_value = getUnicodeValue(key); + if (*lunicode_value) + return lunicode_value; + return getSpecialKeyName(key); } /************************************************************************** diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index bee874e6a..feb414941 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -290,7 +290,7 @@ class CRCInput static bool isNumeric(const neutrino_msg_t key); static int getNumericValue(const neutrino_msg_t key); static unsigned int convertDigitToKey(const unsigned int digit); - static int getUnicodeValue(const neutrino_msg_t key); + static const char *getUnicodeValue(const neutrino_msg_t key); uint32_t *setAllowRepeat(uint32_t *); static const char * getSpecialKeyName(const unsigned int key); diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 04e2b769c..5099f2c55 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -430,7 +430,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) { keyRightPressed(); } - else if (CRCInput::getUnicodeValue(msg) != -1) + else if (*CRCInput::getUnicodeValue(msg)) { NormalKeyPressed(msg); } @@ -701,7 +701,7 @@ void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key) } else { - valueString->at(selected) = (char)CRCInput::getUnicodeValue(key); + valueString->at(selected) = *CRCInput::getUnicodeValue(key); keyRedPressed(); /* to lower, paintChar */ keyRightPressed(); /* last_digit = -1, move to next position */ } diff --git a/src/gui/widget/stringinput_ext.cpp b/src/gui/widget/stringinput_ext.cpp index 82abac222..c56ef9aca 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -218,7 +218,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); } } - else if ( (CRCInput::getUnicodeValue(msg) != -1) || (msg == CRCInput::RC_red) || (msg == CRCInput::RC_green) || (msg == CRCInput::RC_blue) || (msg == CRCInput::RC_yellow) + else if ( (!*CRCInput::getUnicodeValue(msg)) || (msg == CRCInput::RC_red) || (msg == CRCInput::RC_green) || (msg == CRCInput::RC_blue) || (msg == CRCInput::RC_yellow) || (msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)) { inputFields[selectedChar]->keyPressed(msg); @@ -377,12 +377,12 @@ int CExtendedInput_Item_Char::getCharID( char ch ) void CExtendedInput_Item_Char::keyPressed(const int key) { - int value = CRCInput::getUnicodeValue(key); - if (value != -1) + const char *value = CRCInput::getUnicodeValue(key); + if (*value) { - if (isAllowedChar((char)value)) + if (isAllowedChar(*value)) { - *data = (char)value; + *data = *value; g_RCInput->postMsg( CRCInput::RC_right, 0 ); } }