[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/3 V3] lib: add virtkey



Add virtkey lib for usage-improvment and keycode translating.
Add 4 internal API for the aim

const char *virKeycodeSetName(virKeycodeSet codeset);
virKeycodeSet virParseKeycodeSet(const char *name);
int virParseKeyName(virKeycodeSet codeset, const char *keyname);
int virTranslateKeyCode(virKeycodeSet from_codeset,
                        virKeycodeSet to_offset,
                        int key_value);

Signed-off-by: Lai Jiangshan <laijs cn fujitsu com>
---
 include/libvirt/libvirt.h.in |    6 +
 src/Makefile.am              |    3 +-
 src/libvirt_private.syms     |    5 +
 src/util/virtkey.c           |  633 ++++++++++++++++++++++++++++++++++++++++++
 src/util/virtkey.h           |   21 ++
 tools/virsh.c                |    1 +
 6 files changed, 668 insertions(+), 1 deletions(-)
 create mode 100644 src/util/virtkey.c
 create mode 100644 src/util/virtkey.h

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 3f634e6..2f2efe7 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1815,6 +1815,12 @@ typedef enum {
     VIR_KEYCODE_SET_ATSET1         = 2,
     VIR_KEYCODE_SET_ATSET2         = 3,
     VIR_KEYCODE_SET_ATSET3         = 4,
+    VIR_KEYCODE_SET_OSX            = 5,
+    VIR_KEYCODE_SET_XT_KBD         = 6,
+    VIR_KEYCODE_SET_USB            = 7,
+    VIR_KEYCODE_SET_WIN32          = 8,
+    VIR_KEYCODE_SET_XWIN_XT        = 9,
+    VIR_KEYCODE_SET_XFREE86_KBD_XT = 10,
 } virKeycodeSet;
 
 /**
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f9bfc9..e34ea74 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -81,7 +81,8 @@ UTIL_SOURCES =							\
 		util/util.c util/util.h				\
 		util/xml.c util/xml.h				\
 		util/virtaudit.c util/virtaudit.h               \
-		util/virterror.c util/virterror_internal.h
+		util/virterror.c util/virterror_internal.hi	\
+		util/virtkey.c util/virtkey.h
 
 EXTRA_DIST += util/threads-pthread.c util/threads-win32.c
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 09b0159..151e256 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1059,6 +1059,11 @@ virSetError;
 virSetErrorLogPriorityFunc;
 virStrerror;
 
+# virtkey.h
+virKeycodeSetName;
+virParseKeycodeSet;
+virParseKeyName;
+virTranslateKeyCode;
 
 # xml.h
 virXMLParseFileHelper;
diff --git a/src/util/virtkey.c b/src/util/virtkey.c
new file mode 100644
index 0000000..48fbfcc
--- /dev/null
+++ b/src/util/virtkey.c
@@ -0,0 +1,633 @@
+
+/*
+ * Copyright (c) 2011 Lai Jiangshan
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <config.h>
+#include <string.h>
+#include <stddef.h>
+#include <libvirt/libvirt.h>
+#include "virtkey.h"
+
+#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
+#define getfield(object, field_type, field_offset) \
+    (*(typeof(field_type) *)((char *)(object) + field_offset))
+
+struct keycode {
+    const char *linux_name;
+    const char *os_x_name;
+    const char *win32_name;
+    unsigned short linux_keycode;
+    unsigned short xt;
+    unsigned short atset1;
+    unsigned short atset2;
+    unsigned short atset3;
+    unsigned short os_x;
+    unsigned short xt_kbd;
+    unsigned short usb;
+    unsigned short win32;
+    unsigned short xwin_xt;
+    unsigned short xfree86_kbd_xt;
+};
+
+/*
+ * generated from http://git.gnome.org/browse/gtk-vnc/plain/src/keymaps.csv
+ * script:
+ *
+ * #!/bin/python
+ * import sys
+ * import re
+ *
+ * for line in sys.stdin.xreadlines():
+ *     a = re.match("([^,]*)," * 13 + "([^,]*)$", line[0:-1]).groups()
+ *     b = ""
+ *     for i in (0,2,10,1,7,4,5,6,3,8,9,11,12,13):
+ *         if i in (0, 2, 10):
+ *             b = b + (a[i] and ('"' + a[i] + '"') or 'NULL') + ','
+ *         else:
+ *             b = b + (a[i] or '0') + ','
+ *     print "    { " + b + "},"
+ */
+static struct keycode keycodes[] = {
+    { "KEY_RESERVED",NULL,NULL,0,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ESC","Escape","VK_ESCAPE",1,1,1,118,8,0x35,1,41,0x1b,1,1,},
+    { "KEY_1","ANSI_1","VK_1",2,2,2,22,22,0x12,2,30,0x31,2,2,},
+    { "KEY_2","ANSI_2","VK_2",3,3,3,30,30,0x13,3,31,0x32,3,3,},
+    { "KEY_3","ANSI_3","VK_3",4,4,4,38,38,0x14,4,32,0x33,4,4,},
+    { "KEY_4","ANSI_4","VK_4",5,5,5,37,37,0x15,5,33,0x34,5,5,},
+    { "KEY_5","ANSI_5","VK_5",6,6,6,46,46,0x17,6,34,0x35,6,6,},
+    { "KEY_6","ANSI_6","VK_6",7,7,7,54,54,0x16,7,35,0x36,7,7,},
+    { "KEY_7","ANSI_7","VK_7",8,8,8,61,61,0x1a,8,36,0x37,8,8,},
+    { "KEY_8","ANSI_8","VK_8",9,9,9,62,62,0x1c,9,37,0x38,9,9,},
+    { "KEY_9","ANSI_9","VK_9",10,10,10,70,70,0x19,10,38,0x39,10,10,},
+    { "KEY_0","ANSI_0","VK_0",11,11,11,69,69,0x1d,11,39,0x30,11,11,},
+    { "KEY_MINUS","ANSI_Minus","VK_OEM_MINUS",12,12,12,78,78,0x1b,12,45,0xbd,12,12,},
+    { "KEY_EQUAL","ANSI_Equal","VK_OEM_PLUS",13,13,13,85,85,0x18,13,46,0xbb,13,13,},
+    { "KEY_BACKSPACE","Delete","VK_BACK",14,14,14,102,102,0x33,14,42,0x08,14,14,},
+    { "KEY_TAB","Tab","VK_TAB",15,15,15,13,13,0x30,15,43,0x09,15,15,},
+    { "KEY_Q","ANSI_Q","VK_Q",16,16,16,21,21,0xc,16,20,0x51,16,16,},
+    { "KEY_W","ANSI_W","VK_W",17,17,17,29,29,0xd,17,26,0x57,17,17,},
+    { "KEY_E","ANSI_E","VK_E",18,18,18,36,36,0xe,18,8,0x45,18,18,},
+    { "KEY_R","ANSI_R","VK_R",19,19,19,45,45,0xf,19,21,0x52,19,19,},
+    { "KEY_T","ANSI_T","VK_T",20,20,20,44,44,0x11,20,23,0x54,20,20,},
+    { "KEY_Y","ANSI_Y","VK_Y",21,21,21,53,53,0x10,21,28,0x59,21,21,},
+    { "KEY_U","ANSI_U","VK_U",22,22,22,60,60,0x20,22,24,0x55,22,22,},
+    { "KEY_I","ANSI_I","VK_I",23,23,23,67,67,0x22,23,12,0x49,23,23,},
+    { "KEY_O","ANSI_O","VK_O",24,24,24,68,68,0x1f,24,18,0x4f,24,24,},
+    { "KEY_P","ANSI_P","VK_P",25,25,25,77,77,0x23,25,19,0x50,25,25,},
+    { "KEY_LEFTBRACE","ANSI_LeftBracket","VK_OEM_4",26,26,26,84,84,0x21,26,47,0xdb,26,26,},
+    { "KEY_RIGHTBRACE","ANSI_RightBracket","VK_OEM_6",27,27,27,91,91,0x1e,27,48,0xdd,27,27,},
+    { "KEY_ENTER","Return","VK_RETURN",28,28,28,90,90,0x24,28,40,0x0d,28,28,},
+    { "KEY_LEFTCTRL","Control","VK_LCONTROL",29,29,29,20,17,0x3b,29,224,0xa2,29,29,},
+    { "KEY_A","ANSI_A","VK_A",30,30,30,28,28,0x0,30,4,0x41,30,30,},
+    { "KEY_S","ANSI_S","VK_S",31,31,31,27,27,0x1,31,22,0x53,31,31,},
+    { "KEY_D","ANSI_D","VK_D",32,32,32,35,35,0x2,32,7,0x44,32,32,},
+    { "KEY_F","ANSI_F","VK_F",33,33,33,43,43,0x3,33,9,0x46,33,33,},
+    { "KEY_G","ANSI_G","VK_G",34,34,34,52,52,0x5,34,10,0x47,34,34,},
+    { "KEY_H","ANSI_H","VK_H",35,35,35,51,51,0x4,35,11,0x48,35,35,},
+    { "KEY_J","ANSI_J","VK_J",36,36,36,59,59,0x26,36,13,0x4a,36,36,},
+    { "KEY_K","ANSI_K","VK_K",37,37,37,66,66,0x28,37,14,0x4b,37,37,},
+    { "KEY_L","ANSI_L","VK_L",38,38,38,75,75,0x25,38,15,0x4c,38,38,},
+    { "KEY_SEMICOLON","ANSI_Semicolon","VK_OEM_1",39,39,39,76,76,0x29,39,51,0xba,39,39,},
+    { "KEY_APOSTROPHE","ANSI_Quote","VK_OEM_2",40,40,40,82,82,0x27,40,52,0xbf,40,40,},
+    { "KEY_GRAVE","ANSI_Grave","VK_OEM_3",41,41,41,14,14,0x32,41,53,0xc0,41,41,},
+    { "KEY_LEFTSHIFT","Shift","VK_LSHIFT",42,42,42,18,18,0x38,42,225,0xa0,42,42,},
+    { "KEY_BACKSLASH","ANSI_Backslash","VK_OEM_5",43,43,43,93,93,0x2a,43,50,0xdc,43,43,},
+    { "KEY_Z","ANSI_Z","VK_Z",44,44,44,26,26,0x6,44,29,0x5a,44,44,},
+    { "KEY_X","ANSI_X","VK_X",45,45,45,34,34,0x7,45,27,0x58,45,45,},
+    { "KEY_C","ANSI_C","VK_C",46,46,46,33,33,0x8,46,6,0x43,46,46,},
+    { "KEY_V","ANSI_V","VK_V",47,47,47,42,42,0x9,47,25,0x56,47,47,},
+    { "KEY_B","ANSI_B","VK_B",48,48,48,50,50,0xb,48,5,0x42,48,48,},
+    { "KEY_N","ANSI_N","VK_N",49,49,49,49,49,0x2d,49,17,0x4e,49,49,},
+    { "KEY_M","ANSI_M","VK_M",50,50,50,58,58,0x2e,50,16,0x4d,50,50,},
+    { "KEY_COMMA","ANSI_Comma","VK_OEM_COMMA",51,51,51,65,65,0x2b,51,54,0xbc,51,51,},
+    { "KEY_DOT","ANSI_Period","VK_OEM_PERIOD",52,52,52,73,73,0x2f,52,55,0xbe,52,52,},
+    { "KEY_SLASH","ANSI_Slash","VK_OEM_2",53,53,53,74,74,0x2c,53,56,0xbf,53,53,},
+    { "KEY_RIGHTSHIFT","RightShift","VK_RSHIFT",54,54,54,89,89,0x3c,54,229,0xa1,54,54,},
+    { "KEY_KPASTERISK","ANSI_KeypadMultiply","VK_MULTIPLY",55,55,55,124,126,0x43,55,85,0x6a,55,55,},
+    { "KEY_LEFTALT","Option","VK_LMENU",56,56,56,17,25,0x3a,56,226,0xa4,56,56,},
+    { "KEY_SPACE","Space","VK_SPACE",57,57,57,41,41,0x31,57,44,0x20,57,57,},
+    { "KEY_CAPSLOCK","CapsLock","VK_CAPITAL",58,58,58,88,20,0x39,58,57,0x14,58,58,},
+    { "KEY_F1","F1","VK_F1",59,59,59,5,7,0x7a,59,58,0x70,59,59,},
+    { "KEY_F2","F2","VK_F2",60,60,60,6,15,0x78,60,59,0x71,60,60,},
+    { "KEY_F3","F3","VK_F3",61,61,61,4,23,0x63,61,60,0x72,61,61,},
+    { "KEY_F4","F4","VK_F4",62,62,62,12,31,0x76,62,61,0x73,62,62,},
+    { "KEY_F5","F5","VK_F5",63,63,63,3,39,0x60,63,62,0x74,63,63,},
+    { "KEY_F6","F6","VK_F6",64,64,64,11,47,0x61,64,63,0x75,64,64,},
+    { "KEY_F7","F7","VK_F7",65,65,65,259,55,0x62,65,64,0x76,65,65,},
+    { "KEY_F8","F8","VK_F8",66,66,66,10,63,0x64,66,65,0x77,66,66,},
+    { "KEY_F9","F9","VK_F9",67,67,67,1,71,0x65,67,66,0x78,67,67,},
+    { "KEY_F10","F10","VK_F10",68,68,68,9,79,0x6d,68,67,0x79,68,68,},
+    { "KEY_NUMLOCK",NULL,"VK_NUMLOCK",69,69,69,119,118,0,69,83,0x90,69,69,},
+    { "KEY_SCROLLLOCK",NULL,"VK_SCROLL",70,70,70,126,95,0,70,71,0x91,70,70,},
+    { "KEY_KP7","ANSI_Keypad7","VK_NUMPAD7",71,71,71,108,108,0x59,71,95,0x67,71,71,},
+    { "KEY_KP8","ANSI_Keypad8","VK_NUMPAD8",72,72,72,117,117,0x5b,72,96,0x68,72,72,},
+    { "KEY_KP9","ANSI_Keypad9","VK_NUMPAD9",73,73,73,125,125,0x5c,73,97,0x69,73,73,},
+    { "KEY_KPMINUS","ANSI_KeypadMinus","VK_SUBTRACT",74,74,74,123,132,0x4e,74,86,0x6d,74,74,},
+    { "KEY_KP4","ANSI_Keypad4","VK_NUMPAD4",75,75,75,107,107,0x56,75,92,0x64,75,75,},
+    { "KEY_KP5","ANSI_Keypad5","VK_NUMPAD5",76,76,76,115,115,0x57,76,93,0x65,76,76,},
+    { "KEY_KP6","ANSI_Keypad6","VK_NUMPAD6",77,77,77,116,116,0x58,77,94,0x66,77,77,},
+    { "KEY_KPPLUS","ANSI_KeypadPlus","VK_ADD",78,78,78,121,124,0x45,78,87,0x6b,78,78,},
+    { "KEY_KP1","ANSI_Keypad1","VK_NUMPAD1",79,79,79,105,105,0x53,79,89,0x61,79,79,},
+    { "KEY_KP2","ANSI_Keypad2","VK_NUMPAD2",80,80,80,114,114,0x54,80,90,0x62,80,80,},
+    { "KEY_KP3","ANSI_Keypad3","VK_NUMPAD3",81,81,81,122,122,0x55,81,91,0x63,81,81,},
+    { "KEY_KP0","ANSI_Keypad0","VK_NUMPAD0",82,82,82,112,112,0x52,82,98,0x60,82,82,},
+    { "KEY_KPDOT","ANSI_KeypadDecimal","VK_DECIMAL",83,83,83,113,113,0x41,83,99,0x6e,83,83,},
+    { NULL,NULL,NULL,84,0,0,0,0,0,84,0,0,0,0,},
+    { "KEY_ZENKAKUHANKAKU",NULL,NULL,85,0,118,95,0,0,118,148,0,0,0,},
+    { "KEY_102ND",NULL,"VK_OEM_102",86,0,86,97,19,0,86,100,0xe1,0,0,},
+    { "KEY_F11","F11","VK_F11",87,101,87,120,86,0x67,87,68,0x7a,0,0,},
+    { "KEY_F12","F12","VK_F12",88,102,88,7,94,0x6f,88,69,0x7b,0,0,},
+    { "KEY_RO",NULL,NULL,89,0,115,81,0,0,115,135,0,0,0,},
+    { "KEY_KATAKANA","JIS_Kana????","VK_KANA",90,0,120,99,0,0x68,120,146,0x15,0,0,},
+    { "KEY_HIRAGANA",NULL,NULL,91,0,119,98,0,0,119,147,0,0,0,},
+    { "KEY_HENKAN",NULL,NULL,92,0,121,100,134,0,121,138,0,0,0,},
+    { "KEY_KATAKANAHIRAGANA",NULL,NULL,93,0,112,19,135,0,112,136,0,0xc8,0xc8,},
+    { "KEY_MUHENKAN",NULL,NULL,94,0,123,103,133,0,123,139,0,0,0,},
+    { "KEY_KPJPCOMMA","JIS_KeypadComma",NULL,95,0,92,39,0,0x5f,92,140,0,0,0,},
+    { "KEY_KPENTER","ANSI_KeypadEnter",NULL,96,0,0,158,121,0x4c,284,88,0,0x64,0x64,},
+    { "KEY_RIGHTCTRL","RightControl","VK_RCONTROL",97,0,0,0,88,0x3e,285,228,0xa3,0x65,0x65,},
+    { "KEY_KPSLASH","ANSI_KeypadDivide","VK_DIVIDE",98,0,0,181,119,0x4b,309,84,0x6f,0x68,0x68,},
+    { "KEY_SYSRQ",NULL,"VK_SNAPSHOT ???",99,0,84,260,87,0,84,70,0x2c,0x67,0x67,},
+    { "KEY_RIGHTALT","RightOption","VK_RMENU",100,0,0,0,57,0x3d,312,230,0xa5,0x69,0x69,},
+    { "KEY_LINEFEED",NULL,NULL,101,0,0,0,0,0,91,0,0,0,0,},
+    { "KEY_HOME","Home","VK_HOME",102,0,0,224,110,0x73,327,74,0x24,0x59,0x59,},
+    { "KEY_UP","UpArrow","VK_UP",103,109,0,236,99,0x7e,328,82,0x26,0x5a,0x5a,},
+    { "KEY_PAGEUP","PageUp","VK_PRIOR",104,0,0,201,111,0x74,329,75,0x21,0x5b,0x5b,},
+    { "KEY_LEFT","LeftArrow","VK_LEFT",105,111,0,203,97,0x7b,331,80,0x25,0x5c,0x5c,},
+    { "KEY_RIGHT","RightArrow","VK_RIGHT",106,112,0,205,106,0x7c,333,79,0x27,0x5e,0x5e,},
+    { "KEY_END","End","VK_END",107,0,0,225,101,0x77,335,77,0x23,0x5f,0x5f,},
+    { "KEY_DOWN","DownArrow","VK_DOWN",108,110,0,254,96,0x7d,336,81,0x28,0x60,0x60,},
+    { "KEY_PAGEDOWN","PageDown","VK_NEXT",109,0,0,243,109,0x79,337,78,0x22,0x61,0x61,},
+    { "KEY_INSERT",NULL,"VK_INSERT",110,107,0,210,103,0,338,73,0x2d,0x62,0x62,},
+    { "KEY_DELETE","ForwardDelete","VK_DELETE",111,108,0,244,100,0x75,339,76,0x2e,0x63,0x63,},
+    { "KEY_MACRO",NULL,NULL,112,0,0,239,142,0,367,0,0,0,0,},
+    { "KEY_MUTE","Mute","VK_VOLUME_MUTE",113,0,0,251,156,0x4a,288,239,0xad,0,0,},
+    { "KEY_VOLUMEDOWN","VolumeDown","VK_VOLUME_DOWN",114,0,0,0,157,0x49,302,238,0xae,0,0,},
+    { "KEY_VOLUMEUP","VolumeUp","VK_VOLUME_UP",115,0,0,233,149,0x48,304,237,0xaf,0,0,},
+    { "KEY_POWER",NULL,NULL,116,0,0,0,0,0,350,102,0,0,0,},
+    { "KEY_KPEQUAL","ANSI_KeypadEquals",NULL,117,0,89,15,0,0x51,89,103,0,0x76,0x76,},
+    { "KEY_KPPLUSMINUS",NULL,NULL,118,0,0,206,0,0,334,0,0,0,0,},
+    { "KEY_PAUSE",NULL,"VK_PAUSE",119,0,0,198,98,0,326,72,0x013,0x66,0x66,},
+    { "KEY_SCALE",NULL,NULL,120,0,0,0,0,0,267,0,0,0,0,},
+    { "KEY_KPCOMMA","ANSI_KeypadClear????","VK_SEPARATOR??",121,0,126,109,0,0x47,126,133,0x6c,0,0,},
+    { "KEY_HANGEUL",NULL,"VK_HANGEUL",122,0,0,0,0,0,0,144,0x15,0,0,},
+    { "KEY_HANJA",NULL,"VK_HANJA",123,0,0,0,0,0,269,145,0x19,0,0,},
+    { "KEY_YEN","JIS_Yen",NULL,124,0,125,106,0,0x5d,125,137,0,0x7d,0x7d,},
+    { "KEY_LEFTMETA","Command","VK_LWIN",125,0,0,0,139,0x37,347,227,0x5b,0x6b,0x6b,},
+    { "KEY_RIGHTMETA",NULL,"VK_RWIN",126,0,0,0,140,0,348,231,0x5c,0x6c,0x6c,},
+    { "KEY_COMPOSE","Function","VK_APPS",127,0,0,0,141,0x3f,349,101,0x5d,0x6d,0x6d,},
+    { "KEY_STOP",NULL,"VK_BROWSER_STOP",128,0,0,0,10,0,360,243,0xa9,0,0,},
+    { "KEY_AGAIN",NULL,NULL,129,0,0,0,11,0,261,121,0,0,0,},
+    { "KEY_PROPS",NULL,NULL,130,0,0,0,12,0,262,118,0,0,0,},
+    { "KEY_UNDO",NULL,NULL,131,0,0,0,16,0,263,122,0,0,0,},
+    { "KEY_FRONT",NULL,NULL,132,0,0,0,0,0,268,119,0,0,0,},
+    { "KEY_COPY",NULL,NULL,133,0,0,0,24,0,376,124,0,0,0,},
+    { "KEY_OPEN",NULL,NULL,134,0,0,0,32,0,100,116,0,0,0,},
+    { "KEY_PASTE",NULL,NULL,135,0,0,0,40,0,101,125,0,0,0,},
+    { "KEY_FIND",NULL,NULL,136,0,0,0,48,0,321,244,0,0,0,},
+    { "KEY_CUT",NULL,NULL,137,0,0,0,56,0,316,123,0,0,0,},
+    { "KEY_HELP",NULL,"VK_HELP",138,0,0,0,9,0,373,117,0x2f,0,0,},
+    { "KEY_MENU",NULL,NULL,139,0,0,0,145,0,286,0,0,0,0,},
+    { "KEY_CALC",NULL,NULL,140,0,0,174,163,0,289,251,0,0,0,},
+    { "KEY_SETUP",NULL,NULL,141,0,0,0,0,0,102,0,0,0,0,},
+    { "KEY_SLEEP",NULL,"VK_SLEEP",142,0,0,0,0,0,351,248,0x5f,0,0,},
+    { "KEY_WAKEUP",NULL,NULL,143,0,0,0,0,0,355,0,0,0,0,},
+    { "KEY_FILE",NULL,NULL,144,0,0,0,0,0,103,0,0,0,0,},
+    { "KEY_SENDFILE",NULL,NULL,145,0,0,0,0,0,104,0,0,0,0,},
+    { "KEY_DELETEFILE",NULL,NULL,146,0,0,0,0,0,105,0,0,0,0,},
+    { "KEY_XFER",NULL,NULL,147,0,0,0,162,0,275,0,0,0,0,},
+    { "KEY_PROG1",NULL,NULL,148,0,0,0,160,0,287,0,0,0,0,},
+    { "KEY_PROG2",NULL,NULL,149,0,0,0,161,0,279,0,0,0,0,},
+    { "KEY_WWW",NULL,NULL,150,0,0,0,0,0,258,240,0,0,0,},
+    { "KEY_MSDOS",NULL,NULL,151,0,0,0,0,0,106,0,0,0,0,},
+    { "KEY_SCREENLOCK",NULL,NULL,152,0,0,0,150,0,274,249,0,0,0,},
+    { "KEY_DIRECTION",NULL,NULL,153,0,0,0,0,0,107,0,0,0,0,},
+    { "KEY_CYCLEWINDOWS",NULL,NULL,154,0,0,0,155,0,294,0,0,0,0,},
+    { "KEY_MAIL",NULL,NULL,155,0,0,0,0,0,364,0,0,0,0,},
+    { "KEY_BOOKMARKS",NULL,NULL,156,0,0,0,0,0,358,0,0,0,0,},
+    { "KEY_COMPUTER",NULL,NULL,157,0,0,0,0,0,363,0,0,0,0,},
+    { "KEY_BACK",NULL,"VK_BROWSER_BACK",158,0,0,0,0,0,362,241,0xa6,0,0,},
+    { "KEY_FORWARD",NULL,"VK_BROWSER_FORWARD",159,0,0,0,0,0,361,242,0xa7,0,0,},
+    { "KEY_CLOSECD",NULL,NULL,160,0,0,0,154,0,291,0,0,0,0,},
+    { "KEY_EJECTCD",NULL,NULL,161,0,0,0,0,0,108,236,0,0,0,},
+    { "KEY_EJECTCLOSECD",NULL,NULL,162,0,0,0,0,0,381,0,0,0,0,},
+    { "KEY_NEXTSONG",NULL,"VK_MEDIA_NEXT_TRACK",163,0,0,241,147,0,281,235,0xb0,0,0,},
+    { "KEY_PLAYPAUSE",NULL,"VK_MEDIA_PLAY_PAUSE",164,0,0,173,0,0,290,232,0xb3,0,0,},
+    { "KEY_PREVIOUSSONG",NULL,"VK_MEDIA_PREV_TRACK",165,0,0,250,148,0,272,234,0xb1,0,0,},
+    { "KEY_STOPCD",NULL,"VK_MEDIA_STOP",166,0,0,164,152,0,292,233,0xb2,0,0,},
+    { "KEY_RECORD",NULL,NULL,167,0,0,0,158,0,305,0,0,0,0,},
+    { "KEY_REWIND",NULL,NULL,168,0,0,0,159,0,280,0,0,0,0,},
+    { "KEY_PHONE",NULL,NULL,169,0,0,0,0,0,99,0,0,0,0,},
+    { "KEY_ISO","ISO_Section",NULL,170,0,0,0,0,0xa,112,0,0,0,0,},
+    { "KEY_CONFIG",NULL,NULL,171,0,0,0,0,0,257,0,0,0,0,},
+    { "KEY_HOMEPAGE",NULL,"VK_BROWSER_HOME",172,0,0,178,151,0,306,0,0xac,0,0,},
+    { "KEY_REFRESH",NULL,"VK_BROWSER_REFRESH",173,0,0,0,0,0,359,250,0xa8,0,0,},
+    { "KEY_EXIT",NULL,NULL,174,0,0,0,0,0,113,0,0,0,0,},
+    { "KEY_MOVE",NULL,NULL,175,0,0,0,0,0,114,0,0,0,0,},
+    { "KEY_EDIT",NULL,NULL,176,0,0,0,0,0,264,247,0,0,0,},
+    { "KEY_SCROLLUP",NULL,NULL,177,0,0,0,0,0,117,245,0,0,0,},
+    { "KEY_SCROLLDOWN",NULL,NULL,178,0,0,0,0,0,271,246,0,0,0,},
+    { "KEY_KPLEFTPAREN",NULL,NULL,179,0,0,0,0,0,374,182,0,0,0,},
+    { "KEY_KPRIGHTPAREN",NULL,NULL,180,0,0,0,0,0,379,183,0,0,0,},
+    { "KEY_NEW",NULL,NULL,181,0,0,0,0,0,265,0,0,0,0,},
+    { "KEY_REDO",NULL,NULL,182,0,0,0,0,0,266,0,0,0,0,},
+    { "KEY_F13","F13","VK_F13",183,0,93,47,127,0x69,93,104,0x7c,0x6e,0x6e,},
+    { "KEY_F14","F14","VK_F14",184,0,94,55,128,0x6b,94,105,0x7d,0x6f,0x6f,},
+    { "KEY_F15","F15","VK_F15",185,0,95,63,129,0x71,95,106,0x7e,0x70,0x70,},
+    { "KEY_F16","F16","VK_F16",186,0,0,0,130,0x6a,85,107,0x7f,0x71,0x71,},
+    { "KEY_F17","F17","VK_F17",187,0,0,0,131,0x40,259,108,0x80,0x72,0x72,},
+    { "KEY_F18","F18","VK_F18",188,0,0,0,0,0x4f,375,109,0x81,0,0,},
+    { "KEY_F19","F19","VK_F19",189,0,0,0,0,0x50,260,110,0x82,0,0,},
+    { "KEY_F20","F20","VK_F20",190,0,0,0,0,0x5a,90,111,0x83,0,0,},
+    { "KEY_F21",NULL,"VK_F21",191,0,0,0,0,0,116,112,0x84,0,0,},
+    { "KEY_F22",NULL,"VK_F22",192,0,0,0,0,0,377,113,0x85,0,0,},
+    { "KEY_F23",NULL,"VK_F23",193,0,0,0,0,0,109,114,0x86,0,0,},
+    { "KEY_F24",NULL,"VK_F24",194,0,0,0,0,0,111,115,0x87,0,0,},
+    { NULL,NULL,NULL,195,0,0,0,0,0,277,0,0,0,0,},
+    { NULL,NULL,NULL,196,0,0,0,0,0,278,0,0,0,0,},
+    { NULL,NULL,NULL,197,0,0,0,0,0,282,0,0,0,0,},
+    { NULL,NULL,NULL,198,0,0,0,0,0,283,0,0,0,0,},
+    { NULL,NULL,NULL,199,0,0,0,0,0,295,0,0,0,0,},
+    { "KEY_PLAYCD",NULL,NULL,200,0,0,0,0,0,296,0,0,0,0,},
+    { "KEY_PAUSECD",NULL,NULL,201,0,0,0,0,0,297,0,0,0,0,},
+    { "KEY_PROG3",NULL,NULL,202,0,0,0,0,0,299,0,0,0,0,},
+    { "KEY_PROG4",NULL,NULL,203,0,0,0,0,0,300,0,0,0,0,},
+    { "KEY_DASHBOARD",NULL,NULL,204,0,0,0,0,0,301,0,0,0,0,},
+    { "KEY_SUSPEND",NULL,NULL,205,0,0,0,0,0,293,0,0,0,0,},
+    { "KEY_CLOSE",NULL,NULL,206,0,0,0,0,0,303,0,0,0,0,},
+    { "KEY_PLAY",NULL,"VK_PLAY",207,0,0,0,0,0,307,0,0xfa,0,0,},
+    { "KEY_FASTFORWARD",NULL,NULL,208,0,0,0,0,0,308,0,0,0,0,},
+    { "KEY_BASSBOOST",NULL,NULL,209,0,0,0,0,0,310,0,0,0,0,},
+    { "KEY_PRINT",NULL,"VK_PRINT",210,0,0,0,0,0,313,0,0x2a,0,0,},
+    { "KEY_HP",NULL,NULL,211,0,0,0,0,0,314,0,0,0,0,},
+    { "KEY_CAMERA",NULL,NULL,212,0,0,0,0,0,315,0,0,0,0,},
+    { "KEY_SOUND",NULL,NULL,213,0,0,0,0,0,317,0,0,0,0,},
+    { "KEY_QUESTION",NULL,NULL,214,0,0,0,0,0,318,0,0,0,0,},
+    { "KEY_EMAIL",NULL,"VK_LAUNCH_MAIL",215,0,0,0,0,0,319,0,0xb4,0,0,},
+    { "KEY_CHAT",NULL,NULL,216,0,0,0,0,0,320,0,0,0,0,},
+    { "KEY_SEARCH",NULL,"VK_BROWSER_SEARCH",217,0,0,0,0,0,357,0,0xaa,0,0,},
+    { "KEY_CONNECT",NULL,NULL,218,0,0,0,0,0,322,0,0,0,0,},
+    { "KEY_FINANCE",NULL,NULL,219,0,0,0,0,0,323,0,0,0,0,},
+    { "KEY_SPORT",NULL,NULL,220,0,0,0,0,0,324,0,0,0,0,},
+    { "KEY_SHOP",NULL,NULL,221,0,0,0,0,0,325,0,0,0,0,},
+    { "KEY_ALTERASE",NULL,NULL,222,0,0,0,0,0,276,0,0,0,0,},
+    { "KEY_CANCEL",NULL,NULL,223,0,0,0,0,0,330,0,0,0,0,},
+    { "KEY_BRIGHTNESSDOWN",NULL,NULL,224,0,0,0,0,0,332,0,0,0,0,},
+    { "KEY_BRIGHTNESSUP",NULL,NULL,225,0,0,0,0,0,340,0,0,0,0,},
+    { "KEY_MEDIA",NULL,NULL,226,0,0,0,0,0,365,0,0,0,0,},
+    { "KEY_SWITCHVIDEOMODE",NULL,NULL,227,0,0,0,0,0,342,0,0,0,0,},
+    { "KEY_KBDILLUMTOGGLE",NULL,NULL,228,0,0,0,0,0,343,0,0,0,0,},
+    { "KEY_KBDILLUMDOWN",NULL,NULL,229,0,0,0,0,0,344,0,0,0,0,},
+    { "KEY_KBDILLUMUP",NULL,NULL,230,0,0,0,0,0,345,0,0,0,0,},
+    { "KEY_SEND",NULL,NULL,231,0,0,0,0,0,346,0,0,0,0,},
+    { "KEY_REPLY",NULL,NULL,232,0,0,0,0,0,356,0,0,0,0,},
+    { "KEY_FORWARDMAIL",NULL,NULL,233,0,0,0,0,0,270,0,0,0,0,},
+    { "KEY_SAVE",NULL,NULL,234,0,0,0,0,0,341,0,0,0,0,},
+    { "KEY_DOCUMENTS",NULL,NULL,235,0,0,0,0,0,368,0,0,0,0,},
+    { "KEY_BATTERY",NULL,NULL,236,0,0,0,0,0,369,0,0,0,0,},
+    { "KEY_BLUETOOTH",NULL,NULL,237,0,0,0,0,0,370,0,0,0,0,},
+    { "KEY_WLAN",NULL,NULL,238,0,0,0,0,0,371,0,0,0,0,},
+    { "KEY_UWB",NULL,NULL,239,0,0,0,0,0,372,0,0,0,0,},
+    { "KEY_UNKNOWN",NULL,NULL,240,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VIDEO_NEXT",NULL,NULL,241,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VIDEO_PREV",NULL,NULL,242,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRIGHTNESS_CYCLE",NULL,NULL,243,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRIGHTNESS_ZERO",NULL,NULL,244,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DISPLAY_OFF",NULL,NULL,245,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_WIMAX",NULL,NULL,246,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,247,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,248,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,249,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,250,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,251,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,252,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,253,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,254,0,0,0,0,0,0,0,0,0,0,},
+    { NULL,NULL,NULL,255,0,0,182,0,0,0,0,0,0,0,},
+    { "BTN_MISC",NULL,NULL,0x100,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_0",NULL,"VK_LBUTTON",0x100,0,0,0,0,0,0,0,0x01,0,0,},
+    { "BTN_1",NULL,"VK_RBUTTON",0x101,0,0,0,0,0,0,0,0x02,0,0,},
+    { "BTN_2",NULL,"VK_MBUTTON",0x102,0,0,0,0,0,0,0,0x04,0,0,},
+    { "BTN_3",NULL,"VK_XBUTTON1",0x103,0,0,0,0,0,0,0,0x05,0,0,},
+    { "BTN_4",NULL,"VK_XBUTTON2",0x104,0,0,0,0,0,0,0,0x06,0,0,},
+    { "BTN_5",NULL,NULL,0x105,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_6",NULL,NULL,0x106,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_7",NULL,NULL,0x107,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_8",NULL,NULL,0x108,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_9",NULL,NULL,0x109,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_MOUSE",NULL,NULL,0x110,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_LEFT",NULL,NULL,0x110,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_RIGHT",NULL,NULL,0x111,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_MIDDLE",NULL,NULL,0x112,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_SIDE",NULL,NULL,0x113,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_EXTRA",NULL,NULL,0x114,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_FORWARD",NULL,NULL,0x115,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BACK",NULL,NULL,0x116,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TASK",NULL,NULL,0x117,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_JOYSTICK",NULL,NULL,0x120,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TRIGGER",NULL,NULL,0x120,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_THUMB",NULL,NULL,0x121,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_THUMB2",NULL,NULL,0x122,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOP",NULL,NULL,0x123,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOP2",NULL,NULL,0x124,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_PINKIE",NULL,NULL,0x125,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BASE",NULL,NULL,0x126,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BASE2",NULL,NULL,0x127,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BASE3",NULL,NULL,0x128,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BASE4",NULL,NULL,0x129,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BASE5",NULL,NULL,0x12a,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_BASE6",NULL,NULL,0x12b,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_DEAD",NULL,NULL,0x12f,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_GAMEPAD",NULL,NULL,0x130,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_A",NULL,NULL,0x130,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_B",NULL,NULL,0x131,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_C",NULL,NULL,0x132,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_X",NULL,NULL,0x133,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_Y",NULL,NULL,0x134,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_Z",NULL,NULL,0x135,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TL",NULL,NULL,0x136,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TR",NULL,NULL,0x137,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TL2",NULL,NULL,0x138,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TR2",NULL,NULL,0x139,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_SELECT",NULL,NULL,0x13a,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_START",NULL,NULL,0x13b,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_MODE",NULL,NULL,0x13c,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_THUMBL",NULL,NULL,0x13d,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_THUMBR",NULL,NULL,0x13e,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_DIGI",NULL,NULL,0x140,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_PEN",NULL,NULL,0x140,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_RUBBER",NULL,NULL,0x141,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_BRUSH",NULL,NULL,0x142,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_PENCIL",NULL,NULL,0x143,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_AIRBRUSH",NULL,NULL,0x144,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_FINGER",NULL,NULL,0x145,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_MOUSE",NULL,NULL,0x146,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_LENS",NULL,NULL,0x147,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOUCH",NULL,NULL,0x14a,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_STYLUS",NULL,NULL,0x14b,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_STYLUS2",NULL,NULL,0x14c,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_DOUBLETAP",NULL,NULL,0x14d,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_TRIPLETAP",NULL,NULL,0x14e,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_TOOL_QUADTAP",NULL,NULL,0x14f,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_WHEEL",NULL,NULL,0x150,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_GEAR_DOWN",NULL,NULL,0x150,0,0,0,0,0,0,0,0,0,0,},
+    { "BTN_GEAR_UP",NULL,NULL,0x151,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_OK",NULL,NULL,0x160,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SELECT",NULL,"VK_SELECT",0x161,0,0,0,0,0,0,0,0x29,0,0,},
+    { "KEY_GOTO",NULL,NULL,0x162,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CLEAR",NULL,NULL,0x163,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_POWER2",NULL,NULL,0x164,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_OPTION",NULL,NULL,0x165,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_INFO",NULL,NULL,0x166,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TIME",NULL,NULL,0x167,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VENDOR",NULL,NULL,0x168,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ARCHIVE",NULL,NULL,0x169,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_PROGRAM",NULL,NULL,0x16a,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CHANNEL",NULL,NULL,0x16b,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FAVORITES",NULL,"VK_BROWSER_FAVOURITES",0x16c,0,0,0,0,0,0,0,0xab,0,0,},
+    { "KEY_EPG",NULL,NULL,0x16d,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_PVR",NULL,NULL,0x16e,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_MHP",NULL,NULL,0x16f,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_LANGUAGE",NULL,NULL,0x170,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TITLE",NULL,NULL,0x171,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SUBTITLE",NULL,NULL,0x172,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ANGLE",NULL,NULL,0x173,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ZOOM",NULL,"VK_ZOOM",0x174,0,0,0,0,0,0,0,0xfb,0,0,},
+    { "KEY_MODE",NULL,NULL,0x175,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_KEYBOARD",NULL,NULL,0x176,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SCREEN",NULL,NULL,0x177,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_PC",NULL,NULL,0x178,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TV",NULL,NULL,0x179,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TV2",NULL,NULL,0x17a,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VCR",NULL,NULL,0x17b,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VCR2",NULL,NULL,0x17c,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SAT",NULL,NULL,0x17d,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SAT2",NULL,NULL,0x17e,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CD",NULL,NULL,0x17f,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TAPE",NULL,NULL,0x180,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_RADIO",NULL,NULL,0x181,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TUNER",NULL,NULL,0x182,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_PLAYER",NULL,NULL,0x183,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TEXT",NULL,NULL,0x184,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DVD",NULL,NULL,0x185,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_AUX",NULL,NULL,0x186,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_MP3",NULL,NULL,0x187,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_AUDIO",NULL,NULL,0x188,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VIDEO",NULL,NULL,0x189,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DIRECTORY",NULL,NULL,0x18a,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_LIST",NULL,NULL,0x18b,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_MEMO",NULL,NULL,0x18c,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CALENDAR",NULL,NULL,0x18d,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_RED",NULL,NULL,0x18e,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_GREEN",NULL,NULL,0x18f,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_YELLOW",NULL,NULL,0x190,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BLUE",NULL,NULL,0x191,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CHANNELUP",NULL,NULL,0x192,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CHANNELDOWN",NULL,NULL,0x193,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FIRST",NULL,NULL,0x194,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_LAST",NULL,NULL,0x195,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_AB",NULL,NULL,0x196,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NEXT",NULL,NULL,0x197,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_RESTART",NULL,NULL,0x198,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SLOW",NULL,NULL,0x199,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SHUFFLE",NULL,NULL,0x19a,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BREAK",NULL,NULL,0x19b,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_PREVIOUS",NULL,NULL,0x19c,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DIGITS",NULL,NULL,0x19d,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TEEN",NULL,NULL,0x19e,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_TWEN",NULL,NULL,0x19f,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VIDEOPHONE",NULL,NULL,0x1a0,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_GAMES",NULL,NULL,0x1a1,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ZOOMIN",NULL,NULL,0x1a2,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ZOOMOUT",NULL,NULL,0x1a3,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ZOOMRESET",NULL,NULL,0x1a4,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_WORDPROCESSOR",NULL,NULL,0x1a5,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_EDITOR",NULL,NULL,0x1a6,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SPREADSHEET",NULL,NULL,0x1a7,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_GRAPHICSEDITOR",NULL,NULL,0x1a8,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_PRESENTATION",NULL,NULL,0x1a9,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DATABASE",NULL,NULL,0x1aa,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NEWS",NULL,NULL,0x1ab,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_VOICEMAIL",NULL,NULL,0x1ac,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_ADDRESSBOOK",NULL,NULL,0x1ad,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_MESSENGER",NULL,NULL,0x1ae,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DISPLAYTOGGLE",NULL,NULL,0x1af,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_SPELLCHECK",NULL,NULL,0x1b0,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_LOGOFF",NULL,NULL,0x1b1,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DOLLAR",NULL,NULL,0x1b2,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_EURO",NULL,NULL,0x1b3,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FRAMEBACK",NULL,NULL,0x1b4,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FRAMEFORWARD",NULL,NULL,0x1b5,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_CONTEXT_MENU",NULL,NULL,0x1b6,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_MEDIA_REPEAT",NULL,NULL,0x1b7,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DEL_EOL",NULL,NULL,0x1c0,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DEL_EOS",NULL,NULL,0x1c1,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_INS_LINE",NULL,NULL,0x1c2,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_DEL_LINE",NULL,NULL,0x1c3,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN",NULL,NULL,0x1d0,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_ESC",NULL,NULL,0x1d1,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F1",NULL,NULL,0x1d2,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F2",NULL,NULL,0x1d3,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F3",NULL,NULL,0x1d4,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F4",NULL,NULL,0x1d5,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F5",NULL,NULL,0x1d6,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F6",NULL,NULL,0x1d7,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F7",NULL,NULL,0x1d8,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F8",NULL,NULL,0x1d9,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F9",NULL,NULL,0x1da,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F10",NULL,NULL,0x1db,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F11",NULL,NULL,0x1dc,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F12",NULL,NULL,0x1dd,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_1",NULL,NULL,0x1de,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_2",NULL,NULL,0x1df,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_D",NULL,NULL,0x1e0,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_E",NULL,NULL,0x1e1,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_F",NULL,NULL,0x1e2,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_S",NULL,NULL,0x1e3,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_FN_B",NULL,NULL,0x1e4,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT1",NULL,NULL,0x1f1,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT2",NULL,NULL,0x1f2,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT3",NULL,NULL,0x1f3,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT4",NULL,NULL,0x1f4,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT5",NULL,NULL,0x1f5,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT6",NULL,NULL,0x1f6,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT7",NULL,NULL,0x1f7,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT8",NULL,NULL,0x1f8,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT9",NULL,NULL,0x1f9,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_BRL_DOT10",NULL,NULL,0x1fa,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_0",NULL,NULL,0x200,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_1",NULL,NULL,0x201,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_2",NULL,NULL,0x202,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_3",NULL,NULL,0x203,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_4",NULL,NULL,0x204,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_5",NULL,NULL,0x205,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_6",NULL,NULL,0x206,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_7",NULL,NULL,0x207,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_8",NULL,NULL,0x208,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_9",NULL,NULL,0x209,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_STAR",NULL,NULL,0x20a,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_NUMERIC_POUND",NULL,NULL,0x20b,0,0,0,0,0,0,0,0,0,0,},
+    { "KEY_RFKILL",NULL,NULL,0x20c,0,0,0,0,0,0,0,0,0,0,},
+};
+
+struct virCodesetInfo {
+    const char *name;
+    unsigned int offset;
+};
+
+struct virCodesetInfo codesetInfo[] = {
+    [VIR_KEYCODE_SET_LINUX] =
+        { "linux", offsetof(struct keycode, linux_keycode)},
+    [VIR_KEYCODE_SET_XT] =
+        { "xt", offsetof(struct keycode, xt)},
+    [VIR_KEYCODE_SET_ATSET1] =
+        { "atset1", offsetof(struct keycode, atset1)},
+    [VIR_KEYCODE_SET_ATSET2] =
+        { "atset2", offsetof(struct keycode, atset2)},
+    [VIR_KEYCODE_SET_ATSET3] =
+        { "atset3", offsetof(struct keycode, atset3)},
+    [VIR_KEYCODE_SET_OSX] =
+        { "os-x", offsetof(struct keycode, os_x)},
+    [VIR_KEYCODE_SET_XT_KBD] =
+        { "xt_kbd", offsetof(struct keycode, xt_kbd)},
+    [VIR_KEYCODE_SET_USB] =
+        { "usb", offsetof(struct keycode, usb)},
+    [VIR_KEYCODE_SET_WIN32] =
+        { "win32", offsetof(struct keycode, win32)},
+    [VIR_KEYCODE_SET_XWIN_XT] =
+        { "xwin_xt", offsetof(struct keycode, xwin_xt)},
+    [VIR_KEYCODE_SET_XFREE86_KBD_XT] =
+        { "xfree86_kbd_xt", offsetof(struct keycode, xfree86_kbd_xt)},
+};
+
+const char *virKeycodeSetName(virKeycodeSet codeset)
+{
+    int i = (int)codeset;
+
+    if (i < 0 || i >= ARRAY_SIZE(codesetInfo))
+        return "UNKNOWN";
+
+    return codesetInfo[i].name;
+}
+
+virKeycodeSet virParseKeycodeSet(const char *name)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(codesetInfo); i++) {
+        if (!strcmp(codesetInfo[i].name, name))
+            return (virKeycodeSet)i;
+    }
+
+    return (virKeycodeSet)-1;
+}
+
+static int virParseKeyNameOffset(unsigned int name_offset,
+                                 unsigned int code_offset,
+                                 const char *keyname)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(keycodes); i++) {
+        const char *name = getfield(keycodes + i, const char *, name_offset);
+
+        if (name && !strcmp(name, keyname))
+            return getfield(keycodes + i, unsigned short, code_offset);
+    }
+
+    return -1;
+}
+
+int virParseKeyName(virKeycodeSet codeset, const char *keyname)
+{
+    switch (codeset) {
+    case VIR_KEYCODE_SET_LINUX:
+        return virParseKeyNameOffset(offsetof(struct keycode, linux_name),
+                                     offsetof(struct keycode, linux_keycode), keyname);
+    case VIR_KEYCODE_SET_OSX:
+        return virParseKeyNameOffset(offsetof(struct keycode, os_x_name),
+                                     offsetof(struct keycode, os_x), keyname);
+    case VIR_KEYCODE_SET_WIN32:
+        return virParseKeyNameOffset(offsetof(struct keycode, win32_name),
+                                     offsetof(struct keycode, win32), keyname);
+    default:
+        return -1;
+    }
+}
+
+static int virTranslateKeyCodeOffset(unsigned int from_offset,
+                                     unsigned int to_offset,
+                                     int key_value)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(keycodes); i++) {
+        if (getfield(keycodes + i, unsigned short, from_offset) == key_value)
+            return getfield(keycodes + i, unsigned short, to_offset);
+    }
+
+    return -1;
+}
+
+int virTranslateKeyCode(virKeycodeSet from_codeset,
+                        virKeycodeSet to_codeset,
+                        int key_value)
+{
+    if (key_value <= 0)
+        return -1;
+
+    key_value = virTranslateKeyCodeOffset(codesetInfo[from_codeset].offset,
+                                          codesetInfo[to_codeset].offset,
+                                          key_value);
+    if (key_value <= 0)
+        return -1;
+
+    return key_value;
+}
+
+
diff --git a/src/util/virtkey.h b/src/util/virtkey.h
new file mode 100644
index 0000000..f81bcb1
--- /dev/null
+++ b/src/util/virtkey.h
@@ -0,0 +1,21 @@
+#ifndef __UTIL_VIRTKEY_H__
+#define __UTIL_VIRTKEY_H__
+
+/*
+ * Copyright (c) 2011 Lai Jiangshan
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <libvirt/libvirt.h>
+
+const char *virKeycodeSetName(virKeycodeSet codeset);
+virKeycodeSet virParseKeycodeSet(const char *name);
+int virParseKeyName(virKeycodeSet codeset, const char *keyname);
+int virTranslateKeyCode(virKeycodeSet from_codeset,
+                        virKeycodeSet to_offset,
+                        int key_value);
+
+#endif
diff --git a/tools/virsh.c b/tools/virsh.c
index fcd254d..a1e2f83 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -58,6 +58,7 @@
 #include "threads.h"
 #include "command.h"
 #include "count-one-bits.h"
+#include "virtkey.h"
 
 static char *progname;
 
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]