driver/rcinput: let getUnicodeValue() return const char *

This commit is contained in:
martii
2014-02-23 10:26:34 +01:00
committed by svenhoefer
parent 7826ab0fca
commit 34c23ed7a5
4 changed files with 21 additions and 27 deletions

View File

@@ -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 #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 , static const char unicode_value[UNICODE_VALUE_SIZE * 2] =
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', -1 , -1 , 'A', 'S', "\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"
'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', -1 /* FIXME */, -1 /* FIXME */, -1 , '\\', 'Z', 'X', 'C', 'V', "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"
'B', 'N', 'M', ',', '.', '/', -1, -1, -1, ' '}; "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) if (key < UNICODE_VALUE_SIZE)
return unicode_value[key]; return unicode_value + key * 2;
else return "";
return -1;
} }
/************************************************************************** /**************************************************************************
@@ -1584,16 +1584,10 @@ std::string CRCInput::getKeyName(const unsigned int key)
const char *CRCInput::getKeyNameC(const unsigned int key) const char *CRCInput::getKeyNameC(const unsigned int key)
{ {
int lunicode_value = getUnicodeValue(key); const char *lunicode_value = getUnicodeValue(key);
if (lunicode_value == -1) if (*lunicode_value)
return getSpecialKeyName(key); return lunicode_value;
else return getSpecialKeyName(key);
{
static char tmp[2];
tmp[0] = lunicode_value;
tmp[1] = 0;
return tmp;
}
} }
/************************************************************************** /**************************************************************************

View File

@@ -290,7 +290,7 @@ class CRCInput
static bool isNumeric(const neutrino_msg_t key); static bool isNumeric(const neutrino_msg_t key);
static int getNumericValue(const neutrino_msg_t key); static int getNumericValue(const neutrino_msg_t key);
static unsigned int convertDigitToKey(const unsigned int digit); 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 *); uint32_t *setAllowRepeat(uint32_t *);
static const char * getSpecialKeyName(const unsigned int key); static const char * getSpecialKeyName(const unsigned int key);

View File

@@ -430,7 +430,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & )
{ {
keyRightPressed(); keyRightPressed();
} }
else if (CRCInput::getUnicodeValue(msg) != -1) else if (*CRCInput::getUnicodeValue(msg))
{ {
NormalKeyPressed(msg); NormalKeyPressed(msg);
} }
@@ -701,7 +701,7 @@ void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key)
} }
else else
{ {
valueString->at(selected) = (char)CRCInput::getUnicodeValue(key); valueString->at(selected) = *CRCInput::getUnicodeValue(key);
keyRedPressed(); /* to lower, paintChar */ keyRedPressed(); /* to lower, paintChar */
keyRightPressed(); /* last_digit = -1, move to next position */ keyRightPressed(); /* last_digit = -1, move to next position */
} }

View File

@@ -218,7 +218,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); 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)) || (msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))
{ {
inputFields[selectedChar]->keyPressed(msg); inputFields[selectedChar]->keyPressed(msg);
@@ -377,12 +377,12 @@ int CExtendedInput_Item_Char::getCharID( char ch )
void CExtendedInput_Item_Char::keyPressed(const int key) void CExtendedInput_Item_Char::keyPressed(const int key)
{ {
int value = CRCInput::getUnicodeValue(key); const char *value = CRCInput::getUnicodeValue(key);
if (value != -1) if (*value)
{ {
if (isAllowedChar((char)value)) if (isAllowedChar(*value))
{ {
*data = (char)value; *data = *value;
g_RCInput->postMsg( CRCInput::RC_right, 0 ); g_RCInput->postMsg( CRCInput::RC_right, 0 );
} }
} }