* Added Virtual Keyboard descriptions for all keycodes
* Tweaking of key delivery queue svn-id: r33907
This commit is contained in:
parent
6f09c4f10e
commit
6ef8324302
5 changed files with 398 additions and 26 deletions
331
backends/vkeybd/keycode-descriptions.h
Normal file
331
backends/vkeybd/keycode-descriptions.h
Normal file
|
@ -0,0 +1,331 @@
|
||||||
|
#ifndef KEYCODE_DESCRIPTIONS
|
||||||
|
#define KEYCODE_DESCRIPTIONS
|
||||||
|
|
||||||
|
static const char *keycodeDescTable[] = {
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Backspace",
|
||||||
|
"Tab",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Clear",
|
||||||
|
"Return",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Pause",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Escape",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
" ",
|
||||||
|
"!",
|
||||||
|
"\"",
|
||||||
|
"#",
|
||||||
|
"$",
|
||||||
|
"%",
|
||||||
|
"&",
|
||||||
|
"'",
|
||||||
|
"(",
|
||||||
|
")",
|
||||||
|
"*",
|
||||||
|
"+",
|
||||||
|
",",
|
||||||
|
"-",
|
||||||
|
".",
|
||||||
|
"/",
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
":",
|
||||||
|
";",
|
||||||
|
"<",
|
||||||
|
"=",
|
||||||
|
">",
|
||||||
|
"?",
|
||||||
|
"@",
|
||||||
|
"A",
|
||||||
|
"B",
|
||||||
|
"C",
|
||||||
|
"D",
|
||||||
|
"E",
|
||||||
|
"F",
|
||||||
|
"G",
|
||||||
|
"H",
|
||||||
|
"I",
|
||||||
|
"J",
|
||||||
|
"K",
|
||||||
|
"L",
|
||||||
|
"M",
|
||||||
|
"N",
|
||||||
|
"O",
|
||||||
|
"P",
|
||||||
|
"Q",
|
||||||
|
"R",
|
||||||
|
"S",
|
||||||
|
"T",
|
||||||
|
"U",
|
||||||
|
"V",
|
||||||
|
"W",
|
||||||
|
"X",
|
||||||
|
"Y",
|
||||||
|
"Z",
|
||||||
|
"[",
|
||||||
|
"\\",
|
||||||
|
"]",
|
||||||
|
"^",
|
||||||
|
"_",
|
||||||
|
"`",
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c",
|
||||||
|
"d",
|
||||||
|
"e",
|
||||||
|
"f",
|
||||||
|
"g",
|
||||||
|
"h",
|
||||||
|
"i",
|
||||||
|
"j",
|
||||||
|
"k",
|
||||||
|
"l",
|
||||||
|
"m",
|
||||||
|
"n",
|
||||||
|
"o",
|
||||||
|
"p",
|
||||||
|
"q",
|
||||||
|
"r",
|
||||||
|
"s",
|
||||||
|
"t",
|
||||||
|
"u",
|
||||||
|
"v",
|
||||||
|
"w",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"{",
|
||||||
|
"|",
|
||||||
|
"}",
|
||||||
|
"~",
|
||||||
|
"Delete",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
".",
|
||||||
|
"/",
|
||||||
|
"*",
|
||||||
|
"-",
|
||||||
|
"+",
|
||||||
|
"Enter",
|
||||||
|
"=",
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Right",
|
||||||
|
"Left",
|
||||||
|
"Ins",
|
||||||
|
"Home",
|
||||||
|
"End",
|
||||||
|
"Page Up",
|
||||||
|
"Page Down",
|
||||||
|
"F1",
|
||||||
|
"F2",
|
||||||
|
"F3",
|
||||||
|
"F4",
|
||||||
|
"F5",
|
||||||
|
"F6",
|
||||||
|
"F7",
|
||||||
|
"F8",
|
||||||
|
"F9",
|
||||||
|
"F10",
|
||||||
|
"F11",
|
||||||
|
"F12",
|
||||||
|
"F13",
|
||||||
|
"F14",
|
||||||
|
"F15",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Num Lock",
|
||||||
|
"Caps Lock",
|
||||||
|
"Scroll Lock",
|
||||||
|
"Shift",
|
||||||
|
"Shift",
|
||||||
|
"Ctrl",
|
||||||
|
"Ctrl",
|
||||||
|
"Alt",
|
||||||
|
"Alt",
|
||||||
|
"Meta",
|
||||||
|
"Meta",
|
||||||
|
"Super",
|
||||||
|
"Super",
|
||||||
|
"Mode",
|
||||||
|
"Compose",
|
||||||
|
"Help",
|
||||||
|
"Print",
|
||||||
|
"SysReq",
|
||||||
|
"Break",
|
||||||
|
"Menu",
|
||||||
|
"Power",
|
||||||
|
"€",
|
||||||
|
"Undo"
|
||||||
|
};
|
||||||
|
static const int keycodeDescTableSize = 322;
|
||||||
|
|
||||||
|
#endif
|
|
@ -317,6 +317,8 @@ void VirtualKeyboardGUI::animateCaret() {
|
||||||
void VirtualKeyboardGUI::updateDisplay() {
|
void VirtualKeyboardGUI::updateDisplay() {
|
||||||
if (!_displayEnabled) return;
|
if (!_displayEnabled) return;
|
||||||
|
|
||||||
|
_refreshDisplay = false;
|
||||||
|
|
||||||
// calculate the text to display
|
// calculate the text to display
|
||||||
uint cursorPos = _kbd->_keyQueue.getInsertIndex();
|
uint cursorPos = _kbd->_keyQueue.getInsertIndex();
|
||||||
String wholeText = _kbd->_keyQueue.getString();
|
String wholeText = _kbd->_keyQueue.getString();
|
||||||
|
|
|
@ -26,8 +26,12 @@
|
||||||
#include "backends/vkeybd/virtual-keyboard.h"
|
#include "backends/vkeybd/virtual-keyboard.h"
|
||||||
#include "backends/vkeybd/virtual-keyboard-gui.h"
|
#include "backends/vkeybd/virtual-keyboard-gui.h"
|
||||||
#include "backends/vkeybd/virtual-keyboard-parser.h"
|
#include "backends/vkeybd/virtual-keyboard-parser.h"
|
||||||
|
#include "backends/vkeybd/keycode-descriptions.h"
|
||||||
#include "graphics/imageman.h"
|
#include "graphics/imageman.h"
|
||||||
|
|
||||||
|
#define KEY_START_CHAR ('[')
|
||||||
|
#define KEY_END_CHAR (']')
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
VirtualKeyboard::VirtualKeyboard() : _currentMode(0) {
|
VirtualKeyboard::VirtualKeyboard() : _currentMode(0) {
|
||||||
|
@ -37,6 +41,8 @@ VirtualKeyboard::VirtualKeyboard() : _currentMode(0) {
|
||||||
_parser = new VirtualKeyboardParser(this);
|
_parser = new VirtualKeyboardParser(this);
|
||||||
_kbdGUI = new VirtualKeyboardGUI(this);
|
_kbdGUI = new VirtualKeyboardGUI(this);
|
||||||
_submitKeys = _loaded = false;
|
_submitKeys = _loaded = false;
|
||||||
|
|
||||||
|
printf("\t\"%c\",\n",255);
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualKeyboard::~VirtualKeyboard() {
|
VirtualKeyboard::~VirtualKeyboard() {
|
||||||
|
@ -231,44 +237,62 @@ VirtualKeyboard::KeyPressQueue::KeyPressQueue() {
|
||||||
_keyPos = _keys.end();
|
_keyPos = _keys.end();
|
||||||
_strPos = 0;
|
_strPos = 0;
|
||||||
_strChanged = false;
|
_strChanged = false;
|
||||||
_keyFlags = 0;
|
_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualKeyboard::KeyPressQueue::toggleFlags(byte fl) {
|
void VirtualKeyboard::KeyPressQueue::toggleFlags(byte fl) {
|
||||||
_keyFlags ^= fl;
|
_flags ^= fl;
|
||||||
|
_flagsStr.clear();
|
||||||
|
if (_flags) {
|
||||||
|
_flagsStr = KEY_START_CHAR;
|
||||||
|
if (_flags & KBD_CTRL)
|
||||||
|
_flagsStr += "Ctrl+";
|
||||||
|
if (_flags & KBD_ALT)
|
||||||
|
_flagsStr += "Alt+";
|
||||||
|
if (_flags & KBD_SHIFT)
|
||||||
|
_flagsStr += "Shift+";
|
||||||
|
}
|
||||||
_strChanged = true;
|
_strChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualKeyboard::KeyPressQueue::clearFlags() {
|
void VirtualKeyboard::KeyPressQueue::clearFlags() {
|
||||||
_keyFlags = 0;
|
_flags = 0;
|
||||||
|
_flagsStr.clear();
|
||||||
_strChanged = true;
|
_strChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) {
|
void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) {
|
||||||
_strChanged = true;
|
_strChanged = true;
|
||||||
key.flags ^= _keyFlags;
|
key.flags ^= _flags;
|
||||||
if ((key.keycode >= Common::KEYCODE_a) && (key.keycode <= Common::KEYCODE_z))
|
if ((key.keycode >= Common::KEYCODE_a) && (key.keycode <= Common::KEYCODE_z))
|
||||||
key.ascii = (key.flags & Common::KBD_SHIFT) ? key.keycode - 32 : key.keycode;
|
key.ascii = (key.flags & Common::KBD_SHIFT) ? key.keycode - 32 : key.keycode;
|
||||||
clearFlags();
|
clearFlags();
|
||||||
|
|
||||||
String keyStr;
|
String keyStr;
|
||||||
if (key.keycode >= 32 && key.keycode <= 126) {
|
if (key.flags & KBD_CTRL) keyStr += "Ctrl+";
|
||||||
if (key.flags & KBD_CTRL)
|
if (key.flags & KBD_ALT) keyStr += "Alt+";
|
||||||
keyStr += "Ctrl+";
|
|
||||||
if (key.flags & KBD_ALT)
|
if (key.ascii >= 32 && key.ascii <= 255) {
|
||||||
keyStr += "Alt+";
|
|
||||||
if (key.flags & KBD_SHIFT && (key.ascii < 65 || key.ascii > 90))
|
if (key.flags & KBD_SHIFT && (key.ascii < 65 || key.ascii > 90))
|
||||||
keyStr += "Shift+";
|
keyStr += "Shift+";
|
||||||
keyStr += (char)key.ascii;
|
keyStr += (char)key.ascii;
|
||||||
|
} else {
|
||||||
|
if (key.flags & KBD_SHIFT) keyStr += "Shift+";
|
||||||
|
if (key.keycode >= 0 && key.keycode < keycodeDescTableSize)
|
||||||
|
keyStr += keycodeDescTable[key.keycode];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyStr.empty()) keyStr += "???";
|
||||||
|
|
||||||
|
_keysStr.insertChar(KEY_START_CHAR, _strPos++);
|
||||||
const char *k = keyStr.c_str();
|
const char *k = keyStr.c_str();
|
||||||
while (char ch = *k++)
|
while (char ch = *k++)
|
||||||
_str.insertChar(ch, _strPos++);
|
_keysStr.insertChar(ch, _strPos++);
|
||||||
|
_keysStr.insertChar(KEY_END_CHAR, _strPos++);
|
||||||
|
|
||||||
VirtualKeyPress kp;
|
VirtualKeyPress kp;
|
||||||
kp.key = key;
|
kp.key = key;
|
||||||
kp.strLen = keyStr.size();
|
kp.strLen = keyStr.size() + 2;
|
||||||
_keys.insert(_keyPos, kp);
|
_keys.insert(_keyPos, kp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +303,7 @@ void VirtualKeyboard::KeyPressQueue::deleteKey() {
|
||||||
it--;
|
it--;
|
||||||
_strPos -= it->strLen;
|
_strPos -= it->strLen;
|
||||||
while((it->strLen)-- > 0)
|
while((it->strLen)-- > 0)
|
||||||
_str.deleteChar(_strPos);
|
_keysStr.deleteChar(_strPos);
|
||||||
_keys.erase(it);
|
_keys.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +332,7 @@ KeyState VirtualKeyboard::KeyPressQueue::pop() {
|
||||||
_strPos -= kp.strLen;
|
_strPos -= kp.strLen;
|
||||||
|
|
||||||
while (kp.strLen-- > 0)
|
while (kp.strLen-- > 0)
|
||||||
_str.deleteChar(0);
|
_keysStr.deleteChar(0);
|
||||||
|
|
||||||
return kp.key;
|
return kp.key;
|
||||||
}
|
}
|
||||||
|
@ -316,9 +340,9 @@ KeyState VirtualKeyboard::KeyPressQueue::pop() {
|
||||||
void VirtualKeyboard::KeyPressQueue::clear() {
|
void VirtualKeyboard::KeyPressQueue::clear() {
|
||||||
_keys.clear();
|
_keys.clear();
|
||||||
_keyPos = _keys.end();
|
_keyPos = _keys.end();
|
||||||
_str.clear();
|
_keysStr.clear();
|
||||||
_strPos = 0;
|
_strPos = 0;
|
||||||
_keyFlags = 0;
|
_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VirtualKeyboard::KeyPressQueue::empty()
|
bool VirtualKeyboard::KeyPressQueue::empty()
|
||||||
|
@ -328,18 +352,25 @@ bool VirtualKeyboard::KeyPressQueue::empty()
|
||||||
|
|
||||||
String VirtualKeyboard::KeyPressQueue::getString()
|
String VirtualKeyboard::KeyPressQueue::getString()
|
||||||
{
|
{
|
||||||
String flags;
|
if (_keysStr.empty())
|
||||||
if (_keyFlags & KBD_CTRL)
|
return _flagsStr;
|
||||||
flags += "Ctrl+";
|
if (_flagsStr.empty())
|
||||||
if (_keyFlags & KBD_ALT)
|
return _keysStr;
|
||||||
flags += "Alt+";
|
if (_strPos == _keysStr.size())
|
||||||
if (_keyFlags & KBD_SHIFT)
|
return _keysStr + _flagsStr;
|
||||||
flags += "Shift+";
|
|
||||||
return _str + flags;
|
uint len = _keysStr.size() + _flagsStr.size();
|
||||||
|
char *str = new char[len];
|
||||||
|
memcpy(str, _keysStr.c_str(), _strPos);
|
||||||
|
memcpy(str + _strPos, _flagsStr.c_str(), _flagsStr.size());
|
||||||
|
memcpy(str + _strPos + _flagsStr.size(), _keysStr.c_str() + _strPos, _keysStr.size() - _strPos);
|
||||||
|
String ret(str, len);
|
||||||
|
delete[] str;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint VirtualKeyboard::KeyPressQueue::getInsertIndex() {
|
uint VirtualKeyboard::KeyPressQueue::getInsertIndex() {
|
||||||
return _strPos;
|
return _strPos + _flagsStr.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VirtualKeyboard::KeyPressQueue::hasStringChanged() {
|
bool VirtualKeyboard::KeyPressQueue::hasStringChanged() {
|
||||||
|
|
|
@ -118,10 +118,12 @@ protected:
|
||||||
bool hasStringChanged();
|
bool hasStringChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
byte _keyFlags;
|
byte _flags;
|
||||||
|
String _flagsStr;
|
||||||
|
|
||||||
|
|
||||||
List<VirtualKeyPress> _keys;
|
List<VirtualKeyPress> _keys;
|
||||||
String _str;
|
String _keysStr;
|
||||||
|
|
||||||
bool _strChanged;
|
bool _strChanged;
|
||||||
|
|
||||||
|
@ -129,6 +131,8 @@ protected:
|
||||||
uint _strPos;
|
uint _strPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VirtualKeyboard();
|
VirtualKeyboard();
|
||||||
virtual ~VirtualKeyboard();
|
virtual ~VirtualKeyboard();
|
||||||
|
|
|
@ -1044,6 +1044,10 @@
|
||||||
RelativePath="..\..\backends\vkeybd\image-map.h"
|
RelativePath="..\..\backends\vkeybd\image-map.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\backends\vkeybd\keycode-descriptions.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\backends\vkeybd\polygon.cpp"
|
RelativePath="..\..\backends\vkeybd\polygon.cpp"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue