Misc cleanup and fixes

This commit is contained in:
simon.kagstrom 2009-04-13 07:44:27 +00:00
parent c159d07116
commit 7b4b2fa3a9
2 changed files with 18 additions and 13 deletions

View File

@ -209,10 +209,19 @@ int VirtualKeyboard::char_to_keycode(char c)
return -1;
}
const char VirtualKeyboard::get_char(int kc)
const char VirtualKeyboard::keycode_to_char(int kc)
{
const char *s = this->keycode_to_string(kc);
if (strcmp(s, "space") == 0)
return ' ';
if (strcmp(s, "Ret") == 0)
return '\n';
if (strcmp(s, "Del") == 0)
return '\b';
/* NULL is never, ever returned */
return this->keycode_to_string(kc)[0];
return s[0];
}
struct virtkey *VirtualKeyboard::get_key_internal()
@ -298,12 +307,8 @@ const char *VirtualKeyboard::get_string()
}
else
{
c = this->get_char( this->shift_on ? key->kc | 0x80 : key->kc );
c = this->keycode_to_char( this->shift_on ? key->kc | 0x80 : key->kc );
if (strcmp(key->name, "space") == 0)
c = ' ';
else if (strcmp(key->name, "Ret") == 0)
c = '\n';
this->buf[cnt] = c;
}
@ -321,3 +326,5 @@ const char *VirtualKeyboard::get_string()
/* Not reachable */
return NULL;
}
VirtualKeyboard *virtual_keyboard;

View File

@ -21,16 +21,11 @@ public:
int get_key();
const char *get_string();
const char *keycode_to_string(int kc);
char keycode_to_char(int kc)
{
return this->keycode_to_string(kc)[0];
}
const char keycode_to_char(int kc);
int char_to_keycode(char c);
private:
const char get_char(int kc);
struct virtkey *get_key_internal();
void draw();
void select_next(int dx, int dy);
@ -44,3 +39,6 @@ private:
char buf[255];
};
extern VirtualKeyboard *virtual_keyboard;