From 9873ce28d0dd486c65d17c8913a736e5ca46b2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 28 Feb 2013 08:41:51 -0500 Subject: [PATCH 01/18] libwinpr-utils: experiment with printf replacement --- libfreerdp/primitives/CMakeLists.txt | 2 +- winpr/libwinpr/utils/test/CMakeLists.txt | 1 + winpr/libwinpr/utils/test/TestPrint.c | 359 +++++++++++++++++++++++ 3 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 winpr/libwinpr/utils/test/TestPrint.c diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt index e8d1a7bfb..807a46835 100644 --- a/libfreerdp/primitives/CMakeLists.txt +++ b/libfreerdp/primitives/CMakeLists.txt @@ -101,6 +101,6 @@ endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") if(BUILD_TESTING AND ((NOT WIN32) AND (NOT APPLE))) - add_subdirectory(test) +# add_subdirectory(test) endif() diff --git a/winpr/libwinpr/utils/test/CMakeLists.txt b/winpr/libwinpr/utils/test/CMakeLists.txt index 07f7e589e..cf967be4b 100644 --- a/winpr/libwinpr/utils/test/CMakeLists.txt +++ b/winpr/libwinpr/utils/test/CMakeLists.txt @@ -6,6 +6,7 @@ set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) set(${MODULE_PREFIX}_TESTS TestQueue.c + TestPrint.c TestArrayList.c TestCmdLine.c TestMessageQueue.c diff --git a/winpr/libwinpr/utils/test/TestPrint.c b/winpr/libwinpr/utils/test/TestPrint.c new file mode 100644 index 000000000..e27a46b2b --- /dev/null +++ b/winpr/libwinpr/utils/test/TestPrint.c @@ -0,0 +1,359 @@ + +#include +#include +#include + +#include +#include +#include + +int wprintfx(const char *fmt, ...); + +int TestPrint(int argc, char* argv[]) +{ + wprintfx("this %s a test: %d\n", "is", 65); + + return 0; +} + +/*---------------------------------------------------------------------------- +Stripped-down printf() +Chris Giese http://my.execpc.com/~geezer +Release date: Feb 3, 2008 +This code is public domain (no copyright). +You can do whatever you want with it. + +%[flag][width][.prec][mod][conv] +flag: - left justify, pad right w/ blanks DONE + 0 pad left w/ 0 for numerics DONE + + always print sign, + or - no + ' ' (blank) no + # (???) no + +width: (field width) DONE + +prec: (precision) no + +conv: d,i decimal int DONE + u decimal unsigned DONE + o octal DONE + x,X hex DONE + f,e,g,E,G float no + c char DONE + s string DONE + p ptr DONE + +mod: N near ptr DONE + F far ptr no + h short (16-bit) int DONE + l long (32-bit) int DONE + L long long (64-bit) int no +----------------------------------------------------------------------------*/ +#include /* strlen() */ + +/* flags used in processing format string */ +#define PR_LJ 0x01 /* left justify */ +#define PR_CA 0x02 /* use A-F instead of a-f for hex */ +#define PR_SG 0x04 /* signed numeric conversion (%d vs. %u) */ +#define PR_32 0x08 /* long (32-bit) numeric conversion */ +#define PR_16 0x10 /* short (16-bit) numeric conversion */ +#define PR_WS 0x20 /* PR_SG set and num was < 0 */ +#define PR_LZ 0x40 /* pad left with '0' instead of ' ' */ +#define PR_FP 0x80 /* pointers are far */ + +/* largest number handled is 2^32-1, lowest radix handled is 8. +2^32-1 in base 8 has 11 digits (add 5 for trailing NUL and for slop) */ +#define PR_BUFLEN 16 + +typedef int (*fnptr_t)(unsigned c, void **helper); +/***************************************************************************** +name: do_printf +action: minimal subfunction for ?printf, calls function + 'fn' with arg 'ptr' for each character to be output +returns:total number of characters output +*****************************************************************************/ +int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr) +{ + unsigned flags, actual_wd, count, given_wd; + unsigned char *where, buf[PR_BUFLEN]; + unsigned char state, radix; + long num; + + state = flags = count = given_wd = 0; +/* begin scanning format specifier list */ + for (; *fmt; fmt++) + { + switch (state) + { +/* STATE 0: AWAITING % */ + case 0: + if (*fmt != '%') /* not %... */ + { + fn(*fmt, &ptr); /* ...just echo it */ + count++; + break; + } +/* found %, get next char and advance state to check if next char is a flag */ + state++; + fmt++; + /* FALL THROUGH */ +/* STATE 1: AWAITING FLAGS (%-0) */ + case 1: + if (*fmt == '%') /* %% */ + { + fn(*fmt, &ptr); + count++; + state = flags = given_wd = 0; + break; + } + if (*fmt == '-') + { + if (flags & PR_LJ)/* %-- is illegal */ + state = flags = given_wd = 0; + else + flags |= PR_LJ; + break; + } +/* not a flag char: advance state to check if it's field width */ + state++; +/* check now for '%0...' */ + if (*fmt == '0') + { + flags |= PR_LZ; + fmt++; + } + /* FALL THROUGH */ +/* STATE 2: AWAITING (NUMERIC) FIELD WIDTH */ + case 2: + if (*fmt >= '0' && *fmt <= '9') + { + given_wd = 10 * given_wd + (*fmt - '0'); + break; + } +/* not field width: advance state to check if it's a modifier */ + state++; + /* FALL THROUGH */ +/* STATE 3: AWAITING MODIFIER CHARS (FNlh) */ + case 3: + if (*fmt == 'F') + { + flags |= PR_FP; + break; + } + if (*fmt == 'N') + break; + if (*fmt == 'l') + { + flags |= PR_32; + break; + } + if (*fmt == 'h') + { + flags |= PR_16; + break; + } +/* not modifier: advance state to check if it's a conversion char */ + state++; + /* FALL THROUGH */ +/* STATE 4: AWAITING CONVERSION CHARS (Xxpndiuocs) */ + case 4: + where = buf + PR_BUFLEN - 1; + *where = '\0'; + switch (*fmt) + { + case 'X': + flags |= PR_CA; + /* FALL THROUGH */ +/* xxx - far pointers (%Fp, %Fn) not yet supported */ + case 'x': + case 'p': + case 'n': + radix = 16; + goto DO_NUM; + case 'd': + case 'i': + flags |= PR_SG; + /* FALL THROUGH */ + case 'u': + radix = 10; + goto DO_NUM; + case 'o': + radix = 8; +/* load the value to be printed. l=long=32 bits: */ +DO_NUM: if (flags & PR_32) + num = va_arg(args, unsigned long); +/* h=short=16 bits (signed or unsigned) */ + else if (flags & PR_16) + { + if (flags & PR_SG) + num = (short) va_arg(args, int); + else + num = (unsigned short) va_arg(args, int); + } +/* no h nor l: sizeof(int) bits (signed or unsigned) */ + else + { + if (flags & PR_SG) + num = va_arg(args, int); + else + num = va_arg(args, unsigned int); + } +/* take care of sign */ + if (flags & PR_SG) + { + if (num < 0) + { + flags |= PR_WS; + num = -num; + } + } +/* convert binary to octal/decimal/hex ASCII +OK, I found my mistake. The math here is _always_ unsigned */ + do + { + unsigned long temp; + + temp = (unsigned long)num % radix; + where--; + if (temp < 10) + *where = temp + '0'; + else if (flags & PR_CA) + *where = temp - 10 + 'A'; + else + *where = temp - 10 + 'a'; + num = (unsigned long)num / radix; + } + while (num != 0); + goto EMIT; + case 'c': +/* disallow pad-left-with-zeroes for %c */ + flags &= ~PR_LZ; + where--; + *where = (unsigned char) va_arg(args, int); + actual_wd = 1; + goto EMIT2; + case 's': +/* disallow pad-left-with-zeroes for %s */ + flags &= ~PR_LZ; + where = va_arg(args, unsigned char*); +EMIT: + actual_wd = strlen((char*) where); + if (flags & PR_WS) + actual_wd++; +/* if we pad left with ZEROES, do the sign now */ + if ((flags & (PR_WS | PR_LZ)) == (PR_WS | PR_LZ)) + { + fn('-', &ptr); + count++; + } +/* pad on left with spaces or zeroes (for right justify) */ +EMIT2: if ((flags & PR_LJ) == 0) + { + while (given_wd > actual_wd) + { + fn((flags & PR_LZ) ? '0' : ' ', &ptr); + count++; + given_wd--; + } + } +/* if we pad left with SPACES, do the sign now */ + if ((flags & (PR_WS | PR_LZ)) == PR_WS) + { + fn('-', &ptr); + count++; + } +/* emit string/char/converted number */ + while (*where != '\0') + { + fn(*where++, &ptr); + count++; + } +/* pad on right with spaces (for left justify) */ + if (given_wd < actual_wd) + given_wd = 0; + else given_wd -= actual_wd; + for (; given_wd; given_wd--) + { + fn(' ', &ptr); + count++; + } + break; + default: + break; + } + default: + state = flags = given_wd = 0; + break; + } + } + return count; +} + +/***************************************************************************** +SPRINTF +*****************************************************************************/ +static int vsprintf_help(unsigned c, void **ptr) +{ + char *dst; + + dst = *ptr; + *dst++ = (char) c; + *ptr = dst; + + return 0; +} + +int vsprintf(char *buf, const char *fmt, va_list args) +{ + int status; + + status = do_printf(fmt, args, vsprintf_help, (void*) buf); + buf[status] = '\0'; + + return status; +} + +static int discard(unsigned c_UNUSED, void **ptr_UNUSED) +{ + return 0; +} + +int sprintf(char *buf, const char *fmt, ...) +{ + va_list args; + int status; + + va_start(args, fmt); + + if (!buf) + status = do_printf(fmt, args, discard, NULL); + else + status = vsprintf(buf, fmt, args); + + va_end(args); + + return status; +} + +int vprintf_help(unsigned c, void **ptr_UNUSED) +{ + putchar(c); + return 0; +} + +int vprintf(const char *fmt, va_list args) +{ + return do_printf(fmt, args, vprintf_help, NULL); +} + +int wprintfx(const char *fmt, ...) +{ + va_list args; + int status; + + va_start(args, fmt); + status = vprintf(fmt, args); + va_end(args); + + return status; +} From 5687cd393db2b950b00cd1a5c696015f668499c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 28 Feb 2013 14:49:56 -0500 Subject: [PATCH 02/18] libfreerdp-locale: remove old X11 keymaps --- keymaps/CMakeLists.txt | 24 -- keymaps/aliases | 17 - keymaps/amiga | 193 --------- keymaps/ataritt | 104 ----- keymaps/digital_vndr/lk | 197 --------- keymaps/digital_vndr/pc | 192 --------- keymaps/empty | 13 - keymaps/evdev | 135 ------ keymaps/fujitsu | 119 ------ keymaps/hp | 105 ----- keymaps/ibm | 5 - keymaps/macintosh | 142 ------- keymaps/macosx | 109 ----- keymaps/sgi_vndr/indigo | 116 ------ keymaps/sgi_vndr/indy | 148 ------- keymaps/sgi_vndr/iris | 10 - keymaps/sony | 103 ----- keymaps/sun | 618 ---------------------------- keymaps/xfree86 | 152 ------- keymaps/xfree98 | 106 ----- libfreerdp/locale/CMakeLists.txt | 2 - libfreerdp/locale/keyboard.c | 1 - libfreerdp/locale/keyboard_keymap.c | 212 ---------- libfreerdp/locale/keyboard_keymap.h | 28 -- libfreerdp/locale/keyboard_x11.c | 1 - 25 files changed, 2852 deletions(-) delete mode 100644 keymaps/CMakeLists.txt delete mode 100644 keymaps/aliases delete mode 100644 keymaps/amiga delete mode 100644 keymaps/ataritt delete mode 100644 keymaps/digital_vndr/lk delete mode 100644 keymaps/digital_vndr/pc delete mode 100644 keymaps/empty delete mode 100644 keymaps/evdev delete mode 100644 keymaps/fujitsu delete mode 100644 keymaps/hp delete mode 100644 keymaps/ibm delete mode 100644 keymaps/macintosh delete mode 100644 keymaps/macosx delete mode 100644 keymaps/sgi_vndr/indigo delete mode 100644 keymaps/sgi_vndr/indy delete mode 100644 keymaps/sgi_vndr/iris delete mode 100644 keymaps/sony delete mode 100644 keymaps/sun delete mode 100644 keymaps/xfree86 delete mode 100644 keymaps/xfree98 delete mode 100644 libfreerdp/locale/keyboard_keymap.c delete mode 100644 libfreerdp/locale/keyboard_keymap.h diff --git a/keymaps/CMakeLists.txt b/keymaps/CMakeLists.txt deleted file mode 100644 index 75a6806a0..000000000 --- a/keymaps/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# FreeRDP: A Remote Desktop Protocol Implementation -# keymaps cmake build script -# -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(NOT WITH_XKBFILE) - install(FILES aliases amiga ataritt empty evdev fujitsu hp ibm macintosh macosx sony sun xfree86 xfree98 DESTINATION ${FREERDP_KEYMAP_PATH}) - install(DIRECTORY digital_vndr DESTINATION ${FREERDP_KEYMAP_PATH} FILES_MATCHING PATTERN "*") - install(DIRECTORY sgi_vndr DESTINATION ${FREERDP_KEYMAP_PATH} FILES_MATCHING PATTERN "*") -endif() diff --git a/keymaps/aliases b/keymaps/aliases deleted file mode 100644 index e26c243f6..000000000 --- a/keymaps/aliases +++ /dev/null @@ -1,17 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "qwerty" -{ -}; - -keyboard "azerty" -{ -}; - -keyboard "qwertz" -{ -}; - diff --git a/keymaps/amiga b/keymaps/amiga deleted file mode 100644 index 7ac2df8ce..000000000 --- a/keymaps/amiga +++ /dev/null @@ -1,193 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "usa1" -{ - VK_ESCAPE <77> - VK_F1 <88> - VK_F2 <89> - VK_F3 <90> - VK_F4 <91> - VK_F5 <92> - VK_F6 <93> - VK_F7 <94> - VK_F8 <95> - VK_F9 <96> - VK_F10 <97> - VK_OEM_3 <8> - VK_KEY_1 <9> - VK_KEY_2 <10> - VK_KEY_3 <11> - VK_KEY_4 <12> - VK_KEY_5 <13> - VK_KEY_6 <14> - VK_KEY_7 <15> - VK_KEY_8 <16> - VK_KEY_9 <17> - VK_KEY_0 <18> - VK_OEM_MINUS <19> - VK_OEM_PLUS <20> - VK_OEM_5 <21> - VK_BACK <73> - VK_TAB <74> - VK_KEY_Q <24> - VK_KEY_W <25> - VK_KEY_E <26> - VK_KEY_R <27> - VK_KEY_T <28> - VK_KEY_Y <29> - VK_KEY_U <30> - VK_KEY_I <31> - VK_KEY_O <32> - VK_KEY_P <33> - VK_OEM_4 <34> - VK_OEM_6 <35> - VK_RETURN <76> - VK_LCONTROL <107> - VK_CAPITAL <106> - VK_KEY_A <40> - VK_KEY_S <41> - VK_KEY_D <42> - VK_KEY_F <43> - VK_KEY_G <44> - VK_KEY_H <45> - VK_KEY_J <46> - VK_KEY_K <47> - VK_KEY_L <48> - VK_OEM_1 <49> - VK_OEM_7 <50> - VK_LSHIFT <104> - VK_KEY_Z <57> - VK_KEY_X <58> - VK_KEY_C <59> - VK_KEY_V <60> - VK_KEY_B <61> - VK_KEY_N <62> - VK_KEY_M <63> - VK_OEM_COMMA <64> - VK_OEM_PERIOD <65> - VK_OEM_2 <66> - VK_RSHIFT <105> - VK_LMENU <108> - VK_SPACE <72> - VK_RMENU <109> - VK_DELETE <78> - VK_HELP <103> - VK_UP <84> - VK_LEFT <87> - VK_DOWN <85> - VK_RIGHT <86> - VK_DIVIDE <100> - VK_MULTIPLY <101> - VK_NUMPAD7 <69> - VK_NUMPAD8 <70> - VK_NUMPAD9 <71> - VK_SUBTRACT <82> - VK_NUMPAD4 <53> - VK_NUMPAD5 <54> - VK_NUMPAD6 <55> - VK_ADD <102> - VK_NUMPAD1 <37> - VK_NUMPAD2 <38> - VK_NUMPAD3 <39> - VK_NUMPAD0 <23> - VK_RETURN <75> -}; - -keyboard "de" -{ - VK_ESCAPE <77> - VK_F1 <88> - VK_F2 <89> - VK_F3 <90> - VK_F4 <91> - VK_F5 <92> - VK_F6 <93> - VK_F7 <94> - VK_F8 <95> - VK_F9 <96> - VK_F10 <97> - VK_OEM_3 <8> - VK_KEY_1 <9> - VK_KEY_2 <10> - VK_KEY_3 <11> - VK_KEY_4 <12> - VK_KEY_5 <13> - VK_KEY_6 <14> - VK_KEY_7 <15> - VK_KEY_8 <16> - VK_KEY_9 <17> - VK_KEY_0 <18> - VK_OEM_MINUS <19> - VK_OEM_PLUS <20> - VK_OEM_5 <21> - VK_BACK <73> - VK_TAB <74> - VK_KEY_Q <24> - VK_KEY_W <25> - VK_KEY_E <26> - VK_KEY_R <27> - VK_KEY_T <28> - VK_KEY_Y <29> - VK_KEY_U <30> - VK_KEY_I <31> - VK_KEY_O <32> - VK_KEY_P <33> - VK_OEM_4 <34> - VK_OEM_6 <35> - VK_RETURN <76> - VK_LCONTROL <107> - VK_CAPITAL <106> - VK_KEY_A <40> - VK_KEY_S <41> - VK_KEY_D <42> - VK_KEY_F <43> - VK_KEY_G <44> - VK_KEY_H <45> - VK_KEY_J <46> - VK_KEY_K <47> - VK_KEY_L <48> - VK_OEM_1 <49> - VK_OEM_7 <50> - VK_OEM_5 <51> - VK_LSHIFT <104> - VK_OEM_102 <56> - VK_KEY_Z <57> - VK_KEY_X <58> - VK_KEY_C <59> - VK_KEY_V <60> - VK_KEY_B <61> - VK_KEY_N <62> - VK_KEY_M <63> - VK_OEM_COMMA <64> - VK_OEM_PERIOD <65> - VK_OEM_2 <66> - VK_RSHIFT <105> - VK_LMENU <108> - VK_SPACE <72> - VK_RMENU <109> - VK_DELETE <78> - VK_HELP <103> - VK_UP <84> - VK_LEFT <87> - VK_DOWN <85> - VK_RIGHT <86> - VK_DIVIDE <100> - VK_MULTIPLY <101> - VK_NUMPAD7 <69> - VK_NUMPAD8 <70> - VK_NUMPAD9 <71> - VK_SUBTRACT <82> - VK_NUMPAD4 <53> - VK_NUMPAD5 <54> - VK_NUMPAD6 <55> - VK_ADD <102> - VK_NUMPAD1 <37> - VK_NUMPAD2 <38> - VK_NUMPAD3 <39> - VK_NUMPAD0 <23> - VK_RETURN <75> -}; - diff --git a/keymaps/ataritt b/keymaps/ataritt deleted file mode 100644 index 4229cea47..000000000 --- a/keymaps/ataritt +++ /dev/null @@ -1,104 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "us" -{ - VK_ESCAPE <9> - VK_KEY_1 <10> - VK_KEY_2 <11> - VK_KEY_3 <12> - VK_KEY_4 <13> - VK_KEY_5 <14> - VK_KEY_6 <15> - VK_KEY_7 <16> - VK_KEY_8 <17> - VK_KEY_9 <18> - VK_KEY_0 <19> - VK_OEM_MINUS <20> - VK_OEM_PLUS <21> - VK_OEM_3 <49> - VK_BACK <22> - VK_TAB <23> - VK_KEY_Q <24> - VK_KEY_W <25> - VK_KEY_E <26> - VK_KEY_R <27> - VK_KEY_T <28> - VK_KEY_Y <29> - VK_KEY_U <30> - VK_KEY_I <31> - VK_KEY_O <32> - VK_KEY_P <33> - VK_OEM_4 <34> - VK_OEM_6 <35> - VK_RETURN <36> - VK_DELETE <91> - VK_LCONTROL <37> - VK_KEY_A <38> - VK_KEY_S <39> - VK_KEY_D <40> - VK_KEY_F <41> - VK_KEY_G <42> - VK_KEY_H <43> - VK_KEY_J <44> - VK_KEY_K <45> - VK_KEY_L <46> - VK_OEM_1 <47> - VK_OEM_7 <48> - VK_OEM_5 <51> - VK_LSHIFT <50> - VK_KEY_Z <52> - VK_KEY_X <53> - VK_KEY_C <54> - VK_KEY_V <55> - VK_KEY_B <56> - VK_KEY_N <57> - VK_KEY_M <58> - VK_OEM_COMMA <59> - VK_OEM_PERIOD <60> - VK_OEM_2 <61> - VK_RSHIFT <62> - VK_SPACE <65> - VK_CAPITAL <66> - VK_F1 <67> - VK_F2 <68> - VK_F3 <69> - VK_F4 <70> - VK_F5 <71> - VK_F6 <72> - VK_F7 <73> - VK_F8 <74> - VK_F9 <75> - VK_F10 <76> - VK_HELP <106> - VK_INSERT <90> - VK_HOME <79> - VK_UP <80> - VK_LEFT <83> - VK_DOWN <88> - VK_RIGHT <85> - VK_DIVIDE <109> - VK_MULTIPLY <110> - VK_NUMPAD7 <111> - VK_NUMPAD8 <112> - VK_NUMPAD9 <113> - VK_SUBTRACT <82> - VK_NUMPAD4 <114> - VK_NUMPAD5 <115> - VK_NUMPAD6 <116> - VK_ADD <86> - VK_NUMPAD1 <117> - VK_NUMPAD2 <118> - VK_NUMPAD3 <119> - VK_NUMPAD0 <120> - VK_RETURN <122> -}; - -keyboard "de" -: extends "ataritt(us)" -{ - VK_OEM_102 <104> -}; - diff --git a/keymaps/digital_vndr/lk b/keymaps/digital_vndr/lk deleted file mode 100644 index 77ff19c3c..000000000 --- a/keymaps/digital_vndr/lk +++ /dev/null @@ -1,197 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "lk_common" -{ - VK_F1 <86> - VK_F2 <87> - VK_F3 <88> - VK_F4 <89> - VK_F5 <90> - VK_F6 <100> - VK_F7 <101> - VK_F8 <102> - VK_F9 <103> - VK_F10 <104> - VK_F11 <113> - VK_F12 <114> - VK_UP <170> - VK_LEFT <167> - VK_DOWN <169> - VK_RIGHT <168> - VK_NUMPAD7 <157> - VK_NUMPAD8 <158> - VK_NUMPAD9 <159> - VK_NUMPAD4 <153> - VK_NUMPAD5 <154> - VK_NUMPAD6 <155> - VK_NUMPAD1 <150> - VK_NUMPAD2 <151> - VK_NUMPAD3 <152> - VK_RETURN <149> - VK_NUMPAD0 <146> - VK_DECIMAL <148> - VK_TILDE <191> - VK_KEY_1 <192> - VK_KEY_2 <197> - VK_KEY_3 <203> - VK_KEY_4 <208> - VK_KEY_5 <214> - VK_KEY_6 <219> - VK_KEY_7 <224> - VK_KEY_8 <229> - VK_KEY_9 <234> - VK_KEY_0 <239> - VK_OEM_MINUS <249> - VK_OEM_PLUS <245> - VK_BACK <188> - VK_TAB <190> - VK_KEY_Q <193> - VK_KEY_W <198> - VK_KEY_E <204> - VK_KEY_R <209> - VK_KEY_T <215> - VK_KEY_Y <220> - VK_KEY_U <225> - VK_KEY_I <230> - VK_KEY_O <235> - VK_KEY_P <240> - VK_OEM_4 <250> - VK_OEM_6 <246> - VK_RETURN <189> - VK_LCONTROL <175> - VK_CAPITAL <176> - VK_KEY_A <194> - VK_KEY_S <199> - VK_KEY_D <205> - VK_KEY_F <210> - VK_KEY_G <216> - VK_KEY_H <221> - VK_KEY_J <226> - VK_KEY_K <231> - VK_KEY_L <236> - VK_OEM_1 <242> - VK_OEM_7 <251> - VK_LSHIFT <174> - VK_KEY_Z <195> - VK_KEY_X <200> - VK_KEY_C <206> - VK_KEY_V <211> - VK_KEY_B <217> - VK_KEY_N <222> - VK_KEY_M <227> - VK_OEM_COMMA <232> - VK_OEM_PERIOD <237> - VK_OEM_2 <243> - VK_RSHIFT <171> - VK_SPACE <212> -}; - -keyboard "lkx01" -: extends "digital_vndr/lk(lk_common)" -{ - VK_LSHIFT <201> - VK_F13 <115> - VK_F14 <116> - VK_F17 <128> - VK_F18 <129> - VK_F19 <130> - VK_F20 <131> - VK_HELP <124> - VK_INSERT <139> - VK_DELETE <140> - VK_SELECT <141> - VK_PRIOR <142> - VK_NEXT <143> - VK_NUMLOCK <161> - VK_DIVIDE <162> - VK_MULTIPLY <163> - VK_SUBTRACT <164> - VK_SUBTRACT <160> - VK_ADD <156> - VK_OEM_5 <247> -}; - -keyboard "lk201" -: extends "digital_vndr/lk(lkx01)" -{ -}; - -keyboard "lk421" -: extends "digital_vndr/lk(lkx01)" -{ - VK_LMENU <172> - VK_RMENU <178> -}; - -keyboard "lk401" -: extends "digital_vndr/lk(lk421)" -{ -}; - -keyboard "lk44x" -: extends "digital_vndr/lk(lk_common)" -{ - VK_ESCAPE <85> - VK_SNAPSHOT <115> - VK_SCROLL <116> - VK_PAUSE <124> - VK_INSERT <138> - VK_HOME <139> - VK_PRIOR <140> - VK_DELETE <141> - VK_END <142> - VK_NEXT <143> - VK_NUMLOCK <161> - VK_DIVIDE <162> - VK_MULTIPLY <163> - VK_SUBTRACT <164> - VK_ADD <156> - VK_LMENU <172> - VK_RMENU <178> - VK_RCONTROL <173> -}; - -keyboard "lk443" -: extends "digital_vndr/lk(lk44x)" -{ - VK_OEM_5 <247> -}; - -keyboard "lk444" -: extends "digital_vndr/lk(lk44x)" -{ - VK_OEM_5 <201> - VK_OEM_5 <247> -}; - -keyboard "lk421aj" -: extends "digital_vndr/lk(lk421)" -{ - VK_ABNT_C1 <252> -}; - -keyboard "lk421jj" -: extends "digital_vndr/lk(lk421aj)" -{ - VK_NONCONVERT <94> - VK_KANJI <95> - VK_KANA <97> -}; - -keyboard "lk401bj" -: extends "digital_vndr/lk(lk401)" -{ - VK_NONCONVERT <94> - VK_KANJI <95> - VK_KANA <97> -}; - -keyboard "lk401jj" -: extends "digital_vndr/lk(lk401bj)" -{ - VK_ABNT_C1 <252> -}; - diff --git a/keymaps/digital_vndr/pc b/keymaps/digital_vndr/pc deleted file mode 100644 index 81dabb98b..000000000 --- a/keymaps/digital_vndr/pc +++ /dev/null @@ -1,192 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "pc_common" -{ - VK_F1 <9> - VK_F2 <15> - VK_F3 <23> - VK_F4 <31> - VK_F5 <39> - VK_F6 <47> - VK_F7 <55> - VK_F8 <63> - VK_F9 <71> - VK_F10 <79> - VK_F11 <86> - VK_F12 <94> - VK_UP <99> - VK_LEFT <97> - VK_DOWN <96> - VK_RIGHT <106> - VK_NUMPAD7 <108> - VK_NUMPAD8 <117> - VK_NUMPAD9 <125> - VK_NUMPAD4 <107> - VK_NUMPAD5 <115> - VK_NUMPAD6 <116> - VK_NUMPAD1 <105> - VK_NUMPAD2 <114> - VK_NUMPAD3 <122> - VK_RETURN <121> - VK_NUMPAD0 <112> - VK_DECIMAL <113> - VK_KEY_1 <22> - VK_KEY_2 <30> - VK_KEY_3 <38> - VK_KEY_4 <37> - VK_KEY_5 <46> - VK_KEY_6 <54> - VK_KEY_7 <61> - VK_KEY_8 <62> - VK_KEY_9 <70> - VK_KEY_0 <69> - VK_OEM_MINUS <78> - VK_OEM_PLUS <85> - VK_BACK <102> - VK_TAB <13> - VK_KEY_Q <21> - VK_KEY_W <29> - VK_KEY_E <36> - VK_KEY_R <45> - VK_KEY_T <44> - VK_KEY_Y <53> - VK_KEY_U <60> - VK_KEY_I <67> - VK_KEY_O <68> - VK_KEY_P <77> - VK_OEM_4 <84> - VK_OEM_6 <91> - VK_CAPITAL <20> - VK_KEY_A <28> - VK_KEY_S <27> - VK_KEY_D <35> - VK_KEY_F <43> - VK_KEY_G <52> - VK_KEY_H <51> - VK_KEY_J <59> - VK_KEY_K <66> - VK_KEY_L <75> - VK_OEM_1 <76> - VK_OEM_7 <82> - VK_RETURN <90> - VK_LSHIFT <18> - VK_KEY_Z <26> - VK_KEY_X <34> - VK_KEY_C <33> - VK_KEY_V <42> - VK_KEY_B <50> - VK_KEY_N <49> - VK_KEY_M <58> - VK_OEM_COMMA <65> - VK_OEM_PERIOD <73> - VK_OEM_2 <74> - VK_RSHIFT <89> - VK_LCONTROL <17> - VK_LMENU <25> - VK_SPACE <41> - VK_RMENU <57> -}; - -keyboard "pc10x" -: extends "digital_vndr/pc(pc_common)" -{ - VK_ESCAPE <8> - VK_TILDE <14> - VK_SNAPSHOT <87> - VK_SCROLL <95> - VK_PAUSE <98> - VK_INSERT <103> - VK_HOME <110> - VK_PRIOR <111> - VK_DELETE <100> - VK_END <101> - VK_NEXT <109> - VK_NUMLOCK <118> - VK_DIVIDE <119> - VK_MULTIPLY <126> - VK_SUBTRACT <132> - VK_ADD <124> - VK_RCONTROL <88> -}; - -keyboard "pc101" -: extends "digital_vndr/pc(pc10x)" -{ - VK_OEM_5 <92> -}; - -keyboard "pc102" -: extends "digital_vndr/pc(pc10x)" -{ - VK_OEM_5 <19> - VK_OEM_5 <83> -}; - -keyboard "pc104" -: extends "digital_vndr/pc(pc101)" -{ - VK_LWIN <139> - VK_RWIN <140> - VK_APPS <141> -}; - -keyboard "lk411_common" -: extends "digital_vndr/pc(pc_common)" -{ - VK_TILDE <8> - VK_LSHIFT <14> - VK_F13 <24> - VK_F14 <10> - VK_F17 <16> - VK_F18 <87> - VK_F19 <95> - VK_F20 <98> - VK_HELP <11> - VK_INSERT <103> - VK_DELETE <100> - VK_SELECT <101> - VK_PRIOR <111> - VK_NEXT <109> - VK_NUMLOCK <118> - VK_DIVIDE <119> - VK_MULTIPLY <126> - VK_SUBTRACT <132> - VK_SUBTRACT <19> - VK_ADD <124> -}; - -keyboard "lk411" -: extends "digital_vndr/pc(lk411_common)" -{ - VK_OEM_5 <92> -}; - -keyboard "lk450" -: extends "digital_vndr/pc(lk411)" -{ -}; - -keyboard "pcxajaa" -: extends "digital_vndr/pc(pc10x)" -{ - VK_OEM_5 <93> - VK_OEM_5 <83> - VK_ABNT_C1 <81> - VK_NONCONVERT <133> - VK_KANJI <134> - VK_KANA <135> -}; - -keyboard "lk411jj" -: extends "digital_vndr/pc(lk411_common)" -{ - VK_ABNT_C1 <81> - VK_OEM_5 <83> - VK_NONCONVERT <133> - VK_KANJI <134> - VK_KANA <135> -}; - diff --git a/keymaps/empty b/keymaps/empty deleted file mode 100644 index b0c6667d9..000000000 --- a/keymaps/empty +++ /dev/null @@ -1,13 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "empty" -{ -}; - -keyboard "empty" -{ -}; - diff --git a/keymaps/evdev b/keymaps/evdev deleted file mode 100644 index cb78135c8..000000000 --- a/keymaps/evdev +++ /dev/null @@ -1,135 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "evdev" -{ - VK_OEM_102 <94> - VK_OEM_3 <49> - VK_KEY_1 <10> - VK_KEY_2 <11> - VK_KEY_3 <12> - VK_KEY_4 <13> - VK_KEY_5 <14> - VK_KEY_6 <15> - VK_KEY_7 <16> - VK_KEY_8 <17> - VK_KEY_9 <18> - VK_KEY_0 <19> - VK_OEM_MINUS <20> - VK_OEM_PLUS <21> - VK_BACK <22> - VK_TAB <23> - VK_KEY_Q <24> - VK_KEY_W <25> - VK_KEY_E <26> - VK_KEY_R <27> - VK_KEY_T <28> - VK_KEY_Y <29> - VK_KEY_U <30> - VK_KEY_I <31> - VK_KEY_O <32> - VK_KEY_P <33> - VK_OEM_4 <34> - VK_OEM_6 <35> - VK_OEM_5 <51> - VK_RETURN <36> - VK_CAPITAL <66> - VK_KEY_A <38> - VK_KEY_S <39> - VK_KEY_D <40> - VK_KEY_F <41> - VK_KEY_G <42> - VK_KEY_H <43> - VK_KEY_J <44> - VK_KEY_K <45> - VK_KEY_L <46> - VK_OEM_1 <47> - VK_OEM_7 <48> - VK_LSHIFT <50> - VK_KEY_Z <52> - VK_KEY_X <53> - VK_KEY_C <54> - VK_KEY_V <55> - VK_KEY_B <56> - VK_KEY_N <57> - VK_KEY_M <58> - VK_OEM_COMMA <59> - VK_OEM_PERIOD <60> - VK_OEM_2 <61> - VK_RSHIFT <62> - VK_LMENU <64> - VK_LCONTROL <37> - VK_SPACE <65> - VK_RCONTROL <105> - VK_RMENU <108> - VK_LWIN <133> - VK_RWIN <134> - VK_APPS <135> - VK_ESCAPE <9> - VK_F1 <67> - VK_F2 <68> - VK_F3 <69> - VK_F4 <70> - VK_F5 <71> - VK_F6 <72> - VK_F7 <73> - VK_F8 <74> - VK_F9 <75> - VK_F10 <76> - VK_F11 <95> - VK_F12 <96> - VK_SNAPSHOT <107> - VK_SCROLL <78> - VK_PAUSE <127> - VK_INSERT <118> - VK_HOME <110> - VK_PRIOR <112> - VK_DELETE <119> - VK_END <115> - VK_NEXT <117> - VK_UP <111> - VK_LEFT <113> - VK_DOWN <116> - VK_RIGHT <114> - VK_NUMLOCK <77> - VK_DIVIDE <106> - VK_MULTIPLY <63> - VK_SUBTRACT <82> - VK_NUMPAD7 <79> - VK_NUMPAD8 <80> - VK_NUMPAD9 <81> - VK_ADD <86> - VK_NUMPAD4 <83> - VK_NUMPAD5 <84> - VK_NUMPAD6 <85> - VK_NUMPAD1 <87> - VK_NUMPAD2 <88> - VK_NUMPAD3 <89> - VK_RETURN <104> - VK_NUMPAD0 <90> - VK_DECIMAL <91> - VK_F13 <191> - VK_F14 <192> - VK_F15 <193> - VK_F16 <194> - VK_F17 <195> - VK_F18 <196> - VK_F19 <197> - VK_F20 <198> - VK_F21 <199> - VK_F22 <200> - VK_F23 <201> - VK_F24 <202> - VK_ABNT_C1 <97> - VK_NONCONVERT <102> - VK_KANA <99> - VK_HELP <146> -}; - -keyboard "pc98" -: extends "evdev(evdev)" -{ -}; - diff --git a/keymaps/fujitsu b/keymaps/fujitsu deleted file mode 100644 index 6f213681b..000000000 --- a/keymaps/fujitsu +++ /dev/null @@ -1,119 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "138" -{ - VK_ESCAPE <37> - VK_KEY_1 <38> - VK_KEY_2 <39> - VK_KEY_3 <40> - VK_KEY_4 <41> - VK_KEY_5 <42> - VK_KEY_6 <43> - VK_KEY_7 <44> - VK_KEY_8 <45> - VK_KEY_9 <46> - VK_KEY_0 <47> - VK_OEM_MINUS <48> - VK_OEM_PLUS <49> - VK_OEM_3 <50> - VK_BACK <51> - VK_TAB <61> - VK_KEY_Q <62> - VK_KEY_W <63> - VK_KEY_E <64> - VK_KEY_R <65> - VK_KEY_T <66> - VK_KEY_Y <67> - VK_KEY_U <68> - VK_KEY_I <69> - VK_KEY_O <70> - VK_KEY_P <71> - VK_OEM_4 <72> - VK_OEM_6 <73> - VK_LCONTROL <84> - VK_KEY_A <85> - VK_KEY_S <86> - VK_KEY_D <87> - VK_KEY_F <88> - VK_KEY_G <89> - VK_KEY_H <90> - VK_KEY_J <91> - VK_KEY_K <92> - VK_KEY_L <93> - VK_OEM_1 <94> - VK_OEM_7 <95> - VK_OEM_5 <96> - VK_RETURN <97> - VK_LSHIFT <107> - VK_KEY_Z <108> - VK_KEY_X <109> - VK_KEY_C <110> - VK_KEY_V <111> - VK_KEY_B <112> - VK_KEY_N <113> - VK_KEY_M <114> - VK_OEM_COMMA <115> - VK_OEM_PERIOD <116> - VK_OEM_2 <117> - VK_ABNT_C1 <52> - VK_RSHIFT <118> - VK_CAPITAL <127> - VK_LMENU <27> - VK_SPACE <129> - VK_RMENU <23> - VK_APPS <75> - VK_F1 <13> - VK_F2 <14> - VK_F3 <16> - VK_F4 <18> - VK_F5 <20> - VK_F6 <22> - VK_F7 <24> - VK_F8 <25> - VK_F9 <26> - VK_F10 <15> - VK_F11 <17> - VK_F12 <19> - VK_F13 <137> - VK_F14 <138> - VK_F15 <139> - VK_F16 <140> - VK_F17 <141> - VK_F18 <142> - VK_F19 <143> - VK_F20 <144> - VK_F21 <145> - VK_F22 <146> - VK_F23 <147> - VK_F24 <148> - VK_HELP <126> - VK_SNAPSHOT <30> - VK_PAUSE <29> - VK_PRIOR <35> - VK_HOME <32> - VK_NEXT <36> - VK_INSERT <60> - VK_UP <33> - VK_DOWN <103> - VK_LEFT <57> - VK_RIGHT <80> - VK_MULTIPLY <55> - VK_DIVIDE <54> - VK_ADD <133> - VK_SUBTRACT <79> - VK_NUMPAD7 <76> - VK_NUMPAD8 <77> - VK_NUMPAD9 <78> - VK_NUMPAD4 <99> - VK_NUMPAD5 <100> - VK_NUMPAD6 <101> - VK_NUMPAD1 <120> - VK_NUMPAD2 <121> - VK_NUMPAD3 <122> - VK_RETURN <98> - VK_NUMPAD0 <102> -}; - diff --git a/keymaps/hp b/keymaps/hp deleted file mode 100644 index 270d149c3..000000000 --- a/keymaps/hp +++ /dev/null @@ -1,105 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "hil" -{ - VK_OEM_3 <71> - VK_KEY_1 <70> - VK_KEY_2 <69> - VK_KEY_3 <68> - VK_KEY_4 <67> - VK_KEY_5 <66> - VK_KEY_6 <65> - VK_KEY_7 <64> - VK_KEY_8 <96> - VK_KEY_9 <97> - VK_KEY_0 <98> - VK_OEM_MINUS <99> - VK_OEM_PLUS <100> - VK_BACK <101> - VK_TAB <63> - VK_KEY_Q <62> - VK_KEY_W <61> - VK_KEY_E <60> - VK_KEY_R <59> - VK_KEY_T <58> - VK_KEY_Y <57> - VK_KEY_U <56> - VK_KEY_I <104> - VK_KEY_O <105> - VK_KEY_P <106> - VK_OEM_4 <107> - VK_OEM_6 <108> - VK_OEM_5 <109> - VK_CAPITAL <55> - VK_KEY_A <53> - VK_KEY_S <52> - VK_KEY_D <51> - VK_KEY_F <50> - VK_KEY_G <49> - VK_KEY_H <48> - VK_KEY_J <112> - VK_KEY_K <113> - VK_KEY_L <114> - VK_OEM_1 <115> - VK_OEM_7 <116> - VK_RETURN <117> - VK_LSHIFT <13> - VK_KEY_Z <36> - VK_KEY_X <35> - VK_KEY_C <34> - VK_KEY_V <33> - VK_KEY_B <32> - VK_KEY_N <128> - VK_KEY_M <120> - VK_OEM_COMMA <121> - VK_OEM_PERIOD <122> - VK_OEM_2 <123> - VK_RSHIFT <12> - VK_LCONTROL <14> - VK_LMENU <11> - VK_SPACE <129> - VK_RMENU <10> - VK_SNAPSHOT <87> - VK_ESCAPE <39> - VK_F1 <84> - VK_F2 <83> - VK_F3 <82> - VK_F4 <81> - VK_APPS <80> - VK_F5 <89> - VK_F6 <90> - VK_F7 <91> - VK_F8 <92> - VK_F9 <45> - VK_F10 <41> - VK_F11 <43> - VK_F12 <47> - VK_HOME <118> - VK_PRIOR <119> - VK_NEXT <127> - VK_SELECT <125> - VK_UP <134> - VK_LEFT <132> - VK_DOWN <133> - VK_RIGHT <135> - VK_DIVIDE <25> - VK_MULTIPLY <29> - VK_ADD <27> - VK_SUBTRACT <31> - VK_NUMPAD7 <21> - VK_NUMPAD8 <17> - VK_NUMPAD9 <19> - VK_RETURN <23> - VK_NUMPAD4 <16> - VK_NUMPAD5 <18> - VK_NUMPAD6 <20> - VK_NUMPAD1 <24> - VK_NUMPAD2 <26> - VK_NUMPAD3 <28> - VK_NUMPAD0 <30> - VK_DECIMAL <44> -}; - diff --git a/keymaps/ibm b/keymaps/ibm deleted file mode 100644 index be9e61bda..000000000 --- a/keymaps/ibm +++ /dev/null @@ -1,5 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - diff --git a/keymaps/macintosh b/keymaps/macintosh deleted file mode 100644 index 8d24f7d56..000000000 --- a/keymaps/macintosh +++ /dev/null @@ -1,142 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "macintosh" -: extends "xfree86" -{ - VK_F13 <182> - VK_F14 <183> - VK_F15 <184> -}; - -keyboard "old" -{ - VK_ESCAPE <61> - VK_OEM_3 <58> - VK_KEY_1 <26> - VK_KEY_2 <27> - VK_KEY_3 <28> - VK_KEY_4 <29> - VK_KEY_5 <31> - VK_KEY_6 <30> - VK_KEY_7 <34> - VK_KEY_8 <36> - VK_KEY_9 <33> - VK_KEY_0 <37> - VK_OEM_MINUS <35> - VK_OEM_PLUS <32> - VK_BACK <59> - VK_TAB <56> - VK_KEY_Q <20> - VK_KEY_W <21> - VK_KEY_E <22> - VK_KEY_R <23> - VK_KEY_T <25> - VK_KEY_Y <24> - VK_KEY_U <40> - VK_KEY_I <42> - VK_KEY_O <39> - VK_KEY_P <43> - VK_OEM_4 <41> - VK_OEM_6 <38> - VK_OEM_5 <50> - VK_CAPITAL <65> - VK_KEY_A <8> - VK_KEY_S <9> - VK_KEY_D <10> - VK_KEY_F <11> - VK_KEY_G <13> - VK_KEY_H <12> - VK_KEY_J <46> - VK_KEY_K <48> - VK_KEY_L <45> - VK_OEM_1 <49> - VK_OEM_7 <47> - VK_RETURN <44> - VK_OEM_102 <18> - VK_KEY_Z <14> - VK_KEY_X <15> - VK_KEY_C <16> - VK_KEY_V <17> - VK_KEY_B <19> - VK_KEY_N <53> - VK_KEY_M <54> - VK_OEM_COMMA <51> - VK_OEM_PERIOD <55> - VK_OEM_2 <52> - VK_SPACE <57> - VK_LCONTROL <62> - VK_LMENU <63> - VK_LSHIFT <64> - VK_RMENU <66> - VK_RSHIFT <131> - VK_RMENU <132> - VK_RCONTROL <133> - VK_F1 <130> - VK_F2 <128> - VK_F3 <107> - VK_F4 <126> - VK_F5 <104> - VK_F6 <105> - VK_F7 <106> - VK_F8 <108> - VK_F9 <109> - VK_F10 <117> - VK_F11 <111> - VK_F12 <119> - VK_SNAPSHOT <113> - VK_SCROLL <115> - VK_PAUSE <121> - VK_INSERT <122> - VK_HOME <123> - VK_PRIOR <124> - VK_DELETE <125> - VK_END <127> - VK_NEXT <129> - VK_UP <70> - VK_LEFT <67> - VK_DOWN <69> - VK_RIGHT <68> - VK_NUMLOCK <79> - VK_DIVIDE <83> - VK_MULTIPLY <75> - VK_NUMPAD7 <97> - VK_NUMPAD8 <99> - VK_NUMPAD9 <100> - VK_SUBTRACT <86> - VK_NUMPAD4 <94> - VK_NUMPAD5 <95> - VK_NUMPAD6 <96> - VK_ADD <77> - VK_NUMPAD1 <91> - VK_NUMPAD2 <92> - VK_NUMPAD3 <93> - VK_RETURN <84> - VK_NUMPAD0 <90> - VK_DECIMAL <73> -}; - -keyboard "hhk" -: extends "macintosh" -{ - VK_OEM_5 <51> - VK_LWIN <49> - VK_RWIN <208> - VK_F13 <111> - VK_F14 <78> - VK_F15 <110> -}; - -keyboard "alukbd" -: extends "xfree86" -{ - VK_F18 <129> - VK_F19 <130> -}; - -keyboard "jisevdev" -{ -}; - diff --git a/keymaps/macosx b/keymaps/macosx deleted file mode 100644 index 4f55dd72e..000000000 --- a/keymaps/macosx +++ /dev/null @@ -1,109 +0,0 @@ -# This file is manually edited from the "macintosh" keymap -# X11.app is a special case, and xfreerdp on Mac OS X uses this hard-coded keymap instead - -keyboard "macosx" -{ - VK_ESCAPE <61> - VK_OEM_3 <58> - VK_KEY_1 <26> - VK_KEY_2 <27> - VK_KEY_3 <28> - VK_KEY_4 <29> - VK_KEY_5 <31> - VK_KEY_6 <30> - VK_KEY_7 <34> - VK_KEY_8 <36> - VK_KEY_9 <33> - VK_KEY_0 <37> - VK_OEM_MINUS <35> - VK_OEM_PLUS <32> - VK_BACK <59> - VK_TAB <56> - VK_KEY_Q <20> - VK_KEY_W <21> - VK_KEY_E <22> - VK_KEY_R <23> - VK_KEY_T <25> - VK_KEY_Y <24> - VK_KEY_U <40> - VK_KEY_I <42> - VK_KEY_O <39> - VK_KEY_P <43> - VK_OEM_4 <41> - VK_OEM_6 <38> - VK_OEM_5 <50> - VK_CAPITAL <65> - VK_KEY_A <8> - VK_KEY_S <9> - VK_KEY_D <10> - VK_KEY_F <11> - VK_KEY_G <13> - VK_KEY_H <12> - VK_KEY_J <46> - VK_KEY_K <48> - VK_KEY_L <45> - VK_OEM_1 <49> - VK_OEM_7 <47> - VK_RETURN <44> - VK_OEM_102 <18> - VK_KEY_Z <14> - VK_KEY_X <15> - VK_KEY_C <16> - VK_KEY_V <17> - VK_KEY_B <19> - VK_KEY_N <53> - VK_KEY_M <54> - VK_OEM_COMMA <51> - VK_OEM_PERIOD <55> - VK_OEM_2 <52> - VK_SPACE <57> - VK_LWIN <63> - VK_RWIN <71> - VK_LCONTROL <67> - VK_LMENU <66> - VK_LSHIFT <64> - VK_RMENU <69> - VK_RSHIFT <68> - VK_F1 <130> - VK_F2 <128> - VK_F3 <107> - VK_F4 <126> - VK_F5 <104> - VK_F6 <105> - VK_F7 <106> - VK_F8 <108> - VK_F9 <109> - VK_F10 <117> - VK_F11 <111> - VK_F12 <119> - VK_SNAPSHOT <113> - VK_SCROLL <115> - VK_PAUSE <121> - VK_INSERT <122> - VK_HOME <123> - VK_PRIOR <124> - VK_DELETE <125> - VK_END <127> - VK_NEXT <129> - VK_UP <134> - VK_LEFT <131> - VK_DOWN <133> - VK_RIGHT <132> - VK_NUMLOCK <79> - VK_DIVIDE <83> - VK_MULTIPLY <75> - VK_NUMPAD7 <97> - VK_NUMPAD8 <99> - VK_NUMPAD9 <100> - VK_SUBTRACT <86> - VK_NUMPAD4 <94> - VK_NUMPAD5 <95> - VK_NUMPAD6 <96> - VK_ADD <77> - VK_NUMPAD1 <91> - VK_NUMPAD2 <92> - VK_NUMPAD3 <93> - VK_RETURN <84> - VK_NUMPAD0 <90> - VK_DECIMAL <73> -}; diff --git a/keymaps/sgi_vndr/indigo b/keymaps/sgi_vndr/indigo deleted file mode 100644 index 6a79b2118..000000000 --- a/keymaps/sgi_vndr/indigo +++ /dev/null @@ -1,116 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "pc101" -{ - VK_OEM_3 <62> - VK_KEY_1 <15> - VK_KEY_2 <21> - VK_KEY_3 <22> - VK_KEY_4 <29> - VK_KEY_5 <30> - VK_KEY_6 <37> - VK_KEY_7 <38> - VK_KEY_8 <45> - VK_KEY_9 <46> - VK_KEY_0 <53> - VK_OEM_MINUS <54> - VK_OEM_PLUS <61> - VK_BACK <68> - VK_TAB <16> - VK_KEY_Q <17> - VK_KEY_W <23> - VK_KEY_E <24> - VK_KEY_R <31> - VK_KEY_T <32> - VK_KEY_Y <39> - VK_KEY_U <40> - VK_KEY_I <47> - VK_KEY_O <48> - VK_KEY_P <55> - VK_OEM_4 <56> - VK_OEM_6 <63> - VK_RETURN <58> - VK_CAPITAL <11> - VK_KEY_A <18> - VK_KEY_S <19> - VK_KEY_D <25> - VK_KEY_F <26> - VK_KEY_G <33> - VK_KEY_H <34> - VK_KEY_J <41> - VK_KEY_K <42> - VK_KEY_L <49> - VK_OEM_1 <50> - VK_OEM_7 <57> - VK_LSHIFT <13> - VK_KEY_Z <27> - VK_KEY_X <28> - VK_KEY_C <35> - VK_KEY_V <36> - VK_KEY_B <43> - VK_KEY_N <44> - VK_KEY_M <51> - VK_OEM_COMMA <52> - VK_OEM_PERIOD <59> - VK_OEM_2 <60> - VK_RSHIFT <12> - VK_OEM_5 <64> - VK_LMENU <91> - VK_LCONTROL <10> - VK_SPACE <90> - VK_RCONTROL <93> - VK_RMENU <92> - VK_ESCAPE <14> - VK_F1 <94> - VK_F2 <95> - VK_F3 <96> - VK_F4 <97> - VK_F5 <98> - VK_F6 <99> - VK_F7 <100> - VK_F8 <101> - VK_F9 <102> - VK_F10 <103> - VK_F11 <104> - VK_F12 <105> - VK_SNAPSHOT <106> - VK_SCROLL <107> - VK_PAUSE <108> - VK_INSERT <109> - VK_HOME <110> - VK_PRIOR <111> - VK_DELETE <69> - VK_END <112> - VK_NEXT <113> - VK_UP <88> - VK_LEFT <80> - VK_DOWN <81> - VK_RIGHT <87> - VK_NUMLOCK <114> - VK_DIVIDE <115> - VK_MULTIPLY <116> - VK_SUBTRACT <83> - VK_NUMPAD7 <74> - VK_NUMPAD8 <75> - VK_NUMPAD9 <82> - VK_ADD <117> - VK_NUMPAD4 <70> - VK_NUMPAD5 <76> - VK_NUMPAD6 <77> - VK_NUMPAD1 <65> - VK_NUMPAD2 <71> - VK_NUMPAD3 <72> - VK_RETURN <89> - VK_NUMPAD0 <66> - VK_DECIMAL <73> -}; - -keyboard "pc102" -: extends "sgi_vndr/indigo(pc101)" -{ - VK_OEM_102 <118> -}; - diff --git a/keymaps/sgi_vndr/indy b/keymaps/sgi_vndr/indy deleted file mode 100644 index e45192615..000000000 --- a/keymaps/sgi_vndr/indy +++ /dev/null @@ -1,148 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "universal" -{ - VK_OEM_5 <91> - VK_OEM_5 <100> - VK_OEM_5 <101> -}; - -keyboard "pc101" -{ - VK_OEM_3 <22> - VK_KEY_1 <30> - VK_KEY_2 <38> - VK_KEY_3 <46> - VK_KEY_4 <45> - VK_KEY_5 <54> - VK_KEY_6 <62> - VK_KEY_7 <69> - VK_KEY_8 <70> - VK_KEY_9 <78> - VK_KEY_0 <77> - VK_OEM_MINUS <86> - VK_OEM_PLUS <93> - VK_BACK <110> - VK_TAB <21> - VK_KEY_Q <29> - VK_KEY_W <37> - VK_KEY_E <44> - VK_KEY_R <53> - VK_KEY_T <52> - VK_KEY_Y <61> - VK_KEY_U <68> - VK_KEY_I <75> - VK_KEY_O <76> - VK_KEY_P <85> - VK_OEM_4 <92> - VK_OEM_6 <99> - VK_RETURN <98> - VK_CAPITAL <28> - VK_KEY_A <36> - VK_KEY_S <35> - VK_KEY_D <43> - VK_KEY_F <51> - VK_KEY_G <60> - VK_KEY_H <59> - VK_KEY_J <67> - VK_KEY_K <74> - VK_KEY_L <83> - VK_OEM_1 <84> - VK_OEM_7 <90> - VK_LSHIFT <26> - VK_KEY_Z <34> - VK_KEY_X <42> - VK_KEY_C <41> - VK_KEY_V <50> - VK_KEY_B <58> - VK_KEY_N <57> - VK_KEY_M <66> - VK_OEM_COMMA <73> - VK_OEM_PERIOD <81> - VK_OEM_2 <82> - VK_RSHIFT <97> - VK_OEM_5 <100> - VK_LMENU <33> - VK_LCONTROL <25> - VK_SPACE <49> - VK_RCONTROL <96> - VK_RMENU <65> - VK_ESCAPE <16> - VK_F1 <15> - VK_F2 <23> - VK_F3 <31> - VK_F4 <39> - VK_F5 <47> - VK_F6 <55> - VK_F7 <63> - VK_F8 <71> - VK_F9 <79> - VK_F10 <87> - VK_F11 <94> - VK_F12 <102> - VK_SNAPSHOT <95> - VK_SCROLL <103> - VK_PAUSE <106> - VK_INSERT <111> - VK_HOME <118> - VK_PRIOR <119> - VK_DELETE <108> - VK_END <109> - VK_NEXT <117> - VK_UP <107> - VK_LEFT <105> - VK_DOWN <104> - VK_RIGHT <114> - VK_NUMLOCK <126> - VK_DIVIDE <127> - VK_MULTIPLY <134> - VK_SUBTRACT <140> - VK_NUMPAD7 <116> - VK_NUMPAD8 <125> - VK_NUMPAD9 <133> - VK_ADD <132> - VK_NUMPAD4 <115> - VK_NUMPAD5 <123> - VK_NUMPAD6 <124> - VK_NUMPAD1 <113> - VK_NUMPAD2 <122> - VK_NUMPAD3 <130> - VK_RETURN <129> - VK_NUMPAD0 <120> - VK_DECIMAL <121> -}; - -keyboard "pc102" -{ - VK_OEM_102 <27> -}; - -keyboard "pc104" -: extends "sgi_vndr/indy(pc101)" -{ - VK_LWIN <147> - VK_RWIN <148> - VK_APPS <149> -}; - -keyboard "pc105" -{ -}; - -keyboard "jp106" -{ - VK_ABNT_C1 <89> - VK_OEM_5 <91> -}; - -keyboard "overlayKeypad" -{ -}; - -keyboard "shiftLock" -{ -}; - diff --git a/keymaps/sgi_vndr/iris b/keymaps/sgi_vndr/iris deleted file mode 100644 index 2b2fa5585..000000000 --- a/keymaps/sgi_vndr/iris +++ /dev/null @@ -1,10 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "iris" -: extends "sgi_vndr/indigo(pc101)" -{ -}; - diff --git a/keymaps/sony b/keymaps/sony deleted file mode 100644 index f65782a51..000000000 --- a/keymaps/sony +++ /dev/null @@ -1,103 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "nwp5461" -{ - VK_ESCAPE <18> - VK_KEY_1 <19> - VK_KEY_2 <20> - VK_KEY_3 <21> - VK_KEY_4 <22> - VK_KEY_5 <23> - VK_KEY_6 <24> - VK_KEY_7 <25> - VK_KEY_8 <26> - VK_KEY_9 <27> - VK_KEY_0 <28> - VK_OEM_MINUS <29> - VK_OEM_PLUS <30> - VK_OEM_5 <31> - VK_BACK <32> - VK_TAB <33> - VK_KEY_Q <34> - VK_KEY_W <35> - VK_KEY_E <36> - VK_KEY_R <37> - VK_KEY_T <38> - VK_KEY_Y <39> - VK_KEY_U <40> - VK_KEY_I <41> - VK_KEY_O <42> - VK_KEY_P <43> - VK_OEM_4 <44> - VK_OEM_6 <45> - VK_DELETE <46> - VK_LCONTROL <47> - VK_KEY_A <48> - VK_KEY_S <49> - VK_KEY_D <50> - VK_KEY_F <51> - VK_KEY_G <52> - VK_KEY_H <53> - VK_KEY_J <54> - VK_KEY_K <55> - VK_KEY_L <56> - VK_OEM_1 <57> - VK_OEM_7 <58> - VK_OEM_3 <59> - VK_RETURN <60> - VK_LSHIFT <61> - VK_KEY_Z <62> - VK_KEY_X <63> - VK_KEY_C <64> - VK_KEY_V <65> - VK_KEY_B <66> - VK_KEY_N <67> - VK_KEY_M <68> - VK_OEM_COMMA <69> - VK_OEM_PERIOD <70> - VK_OEM_2 <71> - VK_ABNT_C1 <72> - VK_RSHIFT <73> - VK_LMENU <74> - VK_CAPITAL <75> - VK_SPACE <77> - VK_F1 <8> - VK_F2 <9> - VK_F3 <10> - VK_F4 <11> - VK_F5 <12> - VK_F6 <13> - VK_F7 <14> - VK_F8 <15> - VK_F9 <16> - VK_F10 <17> - VK_F11 <111> - VK_F12 <112> - VK_HELP <113> - VK_INSERT <114> - VK_PRIOR <116> - VK_NEXT <117> - VK_UP <95> - VK_LEFT <98> - VK_DOWN <99> - VK_RIGHT <100> - VK_MULTIPLY <107> - VK_DIVIDE <108> - VK_ADD <89> - VK_NUMPAD7 <82> - VK_NUMPAD8 <83> - VK_NUMPAD9 <84> - VK_SUBTRACT <85> - VK_NUMPAD4 <86> - VK_NUMPAD5 <87> - VK_NUMPAD6 <88> - VK_NUMPAD1 <90> - VK_NUMPAD2 <91> - VK_NUMPAD3 <92> - VK_RETURN <97> - VK_NUMPAD0 <94> -}; - diff --git a/keymaps/sun b/keymaps/sun deleted file mode 100644 index 1eecd1bd9..000000000 --- a/keymaps/sun +++ /dev/null @@ -1,618 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "type4" -{ - VK_ESCAPE <36> - VK_KEY_1 <37> - VK_KEY_2 <38> - VK_KEY_3 <39> - VK_KEY_4 <40> - VK_KEY_5 <41> - VK_KEY_6 <42> - VK_KEY_7 <43> - VK_KEY_8 <44> - VK_KEY_9 <45> - VK_KEY_0 <46> - VK_OEM_MINUS <47> - VK_OEM_PLUS <48> - VK_OEM_3 <49> - VK_BACK <50> - VK_TAB <60> - VK_KEY_Q <61> - VK_KEY_W <62> - VK_KEY_E <63> - VK_KEY_R <64> - VK_KEY_T <65> - VK_KEY_Y <66> - VK_KEY_U <67> - VK_KEY_I <68> - VK_KEY_O <69> - VK_KEY_P <70> - VK_OEM_4 <71> - VK_OEM_6 <72> - VK_DELETE <73> - VK_LCONTROL <83> - VK_KEY_A <84> - VK_KEY_S <85> - VK_KEY_D <86> - VK_KEY_F <87> - VK_KEY_G <88> - VK_KEY_H <89> - VK_KEY_J <90> - VK_KEY_K <91> - VK_KEY_L <92> - VK_OEM_1 <93> - VK_OEM_7 <94> - VK_OEM_5 <95> - VK_RETURN <96> - VK_LSHIFT <106> - VK_KEY_Z <107> - VK_KEY_X <108> - VK_KEY_C <109> - VK_KEY_V <110> - VK_KEY_B <111> - VK_KEY_N <112> - VK_KEY_M <113> - VK_OEM_COMMA <114> - VK_OEM_PERIOD <115> - VK_OEM_2 <116> - VK_RSHIFT <117> - VK_HELP <125> - VK_CAPITAL <126> - VK_LMENU <26> - VK_SPACE <128> - VK_APPS <74> - VK_F1 <12> - VK_F2 <13> - VK_F3 <15> - VK_F4 <17> - VK_F5 <19> - VK_F6 <21> - VK_F7 <23> - VK_F8 <24> - VK_F9 <25> - VK_F10 <14> - VK_F11 <16> - VK_F12 <18> - VK_SNAPSHOT <29> - VK_SCROLL <30> - VK_PAUSE <28> - VK_NUMLOCK <105> - VK_DIVIDE <53> - VK_MULTIPLY <54> - VK_SUBTRACT <78> - VK_NUMPAD7 <75> - VK_NUMPAD8 <76> - VK_NUMPAD9 <77> - VK_ADD <132> - VK_NUMPAD4 <98> - VK_NUMPAD5 <99> - VK_NUMPAD6 <100> - VK_NUMPAD1 <119> - VK_NUMPAD2 <120> - VK_NUMPAD3 <121> - VK_RETURN <97> - VK_NUMPAD0 <101> - VK_DECIMAL <57> -}; - -keyboard "type5" -{ - VK_ESCAPE <36> - VK_KEY_1 <37> - VK_KEY_2 <38> - VK_KEY_3 <39> - VK_KEY_4 <40> - VK_KEY_5 <41> - VK_KEY_6 <42> - VK_KEY_7 <43> - VK_KEY_8 <44> - VK_KEY_9 <45> - VK_KEY_0 <46> - VK_OEM_MINUS <47> - VK_OEM_PLUS <48> - VK_OEM_3 <49> - VK_BACK <50> - VK_TAB <60> - VK_KEY_Q <61> - VK_KEY_W <62> - VK_KEY_E <63> - VK_KEY_R <64> - VK_KEY_T <65> - VK_KEY_Y <66> - VK_KEY_U <67> - VK_KEY_I <68> - VK_KEY_O <69> - VK_KEY_P <70> - VK_OEM_4 <71> - VK_OEM_6 <72> - VK_DELETE <73> - VK_APPS <74> - VK_LCONTROL <83> - VK_KEY_A <84> - VK_KEY_S <85> - VK_KEY_D <86> - VK_KEY_F <87> - VK_KEY_G <88> - VK_KEY_H <89> - VK_KEY_J <90> - VK_KEY_K <91> - VK_KEY_L <92> - VK_OEM_1 <93> - VK_OEM_7 <94> - VK_OEM_5 <95> - VK_RETURN <96> - VK_LSHIFT <106> - VK_KEY_Z <107> - VK_KEY_X <108> - VK_KEY_C <109> - VK_KEY_V <110> - VK_KEY_B <111> - VK_KEY_N <112> - VK_KEY_M <113> - VK_OEM_COMMA <114> - VK_OEM_PERIOD <115> - VK_OEM_2 <116> - VK_RSHIFT <117> - VK_LMENU <26> - VK_CAPITAL <126> - VK_SPACE <128> - VK_F1 <12> - VK_F2 <13> - VK_F3 <15> - VK_F4 <17> - VK_F5 <19> - VK_F6 <21> - VK_F7 <23> - VK_F8 <24> - VK_F9 <25> - VK_F10 <14> - VK_F11 <16> - VK_F12 <18> - VK_SNAPSHOT <29> - VK_SCROLL <30> - VK_PAUSE <28> - VK_NUMLOCK <105> - VK_DIVIDE <53> - VK_MULTIPLY <54> - VK_SUBTRACT <78> - VK_NUMPAD7 <75> - VK_NUMPAD8 <76> - VK_NUMPAD9 <77> - VK_ADD <132> - VK_NUMPAD4 <98> - VK_NUMPAD5 <99> - VK_NUMPAD6 <100> - VK_NUMPAD1 <119> - VK_NUMPAD2 <120> - VK_NUMPAD3 <121> - VK_RETURN <97> - VK_NUMPAD0 <101> - VK_DECIMAL <57> - VK_UP <27> - VK_LEFT <31> - VK_DOWN <34> - VK_RIGHT <35> - VK_INSERT <51> - VK_HOME <59> - VK_END <81> - VK_PRIOR <103> - VK_NEXT <130> - VK_HELP <125> -}; - -keyboard "type4tuv" -: extends "sun(type4)" -{ - VK_OEM_102 <131> -}; - -keyboard "type4_ca" -: extends "sun(type4)" -{ - VK_OEM_102 <131> -}; - -keyboard "type4_jp" -: extends "sun(type4)" -{ - VK_KANJI <123> -}; - -keyboard "type4_euro" -: extends "sun(type4)" -{ - VK_OEM_102 <131> -}; - -keyboard "type5tuv" -: extends "sun(type5)" -{ - VK_OEM_102 <131> -}; - -keyboard "type5_jp" -: extends "sun(type5)" -{ - VK_KANJI <123> -}; - -keyboard "type5_euro" -: extends "sun(type5)" -{ - VK_OEM_102 <131> -}; - -keyboard "type5hobo" -{ - VK_ESCAPE <36> - VK_KEY_1 <37> - VK_KEY_2 <38> - VK_KEY_3 <39> - VK_KEY_4 <40> - VK_KEY_5 <41> - VK_KEY_6 <42> - VK_KEY_7 <43> - VK_KEY_8 <44> - VK_KEY_9 <45> - VK_KEY_0 <46> - VK_OEM_MINUS <47> - VK_OEM_PLUS <48> - VK_OEM_3 <49> - VK_BACK <50> - VK_TAB <60> - VK_KEY_Q <61> - VK_KEY_W <62> - VK_KEY_E <63> - VK_KEY_R <64> - VK_KEY_T <65> - VK_KEY_Y <66> - VK_KEY_U <67> - VK_KEY_I <68> - VK_KEY_O <69> - VK_KEY_P <70> - VK_OEM_4 <71> - VK_OEM_6 <72> - VK_DELETE <73> - VK_APPS <74> - VK_LCONTROL <83> - VK_KEY_A <84> - VK_KEY_S <85> - VK_KEY_D <86> - VK_KEY_F <87> - VK_KEY_G <88> - VK_KEY_H <89> - VK_KEY_J <90> - VK_KEY_K <91> - VK_KEY_L <92> - VK_OEM_1 <93> - VK_OEM_7 <94> - VK_OEM_5 <95> - VK_RETURN <96> - VK_LSHIFT <106> - VK_KEY_Z <107> - VK_KEY_X <108> - VK_KEY_C <109> - VK_KEY_V <110> - VK_KEY_B <111> - VK_KEY_N <112> - VK_KEY_M <113> - VK_OEM_COMMA <114> - VK_OEM_PERIOD <115> - VK_OEM_2 <116> - VK_RSHIFT <117> - VK_LMENU <26> - VK_CAPITAL <126> - VK_SPACE <128> - VK_F1 <12> - VK_F2 <13> - VK_F3 <15> - VK_F4 <17> - VK_F5 <19> - VK_F6 <21> - VK_F7 <23> - VK_F8 <24> - VK_F9 <25> - VK_F10 <14> - VK_F11 <16> - VK_F12 <18> - VK_SNAPSHOT <29> - VK_SCROLL <30> - VK_PAUSE <28> - VK_NUMLOCK <105> - VK_DIVIDE <53> - VK_MULTIPLY <54> - VK_SUBTRACT <78> - VK_NUMPAD7 <75> - VK_NUMPAD8 <76> - VK_NUMPAD9 <77> - VK_ADD <132> - VK_NUMPAD4 <98> - VK_NUMPAD5 <99> - VK_NUMPAD6 <100> - VK_NUMPAD1 <119> - VK_NUMPAD2 <120> - VK_NUMPAD3 <121> - VK_RETURN <97> - VK_NUMPAD0 <101> - VK_DECIMAL <57> - VK_UP <27> - VK_LEFT <31> - VK_DOWN <34> - VK_RIGHT <35> - VK_INSERT <51> - VK_HOME <59> - VK_END <81> - VK_PRIOR <103> - VK_NEXT <130> - VK_HELP <125> -}; - -keyboard "type5tuvhobo" -: extends "sun(type5hobo)" -{ - VK_OEM_102 <131> -}; - -keyboard "type5_jphobo" -: extends "sun(type5hobo)" -{ - VK_KANJI <123> -}; - -keyboard "type6" -: extends "sun(type5)" -{ -}; - -keyboard "type6tuv" -: extends "sun(type5tuv)" -{ -}; - -keyboard "type6unix" -: extends "sun(type5)" -{ -}; - -keyboard "type6_jp" -: extends "sun(type5_jp)" -{ -}; - -keyboard "type6_euro" -: extends "sun(type5_euro)" -{ -}; - -keyboard "type6_usb" -: extends "xfree86" -{ - VK_HELP <245> -}; - -keyboard "type6tuv_usb" -: extends "sun(type6_usb)" -{ - VK_OEM_102 <94> - VK_OEM_5 <51> -}; - -keyboard "type6_jp_usb" -: extends "sun(type6_usb)" -{ -}; - -keyboard "type5_se" -{ - VK_HELP <125> - VK_ESCAPE <36> - VK_F1 <12> - VK_F2 <13> - VK_F3 <15> - VK_F4 <17> - VK_F5 <19> - VK_F6 <21> - VK_F7 <23> - VK_F8 <24> - VK_F9 <25> - VK_F10 <14> - VK_F11 <16> - VK_F12 <18> - VK_SNAPSHOT <29> - VK_SCROLL <30> - VK_PAUSE <28> - VK_TILDE <49> - VK_KEY_1 <37> - VK_KEY_2 <38> - VK_KEY_3 <39> - VK_KEY_4 <40> - VK_KEY_5 <41> - VK_KEY_6 <42> - VK_KEY_7 <43> - VK_KEY_8 <44> - VK_KEY_9 <45> - VK_KEY_0 <46> - VK_OEM_MINUS <47> - VK_OEM_PLUS <48> - VK_BACK <50> - VK_INSERT <51> - VK_HOME <59> - VK_PRIOR <103> - VK_NUMLOCK <105> - VK_DIVIDE <53> - VK_MULTIPLY <54> - VK_SUBTRACT <78> - VK_KEY_Q <61> - VK_KEY_W <62> - VK_KEY_E <63> - VK_KEY_R <64> - VK_KEY_T <65> - VK_KEY_Y <66> - VK_KEY_U <67> - VK_KEY_I <68> - VK_KEY_O <69> - VK_KEY_P <70> - VK_OEM_4 <71> - VK_OEM_6 <72> - VK_DELETE <73> - VK_END <81> - VK_NEXT <130> - VK_NUMPAD7 <75> - VK_NUMPAD8 <76> - VK_NUMPAD9 <77> - VK_ADD <132> - VK_KEY_A <84> - VK_KEY_S <85> - VK_KEY_D <86> - VK_KEY_F <87> - VK_KEY_G <88> - VK_KEY_H <89> - VK_KEY_J <90> - VK_KEY_K <91> - VK_KEY_L <92> - VK_OEM_1 <93> - VK_OEM_7 <94> - VK_OEM_5 <95> - VK_RETURN <96> - VK_NUMPAD4 <98> - VK_NUMPAD5 <99> - VK_NUMPAD6 <100> - VK_LSHIFT <106> - VK_LSHIFT <131> - VK_KEY_Z <107> - VK_KEY_X <108> - VK_KEY_C <109> - VK_KEY_V <110> - VK_KEY_B <111> - VK_KEY_N <112> - VK_KEY_M <113> - VK_OEM_COMMA <114> - VK_OEM_PERIOD <115> - VK_OEM_2 <116> - VK_RSHIFT <117> - VK_UP <27> - VK_NUMPAD1 <119> - VK_NUMPAD2 <120> - VK_NUMPAD3 <121> - VK_RETURN <97> - VK_LCONTROL <83> - VK_LMENU <26> - VK_SPACE <128> - VK_APPS <74> - VK_LEFT <31> - VK_DOWN <34> - VK_RIGHT <35> - VK_NUMPAD0 <101> - VK_DECIMAL <57> -}; - -keyboard "type5c_se" -: extends "sun(type5_se)" -{ -}; - -keyboard "type4__se" -{ - VK_F1 <12> - VK_F2 <13> - VK_F3 <15> - VK_F4 <17> - VK_F5 <19> - VK_F6 <21> - VK_F7 <23> - VK_F8 <24> - VK_F9 <25> - VK_F10 <14> - VK_F11 <16> - VK_F12 <18> - VK_DELETE <73> - VK_PAUSE <28> - VK_SNAPSHOT <29> - VK_SCROLL <30> - VK_NUMLOCK <105> - VK_TILDE <36> - VK_KEY_1 <37> - VK_KEY_2 <38> - VK_KEY_3 <39> - VK_KEY_4 <40> - VK_KEY_5 <41> - VK_KEY_6 <42> - VK_KEY_7 <43> - VK_KEY_8 <44> - VK_KEY_9 <45> - VK_KEY_0 <46> - VK_OEM_MINUS <47> - VK_OEM_PLUS <48> - VK_BACK <50> - VK_DIVIDE <53> - VK_MULTIPLY <54> - VK_SUBTRACT <78> - VK_KEY_Q <61> - VK_KEY_W <62> - VK_KEY_E <63> - VK_KEY_R <64> - VK_KEY_T <65> - VK_KEY_Y <66> - VK_KEY_U <67> - VK_KEY_I <68> - VK_KEY_O <69> - VK_KEY_P <70> - VK_OEM_4 <71> - VK_OEM_6 <72> - VK_NUMPAD7 <75> - VK_NUMPAD8 <76> - VK_NUMPAD9 <77> - VK_ADD <132> - VK_KEY_A <84> - VK_KEY_S <85> - VK_KEY_D <86> - VK_KEY_F <87> - VK_KEY_G <88> - VK_KEY_H <89> - VK_KEY_J <90> - VK_KEY_K <91> - VK_KEY_L <92> - VK_OEM_1 <93> - VK_OEM_7 <94> - VK_OEM_5 <49> - VK_RETURN <96> - VK_NUMPAD4 <98> - VK_NUMPAD5 <99> - VK_NUMPAD6 <100> - VK_LSHIFT <106> - VK_LSHIFT <131> - VK_KEY_Z <107> - VK_KEY_X <108> - VK_KEY_C <109> - VK_KEY_V <110> - VK_KEY_B <111> - VK_KEY_N <112> - VK_KEY_M <113> - VK_OEM_COMMA <114> - VK_OEM_PERIOD <115> - VK_OEM_2 <116> - VK_RSHIFT <117> - VK_NUMPAD1 <119> - VK_NUMPAD2 <120> - VK_NUMPAD3 <121> - VK_RETURN <97> - VK_HELP <125> - VK_LMENU <26> - VK_SPACE <128> - VK_APPS <74> - VK_NUMPAD0 <101> - VK_DECIMAL <57> -}; - -keyboard "type4_se" -{ -}; - -keyboard "type4_se_swapctl" -{ -}; - diff --git a/keymaps/xfree86 b/keymaps/xfree86 deleted file mode 100644 index 63d5c2e01..000000000 --- a/keymaps/xfree86 +++ /dev/null @@ -1,152 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "xfree86" -: extends "xfree86(basic)" -{ - VK_OEM_5 <51> - VK_OEM_102 <94> -}; - -keyboard "basic" -{ - VK_OEM_3 <49> - VK_KEY_1 <10> - VK_KEY_2 <11> - VK_KEY_3 <12> - VK_KEY_4 <13> - VK_KEY_5 <14> - VK_KEY_6 <15> - VK_KEY_7 <16> - VK_KEY_8 <17> - VK_KEY_9 <18> - VK_KEY_0 <19> - VK_OEM_MINUS <20> - VK_OEM_PLUS <21> - VK_BACK <22> - VK_TAB <23> - VK_KEY_Q <24> - VK_KEY_W <25> - VK_KEY_E <26> - VK_KEY_R <27> - VK_KEY_T <28> - VK_KEY_Y <29> - VK_KEY_U <30> - VK_KEY_I <31> - VK_KEY_O <32> - VK_KEY_P <33> - VK_OEM_4 <34> - VK_OEM_6 <35> - VK_RETURN <36> - VK_CAPITAL <66> - VK_KEY_A <38> - VK_KEY_S <39> - VK_KEY_D <40> - VK_KEY_F <41> - VK_KEY_G <42> - VK_KEY_H <43> - VK_KEY_J <44> - VK_KEY_K <45> - VK_KEY_L <46> - VK_OEM_1 <47> - VK_OEM_7 <48> - VK_LSHIFT <50> - VK_KEY_Z <52> - VK_KEY_X <53> - VK_KEY_C <54> - VK_KEY_V <55> - VK_KEY_B <56> - VK_KEY_N <57> - VK_KEY_M <58> - VK_OEM_COMMA <59> - VK_OEM_PERIOD <60> - VK_OEM_2 <61> - VK_RSHIFT <62> - VK_LMENU <64> - VK_LCONTROL <37> - VK_SPACE <65> - VK_RCONTROL <109> - VK_RMENU <113> - VK_LWIN <115> - VK_RWIN <116> - VK_APPS <117> - VK_ESCAPE <9> - VK_F1 <67> - VK_F2 <68> - VK_F3 <69> - VK_F4 <70> - VK_F5 <71> - VK_F6 <72> - VK_F7 <73> - VK_F8 <74> - VK_F9 <75> - VK_F10 <76> - VK_F11 <95> - VK_F12 <96> - VK_SNAPSHOT <111> - VK_SCROLL <78> - VK_PAUSE <110> - VK_INSERT <106> - VK_HOME <97> - VK_PRIOR <99> - VK_DELETE <107> - VK_END <103> - VK_NEXT <105> - VK_UP <98> - VK_LEFT <100> - VK_DOWN <104> - VK_RIGHT <102> - VK_NUMLOCK <77> - VK_DIVIDE <112> - VK_MULTIPLY <63> - VK_SUBTRACT <82> - VK_NUMPAD7 <79> - VK_NUMPAD8 <80> - VK_NUMPAD9 <81> - VK_ADD <86> - VK_NUMPAD4 <83> - VK_NUMPAD5 <84> - VK_NUMPAD6 <85> - VK_NUMPAD1 <87> - VK_NUMPAD2 <88> - VK_NUMPAD3 <89> - VK_RETURN <108> - VK_NUMPAD0 <90> - VK_DECIMAL <91> - VK_F13 <118> - VK_F14 <119> - VK_F15 <120> - VK_F16 <121> - VK_F17 <122> - VK_ABNT_C1 <211> -}; - -keyboard "102" -: extends "xfree86(xfree86)" -{ - VK_RMENU <122> - VK_RCONTROL <123> - VK_SNAPSHOT <121> - VK_PAUSE <118> - VK_INSERT <131> - VK_HOME <135> - VK_PRIOR <119> - VK_DELETE <129> - VK_END <130> - VK_NEXT <134> - VK_UP <128> - VK_LEFT <132> - VK_DOWN <120> - VK_RIGHT <133> - VK_DIVIDE <125> - VK_RETURN <124> -}; - -keyboard "thinkpadz60" -: extends "xfree86(xfree86)" -{ - VK_APPS <227> -}; - diff --git a/keymaps/xfree98 b/keymaps/xfree98 deleted file mode 100644 index 6e3bae62c..000000000 --- a/keymaps/xfree98 +++ /dev/null @@ -1,106 +0,0 @@ -# This file was generated with xkb.pl (Wed Aug 11 09:09:10 2010) -# and is based on the X Keyboard Configuration Database version 1.9 -# Please use xkb.pl to re-export newer versions of XKB - - -keyboard "pc98" -{ - VK_ESCAPE <8> - VK_KEY_1 <9> - VK_KEY_2 <10> - VK_KEY_3 <11> - VK_KEY_4 <12> - VK_KEY_5 <13> - VK_KEY_6 <14> - VK_KEY_7 <15> - VK_KEY_8 <16> - VK_KEY_9 <17> - VK_KEY_0 <18> - VK_OEM_MINUS <19> - VK_OEM_PLUS <20> - VK_OEM_5 <21> - VK_BACK <22> - VK_TAB <23> - VK_KEY_Q <24> - VK_KEY_W <25> - VK_KEY_E <26> - VK_KEY_R <27> - VK_KEY_T <28> - VK_KEY_Y <29> - VK_KEY_U <30> - VK_KEY_I <31> - VK_KEY_O <32> - VK_KEY_P <33> - VK_OEM_4 <34> - VK_OEM_6 <35> - VK_RETURN <36> - VK_LCONTROL <124> - VK_CAPITAL <121> - VK_KEY_A <37> - VK_KEY_S <38> - VK_KEY_D <39> - VK_KEY_F <40> - VK_KEY_G <41> - VK_KEY_H <42> - VK_KEY_J <43> - VK_KEY_K <44> - VK_KEY_L <45> - VK_OEM_1 <46> - VK_OEM_7 <47> - VK_OEM_5 <48> - VK_LSHIFT <120> - VK_KEY_Z <49> - VK_KEY_X <50> - VK_KEY_C <51> - VK_KEY_V <52> - VK_KEY_B <53> - VK_KEY_N <54> - VK_KEY_M <55> - VK_OEM_COMMA <56> - VK_OEM_PERIOD <57> - VK_OEM_2 <58> - VK_ABNT_C1 <59> - VK_LMENU <123> - VK_SPACE <60> - VK_SNAPSHOT <105> - VK_F1 <106> - VK_F2 <107> - VK_F3 <108> - VK_F4 <109> - VK_F5 <110> - VK_F6 <111> - VK_F7 <112> - VK_F8 <113> - VK_F9 <114> - VK_F10 <115> - VK_F11 <90> - VK_F12 <91> - VK_F13 <92> - VK_F14 <93> - VK_F15 <94> - VK_INSERT <64> - VK_DELETE <65> - VK_PRIOR <63> - VK_NEXT <62> - VK_UP <66> - VK_LEFT <67> - VK_RIGHT <68> - VK_DOWN <69> - VK_HOME <70> - VK_HELP <71> - VK_SUBTRACT <72> - VK_DIVIDE <73> - VK_NUMPAD7 <74> - VK_NUMPAD8 <75> - VK_NUMPAD9 <76> - VK_MULTIPLY <77> - VK_NUMPAD4 <78> - VK_NUMPAD5 <79> - VK_NUMPAD6 <80> - VK_ADD <81> - VK_NUMPAD1 <82> - VK_NUMPAD2 <83> - VK_NUMPAD3 <84> - VK_NUMPAD0 <86> -}; - diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index eb2efe7b5..bb480f7ea 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -31,8 +31,6 @@ set(${MODULE_PREFIX}_X11_SRCS xkb_layout_ids.h) set(${MODULE_PREFIX}_X11_KEYMAP_SRCS - keyboard_keymap.c - keyboard_keymap.h keyboard_x11.c keyboard_x11.h) diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 99b55116f..4dd5cf6c5 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -30,7 +30,6 @@ #include #include -#include "keyboard_keymap.h" #include "liblocale.h" #ifdef WITH_X11 diff --git a/libfreerdp/locale/keyboard_keymap.c b/libfreerdp/locale/keyboard_keymap.c deleted file mode 100644 index af4d6f294..000000000 --- a/libfreerdp/locale/keyboard_keymap.c +++ /dev/null @@ -1,212 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Keyboard Localization - loading of keymap files - * - * Copyright 2009-2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "keyboard_keymap.h" - -#include -#include -#include - -#include - -#include -#include -#include - -#include "liblocale.h" - -#include - -extern const RDP_SCANCODE VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[256]; - -int freerdp_keyboard_load_map(UINT32 keycode_to_vkcode[256], char* name) -{ - FILE* fp; - char* pch; - char* beg; - char* end; - UINT32 vkcode; - int kbd_found = 0; - char* keymap_path; - UINT32 keycode = 0; - char buffer[1024] = ""; - char keymap_name[256] = ""; - char keymap_include[256] = ""; - char keymap_filename[256] = ""; - char keycode_string[32] = ""; - char vkcode_name[128] = ""; - - beg = name; - - /* Extract file name and keymap name */ - if ((end = strrchr(name, '(')) != NULL) - { - strncpy(keymap_filename, &name[beg - name], end - beg); - - beg = end + 1; - if ((end = strrchr(name, ')')) != NULL) - { - strncpy(keymap_name, &name[beg - name], end - beg); - keymap_name[end - beg] = '\0'; - } - } - else - { - /* The keyboard name is the same as the file name */ - strcpy(keymap_filename, name); - strcpy(keymap_name, name); - } - - keymap_path = freerdp_construct_path(FREERDP_KEYMAP_PATH, keymap_filename); - - DEBUG_KBD("Loading keymap %s, first trying %s", name, keymap_path); - - if ((fp = fopen(keymap_path, "r")) == NULL) - { - DEBUG_KBD("%s not found", keymap_path); - free(keymap_path); - return 0; - } - free(keymap_path); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) - { - if (buffer[0] == '#') - { - continue; /* Skip comments */ - } - - if (kbd_found) - { - /* Closing curly bracket and semicolon */ - if ((pch = strstr(buffer, "};")) != NULL) - { - break; - } - else if ((pch = strstr(buffer, "VK_")) != NULL) - { - /* The end is delimited by the first white space */ - end = strcspn(pch, " \t\n\0") + pch; - - /* We copy the virtual key code name in a string */ - beg = pch; - strncpy(vkcode_name, beg, end - beg); - vkcode_name[end - beg] = '\0'; - - /* Now we want to extract the virtual key code itself which is in between '<' and '>' */ - if ((beg = strchr(pch + 3, '<')) == NULL) - break; - else - beg++; - - if ((end = strchr(beg, '>')) == NULL) - break; - - /* We copy the string representing the number in a string */ - strncpy(keycode_string, beg, end - beg); - keycode_string[end - beg] = '\0'; - - /* Convert the string representing the code to an integer */ - keycode = atoi(keycode_string); - - /* Make sure it is a valid keycode */ - if (keycode > 255) - break; - - /* Load this key mapping in the keyboard mapping */ - vkcode = freerdp_keyboard_get_virtual_key_code_from_name(vkcode_name); - keycode_to_vkcode[keycode] = vkcode; - } - else if ((pch = strstr(buffer, ": extends")) != NULL) - { - /* - * This map extends another keymap We extract its name - * and we recursively load the keymap we need to include. - */ - - if ((beg = strchr(pch + sizeof(": extends"), '"')) == NULL) - break; - beg++; - - if ((end = strchr(beg, '"')) == NULL) - break; - - strncpy(keymap_include, beg, end - beg); - keymap_include[end - beg] = '\0'; - - freerdp_keyboard_load_map(keycode_to_vkcode, keymap_include); /* Load included keymap */ - } - } - else if ((pch = strstr(buffer, "keyboard")) != NULL) - { - /* Keyboard map identifier */ - if ((beg = strchr(pch + sizeof("keyboard"), '"')) == NULL) - break; - beg++; - - if ((end = strchr(beg, '"')) == NULL) - break; - - pch = beg; - buffer[end - beg] = '\0'; - - /* Does it match our keymap name? */ - if (strncmp(keymap_name, pch, strlen(keymap_name)) == 0) - kbd_found = 1; - } - } - - fclose(fp); /* Don't forget to close file */ - - return 1; -} - -void freerdp_keyboard_load_maps(UINT32 keycode_to_vkcode[256], char* names) -{ - char* kbd; - char* names_end; - int keymap_loaded = 0; - - ZeroMemory(keycode_to_vkcode, sizeof(UINT32) * 256); - - kbd = names; - names_end = names + strlen(names); - - do - { - /* multiple maps are separated by '+' */ - int kbd_length = strcspn(kbd + 1, "+") + 1; - kbd[kbd_length] = '\0'; - - /* Load keyboard map */ - keymap_loaded += freerdp_keyboard_load_map(keycode_to_vkcode, kbd); - - kbd += kbd_length + 1; - } - while (kbd < names_end); - - DEBUG_KBD("loaded %d keymaps", keymap_loaded); - - if (keymap_loaded <= 0) - printf("error: no keyboard mapping available!\n"); -} diff --git a/libfreerdp/locale/keyboard_keymap.h b/libfreerdp/locale/keyboard_keymap.h deleted file mode 100644 index d64aae207..000000000 --- a/libfreerdp/locale/keyboard_keymap.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Keyboard Localization - loading of keymap files - * - * Copyright 2009-2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __KEYBOARD_KEYMAP_H -#define __KEYBOARD_KEYMAP_H - -#include - -int freerdp_keyboard_load_map(UINT32 keycode_to_vkcode[256], char* name); -void freerdp_keyboard_load_maps(UINT32 keycode_to_vkcode[256], char* names); - -#endif /* __KEYBOARD_KEYMAP_H */ diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index 2f938ae4d..463124744 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -33,7 +33,6 @@ #include #include "keyboard_x11.h" -#include "keyboard_keymap.h" #include "xkb_layout_ids.h" #ifdef WITH_SUN From 4fd085baafd868a7ebe8802e3c467a3fb7e43b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 28 Feb 2013 14:54:08 -0500 Subject: [PATCH 03/18] cmake: remove unused code --- CMakeLists.txt | 9 +--- cmake/FindCmockery.cmake | 41 ------------------ libfreerdp/core/CMakeLists.txt | 5 --- libfreerdp/core/test/.gitignore | 2 - libfreerdp/core/test/CMakeLists.txt | 40 ----------------- libfreerdp/core/test/TestCoreRts.c | 66 ----------------------------- 6 files changed, 1 insertion(+), 162 deletions(-) delete mode 100644 cmake/FindCmockery.cmake delete mode 100644 libfreerdp/core/test/.gitignore delete mode 100644 libfreerdp/core/test/CMakeLists.txt delete mode 100644 libfreerdp/core/test/TestCoreRts.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f9d6697c..1c52299bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,7 +329,6 @@ endif() # Path to put FreeRDP data set(FREERDP_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/freerdp") -set(FREERDP_KEYMAP_PATH "${FREERDP_DATA_PATH}/keymaps") # Path to put plugins @@ -359,9 +358,7 @@ set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..") include(CTest) -if(BUILD_TESTING) - find_package(Cmockery) - +if(BUILD_TESTING) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_TEST_EXPORTS") enable_testing() @@ -412,10 +409,6 @@ if(WITH_THIRD_PARTY) add_subdirectory(third-party) endif() -if(NOT MSVC) - add_subdirectory(keymaps) -endif() - # Packaging SET(CPACK_BINARY_ZIP "ON") diff --git a/cmake/FindCmockery.cmake b/cmake/FindCmockery.cmake deleted file mode 100644 index d7c8c2d13..000000000 --- a/cmake/FindCmockery.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# - Find Cmockery -# Find the Cmockery libraries -# -# This module defines the following variables: -# CMOCKERY_FOUND - true if CMOCKERY_INCLUDE_DIR & CMOCKERY_LIBRARY are found -# CMOCKERY_LIBRARIES - Set when CMOCKERY_LIBRARY is found -# CMOCKERY_INCLUDE_DIRS - Set when CMOCKERY_INCLUDE_DIR is found -# - -#============================================================================= -# Copyright 2012 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#============================================================================= - -find_path(CMOCKERY_INCLUDE_DIR NAMES cmockery.h - PATH_SUFFIXES google) - -find_library(CMOCKERY_LIBRARY NAMES cmockery - DOC "The Cmockery library") - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cmockery DEFAULT_MSG CMOCKERY_LIBRARY CMOCKERY_INCLUDE_DIR) - -if(CMOCKERY_FOUND) - set(CMOCKERY_LIBRARIES ${CMOCKERY_LIBRARY}) - set(CMOCKERY_INCLUDE_DIRS ${CMOCKERY_INCLUDE_DIR}) -endif() - -mark_as_advanced(CMOCKERY_INCLUDE_DIR CMOCKERY_LIBRARY) - diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 8ae77f9a9..9cf9ed8c2 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -147,9 +147,4 @@ endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") -if(BUILD_TESTING) - if(CMOCKERY_FOUND) - add_subdirectory(test) - endif() -endif() diff --git a/libfreerdp/core/test/.gitignore b/libfreerdp/core/test/.gitignore deleted file mode 100644 index 6c68d0825..000000000 --- a/libfreerdp/core/test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -TestCore -TestCore.c diff --git a/libfreerdp/core/test/CMakeLists.txt b/libfreerdp/core/test/CMakeLists.txt deleted file mode 100644 index 940a25516..000000000 --- a/libfreerdp/core/test/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ - -set(MODULE_NAME "TestCore") -set(MODULE_PREFIX "TEST_CORE") - -set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) - -set(${MODULE_PREFIX}_TESTS - TestCoreRts.c) - -create_test_sourcelist(${MODULE_PREFIX}_SRCS - ${${MODULE_PREFIX}_DRIVER} - ${${MODULE_PREFIX}_TESTS}) - -include_directories(..) - -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${CMOCKERY_LIBRARIES}) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE winpr - MODULES winpr-crt winpr-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - -set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") - -foreach(test ${${MODULE_PREFIX}_TESTS}) - get_filename_component(TestName ${test} NAME_WE) - add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName}) -endforeach() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test") - diff --git a/libfreerdp/core/test/TestCoreRts.c b/libfreerdp/core/test/TestCoreRts.c deleted file mode 100644 index ccfab5475..000000000 --- a/libfreerdp/core/test/TestCoreRts.c +++ /dev/null @@ -1,66 +0,0 @@ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "gateway/rts.h" - -/* mocks */ - -extern void rts_generate_cookie(BYTE* cookie); -extern int rpc_in_write(rdpRpc* rpc, BYTE* data, int length); -extern int rpc_out_write(rdpRpc* rpc, BYTE* data, int length); - -BYTE testCookie[16] = "\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC"; - -void rts_generate_cookie(BYTE* cookie) -{ - CopyMemory(cookie, testCookie, 16); -} - -int rpc_in_write(rdpRpc* rpc, BYTE* data, int length) -{ - printf("rpc_in_write: %d\n", length); - //winpr_HexDump(data, length); - return length; -} - -int rpc_out_write(rdpRpc* rpc, BYTE* data, int length) -{ - printf("rpc_out_write: %d\n", length); - //winpr_HexDump(data, length); - return length; -} - -/* tests */ - -void test_rts_generate_cookie(void **state) -{ - BYTE cookie[16]; - rts_generate_cookie(cookie); - assert_memory_equal(cookie, testCookie, 16); -} - -void test_rpc_in_write(void **state) -{ - int status; - status = rpc_in_write(NULL, NULL, 64); - assert_int_equal(status, 64); -} - -int TestCoreRts(int argc, char* argv[]) -{ - const UnitTest tests[] = - { - unit_test(test_rts_generate_cookie), - unit_test(test_rpc_in_write), - }; - - return run_tests(tests); -} From ea63fdb18e3adfd96313b466183a6bf290e6c2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 28 Feb 2013 15:43:57 -0500 Subject: [PATCH 04/18] libwinpr-utils: start custom printf replacement --- winpr/include/winpr/print.h | 2 + winpr/libwinpr/utils/print.c | 387 ++++++++++++++++++++++ winpr/libwinpr/utils/test/TestPrint.c | 445 ++++++-------------------- 3 files changed, 486 insertions(+), 348 deletions(-) diff --git a/winpr/include/winpr/print.h b/winpr/include/winpr/print.h index 73a44d06d..72049692d 100644 --- a/winpr/include/winpr/print.h +++ b/winpr/include/winpr/print.h @@ -27,4 +27,6 @@ WINPR_API void winpr_HexDump(BYTE* data, int length); +WINPR_API int wprintfx(const char *fmt, ...); + #endif /* WINPR_UTILS_PRINT_H */ diff --git a/winpr/libwinpr/utils/print.c b/winpr/libwinpr/utils/print.c index 173df27c7..f7863f268 100644 --- a/winpr/libwinpr/utils/print.c +++ b/winpr/libwinpr/utils/print.c @@ -21,6 +21,10 @@ #include "config.h" #endif +#include +#include +#include + #include #include @@ -53,3 +57,386 @@ void winpr_HexDump(BYTE* data, int length) p += line; } } + +/*---------------------------------------------------------------------------- +Stripped-down printf() +Chris Giese http://my.execpc.com/~geezer +Release date: Feb 3, 2008 + +This code is public domain (no copyright). +You can do whatever you want with it. + +%[flag][width][.prec][mod][conv] +flag: - left justify, pad right w/ blanks DONE + 0 pad left w/ 0 for numerics DONE + + always print sign, + or - no + ' ' (blank) no + # (???) no + +width: (field width) DONE + +prec: (precision) no + +conv: d,i decimal int DONE + u decimal unsigned DONE + o octal DONE + x,X hex DONE + f,e,g,E,G float no + c char DONE + s string DONE + p ptr DONE + +mod: N near ptr DONE + F far ptr no + h short (16-bit) int DONE + l long (32-bit) int DONE + L long long (64-bit) int no +----------------------------------------------------------------------------*/ + +/* flags used in processing format string */ +#define PR_LJ 0x01 /* left justify */ +#define PR_CA 0x02 /* use A-F instead of a-f for hex */ +#define PR_SG 0x04 /* signed numeric conversion (%d vs. %u) */ +#define PR_32 0x08 /* long (32-bit) numeric conversion */ +#define PR_16 0x10 /* short (16-bit) numeric conversion */ +#define PR_WS 0x20 /* PR_SG set and num was < 0 */ +#define PR_LZ 0x40 /* pad left with '0' instead of ' ' */ +#define PR_FP 0x80 /* pointers are far */ + +/* largest number handled is 2^32-1, lowest radix handled is 8. +2^32-1 in base 8 has 11 digits (add 5 for trailing NUL and for slop) */ +#define PR_BUFLEN 16 + +typedef int (*fnptr_t)(unsigned c, void **helper); + +int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr) +{ + long num; + unsigned char state, radix; + unsigned char *where, buf[PR_BUFLEN]; + unsigned flags, actual_wd, count, given_wd; + + state = flags = count = given_wd = 0; + + /* begin scanning format specifier list */ + + for (; *fmt; fmt++) + { + switch (state) + { +/* STATE 0: AWAITING % */ + case 0: + if (*fmt != '%') /* not %... */ + { + fn(*fmt, &ptr); /* ...just echo it */ + count++; + break; + } + + /* found %, get next char and advance state to check if next char is a flag */ + + state++; + fmt++; + /* FALL THROUGH */ +/* STATE 1: AWAITING FLAGS (%-0) */ + case 1: + if (*fmt == '%') /* %% */ + { + fn(*fmt, &ptr); + count++; + state = flags = given_wd = 0; + break; + } + if (*fmt == '-') + { + if (flags & PR_LJ) /* %-- is illegal */ + state = flags = given_wd = 0; + else + flags |= PR_LJ; + break; + } + + /* not a flag char: advance state to check if it's field width */ + + state++; + + /* check now for '%0...' */ + + if (*fmt == '0') + { + flags |= PR_LZ; + fmt++; + } + /* FALL THROUGH */ +/* STATE 2: AWAITING (NUMERIC) FIELD WIDTH */ + case 2: + if (*fmt >= '0' && *fmt <= '9') + { + given_wd = 10 * given_wd + (*fmt - '0'); + break; + } + + /* not field width: advance state to check if it's a modifier */ + + state++; + /* FALL THROUGH */ +/* STATE 3: AWAITING MODIFIER CHARS (FNlh) */ + case 3: + if (*fmt == 'F') + { + flags |= PR_FP; + break; + } + if (*fmt == 'N') + { + break; + } + if (*fmt == 'l') + { + flags |= PR_32; + break; + } + if (*fmt == 'h') + { + flags |= PR_16; + break; + } + + /* not modifier: advance state to check if it's a conversion char */ + + state++; + /* FALL THROUGH */ +/* STATE 4: AWAITING CONVERSION CHARS (Xxpndiuocs) */ + case 4: + where = buf + PR_BUFLEN - 1; + *where = '\0'; + + switch (*fmt) + { + case 'X': + flags |= PR_CA; + /* FALL THROUGH */ + /* xxx - far pointers (%Fp, %Fn) not yet supported */ + case 'x': + case 'p': + case 'n': + radix = 16; + goto DO_NUM; + + case 'd': + case 'i': + flags |= PR_SG; + /* FALL THROUGH */ + case 'u': + radix = 10; + goto DO_NUM; + + case 'o': + radix = 8; +DO_NUM: if (flags & PR_32) + { + /* load the value to be printed. l=long=32 bits: */ + num = va_arg(args, unsigned long); + } + else if (flags & PR_16) + { + /* h=short=16 bits (signed or unsigned) */ + + if (flags & PR_SG) + num = (short) va_arg(args, int); + else + num = (unsigned short) va_arg(args, int); + } + else + { + /* no h nor l: sizeof(int) bits (signed or unsigned) */ + + if (flags & PR_SG) + num = va_arg(args, int); + else + num = va_arg(args, unsigned int); + } + + if (flags & PR_SG) + { + /* take care of sign */ + + if (num < 0) + { + flags |= PR_WS; + num = -num; + } + } + + /* + * convert binary to octal/decimal/hex ASCII + * OK, I found my mistake. The math here is _always_ unsigned + */ + + do + { + unsigned long temp; + + temp = (unsigned long) num % radix; + where--; + + if (temp < 10) + *where = temp + '0'; + else if (flags & PR_CA) + *where = temp - 10 + 'A'; + else + *where = temp - 10 + 'a'; + + num = (unsigned long) num / radix; + } + while (num != 0); + + goto EMIT; + + case 'c': + /* disallow pad-left-with-zeroes for %c */ + flags &= ~PR_LZ; + where--; + *where = (unsigned char) va_arg(args, int); + actual_wd = 1; + goto EMIT2; + + case 's': + /* disallow pad-left-with-zeroes for %s */ + flags &= ~PR_LZ; + where = va_arg(args, unsigned char*); +EMIT: + actual_wd = strlen((char*) where); + + if (flags & PR_WS) + actual_wd++; + + /* if we pad left with ZEROES, do the sign now */ + + if ((flags & (PR_WS | PR_LZ)) == (PR_WS | PR_LZ)) + { + fn('-', &ptr); + count++; + } + + /* pad on left with spaces or zeroes (for right justify) */ + +EMIT2: if ((flags & PR_LJ) == 0) + { + while (given_wd > actual_wd) + { + fn((flags & PR_LZ) ? '0' : ' ', &ptr); + count++; + given_wd--; + } + } + + /* if we pad left with SPACES, do the sign now */ + + if ((flags & (PR_WS | PR_LZ)) == PR_WS) + { + fn('-', &ptr); + count++; + } + + /* emit string/char/converted number */ + + while (*where != '\0') + { + fn(*where++, &ptr); + count++; + } + + /* pad on right with spaces (for left justify) */ + + if (given_wd < actual_wd) + given_wd = 0; + else + given_wd -= actual_wd; + + for (; given_wd; given_wd--) + { + fn(' ', &ptr); + count++; + } + + break; + + default: + break; + } + + default: + state = flags = given_wd = 0; + break; + } + } + + return count; +} + +static int vsprintf_help(unsigned c, void **ptr) +{ + char *dst; + + dst = *ptr; + *dst++ = (char) c; + *ptr = dst; + + return 0; +} + +int vsprintf(char *buf, const char *fmt, va_list args) +{ + int status; + + status = do_printf(fmt, args, vsprintf_help, (void*) buf); + buf[status] = '\0'; + + return status; +} + +static int discard(unsigned c_UNUSED, void **ptr_UNUSED) +{ + return 0; +} + +int sprintf(char *buf, const char *fmt, ...) +{ + va_list args; + int status; + + va_start(args, fmt); + + if (!buf) + status = do_printf(fmt, args, discard, NULL); + else + status = vsprintf(buf, fmt, args); + + va_end(args); + + return status; +} + +int vprintf_help(unsigned c, void **ptr_UNUSED) +{ + putchar(c); + return 0; +} + +int vprintf(const char *fmt, va_list args) +{ + return do_printf(fmt, args, vprintf_help, NULL); +} + +int wprintfx(const char *fmt, ...) +{ + va_list args; + int status; + + va_start(args, fmt); + status = vprintf(fmt, args); + va_end(args); + + return status; +} diff --git a/winpr/libwinpr/utils/test/TestPrint.c b/winpr/libwinpr/utils/test/TestPrint.c index e27a46b2b..0d46f7718 100644 --- a/winpr/libwinpr/utils/test/TestPrint.c +++ b/winpr/libwinpr/utils/test/TestPrint.c @@ -1,359 +1,108 @@ -#include -#include -#include - #include #include #include -int wprintfx(const char *fmt, ...); +/** + * C Programming/C Reference/stdio.h/printf: + * http://en.wikibooks.org/wiki/C_Programming/C_Reference/stdio.h/printf + * + * C Programming/Procedures and functions/printf: + * http://en.wikibooks.org/wiki/C_Programming/Procedures_and_functions/printf + * + * C Tutorial – printf, Format Specifiers, Format Conversions and Formatted Output: + * http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output + */ + +#if 0 +#define _printf printf +#else +#define _printf wprintfx +#endif int TestPrint(int argc, char* argv[]) { - wprintfx("this %s a test: %d\n", "is", 65); + int a, b; + float c, d; + + /** + * 7 + * 7 + * 007 + * 5.10 + */ + + a = 15; + b = a / 2; + _printf("%d\n",b); + _printf("%3d\n",b); + _printf("%03d\n",b); + c = 15.3; d = c / 3; + _printf("%3.2f\n",d); + + /** + * 0 -17.778 + * 20 -6.667 + * 40 04.444 + * 60 15.556 + * 80 26.667 + * 100 37.778 + * 120 48.889 + * 140 60.000 + * 160 71.111 + * 180 82.222 + * 200 93.333 + * 220 104.444 + * 240 115.556 + * 260 126.667 + * 280 137.778 + * 300 148.889 + */ + + for (a = 0; a <= 300; a = a + 20) + _printf("%3d %06.3f\n", a, (5.0 / 9.0) * (a - 32)); + + /** + * The color: blue + * First number: 12345 + * Second number: 0025 + * Third number: 1234 + * Float number: 3.14 + * Hexadecimal: ff + * Octal: 377 + * Unsigned value: 150 + * Just print the percentage sign % + */ + + _printf("The color: %s\n", "blue"); + _printf("First number: %d\n", 12345); + _printf("Second number: %04d\n", 25); + _printf("Third number: %i\n", 1234); + _printf("Float number: %3.2f\n", 3.14159); + _printf("Hexadecimal: %x/%X\n", 255, 255); + _printf("Octal: %o\n", 255); + _printf("Unsigned value: %u\n", 150); + _printf("Just print the percentage sign %%\n", 10); + + /** + * :Hello, world!: + * : Hello, world!: + * :Hello, wor: + * :Hello, world!: + * :Hello, world! : + * :Hello, world!: + * : Hello, wor: + * :Hello, wor : + */ + + _printf(":%s:\n", "Hello, world!"); + _printf(":%15s:\n", "Hello, world!"); + _printf(":%.10s:\n", "Hello, world!"); + _printf(":%-10s:\n", "Hello, world!"); + _printf(":%-15s:\n", "Hello, world!"); + _printf(":%.15s:\n", "Hello, world!"); + _printf(":%15.10s:\n", "Hello, world!"); + _printf(":%-15.10s:\n", "Hello, world!"); return 0; } - -/*---------------------------------------------------------------------------- -Stripped-down printf() -Chris Giese http://my.execpc.com/~geezer -Release date: Feb 3, 2008 -This code is public domain (no copyright). -You can do whatever you want with it. - -%[flag][width][.prec][mod][conv] -flag: - left justify, pad right w/ blanks DONE - 0 pad left w/ 0 for numerics DONE - + always print sign, + or - no - ' ' (blank) no - # (???) no - -width: (field width) DONE - -prec: (precision) no - -conv: d,i decimal int DONE - u decimal unsigned DONE - o octal DONE - x,X hex DONE - f,e,g,E,G float no - c char DONE - s string DONE - p ptr DONE - -mod: N near ptr DONE - F far ptr no - h short (16-bit) int DONE - l long (32-bit) int DONE - L long long (64-bit) int no -----------------------------------------------------------------------------*/ -#include /* strlen() */ - -/* flags used in processing format string */ -#define PR_LJ 0x01 /* left justify */ -#define PR_CA 0x02 /* use A-F instead of a-f for hex */ -#define PR_SG 0x04 /* signed numeric conversion (%d vs. %u) */ -#define PR_32 0x08 /* long (32-bit) numeric conversion */ -#define PR_16 0x10 /* short (16-bit) numeric conversion */ -#define PR_WS 0x20 /* PR_SG set and num was < 0 */ -#define PR_LZ 0x40 /* pad left with '0' instead of ' ' */ -#define PR_FP 0x80 /* pointers are far */ - -/* largest number handled is 2^32-1, lowest radix handled is 8. -2^32-1 in base 8 has 11 digits (add 5 for trailing NUL and for slop) */ -#define PR_BUFLEN 16 - -typedef int (*fnptr_t)(unsigned c, void **helper); -/***************************************************************************** -name: do_printf -action: minimal subfunction for ?printf, calls function - 'fn' with arg 'ptr' for each character to be output -returns:total number of characters output -*****************************************************************************/ -int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr) -{ - unsigned flags, actual_wd, count, given_wd; - unsigned char *where, buf[PR_BUFLEN]; - unsigned char state, radix; - long num; - - state = flags = count = given_wd = 0; -/* begin scanning format specifier list */ - for (; *fmt; fmt++) - { - switch (state) - { -/* STATE 0: AWAITING % */ - case 0: - if (*fmt != '%') /* not %... */ - { - fn(*fmt, &ptr); /* ...just echo it */ - count++; - break; - } -/* found %, get next char and advance state to check if next char is a flag */ - state++; - fmt++; - /* FALL THROUGH */ -/* STATE 1: AWAITING FLAGS (%-0) */ - case 1: - if (*fmt == '%') /* %% */ - { - fn(*fmt, &ptr); - count++; - state = flags = given_wd = 0; - break; - } - if (*fmt == '-') - { - if (flags & PR_LJ)/* %-- is illegal */ - state = flags = given_wd = 0; - else - flags |= PR_LJ; - break; - } -/* not a flag char: advance state to check if it's field width */ - state++; -/* check now for '%0...' */ - if (*fmt == '0') - { - flags |= PR_LZ; - fmt++; - } - /* FALL THROUGH */ -/* STATE 2: AWAITING (NUMERIC) FIELD WIDTH */ - case 2: - if (*fmt >= '0' && *fmt <= '9') - { - given_wd = 10 * given_wd + (*fmt - '0'); - break; - } -/* not field width: advance state to check if it's a modifier */ - state++; - /* FALL THROUGH */ -/* STATE 3: AWAITING MODIFIER CHARS (FNlh) */ - case 3: - if (*fmt == 'F') - { - flags |= PR_FP; - break; - } - if (*fmt == 'N') - break; - if (*fmt == 'l') - { - flags |= PR_32; - break; - } - if (*fmt == 'h') - { - flags |= PR_16; - break; - } -/* not modifier: advance state to check if it's a conversion char */ - state++; - /* FALL THROUGH */ -/* STATE 4: AWAITING CONVERSION CHARS (Xxpndiuocs) */ - case 4: - where = buf + PR_BUFLEN - 1; - *where = '\0'; - switch (*fmt) - { - case 'X': - flags |= PR_CA; - /* FALL THROUGH */ -/* xxx - far pointers (%Fp, %Fn) not yet supported */ - case 'x': - case 'p': - case 'n': - radix = 16; - goto DO_NUM; - case 'd': - case 'i': - flags |= PR_SG; - /* FALL THROUGH */ - case 'u': - radix = 10; - goto DO_NUM; - case 'o': - radix = 8; -/* load the value to be printed. l=long=32 bits: */ -DO_NUM: if (flags & PR_32) - num = va_arg(args, unsigned long); -/* h=short=16 bits (signed or unsigned) */ - else if (flags & PR_16) - { - if (flags & PR_SG) - num = (short) va_arg(args, int); - else - num = (unsigned short) va_arg(args, int); - } -/* no h nor l: sizeof(int) bits (signed or unsigned) */ - else - { - if (flags & PR_SG) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } -/* take care of sign */ - if (flags & PR_SG) - { - if (num < 0) - { - flags |= PR_WS; - num = -num; - } - } -/* convert binary to octal/decimal/hex ASCII -OK, I found my mistake. The math here is _always_ unsigned */ - do - { - unsigned long temp; - - temp = (unsigned long)num % radix; - where--; - if (temp < 10) - *where = temp + '0'; - else if (flags & PR_CA) - *where = temp - 10 + 'A'; - else - *where = temp - 10 + 'a'; - num = (unsigned long)num / radix; - } - while (num != 0); - goto EMIT; - case 'c': -/* disallow pad-left-with-zeroes for %c */ - flags &= ~PR_LZ; - where--; - *where = (unsigned char) va_arg(args, int); - actual_wd = 1; - goto EMIT2; - case 's': -/* disallow pad-left-with-zeroes for %s */ - flags &= ~PR_LZ; - where = va_arg(args, unsigned char*); -EMIT: - actual_wd = strlen((char*) where); - if (flags & PR_WS) - actual_wd++; -/* if we pad left with ZEROES, do the sign now */ - if ((flags & (PR_WS | PR_LZ)) == (PR_WS | PR_LZ)) - { - fn('-', &ptr); - count++; - } -/* pad on left with spaces or zeroes (for right justify) */ -EMIT2: if ((flags & PR_LJ) == 0) - { - while (given_wd > actual_wd) - { - fn((flags & PR_LZ) ? '0' : ' ', &ptr); - count++; - given_wd--; - } - } -/* if we pad left with SPACES, do the sign now */ - if ((flags & (PR_WS | PR_LZ)) == PR_WS) - { - fn('-', &ptr); - count++; - } -/* emit string/char/converted number */ - while (*where != '\0') - { - fn(*where++, &ptr); - count++; - } -/* pad on right with spaces (for left justify) */ - if (given_wd < actual_wd) - given_wd = 0; - else given_wd -= actual_wd; - for (; given_wd; given_wd--) - { - fn(' ', &ptr); - count++; - } - break; - default: - break; - } - default: - state = flags = given_wd = 0; - break; - } - } - return count; -} - -/***************************************************************************** -SPRINTF -*****************************************************************************/ -static int vsprintf_help(unsigned c, void **ptr) -{ - char *dst; - - dst = *ptr; - *dst++ = (char) c; - *ptr = dst; - - return 0; -} - -int vsprintf(char *buf, const char *fmt, va_list args) -{ - int status; - - status = do_printf(fmt, args, vsprintf_help, (void*) buf); - buf[status] = '\0'; - - return status; -} - -static int discard(unsigned c_UNUSED, void **ptr_UNUSED) -{ - return 0; -} - -int sprintf(char *buf, const char *fmt, ...) -{ - va_list args; - int status; - - va_start(args, fmt); - - if (!buf) - status = do_printf(fmt, args, discard, NULL); - else - status = vsprintf(buf, fmt, args); - - va_end(args); - - return status; -} - -int vprintf_help(unsigned c, void **ptr_UNUSED) -{ - putchar(c); - return 0; -} - -int vprintf(const char *fmt, va_list args) -{ - return do_printf(fmt, args, vprintf_help, NULL); -} - -int wprintfx(const char *fmt, ...) -{ - va_list args; - int status; - - va_start(args, fmt); - status = vprintf(fmt, args); - va_end(args); - - return status; -} From c0b33a1ae543dbc8495a1811c30540cd508cff36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 28 Feb 2013 22:06:29 -0500 Subject: [PATCH 05/18] libfreerdp-locale: fix Mac OS X build --- libfreerdp/locale/keyboard_x11.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index 463124744..fe5adc254 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -487,8 +487,6 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco CopyMemory(keycode_to_vkcode, KEYCODE_TO_VKCODE_MACOSX, sizeof(keycode_to_vkcode)); - freerdp_keyboard_load_map(keycode_to_vkcode, "macosx(macosx)"); - #elif defined(WITH_SUN) { char sunkeymap[32]; From be27783e816c1d8eb8fd80e1e7d4a49804dda0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 2 Mar 2013 22:25:40 -0500 Subject: [PATCH 06/18] libwinpr-input: initial commit --- winpr/include/winpr/input.h | 691 +++++++++++++++++++++++ winpr/libwinpr/input/CMakeLists.txt | 43 ++ winpr/libwinpr/input/ModuleOptions.cmake | 9 + winpr/libwinpr/input/keyboard.c | 554 ++++++++++++++++++ 4 files changed, 1297 insertions(+) create mode 100644 winpr/include/winpr/input.h create mode 100644 winpr/libwinpr/input/CMakeLists.txt create mode 100644 winpr/libwinpr/input/ModuleOptions.cmake create mode 100644 winpr/libwinpr/input/keyboard.c diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h new file mode 100644 index 000000000..ecc43cd7a --- /dev/null +++ b/winpr/include/winpr/input.h @@ -0,0 +1,691 @@ +/** + * WinPR: Windows Portable Runtime + * Input Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_INPUT_H +#define WINPR_INPUT_H + +#include +#include + +/* + * Virtual Key Codes (Windows): + * http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731/ + */ + +/* Mouse buttons */ + +#define VK_LBUTTON 0x01 /* Left mouse button */ +#define VK_RBUTTON 0x02 /* Right mouse button */ +#define VK_CANCEL 0x03 /* Control-break processing */ +#define VK_MBUTTON 0x04 /* Middle mouse button (three-button mouse) */ +#define VK_XBUTTON1 0x05 /* Windows 2000/XP: X1 mouse button */ +#define VK_XBUTTON2 0x06 /* Windows 2000/XP: X2 mouse button */ + +/* 0x07 is undefined */ + +#define VK_BACK 0x08 /* BACKSPACE key */ +#define VK_TAB 0x09 /* TAB key */ + +/* 0x0A to 0x0B are reserved */ + +#define VK_CLEAR 0x0C /* CLEAR key */ +#define VK_RETURN 0x0D /* ENTER key */ + +/* 0x0E to 0x0F are undefined */ + +#define VK_SHIFT 0x10 /* SHIFT key */ +#define VK_CONTROL 0x11 /* CTRL key */ +#define VK_MENU 0x12 /* ALT key */ +#define VK_PAUSE 0x13 /* PAUSE key */ +#define VK_CAPITAL 0x14 /* CAPS LOCK key */ +#define VK_KANA 0x15 /* Input Method Editor (IME) Kana mode */ +#define VK_HANGUEL 0x15 /* IME Hanguel mode (maintained for compatibility; use #define VK_HANGUL) */ +#define VK_HANGUL 0x15 /* IME Hangul mode */ + +/* 0x16 is undefined */ + +#define VK_JUNJA 0x17 /* IME Junja mode */ +#define VK_FINAL 0x18 /* IME final mode */ +#define VK_HANJA 0x19 /* IME Hanja mode */ +#define VK_KANJI 0x19 /* IME Kanji mode */ + +/* 0x1A is undefined */ + +#define VK_ESCAPE 0x1B /* ESC key */ +#define VK_CONVERT 0x1C /* IME convert */ +#define VK_NONCONVERT 0x1D /* IME nonconvert */ +#define VK_ACCEPT 0x1E /* IME accept */ +#define VK_MODECHANGE 0x1F /* IME mode change request */ + +#define VK_SPACE 0x20 /* SPACEBAR */ +#define VK_PRIOR 0x21 /* PAGE UP key */ +#define VK_NEXT 0x22 /* PAGE DOWN key */ +#define VK_END 0x23 /* END key */ +#define VK_HOME 0x24 /* HOME key */ +#define VK_LEFT 0x25 /* LEFT ARROW key */ +#define VK_UP 0x26 /* UP ARROW key */ +#define VK_RIGHT 0x27 /* RIGHT ARROW key */ +#define VK_DOWN 0x28 /* DOWN ARROW key */ +#define VK_SELECT 0x29 /* SELECT key */ +#define VK_PRINT 0x2A /* PRINT key */ +#define VK_EXECUTE 0x2B /* EXECUTE key */ +#define VK_SNAPSHOT 0x2C /* PRINT SCREEN key */ +#define VK_INSERT 0x2D /* INS key */ +#define VK_DELETE 0x2E /* DEL key */ +#define VK_HELP 0x2F /* HELP key */ + +/* Digits, the last 4 bits of the code represent the corresponding digit */ + +#define VK_KEY_0 0x30 /* '0' key */ +#define VK_KEY_1 0x31 /* '1' key */ +#define VK_KEY_2 0x32 /* '2' key */ +#define VK_KEY_3 0x33 /* '3' key */ +#define VK_KEY_4 0x34 /* '4' key */ +#define VK_KEY_5 0x35 /* '5' key */ +#define VK_KEY_6 0x36 /* '6' key */ +#define VK_KEY_7 0x37 /* '7' key */ +#define VK_KEY_8 0x38 /* '8' key */ +#define VK_KEY_9 0x39 /* '9' key */ + +/* 0x3A to 0x40 are undefined */ + +/* The alphabet, the code corresponds to the capitalized letter in the ASCII code */ + +#define VK_KEY_A 0x41 /* 'A' key */ +#define VK_KEY_B 0x42 /* 'B' key */ +#define VK_KEY_C 0x43 /* 'C' key */ +#define VK_KEY_D 0x44 /* 'D' key */ +#define VK_KEY_E 0x45 /* 'E' key */ +#define VK_KEY_F 0x46 /* 'F' key */ +#define VK_KEY_G 0x47 /* 'G' key */ +#define VK_KEY_H 0x48 /* 'H' key */ +#define VK_KEY_I 0x49 /* 'I' key */ +#define VK_KEY_J 0x4A /* 'J' key */ +#define VK_KEY_K 0x4B /* 'K' key */ +#define VK_KEY_L 0x4C /* 'L' key */ +#define VK_KEY_M 0x4D /* 'M' key */ +#define VK_KEY_N 0x4E /* 'N' key */ +#define VK_KEY_O 0x4F /* 'O' key */ +#define VK_KEY_P 0x50 /* 'P' key */ +#define VK_KEY_Q 0x51 /* 'Q' key */ +#define VK_KEY_R 0x52 /* 'R' key */ +#define VK_KEY_S 0x53 /* 'S' key */ +#define VK_KEY_T 0x54 /* 'T' key */ +#define VK_KEY_U 0x55 /* 'U' key */ +#define VK_KEY_V 0x56 /* 'V' key */ +#define VK_KEY_W 0x57 /* 'W' key */ +#define VK_KEY_X 0x58 /* 'X' key */ +#define VK_KEY_Y 0x59 /* 'Y' key */ +#define VK_KEY_Z 0x5A /* 'Z' key */ + +#define VK_LWIN 0x5B /* Left Windows key (Microsoft Natural keyboard) */ +#define VK_RWIN 0x5C /* Right Windows key (Natural keyboard) */ +#define VK_APPS 0x5D /* Applications key (Natural keyboard) */ + +/* 0x5E is reserved */ + +#define VK_SLEEP 0x5F /* Computer Sleep key */ + +/* Numeric keypad digits, the last four bits of the code represent the corresponding digit */ + +#define VK_NUMPAD0 0x60 /* Numeric keypad '0' key */ +#define VK_NUMPAD1 0x61 /* Numeric keypad '1' key */ +#define VK_NUMPAD2 0x62 /* Numeric keypad '2' key */ +#define VK_NUMPAD3 0x63 /* Numeric keypad '3' key */ +#define VK_NUMPAD4 0x64 /* Numeric keypad '4' key */ +#define VK_NUMPAD5 0x65 /* Numeric keypad '5' key */ +#define VK_NUMPAD6 0x66 /* Numeric keypad '6' key */ +#define VK_NUMPAD7 0x67 /* Numeric keypad '7' key */ +#define VK_NUMPAD8 0x68 /* Numeric keypad '8' key */ +#define VK_NUMPAD9 0x69 /* Numeric keypad '9' key */ + +/* Numeric keypad operators and special keys */ + +#define VK_MULTIPLY 0x6A /* Multiply key */ +#define VK_ADD 0x6B /* Add key */ +#define VK_SEPARATOR 0x6C /* Separator key */ +#define VK_SUBTRACT 0x6D /* Subtract key */ +#define VK_DECIMAL 0x6E /* Decimal key */ +#define VK_DIVIDE 0x6F /* Divide key */ + +/* Function keys, from F1 to F24 */ + +#define VK_F1 0x70 /* F1 key */ +#define VK_F2 0x71 /* F2 key */ +#define VK_F3 0x72 /* F3 key */ +#define VK_F4 0x73 /* F4 key */ +#define VK_F5 0x74 /* F5 key */ +#define VK_F6 0x75 /* F6 key */ +#define VK_F7 0x76 /* F7 key */ +#define VK_F8 0x77 /* F8 key */ +#define VK_F9 0x78 /* F9 key */ +#define VK_F10 0x79 /* F10 key */ +#define VK_F11 0x7A /* F11 key */ +#define VK_F12 0x7B /* F12 key */ +#define VK_F13 0x7C /* F13 key */ +#define VK_F14 0x7D /* F14 key */ +#define VK_F15 0x7E /* F15 key */ +#define VK_F16 0x7F /* F16 key */ +#define VK_F17 0x80 /* F17 key */ +#define VK_F18 0x81 /* F18 key */ +#define VK_F19 0x82 /* F19 key */ +#define VK_F20 0x83 /* F20 key */ +#define VK_F21 0x84 /* F21 key */ +#define VK_F22 0x85 /* F22 key */ +#define VK_F23 0x86 /* F23 key */ +#define VK_F24 0x87 /* F24 key */ + +/* 0x88 to 0x8F are unassigned */ + +#define VK_NUMLOCK 0x90 /* NUM LOCK key */ +#define VK_SCROLL 0x91 /* SCROLL LOCK key */ + +/* 0x92 to 0x96 are OEM specific */ +/* 0x97 to 0x9F are unassigned */ + +/* Modifier keys */ + +#define VK_LSHIFT 0xA0 /* Left SHIFT key */ +#define VK_RSHIFT 0xA1 /* Right SHIFT key */ +#define VK_LCONTROL 0xA2 /* Left CONTROL key */ +#define VK_RCONTROL 0xA3 /* Right CONTROL key */ +#define VK_LMENU 0xA4 /* Left MENU key */ +#define VK_RMENU 0xA5 /* Right MENU key */ + +/* Browser related keys */ + +#define VK_BROWSER_BACK 0xA6 /* Windows 2000/XP: Browser Back key */ +#define VK_BROWSER_FORWARD 0xA7 /* Windows 2000/XP: Browser Forward key */ +#define VK_BROWSER_REFRESH 0xA8 /* Windows 2000/XP: Browser Refresh key */ +#define VK_BROWSER_STOP 0xA9 /* Windows 2000/XP: Browser Stop key */ +#define VK_BROWSER_SEARCH 0xAA /* Windows 2000/XP: Browser Search key */ +#define VK_BROWSER_FAVORITES 0xAB /* Windows 2000/XP: Browser Favorites key */ +#define VK_BROWSER_HOME 0xAC /* Windows 2000/XP: Browser Start and Home key */ + +/* Volume related keys */ + +#define VK_VOLUME_MUTE 0xAD /* Windows 2000/XP: Volume Mute key */ +#define VK_VOLUME_DOWN 0xAE /* Windows 2000/XP: Volume Down key */ +#define VK_VOLUME_UP 0xAF /* Windows 2000/XP: Volume Up key */ + +/* Media player related keys */ + +#define VK_MEDIA_NEXT_TRACK 0xB0 /* Windows 2000/XP: Next Track key */ +#define VK_MEDIA_PREV_TRACK 0xB1 /* Windows 2000/XP: Previous Track key */ +#define VK_MEDIA_STOP 0xB2 /* Windows 2000/XP: Stop Media key */ +#define VK_MEDIA_PLAY_PAUSE 0xB3 /* Windows 2000/XP: Play/Pause Media key */ + +/* Application launcher keys */ + +#define VK_LAUNCH_MAIL 0xB4 /* Windows 2000/XP: Start Mail key */ +#define VK_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ +#define VK_LAUNCH_APP1 0xB6 /* Windows 2000/XP: Start Application 1 key */ +#define VK_LAUNCH_APP2 0xB7 /* Windows 2000/XP: Start Application 2 key */ + +/* 0xB8 and 0xB9 are reserved */ + +/* OEM keys */ + +#define VK_OEM_1 0xBA /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the ';:' key */ + +#define VK_OEM_PLUS 0xBB /* Windows 2000/XP: For any country/region, the '+' key */ +#define VK_OEM_COMMA 0xBC /* Windows 2000/XP: For any country/region, the ',' key */ +#define VK_OEM_MINUS 0xBD /* Windows 2000/XP: For any country/region, the '-' key */ +#define VK_OEM_PERIOD 0xBE /* Windows 2000/XP: For any country/region, the '.' key */ + +#define VK_OEM_2 0xBF /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '/?' key */ + +#define VK_OEM_3 0xC0 /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '`~' key */ + +/* 0xC1 to 0xD7 are reserved */ +#define VK_ABNT_C1 0xC1 /* Brazilian (ABNT) Keyboard */ +#define VK_ABNT_C2 0xC2 /* Brazilian (ABNT) Keyboard */ + +/* 0xD8 to 0xDA are unassigned */ + +#define VK_OEM_4 0xDB /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '[{' key */ + +#define VK_OEM_5 0xDC /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '\|' key */ + +#define VK_OEM_6 0xDD /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the ']}' key */ + +#define VK_OEM_7 0xDE /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key */ + +#define VK_OEM_8 0xDF /* Used for miscellaneous characters; it can vary by keyboard. */ + +/* 0xE0 is reserved */ +/* 0xE1 is OEM specific */ + +#define VK_OEM_102 0xE2 /* Windows 2000/XP: Either the angle bracket key or */ + /* the backslash key on the RT 102-key keyboard */ + +/* 0xE3 and 0xE4 are OEM specific */ + +#define VK_PROCESSKEY 0xE5 /* Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key */ + +/* 0xE6 is OEM specific */ + +#define VK_PACKET 0xE7 /* Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. */ + /* The #define VK_PACKET key is the low word of a 32-bit Virtual Key value used */ + /* for non-keyboard input methods. For more information, */ + /* see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP */ + +/* 0xE8 is unassigned */ +/* 0xE9 to 0xF5 are OEM specific */ + +#define VK_ATTN 0xF6 /* Attn key */ +#define VK_CRSEL 0xF7 /* CrSel key */ +#define VK_EXSEL 0xF8 /* ExSel key */ +#define VK_EREOF 0xF9 /* Erase EOF key */ +#define VK_PLAY 0xFA /* Play key */ +#define VK_ZOOM 0xFB /* Zoom key */ +#define VK_NONAME 0xFC /* Reserved */ +#define VK_PA1 0xFD /* PA1 key */ +#define VK_OEM_CLEAR 0xFE /* Clear key */ + +#define VK_NONE 0xFF /* no key */ + +/** + * TODO: fix the following definitions + */ + +#define VK_OEM_WSCTRL 0xFF +#define VK_OEM_FINISH 0xFF +#define VK_OEM_JUMP 0xFF +#define VK_OEM_BACKTAB 0xFF +#define VK_OEM_AUTO 0xFF +#define VK_OEM_PA3 0xFF +#define VK_OEM_RESET 0xFF +#define VK_OEM_PA1 0xFF +#define VK_OEM_PA2 0xFF +#define VK_POWER 0xFF +#define VK_LAUNCH_MEDIA_SELECT 0xFF +#define VK_DBE_KATAKANA 0xFF +#define VK_DBE_ALPHANUMERIC 0xFF +#define VK_DBE_SBCSCHAR 0xFF +#define VK_DBE_HIRAGANA 0xFF + +/* + * Keyboard Scan Codes + */ + +/** + * Keyboard Type 4 + */ + +#define KBD4_T00 VK_NONE +#define KBD4_T01 VK_ESCAPE +#define KBD4_T02 VK_KEY_1 +#define KBD4_T03 VK_KEY_2 +#define KBD4_T04 VK_KEY_3 +#define KBD4_T05 VK_KEY_4 +#define KBD4_T06 VK_KEY_5 +#define KBD4_T07 VK_KEY_6 +#define KBD4_T08 VK_KEY_7 +#define KBD4_T09 VK_KEY_8 +#define KBD4_T0A VK_KEY_9 +#define KBD4_T0B VK_KEY_0 +#define KBD4_T0C VK_OEM_MINUS +#define KBD4_T0D VK_OEM_PLUS /* NE */ +#define KBD4_T0E VK_BACK +#define KBD4_T0F VK_TAB +#define KBD4_T10 VK_KEY_Q +#define KBD4_T11 VK_KEY_W +#define KBD4_T12 VK_KEY_E +#define KBD4_T13 VK_KEY_R +#define KBD4_T14 VK_KEY_T +#define KBD4_T15 VK_KEY_Y +#define KBD4_T16 VK_KEY_U +#define KBD4_T17 VK_KEY_I +#define KBD4_T18 VK_KEY_O +#define KBD4_T19 VK_KEY_P +#define KBD4_T1A VK_OEM_4 /* NE */ +#define KBD4_T1B VK_OEM_6 /* NE */ +#define KBD4_T1C VK_RETURN +#define KBD4_T1D VK_LCONTROL +#define KBD4_T1E VK_KEY_A +#define KBD4_T1F VK_KEY_S +#define KBD4_T20 VK_KEY_D +#define KBD4_T21 VK_KEY_F +#define KBD4_T22 VK_KEY_G +#define KBD4_T23 VK_KEY_H +#define KBD4_T24 VK_KEY_J +#define KBD4_T25 VK_KEY_K +#define KBD4_T26 VK_KEY_L +#define KBD4_T27 VK_OEM_1 /* NE */ +#define KBD4_T28 VK_OEM_7 /* NE */ +#define KBD4_T29 VK_OEM_3 /* NE */ +#define KBD4_T2A VK_LSHIFT +#define KBD4_T2B VK_OEM_5 +#define KBD4_T2C VK_KEY_Z +#define KBD4_T2D VK_KEY_X +#define KBD4_T2E VK_KEY_C +#define KBD4_T2F VK_KEY_V +#define KBD4_T30 VK_KEY_B +#define KBD4_T31 VK_KEY_N +#define KBD4_T32 VK_KEY_M +#define KBD4_T33 VK_OEM_COMMA +#define KBD4_T34 VK_OEM_PERIOD +#define KBD4_T35 VK_OEM_2 +#define KBD4_T36 VK_RSHIFT +#define KBD4_T37 VK_MULTIPLY +#define KBD4_T38 VK_LMENU +#define KBD4_T39 VK_SPACE +#define KBD4_T3A VK_CAPITAL +#define KBD4_T3B VK_F1 +#define KBD4_T3C VK_F2 +#define KBD4_T3D VK_F3 +#define KBD4_T3E VK_F4 +#define KBD4_T3F VK_F5 +#define KBD4_T40 VK_F6 +#define KBD4_T41 VK_F7 +#define KBD4_T42 VK_F8 +#define KBD4_T43 VK_F9 +#define KBD4_T44 VK_F10 +#define KBD4_T45 VK_NUMLOCK +#define KBD4_T46 VK_SCROLL +#define KBD4_T47 VK_HOME +#define KBD4_T48 VK_UP +#define KBD4_T49 VK_PRIOR +#define KBD4_T4A VK_SUBTRACT +#define KBD4_T4B VK_LEFT +#define KBD4_T4C VK_CLEAR +#define KBD4_T4D VK_RIGHT +#define KBD4_T4E VK_ADD +#define KBD4_T4F VK_END +#define KBD4_T50 VK_DOWN +#define KBD4_T51 VK_NEXT +#define KBD4_T52 VK_INSERT +#define KBD4_T53 VK_DELETE +#define KBD4_T54 VK_SNAPSHOT +#define KBD4_T55 VK_NONE +#define KBD4_T56 VK_OEM_102 /* NE */ +#define KBD4_T57 VK_F11 /* NE */ +#define KBD4_T58 VK_F12 /* NE */ +#define KBD4_T59 VK_CLEAR +#define KBD4_T5A VK_OEM_WSCTRL +#define KBD4_T5B VK_OEM_FINISH +#define KBD4_T5C VK_OEM_JUMP +#define KBD4_T5D VK_EREOF +#define KBD4_T5E VK_OEM_BACKTAB +#define KBD4_T5F VK_OEM_AUTO +#define KBD4_T60 VK_NONE +#define KBD4_T61 VK_NONE +#define KBD4_T62 VK_ZOOM +#define KBD4_T63 VK_HELP +#define KBD4_T64 VK_F13 +#define KBD4_T65 VK_F14 +#define KBD4_T66 VK_F15 +#define KBD4_T67 VK_F16 +#define KBD4_T68 VK_F17 +#define KBD4_T69 VK_F18 +#define KBD4_T6A VK_F19 +#define KBD4_T6B VK_F20 +#define KBD4_T6C VK_F21 +#define KBD4_T6D VK_F22 +#define KBD4_T6E VK_F23 +#define KBD4_T6F VK_OEM_PA3 +#define KBD4_T70 VK_NONE +#define KBD4_T71 VK_OEM_RESET +#define KBD4_T72 VK_NONE +#define KBD4_T73 VK_ABNT_C1 +#define KBD4_T74 VK_NONE +#define KBD4_T75 VK_NONE +#define KBD4_T76 VK_F24 +#define KBD4_T77 VK_NONE +#define KBD4_T78 VK_NONE +#define KBD4_T79 VK_NONE +#define KBD4_T7A VK_NONE +#define KBD4_T7B VK_OEM_PA1 +#define KBD4_T7C VK_TAB +#define KBD4_T7D VK_NONE +#define KBD4_T7E VK_ABNT_C2 +#define KBD4_T7F VK_OEM_PA2 + +#define KBD4_X10 VK_MEDIA_PREV_TRACK +#define KBD4_X19 VK_MEDIA_NEXT_TRACK +#define KBD4_X1C VK_RETURN +#define KBD4_X1D VK_RCONTROL +#define KBD4_X20 VK_VOLUME_MUTE +#define KBD4_X21 VK_LAUNCH_APP2 +#define KBD4_X22 VK_MEDIA_PLAY_PAUSE +#define KBD4_X24 VK_MEDIA_STOP +#define KBD4_X2E VK_VOLUME_DOWN +#define KBD4_X30 VK_VOLUME_UP +#define KBD4_X32 VK_BROWSER_HOME +#define KBD4_X35 VK_DIVIDE +#define KBD4_X37 VK_SNAPSHOT +#define KBD4_X38 VK_RMENU +#define KBD4_X46 VK_CANCEL +#define KBD4_X47 VK_HOME +#define KBD4_X48 VK_UP +#define KBD4_X49 VK_PRIOR +#define KBD4_X4B VK_LEFT +#define KBD4_X4D VK_RIGHT +#define KBD4_X4F VK_END +#define KBD4_X50 VK_DOWN +#define KBD4_X51 VK_NEXT /* NE */ +#define KBD4_X52 VK_INSERT +#define KBD4_X53 VK_DELETE +#define KBD4_X5B VK_LWIN +#define KBD4_X5C VK_RWIN +#define KBD4_X5D VK_APPS +#define KBD4_X5E VK_POWER +#define KBD4_X5F VK_SLEEP +#define KBD4_X65 VK_BROWSER_SEARCH +#define KBD4_X66 VK_BROWSER_FAVORITES +#define KBD4_X67 VK_BROWSER_REFRESH +#define KBD4_X68 VK_BROWSER_STOP +#define KBD4_X69 VK_BROWSER_FORWARD +#define KBD4_X6A VK_BROWSER_BACK +#define KBD4_X6B VK_LAUNCH_APP1 +#define KBD4_X6C VK_LAUNCH_MAIL +#define KBD4_X6D VK_LAUNCH_MEDIA_SELECT + +#define KBD4_Y1D VK_PAUSE + +/** + * Keyboard Type 7 + */ + +#define KBD7_T00 VK_NONE +#define KBD7_T01 VK_ESCAPE +#define KBD7_T02 VK_KEY_1 +#define KBD7_T03 VK_KEY_2 +#define KBD7_T04 VK_KEY_3 +#define KBD7_T05 VK_KEY_4 +#define KBD7_T06 VK_KEY_5 +#define KBD7_T07 VK_KEY_6 +#define KBD7_T08 VK_KEY_7 +#define KBD7_T09 VK_KEY_8 +#define KBD7_T0A VK_KEY_9 +#define KBD7_T0B VK_KEY_0 +#define KBD7_T0C VK_OEM_MINUS +#define KBD7_T0D VK_OEM_7 /* NE */ +#define KBD7_T0E VK_BACK +#define KBD7_T0F VK_TAB +#define KBD7_T10 VK_KEY_Q +#define KBD7_T11 VK_KEY_W +#define KBD7_T12 VK_KEY_E +#define KBD7_T13 VK_KEY_R +#define KBD7_T14 VK_KEY_T +#define KBD7_T15 VK_KEY_Y +#define KBD7_T16 VK_KEY_U +#define KBD7_T17 VK_KEY_I +#define KBD7_T18 VK_KEY_O +#define KBD7_T19 VK_KEY_P +#define KBD7_T1A VK_OEM_4 /* NE */ +#define KBD7_T1B VK_OEM_6 /* NE */ +#define KBD7_T1C VK_RETURN +#define KBD7_T1D VK_LCONTROL +#define KBD7_T1E VK_KEY_A +#define KBD7_T1F VK_KEY_S +#define KBD7_T20 VK_KEY_D +#define KBD7_T21 VK_KEY_F +#define KBD7_T22 VK_KEY_G +#define KBD7_T23 VK_KEY_H +#define KBD7_T24 VK_KEY_J +#define KBD7_T25 VK_KEY_K +#define KBD7_T26 VK_KEY_L +#define KBD7_T27 VK_OEM_PLUS /* NE */ +#define KBD7_T28 VK_OEM_1 /* NE */ +#define KBD7_T29 VK_OEM_3 /* NE */ +#define KBD7_T2A VK_LSHIFT +#define KBD7_T2B VK_OEM_5 /* NE */ +#define KBD7_T2C VK_KEY_Z +#define KBD7_T2D VK_KEY_X +#define KBD7_T2E VK_KEY_C +#define KBD7_T2F VK_KEY_V +#define KBD7_T30 VK_KEY_B +#define KBD7_T31 VK_KEY_N +#define KBD7_T32 VK_KEY_M +#define KBD7_T33 VK_OEM_COMMA +#define KBD7_T34 VK_OEM_PERIOD +#define KBD7_T35 VK_OEM_2 +#define KBD7_T36 VK_RSHIFT +#define KBD7_T37 VK_MULTIPLY +#define KBD7_T38 VK_LMENU +#define KBD7_T39 VK_SPACE +#define KBD7_T3A VK_DBE_ALPHANUMERIC /* NE */ +#define KBD7_T3B VK_F1 +#define KBD7_T3C VK_F2 +#define KBD7_T3D VK_F3 +#define KBD7_T3E VK_F4 +#define KBD7_T3F VK_F5 +#define KBD7_T40 VK_F6 +#define KBD7_T41 VK_F7 +#define KBD7_T42 VK_F8 +#define KBD7_T43 VK_F9 +#define KBD7_T44 VK_F10 +#define KBD7_T45 VK_NUMLOCK +#define KBD7_T46 VK_SCROLL +#define KBD7_T47 VK_HOME +#define KBD7_T48 VK_UP +#define KBD7_T49 VK_PRIOR +#define KBD7_T4A VK_SUBTRACT +#define KBD7_T4B VK_LEFT +#define KBD7_T4C VK_CLEAR +#define KBD7_T4D VK_RIGHT +#define KBD7_T4E VK_ADD +#define KBD7_T4F VK_END +#define KBD7_T50 VK_DOWN +#define KBD7_T51 VK_NEXT +#define KBD7_T52 VK_INSERT +#define KBD7_T53 VK_DELETE +#define KBD7_T54 VK_SNAPSHOT +#define KBD7_T55 VK_NONE +#define KBD7_T56 VK_NONE /* NE */ +#define KBD7_T57 VK_F11 +#define KBD7_T58 VK_F12 +#define KBD7_T59 VK_CLEAR +#define KBD7_T5A VK_NONAME /* NE */ +#define KBD7_T5B VK_NONAME /* NE */ +#define KBD7_T5C VK_NONAME /* NE */ +#define KBD7_T5D VK_EREOF +#define KBD7_T5E VK_NONE /* NE */ +#define KBD7_T5F VK_NONAME /* NE */ +#define KBD7_T60 VK_NONE +#define KBD7_T61 VK_NONE /* NE */ +#define KBD7_T62 VK_NONE /* NE */ +#define KBD7_T63 VK_NONE +#define KBD7_T64 VK_F13 +#define KBD7_T65 VK_F14 +#define KBD7_T66 VK_F15 +#define KBD7_T67 VK_F16 +#define KBD7_T68 VK_F17 +#define KBD7_T69 VK_F18 +#define KBD7_T6A VK_F19 +#define KBD7_T6B VK_F20 +#define KBD7_T6C VK_F21 +#define KBD7_T6D VK_F22 +#define KBD7_T6E VK_F23 +#define KBD7_T6F VK_NONE /* NE */ +#define KBD7_T70 VK_DBE_KATAKANA /* NE */ +#define KBD7_T71 VK_NONE /* NE */ +#define KBD7_T72 VK_NONE +#define KBD7_T73 VK_OEM_102 /* NE */ +#define KBD7_T74 VK_NONE +#define KBD7_T75 VK_NONE +#define KBD7_T76 VK_F24 +#define KBD7_T77 VK_DBE_SBCSCHAR /* NE */ +#define KBD7_T78 VK_NONE +#define KBD7_T79 VK_CONVERT /* NE */ +#define KBD7_T7A VK_NONE +#define KBD7_T7B VK_NONCONVERT /* NE */ +#define KBD7_T7C VK_TAB +#define KBD7_T7D VK_NONE /* NE */ +#define KBD7_T7E VK_ABNT_C2 +#define KBD7_T7F VK_OEM_PA2 + +#define KBD7_X10 VK_MEDIA_PREV_TRACK +#define KBD7_X19 VK_MEDIA_NEXT_TRACK +#define KBD7_X1C VK_RETURN +#define KBD7_X1D VK_RCONTROL /* NE */ +#define KBD7_X20 VK_VOLUME_MUTE +#define KBD7_X21 VK_LAUNCH_APP2 +#define KBD7_X22 VK_MEDIA_PLAY_PAUSE +#define KBD7_X24 VK_MEDIA_STOP +#define KBD7_X2E VK_VOLUME_DOWN +#define KBD7_X30 VK_VOLUME_UP +#define KBD7_X32 VK_BROWSER_HOME +#define KBD7_X33 VK_OEM_8 /* NE */ +#define KBD7_X35 VK_DIVIDE +#define KBD7_X37 VK_SNAPSHOT +#define KBD7_X38 VK_DBE_HIRAGANA /* NE */ +#define KBD7_X42 VK_NONE +#define KBD7_X43 VK_NONE +#define KBD7_X44 VK_NONE +#define KBD7_X46 VK_CANCEL +#define KBD7_X47 VK_HOME +#define KBD7_X48 VK_UP +#define KBD7_X49 VK_PRIOR +#define KBD7_X4B VK_LEFT +#define KBD7_X4D VK_RIGHT +#define KBD7_X4F VK_END +#define KBD7_X50 VK_DOWN +#define KBD7_X51 VK_NEXT +#define KBD7_X52 VK_INSERT +#define KBD7_X53 VK_DELETE +#define KBD7_X5B VK_LWIN +#define KBD7_X5C VK_RWIN +#define KBD7_X5D VK_APPS +#define KBD7_X5E VK_POWER +#define KBD7_X5F VK_SLEEP +#define KBD7_X65 VK_BROWSER_SEARCH +#define KBD7_X66 VK_BROWSER_FAVORITES +#define KBD7_X67 VK_BROWSER_REFRESH +#define KBD7_X68 VK_BROWSER_STOP +#define KBD7_X69 VK_BROWSER_FORWARD +#define KBD7_X6A VK_BROWSER_BACK +#define KBD7_X6B VK_LAUNCH_APP1 +#define KBD7_X6C VK_LAUNCH_MAIL +#define KBD7_X6D VK_LAUNCH_MEDIA_SELECT +#define KBD7_XF1 VK_NONE /* NE */ +#define KBD7_XF2 VK_NONE /* NE */ + +#define KBD7_Y1D VK_PAUSE + +#endif /* WINPR_INPUT_H */ diff --git a/winpr/libwinpr/input/CMakeLists.txt b/winpr/libwinpr/input/CMakeLists.txt new file mode 100644 index 000000000..a5705def1 --- /dev/null +++ b/winpr/libwinpr/input/CMakeLists.txt @@ -0,0 +1,43 @@ +# WinPR: Windows Portable Runtime +# libwinpr-input cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "winpr-input") +set(MODULE_PREFIX "WINPR_INPUT") + +set(${MODULE_PREFIX}_SRCS + keyboard.c) + +add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" + MONOLITHIC ${MONOLITHIC_BUILD} + SOURCES ${${MODULE_PREFIX}_SRCS}) + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL + MODULE winpr + MODULES winpr-crt) + +if(MONOLITHIC_BUILD) + +else() + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + diff --git a/winpr/libwinpr/input/ModuleOptions.cmake b/winpr/libwinpr/input/ModuleOptions.cmake new file mode 100644 index 000000000..db32710f2 --- /dev/null +++ b/winpr/libwinpr/input/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "input") +set(MINWIN_LONG_NAME "Input Functions") +set(MODULE_LIBRARY_NAME "input") + diff --git a/winpr/libwinpr/input/keyboard.c b/winpr/libwinpr/input/keyboard.c new file mode 100644 index 000000000..6236c3d1a --- /dev/null +++ b/winpr/libwinpr/input/keyboard.c @@ -0,0 +1,554 @@ +/** + * WinPR: Windows Portable Runtime + * Keyboard Input + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +DWORD KBD4T[128] = +{ + KBD4_T00, + KBD4_T01, + KBD4_T02, + KBD4_T03, + KBD4_T04, + KBD4_T05, + KBD4_T06, + KBD4_T07, + KBD4_T08, + KBD4_T09, + KBD4_T0A, + KBD4_T0B, + KBD4_T0C, + KBD4_T0D, + KBD4_T0E, + KBD4_T0F, + KBD4_T10, + KBD4_T11, + KBD4_T12, + KBD4_T13, + KBD4_T14, + KBD4_T15, + KBD4_T16, + KBD4_T17, + KBD4_T18, + KBD4_T19, + KBD4_T1A, + KBD4_T1B, + KBD4_T1C, + KBD4_T1D, + KBD4_T1E, + KBD4_T1F, + KBD4_T20, + KBD4_T21, + KBD4_T22, + KBD4_T23, + KBD4_T24, + KBD4_T25, + KBD4_T26, + KBD4_T27, + KBD4_T28, + KBD4_T29, + KBD4_T2A, + KBD4_T2B, + KBD4_T2C, + KBD4_T2D, + KBD4_T2E, + KBD4_T2F, + KBD4_T30, + KBD4_T31, + KBD4_T32, + KBD4_T33, + KBD4_T34, + KBD4_T35, + KBD4_T36, + KBD4_T37, + KBD4_T38, + KBD4_T39, + KBD4_T3A, + KBD4_T3B, + KBD4_T3C, + KBD4_T3D, + KBD4_T3E, + KBD4_T3F, + KBD4_T40, + KBD4_T41, + KBD4_T42, + KBD4_T43, + KBD4_T44, + KBD4_T45, + KBD4_T46, + KBD4_T47, + KBD4_T48, + KBD4_T49, + KBD4_T4A, + KBD4_T4B, + KBD4_T4C, + KBD4_T4D, + KBD4_T4E, + KBD4_T4F, + KBD4_T50, + KBD4_T51, + KBD4_T52, + KBD4_T53, + KBD4_T54, + KBD4_T55, + KBD4_T56, + KBD4_T57, + KBD4_T58, + KBD4_T59, + KBD4_T5A, + KBD4_T5B, + KBD4_T5C, + KBD4_T5D, + KBD4_T5E, + KBD4_T5F, + KBD4_T60, + KBD4_T61, + KBD4_T62, + KBD4_T63, + KBD4_T64, + KBD4_T65, + KBD4_T66, + KBD4_T67, + KBD4_T68, + KBD4_T69, + KBD4_T6A, + KBD4_T6B, + KBD4_T6C, + KBD4_T6D, + KBD4_T6E, + KBD4_T6F, + KBD4_T70, + KBD4_T71, + KBD4_T72, + KBD4_T73, + KBD4_T74, + KBD4_T75, + KBD4_T76, + KBD4_T77, + KBD4_T78, + KBD4_T79, + KBD4_T7A, + KBD4_T7B, + KBD4_T7C, + KBD4_T7D, + KBD4_T7E, + KBD4_T7F +}; + +DWORD KBD4X[128] = +{ + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X10, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X19, + VK_NONE, + VK_NONE, + KBD4_X1C, + KBD4_X1D, + VK_NONE, + VK_NONE, + KBD4_X20, + KBD4_X21, + KBD4_X22, + VK_NONE, + KBD4_X24, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X2E, + VK_NONE, + KBD4_X30, + VK_NONE, + KBD4_X32, + VK_NONE, + VK_NONE, + KBD4_X35, + VK_NONE, + KBD4_X37, + KBD4_X38, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X46, + KBD4_X47, + KBD4_X48, + KBD4_X49, + VK_NONE, + KBD4_X4B, + VK_NONE, + KBD4_X4D, + VK_NONE, + KBD4_X4F, + KBD4_X50, + KBD4_X51, + KBD4_X52, + KBD4_X53, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X5B, + KBD4_X5C, + KBD4_X5D, + KBD4_X5E, + KBD4_X5F, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X65, + KBD4_X66, + KBD4_X67, + KBD4_X68, + KBD4_X69, + KBD4_X6A, + KBD4_X6B, + KBD4_X6C, + KBD4_X6D, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE +}; + +DWORD KBD7T[128] = +{ + KBD7_T00, + KBD7_T01, + KBD7_T02, + KBD7_T03, + KBD7_T04, + KBD7_T05, + KBD7_T06, + KBD7_T07, + KBD7_T08, + KBD7_T09, + KBD7_T0A, + KBD7_T0B, + KBD7_T0C, + KBD7_T0D, + KBD7_T0E, + KBD7_T0F, + KBD7_T10, + KBD7_T11, + KBD7_T12, + KBD7_T13, + KBD7_T14, + KBD7_T15, + KBD7_T16, + KBD7_T17, + KBD7_T18, + KBD7_T19, + KBD7_T1A, + KBD7_T1B, + KBD7_T1C, + KBD7_T1D, + KBD7_T1E, + KBD7_T1F, + KBD7_T20, + KBD7_T21, + KBD7_T22, + KBD7_T23, + KBD7_T24, + KBD7_T25, + KBD7_T26, + KBD7_T27, + KBD7_T28, + KBD7_T29, + KBD7_T2A, + KBD7_T2B, + KBD7_T2C, + KBD7_T2D, + KBD7_T2E, + KBD7_T2F, + KBD7_T30, + KBD7_T31, + KBD7_T32, + KBD7_T33, + KBD7_T34, + KBD7_T35, + KBD7_T36, + KBD7_T37, + KBD7_T38, + KBD7_T39, + KBD7_T3A, + KBD7_T3B, + KBD7_T3C, + KBD7_T3D, + KBD7_T3E, + KBD7_T3F, + KBD7_T40, + KBD7_T41, + KBD7_T42, + KBD7_T43, + KBD7_T44, + KBD7_T45, + KBD7_T46, + KBD7_T47, + KBD7_T48, + KBD7_T49, + KBD7_T4A, + KBD7_T4B, + KBD7_T4C, + KBD7_T4D, + KBD7_T4E, + KBD7_T4F, + KBD7_T50, + KBD7_T51, + KBD7_T52, + KBD7_T53, + KBD7_T54, + KBD7_T55, + KBD7_T56, + KBD7_T57, + KBD7_T58, + KBD7_T59, + KBD7_T5A, + KBD7_T5B, + KBD7_T5C, + KBD7_T5D, + KBD7_T5E, + KBD7_T5F, + KBD7_T60, + KBD7_T61, + KBD7_T62, + KBD7_T63, + KBD7_T64, + KBD7_T65, + KBD7_T66, + KBD7_T67, + KBD7_T68, + KBD7_T69, + KBD7_T6A, + KBD7_T6B, + KBD7_T6C, + KBD7_T6D, + KBD7_T6E, + KBD7_T6F, + KBD7_T70, + KBD7_T71, + KBD7_T72, + KBD7_T73, + KBD7_T74, + KBD7_T75, + KBD7_T76, + KBD7_T77, + KBD7_T78, + KBD7_T79, + KBD7_T7A, + KBD7_T7B, + KBD7_T7C, + KBD7_T7D, + KBD7_T7E, + KBD7_T7F +}; + +DWORD KBD7X[128] = +{ + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X10, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X19, + VK_NONE, + VK_NONE, + KBD7_X1C, + KBD7_X1D, + VK_NONE, + VK_NONE, + KBD7_X20, + KBD7_X21, + KBD7_X22, + VK_NONE, + KBD7_X24, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X2E, + VK_NONE, + KBD7_X30, + VK_NONE, + KBD7_X32, + KBD7_X33, + VK_NONE, + KBD7_X35, + VK_NONE, + KBD7_X37, + KBD7_X38, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X42, + KBD7_X43, + KBD7_X44, + VK_NONE, + KBD7_X46, + KBD7_X47, + KBD7_X48, + KBD7_X49, + VK_NONE, + KBD7_X4B, + VK_NONE, + KBD7_X4D, + VK_NONE, + KBD7_X4F, + KBD7_X50, + KBD7_X51, + KBD7_X52, + KBD7_X53, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X5B, + KBD7_X5C, + KBD7_X5D, + KBD7_X5E, + KBD7_X5F, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X65, + KBD7_X66, + KBD7_X67, + KBD7_X68, + KBD7_X69, + KBD7_X6A, + KBD7_X6B, + KBD7_X6C, + KBD7_X6D, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE +}; From 44758bfe544e1d65f15a9249046d90e1064d824e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 3 Mar 2013 16:30:31 -0500 Subject: [PATCH 07/18] libfreerdp-locale: start moving some code to libwinpr-input --- client/DirectFB/CMakeLists.txt | 5 + client/DirectFB/df_event.c | 22 +- include/freerdp/locale/keyboard.h | 4 +- include/freerdp/locale/vkcodes.h | 309 -------------------- include/freerdp/scancode.h | 6 +- libfreerdp/locale/CMakeLists.txt | 3 +- libfreerdp/locale/keyboard.c | 14 +- libfreerdp/locale/keyboard_layout.c | 263 ----------------- libfreerdp/locale/keyboard_x11.c | 29 +- libfreerdp/locale/keyboard_xkbfile.c | 5 +- libfreerdp/locale/virtual_key_codes.c | 318 -------------------- winpr/include/winpr/input.h | 23 ++ winpr/libwinpr/input/keyboard.c | 398 ++++++++++++++++++++++++++ 13 files changed, 461 insertions(+), 938 deletions(-) delete mode 100644 include/freerdp/locale/vkcodes.h delete mode 100644 libfreerdp/locale/virtual_key_codes.c diff --git a/client/DirectFB/CMakeLists.txt b/client/DirectFB/CMakeLists.txt index 52c07ef69..061b05c54 100644 --- a/client/DirectFB/CMakeLists.txt +++ b/client/DirectFB/CMakeLists.txt @@ -37,6 +37,11 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE freerdp MODULES freerdp-core freerdp-gdi freerdp-locale freerdp-codec freerdp-primitives freerdp-utils) + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE winpr + MODULES winpr-input winpr-crt) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/client/DirectFB/df_event.c b/client/DirectFB/df_event.c index 68d8d72cd..5ec8b9635 100644 --- a/client/DirectFB/df_event.c +++ b/client/DirectFB/df_event.c @@ -17,6 +17,9 @@ * limitations under the License. */ +#include +#include + #include #include "df_event.h" @@ -26,7 +29,7 @@ static BYTE functionmap[128]; void df_keyboard_init() { - memset(keymap, 0, sizeof(keymap)); + ZeroMemory(keymap, sizeof(keymap)); /* Map DirectFB keycodes to Virtual Key Codes */ @@ -146,8 +149,7 @@ void df_keyboard_init() keymap[DIKI_META_R - DIKI_UNKNOWN] = VK_RWIN; keymap[DIKI_SUPER_L - DIKI_UNKNOWN] = VK_APPS; - - memset(functionmap, 0, sizeof(functionmap)); + ZeroMemory(functionmap, sizeof(functionmap)); functionmap[DFB_FUNCTION_KEY(23) - DFB_FUNCTION_KEY(0)] = VK_HANGUL; functionmap[DFB_FUNCTION_KEY(24) - DFB_FUNCTION_KEY(0)] = VK_HANJA; @@ -190,19 +192,19 @@ void df_send_mouse_wheel_event(rdpInput* input, INT16 axisrel, UINT16 x, UINT16 void df_send_keyboard_event(rdpInput* input, BOOL down, BYTE keycode, BYTE function) { - BYTE vkcode; - RDP_SCANCODE rdp_scancode; - + DWORD scancode = 0; + BYTE vkcode = VK_NONE; + if (keycode) vkcode = keymap[keycode]; else if (function) vkcode = functionmap[function]; - else - return; - rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(vkcode); + if (vkcode != VK_NONE) + scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, input->context->settings->KeyboardType); - freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); + if (scancode) + freerdp_input_send_keyboard_event_ex(input, down, scancode); } BOOL df_event_process(freerdp* instance, DFBEvent* event) diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index c7a915140..1ba6e2158 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -20,10 +20,11 @@ #ifndef FREERDP_LOCALE_KEYBOARD_H #define FREERDP_LOCALE_KEYBOARD_H +#include + #include #include #include -#include #define RDP_KEYBOARD_LAYOUT_TYPE_STANDARD 1 #define RDP_KEYBOARD_LAYOUT_TYPE_VARIANT 2 @@ -203,6 +204,5 @@ FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(UINT32 types); FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(UINT32 keyboardLayoutId); FREERDP_API RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode); FREERDP_API UINT32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(UINT32 scancode, BOOL extended); -FREERDP_API RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(UINT32 vkcode); #endif /* FREERDP_LOCALE_KEYBOARD_H */ diff --git a/include/freerdp/locale/vkcodes.h b/include/freerdp/locale/vkcodes.h deleted file mode 100644 index ca8d008be..000000000 --- a/include/freerdp/locale/vkcodes.h +++ /dev/null @@ -1,309 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Microsoft Windows Virtual-Key Codes - * - * Copyright 2009-2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FREERDP_VIRTUAL_KEY_CODES_H -#define FREERDP_VIRTUAL_KEY_CODES_H - -#include -#include - -/* Virtual-Key Codes, @msdn{dd375731} */ - -/* Mouse buttons */ - -#define VK_LBUTTON 0x01 /* Left mouse button */ -#define VK_RBUTTON 0x02 /* Right mouse button */ -#define VK_CANCEL 0x03 /* Control-break processing */ -#define VK_MBUTTON 0x04 /* Middle mouse button (three-button mouse) */ -#define VK_XBUTTON1 0x05 /* Windows 2000/XP: X1 mouse button */ -#define VK_XBUTTON2 0x06 /* Windows 2000/XP: X2 mouse button */ - -/* 0x07 is undefined */ - -#define VK_BACK 0x08 /* BACKSPACE key */ -#define VK_TAB 0x09 /* TAB key */ - -/* 0x0A to 0x0B are reserved */ - -#define VK_CLEAR 0x0C /* CLEAR key */ -#define VK_RETURN 0x0D /* ENTER key */ - -/* 0x0E to 0x0F are undefined */ - -#define VK_SHIFT 0x10 /* SHIFT key */ -#define VK_CONTROL 0x11 /* CTRL key */ -#define VK_MENU 0x12 /* ALT key */ -#define VK_PAUSE 0x13 /* PAUSE key */ -#define VK_CAPITAL 0x14 /* CAPS LOCK key */ -#define VK_KANA 0x15 /* Input Method Editor (IME) Kana mode */ -#define VK_HANGUEL 0x15 /* IME Hanguel mode (maintained for compatibility; use #define VK_HANGUL) */ -#define VK_HANGUL 0x15 /* IME Hangul mode */ - -/* 0x16 is undefined */ - -#define VK_JUNJA 0x17 /* IME Junja mode */ -#define VK_FINAL 0x18 /* IME final mode */ -#define VK_HANJA 0x19 /* IME Hanja mode */ -#define VK_KANJI 0x19 /* IME Kanji mode */ - -/* 0x1A is undefined */ - -#define VK_ESCAPE 0x1B /* ESC key */ -#define VK_CONVERT 0x1C /* IME convert */ -#define VK_NONCONVERT 0x1D /* IME nonconvert */ -#define VK_ACCEPT 0x1E /* IME accept */ -#define VK_MODECHANGE 0x1F /* IME mode change request */ - -#define VK_SPACE 0x20 /* SPACEBAR */ -#define VK_PRIOR 0x21 /* PAGE UP key */ -#define VK_NEXT 0x22 /* PAGE DOWN key */ -#define VK_END 0x23 /* END key */ -#define VK_HOME 0x24 /* HOME key */ -#define VK_LEFT 0x25 /* LEFT ARROW key */ -#define VK_UP 0x26 /* UP ARROW key */ -#define VK_RIGHT 0x27 /* RIGHT ARROW key */ -#define VK_DOWN 0x28 /* DOWN ARROW key */ -#define VK_SELECT 0x29 /* SELECT key */ -#define VK_PRINT 0x2A /* PRINT key */ -#define VK_EXECUTE 0x2B /* EXECUTE key */ -#define VK_SNAPSHOT 0x2C /* PRINT SCREEN key */ -#define VK_INSERT 0x2D /* INS key */ -#define VK_DELETE 0x2E /* DEL key */ -#define VK_HELP 0x2F /* HELP key */ - -/* Digits, the last 4 bits of the code represent the corresponding digit */ - -#define VK_KEY_0 0x30 /* '0' key */ -#define VK_KEY_1 0x31 /* '1' key */ -#define VK_KEY_2 0x32 /* '2' key */ -#define VK_KEY_3 0x33 /* '3' key */ -#define VK_KEY_4 0x34 /* '4' key */ -#define VK_KEY_5 0x35 /* '5' key */ -#define VK_KEY_6 0x36 /* '6' key */ -#define VK_KEY_7 0x37 /* '7' key */ -#define VK_KEY_8 0x38 /* '8' key */ -#define VK_KEY_9 0x39 /* '9' key */ - -/* 0x3A to 0x40 are undefined */ - -/* The alphabet, the code corresponds to the capitalized letter in the ASCII code */ - -#define VK_KEY_A 0x41 /* 'A' key */ -#define VK_KEY_B 0x42 /* 'B' key */ -#define VK_KEY_C 0x43 /* 'C' key */ -#define VK_KEY_D 0x44 /* 'D' key */ -#define VK_KEY_E 0x45 /* 'E' key */ -#define VK_KEY_F 0x46 /* 'F' key */ -#define VK_KEY_G 0x47 /* 'G' key */ -#define VK_KEY_H 0x48 /* 'H' key */ -#define VK_KEY_I 0x49 /* 'I' key */ -#define VK_KEY_J 0x4A /* 'J' key */ -#define VK_KEY_K 0x4B /* 'K' key */ -#define VK_KEY_L 0x4C /* 'L' key */ -#define VK_KEY_M 0x4D /* 'M' key */ -#define VK_KEY_N 0x4E /* 'N' key */ -#define VK_KEY_O 0x4F /* 'O' key */ -#define VK_KEY_P 0x50 /* 'P' key */ -#define VK_KEY_Q 0x51 /* 'Q' key */ -#define VK_KEY_R 0x52 /* 'R' key */ -#define VK_KEY_S 0x53 /* 'S' key */ -#define VK_KEY_T 0x54 /* 'T' key */ -#define VK_KEY_U 0x55 /* 'U' key */ -#define VK_KEY_V 0x56 /* 'V' key */ -#define VK_KEY_W 0x57 /* 'W' key */ -#define VK_KEY_X 0x58 /* 'X' key */ -#define VK_KEY_Y 0x59 /* 'Y' key */ -#define VK_KEY_Z 0x5A /* 'Z' key */ - -#define VK_LWIN 0x5B /* Left Windows key (Microsoft Natural keyboard) */ -#define VK_RWIN 0x5C /* Right Windows key (Natural keyboard) */ -#define VK_APPS 0x5D /* Applications key (Natural keyboard) */ - -/* 0x5E is reserved */ - -#define VK_SLEEP 0x5F /* Computer Sleep key */ - -/* Numeric keypad digits, the last four bits of the code represent the corresponding digit */ - -#define VK_NUMPAD0 0x60 /* Numeric keypad '0' key */ -#define VK_NUMPAD1 0x61 /* Numeric keypad '1' key */ -#define VK_NUMPAD2 0x62 /* Numeric keypad '2' key */ -#define VK_NUMPAD3 0x63 /* Numeric keypad '3' key */ -#define VK_NUMPAD4 0x64 /* Numeric keypad '4' key */ -#define VK_NUMPAD5 0x65 /* Numeric keypad '5' key */ -#define VK_NUMPAD6 0x66 /* Numeric keypad '6' key */ -#define VK_NUMPAD7 0x67 /* Numeric keypad '7' key */ -#define VK_NUMPAD8 0x68 /* Numeric keypad '8' key */ -#define VK_NUMPAD9 0x69 /* Numeric keypad '9' key */ - -/* Numeric keypad operators and special keys */ - -#define VK_MULTIPLY 0x6A /* Multiply key */ -#define VK_ADD 0x6B /* Add key */ -#define VK_SEPARATOR 0x6C /* Separator key */ -#define VK_SUBTRACT 0x6D /* Subtract key */ -#define VK_DECIMAL 0x6E /* Decimal key */ -#define VK_DIVIDE 0x6F /* Divide key */ - -/* Function keys, from F1 to F24 */ - -#define VK_F1 0x70 /* F1 key */ -#define VK_F2 0x71 /* F2 key */ -#define VK_F3 0x72 /* F3 key */ -#define VK_F4 0x73 /* F4 key */ -#define VK_F5 0x74 /* F5 key */ -#define VK_F6 0x75 /* F6 key */ -#define VK_F7 0x76 /* F7 key */ -#define VK_F8 0x77 /* F8 key */ -#define VK_F9 0x78 /* F9 key */ -#define VK_F10 0x79 /* F10 key */ -#define VK_F11 0x7A /* F11 key */ -#define VK_F12 0x7B /* F12 key */ -#define VK_F13 0x7C /* F13 key */ -#define VK_F14 0x7D /* F14 key */ -#define VK_F15 0x7E /* F15 key */ -#define VK_F16 0x7F /* F16 key */ -#define VK_F17 0x80 /* F17 key */ -#define VK_F18 0x81 /* F18 key */ -#define VK_F19 0x82 /* F19 key */ -#define VK_F20 0x83 /* F20 key */ -#define VK_F21 0x84 /* F21 key */ -#define VK_F22 0x85 /* F22 key */ -#define VK_F23 0x86 /* F23 key */ -#define VK_F24 0x87 /* F24 key */ - -/* 0x88 to 0x8F are unassigned */ - -#define VK_NUMLOCK 0x90 /* NUM LOCK key */ -#define VK_SCROLL 0x91 /* SCROLL LOCK key */ - -/* 0x92 to 0x96 are OEM specific */ -/* 0x97 to 0x9F are unassigned */ - -/* Modifier keys */ - -#define VK_LSHIFT 0xA0 /* Left SHIFT key */ -#define VK_RSHIFT 0xA1 /* Right SHIFT key */ -#define VK_LCONTROL 0xA2 /* Left CONTROL key */ -#define VK_RCONTROL 0xA3 /* Right CONTROL key */ -#define VK_LMENU 0xA4 /* Left MENU key */ -#define VK_RMENU 0xA5 /* Right MENU key */ - -/* Browser related keys */ - -#define VK_BROWSER_BACK 0xA6 /* Windows 2000/XP: Browser Back key */ -#define VK_BROWSER_FORWARD 0xA7 /* Windows 2000/XP: Browser Forward key */ -#define VK_BROWSER_REFRESH 0xA8 /* Windows 2000/XP: Browser Refresh key */ -#define VK_BROWSER_STOP 0xA9 /* Windows 2000/XP: Browser Stop key */ -#define VK_BROWSER_SEARCH 0xAA /* Windows 2000/XP: Browser Search key */ -#define VK_BROWSER_FAVORITES 0xAB /* Windows 2000/XP: Browser Favorites key */ -#define VK_BROWSER_HOME 0xAC /* Windows 2000/XP: Browser Start and Home key */ - -/* Volume related keys */ - -#define VK_VOLUME_MUTE 0xAD /* Windows 2000/XP: Volume Mute key */ -#define VK_VOLUME_DOWN 0xAE /* Windows 2000/XP: Volume Down key */ -#define VK_VOLUME_UP 0xAF /* Windows 2000/XP: Volume Up key */ - -/* Media player related keys */ - -#define VK_MEDIA_NEXT_TRACK 0xB0 /* Windows 2000/XP: Next Track key */ -#define VK_MEDIA_PREV_TRACK 0xB1 /* Windows 2000/XP: Previous Track key */ -#define VK_MEDIA_STOP 0xB2 /* Windows 2000/XP: Stop Media key */ -#define VK_MEDIA_PLAY_PAUSE 0xB3 /* Windows 2000/XP: Play/Pause Media key */ - -/* Application launcher keys */ - -#define VK_LAUNCH_MAIL 0xB4 /* Windows 2000/XP: Start Mail key */ -#define VK_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ -#define VK_LAUNCH_APP1 0xB6 /* Windows 2000/XP: Start Application 1 key */ -#define VK_LAUNCH_APP2 0xB7 /* Windows 2000/XP: Start Application 2 key */ - -/* 0xB8 and 0xB9 are reserved */ - -/* OEM keys */ - -#define VK_OEM_1 0xBA /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the ';:' key */ - -#define VK_OEM_PLUS 0xBB /* Windows 2000/XP: For any country/region, the '+' key */ -#define VK_OEM_COMMA 0xBC /* Windows 2000/XP: For any country/region, the ',' key */ -#define VK_OEM_MINUS 0xBD /* Windows 2000/XP: For any country/region, the '-' key */ -#define VK_OEM_PERIOD 0xBE /* Windows 2000/XP: For any country/region, the '.' key */ - -#define VK_OEM_2 0xBF /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the '/?' key */ - -#define VK_OEM_3 0xC0 /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the '`~' key */ - -/* 0xC1 to 0xD7 are reserved */ -#define VK_ABNT_C1 0xC1 /* Brazilian (ABNT) Keyboard */ -#define VK_ABNT_C2 0xC2 /* Brazilian (ABNT) Keyboard */ - -/* 0xD8 to 0xDA are unassigned */ - -#define VK_OEM_4 0xDB /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the '[{' key */ - -#define VK_OEM_5 0xDC /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the '\|' key */ - -#define VK_OEM_6 0xDD /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the ']}' key */ - -#define VK_OEM_7 0xDE /* Used for miscellaneous characters; it can vary by keyboard. */ - /* Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key */ - -#define VK_OEM_8 0xDF /* Used for miscellaneous characters; it can vary by keyboard. */ - -/* 0xE0 is reserved */ -/* 0xE1 is OEM specific */ - -#define VK_OEM_102 0xE2 /* Windows 2000/XP: Either the angle bracket key or */ - /* the backslash key on the RT 102-key keyboard */ - -/* 0xE3 and 0xE4 are OEM specific */ - -#define VK_PROCESSKEY 0xE5 /* Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key */ - -/* 0xE6 is OEM specific */ - -#define VK_PACKET 0xE7 /* Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. */ - /* The #define VK_PACKET key is the low word of a 32-bit Virtual Key value used */ - /* for non-keyboard input methods. For more information, */ - /* see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP */ - -/* 0xE8 is unassigned */ -/* 0xE9 to 0xF5 are OEM specific */ - -#define VK_ATTN 0xF6 /* Attn key */ -#define VK_CRSEL 0xF7 /* CrSel key */ -#define VK_EXSEL 0xF8 /* ExSel key */ -#define VK_EREOF 0xF9 /* Erase EOF key */ -#define VK_PLAY 0xFA /* Play key */ -#define VK_ZOOM 0xFB /* Zoom key */ -#define VK_NONAME 0xFC /* Reserved */ -#define VK_PA1 0xFD /* PA1 key */ -#define VK_OEM_CLEAR 0xFE /* Clear key */ - -FREERDP_API const char* freerdp_keyboard_get_virtual_key_code_name(UINT32 vkcode); -FREERDP_API UINT32 freerdp_keyboard_get_virtual_key_code_from_name(const char* vkcode_name); - -#endif /* FREERDP_VIRTUAL_KEY_CODES_H */ diff --git a/include/freerdp/scancode.h b/include/freerdp/scancode.h index cb24784de..88f893a0b 100644 --- a/include/freerdp/scancode.h +++ b/include/freerdp/scancode.h @@ -20,6 +20,8 @@ #ifndef FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H #define FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H +#include + /* @msdn{cc240584} says: * "... (a scancode is an 8-bit value specifying a key location on the keyboard). * The server accepts a scancode value and translates it into the correct character depending on the language locale and keyboard layout used in the session." @@ -29,8 +31,8 @@ typedef UINT32 RDP_SCANCODE; /* Our own representation of a RDP protocol scancode */ #define RDP_SCANCODE_CODE(_rdp_scancode) ((BYTE)(_rdp_scancode & 0xFF)) -#define RDP_SCANCODE_EXTENDED(_rdp_scancode) (((_rdp_scancode) & 0x100) ? TRUE : FALSE) -#define MAKE_RDP_SCANCODE(_code, _extended) (((_code) & 0xFF) | ((_extended) ? 0x100 : 0)) +#define RDP_SCANCODE_EXTENDED(_rdp_scancode) (((_rdp_scancode) & KBDEXT) ? TRUE : FALSE) +#define MAKE_RDP_SCANCODE(_code, _extended) (((_code) & 0xFF) | ((_extended) ? KBDEXT : 0)) /* Defines for known RDP_SCANCODE protocol values. * Mostly the same as the PKBDLLHOOKSTRUCT scanCode, "A hardware scan code for the key", @msdn{ms644967}. diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index bb480f7ea..e89dac395 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -19,7 +19,6 @@ set(MODULE_NAME "freerdp-locale") set(MODULE_PREFIX "FREERDP_LOCALE") set(${MODULE_PREFIX}_SRCS - virtual_key_codes.c keyboard_layout.c keyboard.c locale.c @@ -87,7 +86,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE winpr - MODULES winpr-crt) + MODULES winpr-input winpr-crt) if(MONOLITHIC_BUILD) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 4dd5cf6c5..aca2666fc 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -44,8 +44,6 @@ UINT32 RDP_SCANCODE_TO_X11_KEYCODE[256][2]; RDP_SCANCODE X11_KEYCODE_TO_RDP_SCANCODE[256]; -extern const RDP_SCANCODE VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[256]; - UINT32 freerdp_detect_keyboard(UINT32 keyboardLayoutID) { if (keyboardLayoutID != 0) @@ -81,11 +79,14 @@ UINT32 freerdp_keyboard_init(UINT32 keyboardLayoutId) #endif keyboardLayoutId = freerdp_detect_keyboard(keyboardLayoutId); - memset(RDP_SCANCODE_TO_X11_KEYCODE, 0, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); - for (keycode=0; keycode < ARRAYSIZE(RDP_SCANCODE_TO_X11_KEYCODE); keycode++) + ZeroMemory(RDP_SCANCODE_TO_X11_KEYCODE, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); + + for (keycode = 0; keycode < ARRAYSIZE(RDP_SCANCODE_TO_X11_KEYCODE); keycode++) + { RDP_SCANCODE_TO_X11_KEYCODE [RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode])] [RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? 1 : 0] = keycode; + } return keyboardLayoutId; } @@ -106,8 +107,3 @@ UINT32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(UINT32 scancode, BOOL else return RDP_SCANCODE_TO_X11_KEYCODE[scancode][0]; } - -RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(UINT32 vkcode) -{ - return VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[vkcode]; -} diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index 7ab045b74..f84f6fe87 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -214,269 +214,6 @@ static const RDP_KEYBOARD_IME RDP_KEYBOARD_IME_TABLE[] = { KBD_CHINESE_TRADITIONAL_ALPHANUMERIC, "romanime.ime", "Chinese (Traditional) - Alphanumeric" } }; - -/* the index in this table is the virtual key code */ - -const RDP_SCANCODE VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[256] = -{ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, /* VK_LBUTTON */ - RDP_SCANCODE_UNKNOWN, /* VK_RBUTTON */ - RDP_SCANCODE_UNKNOWN, /* VK_CANCEL */ - RDP_SCANCODE_UNKNOWN, /* VK_MBUTTON */ - RDP_SCANCODE_UNKNOWN, /* VK_XBUTTON1 */ - RDP_SCANCODE_UNKNOWN, /* VK_XBUTTON2 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_BACKSPACE, /* VK_BACK */ - RDP_SCANCODE_TAB, /* VK_TAB */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, /* VK_CLEAR */ - RDP_SCANCODE_RETURN, /* VK_RETURN */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_LSHIFT, /* VK_SHIFT */ - RDP_SCANCODE_UNKNOWN, /* VK_CONTROL */ - RDP_SCANCODE_LMENU, /* VK_MENU */ - RDP_SCANCODE_PAUSE, /* VK_PAUSE */ - RDP_SCANCODE_CAPSLOCK, /* VK_CAPITAL */ - RDP_SCANCODE_UNKNOWN, /* VK_KANA / VK_HANGUL */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, /* VK_JUNJA */ - RDP_SCANCODE_UNKNOWN, /* VK_FINAL */ - RDP_SCANCODE_UNKNOWN, /* VK_HANJA / VK_KANJI */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_ESCAPE, /* VK_ESCAPE */ - RDP_SCANCODE_UNKNOWN, /* VK_CONVERT */ - RDP_SCANCODE_UNKNOWN, /* VK_NONCONVERT */ - RDP_SCANCODE_UNKNOWN, /* VK_ACCEPT */ - RDP_SCANCODE_UNKNOWN, /* VK_MODECHANGE */ - RDP_SCANCODE_SPACE, /* VK_SPACE */ - RDP_SCANCODE_PRIOR, /* VK_PRIOR */ - RDP_SCANCODE_NEXT, /* VK_NEXT */ - RDP_SCANCODE_END, /* VK_END */ - RDP_SCANCODE_HOME, /* VK_HOME */ - RDP_SCANCODE_LEFT, /* VK_LEFT */ - RDP_SCANCODE_UP, /* VK_UP */ - RDP_SCANCODE_RIGHT, /* VK_RIGHT */ - RDP_SCANCODE_DOWN, /* VK_DOWN */ - RDP_SCANCODE_UNKNOWN, /* VK_SELECT */ - RDP_SCANCODE_PRINTSCREEN,/* VK_PRINT */ - RDP_SCANCODE_PRINTSCREEN,/* VK_EXECUTE */ - RDP_SCANCODE_PRINTSCREEN,/* VK_SNAPSHOT */ - RDP_SCANCODE_INSERT, /* VK_INSERT */ - RDP_SCANCODE_DELETE, /* VK_DELETE */ - RDP_SCANCODE_HELP, /* VK_HELP */ - RDP_SCANCODE_KEY_0, /* VK_KEY_0 */ - RDP_SCANCODE_KEY_1, /* VK_KEY_1 */ - RDP_SCANCODE_KEY_2, /* VK_KEY_2 */ - RDP_SCANCODE_KEY_3, /* VK_KEY_3 */ - RDP_SCANCODE_KEY_4, /* VK_KEY_4 */ - RDP_SCANCODE_KEY_5, /* VK_KEY_5 */ - RDP_SCANCODE_KEY_6, /* VK_KEY_6 */ - RDP_SCANCODE_KEY_7, /* VK_KEY_7 */ - RDP_SCANCODE_KEY_8, /* VK_KEY_8 */ - RDP_SCANCODE_KEY_9, /* VK_KEY_9 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_KEY_A, /* VK_KEY_A */ - RDP_SCANCODE_KEY_B, /* VK_KEY_B */ - RDP_SCANCODE_KEY_C, /* VK_KEY_C */ - RDP_SCANCODE_KEY_D, /* VK_KEY_D */ - RDP_SCANCODE_KEY_E, /* VK_KEY_E */ - RDP_SCANCODE_KEY_F, /* VK_KEY_F */ - RDP_SCANCODE_KEY_G, /* VK_KEY_G */ - RDP_SCANCODE_KEY_H, /* VK_KEY_H */ - RDP_SCANCODE_KEY_I, /* VK_KEY_I */ - RDP_SCANCODE_KEY_J, /* VK_KEY_J */ - RDP_SCANCODE_KEY_K, /* VK_KEY_K */ - RDP_SCANCODE_KEY_L, /* VK_KEY_L */ - RDP_SCANCODE_KEY_M, /* VK_KEY_M */ - RDP_SCANCODE_KEY_N, /* VK_KEY_N */ - RDP_SCANCODE_KEY_O, /* VK_KEY_O */ - RDP_SCANCODE_KEY_P, /* VK_KEY_P */ - RDP_SCANCODE_KEY_Q, /* VK_KEY_Q */ - RDP_SCANCODE_KEY_R, /* VK_KEY_R */ - RDP_SCANCODE_KEY_S, /* VK_KEY_S */ - RDP_SCANCODE_KEY_T, /* VK_KEY_T */ - RDP_SCANCODE_KEY_U, /* VK_KEY_U */ - RDP_SCANCODE_KEY_V, /* VK_KEY_V */ - RDP_SCANCODE_KEY_W, /* VK_KEY_W */ - RDP_SCANCODE_KEY_X, /* VK_KEY_X */ - RDP_SCANCODE_KEY_Y, /* VK_KEY_Y */ - RDP_SCANCODE_KEY_Z, /* VK_KEY_Z */ - RDP_SCANCODE_LWIN, /* VK_LWIN */ - RDP_SCANCODE_RWIN, /* VK_RWIN */ - RDP_SCANCODE_APPS, /* VK_APPS */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_SLEEP, /* VK_SLEEP */ - RDP_SCANCODE_NUMPAD0, /* VK_NUMPAD0 */ - RDP_SCANCODE_NUMPAD1, /* VK_NUMPAD1 */ - RDP_SCANCODE_NUMPAD2, /* VK_NUMPAD2 */ - RDP_SCANCODE_NUMPAD3, /* VK_NUMPAD3 */ - RDP_SCANCODE_NUMPAD4, /* VK_NUMPAD4 */ - RDP_SCANCODE_NUMPAD5, /* VK_NUMPAD5 */ - RDP_SCANCODE_NUMPAD6, /* VK_NUMPAD6 */ - RDP_SCANCODE_NUMPAD7, /* VK_NUMPAD7 */ - RDP_SCANCODE_NUMPAD8, /* VK_NUMPAD8 */ - RDP_SCANCODE_NUMPAD9, /* VK_NUMPAD9 */ - RDP_SCANCODE_MULTIPLY, /* VK_MULTIPLY */ - RDP_SCANCODE_ADD, /* VK_ADD */ - RDP_SCANCODE_UNKNOWN, /* VK_SEPARATOR */ - RDP_SCANCODE_SUBTRACT, /* VK_SUBTRACT */ - RDP_SCANCODE_DECIMAL, /* VK_DECIMAL */ - RDP_SCANCODE_DIVIDE, /* VK_DIVIDE */ - RDP_SCANCODE_F1, /* VK_F1 */ - RDP_SCANCODE_F2, /* VK_F2 */ - RDP_SCANCODE_F3, /* VK_F3 */ - RDP_SCANCODE_F4, /* VK_F4 */ - RDP_SCANCODE_F5, /* VK_F5 */ - RDP_SCANCODE_F6, /* VK_F6 */ - RDP_SCANCODE_F7, /* VK_F7 */ - RDP_SCANCODE_F8, /* VK_F8 */ - RDP_SCANCODE_F9, /* VK_F9 */ - RDP_SCANCODE_F10, /* VK_F10 */ - RDP_SCANCODE_F11, /* VK_F11 */ - RDP_SCANCODE_F12, /* VK_F12 */ - RDP_SCANCODE_F13, /* VK_F13 */ - RDP_SCANCODE_F14, /* VK_F14 */ - RDP_SCANCODE_F15, /* VK_F15 */ - RDP_SCANCODE_F16, /* VK_F16 */ - RDP_SCANCODE_F17, /* VK_F17 */ - RDP_SCANCODE_F18, /* VK_F18 */ - RDP_SCANCODE_F19, /* VK_F19 */ - RDP_SCANCODE_F20, /* VK_F20 */ - RDP_SCANCODE_F21, /* VK_F21 */ - RDP_SCANCODE_F22, /* VK_F22 */ - RDP_SCANCODE_F23, /* VK_F23 */ - RDP_SCANCODE_F24, /* VK_F24 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_NUMLOCK, /* VK_NUMLOCK */ - RDP_SCANCODE_SCROLLLOCK, /* VK_SCROLL */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_LSHIFT, /* VK_LSHIFT */ - RDP_SCANCODE_RSHIFT, /* VK_RSHIFT */ - RDP_SCANCODE_LCONTROL, /* VK_LCONTROL */ - RDP_SCANCODE_RCONTROL, /* VK_RCONTROL */ - RDP_SCANCODE_LMENU, /* VK_LMENU */ - RDP_SCANCODE_RMENU, /* VK_RMENU */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_BACK */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_FORWARD */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_REFRESH */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_STOP */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_SEARCH */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_FAVORITES */ - RDP_SCANCODE_UNKNOWN, /* VK_BROWSER_HOME */ - RDP_SCANCODE_UNKNOWN, /* VK_VOLUME_MUTE */ - RDP_SCANCODE_UNKNOWN, /* VK_VOLUME_DOWN */ - RDP_SCANCODE_UNKNOWN, /* VK_VOLUME_UP */ - RDP_SCANCODE_UNKNOWN, /* VK_MEDIA_NEXT_TRACK */ - RDP_SCANCODE_UNKNOWN, /* VK_MEDIA_PREV_TRACK */ - RDP_SCANCODE_UNKNOWN, /* VK_MEDIA_STOP */ - RDP_SCANCODE_UNKNOWN, /* VK_MEDIA_PLAY_PAUSE */ - RDP_SCANCODE_UNKNOWN, /* VK_LAUNCH_MAIL */ - RDP_SCANCODE_UNKNOWN, /* VK_MEDIA_SELECT */ - RDP_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */ - RDP_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_OEM_1, /* VK_OEM_1 */ - RDP_SCANCODE_OEM_PLUS, /* VK_OEM_PLUS */ - RDP_SCANCODE_OEM_COMMA, /* VK_OEM_COMMA */ - RDP_SCANCODE_OEM_MINUS, /* VK_OEM_MINUS */ - RDP_SCANCODE_OEM_PERIOD, /* VK_OEM_PERIOD */ - RDP_SCANCODE_OEM_2, /* VK_OEM_2 */ - RDP_SCANCODE_OEM_3, /* VK_OEM_3 */ - RDP_SCANCODE_ABNT_C1, /* VK_ABNT_C1 */ - RDP_SCANCODE_ABNT_C2, /* VK_ABNT_C2 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_OEM_4, /* VK_OEM_4 */ - RDP_SCANCODE_OEM_5, /* VK_OEM_5 */ - RDP_SCANCODE_OEM_6, /* VK_OEM_6 */ - RDP_SCANCODE_OEM_7, /* VK_OEM_7 */ - RDP_SCANCODE_LCONTROL, /* VK_OEM_8 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_OEM_102, /* VK_OEM_102 */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, /* VK_PROCESSKEY */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, /* VK_PACKET */ - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, - RDP_SCANCODE_UNKNOWN, /* VK_ATTN */ - RDP_SCANCODE_UNKNOWN, /* VK_CRSEL */ - RDP_SCANCODE_UNKNOWN, /* VK_EXSEL */ - RDP_SCANCODE_UNKNOWN, /* VK_EREOF */ - RDP_SCANCODE_UNKNOWN, /* VK_PLAY */ - RDP_SCANCODE_ZOOM, /* VK_ZOOM */ - RDP_SCANCODE_UNKNOWN, /* VK_NONAME */ - RDP_SCANCODE_UNKNOWN, /* VK_PA1 */ - RDP_SCANCODE_UNKNOWN, /* VK_OEM_CLEAR */ - RDP_SCANCODE_UNKNOWN -}; - RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(UINT32 types) { int num, length, i; diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index fe5adc254..d94d6176e 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -39,10 +39,6 @@ #include "keyboard_sun.h" #endif - -extern const RDP_SCANCODE VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[256]; - - UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_variant) { char* pch; @@ -67,9 +63,9 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var * "multi" the keyboard layout variant */ - while(fgets(buffer, sizeof(buffer), xprop) != NULL) + while (fgets(buffer, sizeof(buffer), xprop) != NULL) { - if((pch = strstr(buffer, "_XKB_RULES_NAMES_BACKUP(STRING) = ")) != NULL) + if ((pch = strstr(buffer, "_XKB_RULES_NAMES_BACKUP(STRING) = ")) != NULL) { /* "rules" */ pch = strchr(&buffer[34], ','); // We assume it is xorg @@ -113,9 +109,9 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var xprop = popen("xprop -root _XKB_RULES_NAMES", "r"); - while(fgets(buffer, sizeof(buffer), xprop) != NULL) + while (fgets(buffer, sizeof(buffer), xprop) != NULL) { - if((pch = strstr(buffer, "_XKB_RULES_NAMES(STRING) = ")) != NULL) + if ((pch = strstr(buffer, "_XKB_RULES_NAMES(STRING) = ")) != NULL) { /* "rules" */ pch = strchr(&buffer[27], ','); // We assume it is xorg @@ -211,7 +207,7 @@ char* freerdp_detect_keymap_from_xkb() #ifdef __APPLE__ -const UINT32 KEYCODE_TO_VKCODE_MACOSX[256] = +const DWORD KEYCODE_TO_VKCODE_MACOSX[256] = { 0, /* 0 */ 0, /* 1 */ @@ -503,16 +499,17 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco if (keyboardLayoutId == 0) { keyboardLayoutId = freerdp_detect_keyboard_layout_from_xkb(&xkb_layout, &xkb_variant); + if (xkb_layout) free(xkb_layout); + if (xkb_variant) free(xkb_variant); - } keymap = freerdp_detect_keymap_from_xkb(); - if (keymap != NULL) + if (keymap) { freerdp_keyboard_load_maps(keycode_to_vkcode, keymap); free(keymap); @@ -520,15 +517,5 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco } #endif - for (keycode = 0; keycode < 256; keycode++) - { - vkcode = keycode_to_vkcode[keycode]; - - if (!(vkcode > 0 && vkcode < 256)) - continue; - - x11_keycode_to_rdp_scancode[keycode] = VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[vkcode]; - } - return keyboardLayoutId; } diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index 1b15be6ea..e0efb22fd 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -286,14 +286,15 @@ int freerdp_keyboard_load_map_from_xkbfile(void* display, RDP_SCANCODE x11_keyco for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) { found = FALSE; - memcpy(xkb_keyname, xkb->names->keys[i].name, 4); + CopyMemory(xkb_keyname, xkb->names->keys[i].name, 4); if (strlen(xkb_keyname) < 1) continue; + printf("XKB KeyName: %s\n", xkb_keyname); + for (j = 0; j < ARRAYSIZE(XKB_KEY_NAME_SCANCODE_TABLE); j++) { - if (!strcmp(xkb_keyname, XKB_KEY_NAME_SCANCODE_TABLE[j].xkb_keyname)) { DEBUG_KBD("%4s: keycode: 0x%02X -> rdp scancode: 0x%04X", diff --git a/libfreerdp/locale/virtual_key_codes.c b/libfreerdp/locale/virtual_key_codes.c deleted file mode 100644 index 7247f9872..000000000 --- a/libfreerdp/locale/virtual_key_codes.c +++ /dev/null @@ -1,318 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Keyboard Layouts - * - * Copyright 2009-2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include - -#include - -struct _VIRTUAL_KEY_CODE -{ - UINT32 code; /* Windows Virtual Key Code */ - const char* name; /* Virtual Key Code Name */ -}; -typedef struct _VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE; - -static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = -{ - { 0, "" }, - { VK_LBUTTON, "VK_LBUTTON" }, - { VK_RBUTTON, "VK_RBUTTON" }, - { VK_CANCEL, "VK_CANCEL" }, - { VK_MBUTTON, "VK_MBUTTON" }, - { VK_XBUTTON1, "VK_XBUTTON1" }, - { VK_XBUTTON2, "VK_XBUTTON2" }, - { 0, "" }, - { VK_BACK, "VK_BACK" }, - { VK_TAB, "VK_TAB" }, - { 0, "" }, - { 0, "" }, - { VK_CLEAR, "VK_CLEAR" }, - { VK_RETURN, "VK_RETURN" }, - { 0, "" }, - { 0, "" }, - { VK_SHIFT, "VK_SHIFT" }, - { VK_CONTROL, "VK_CONTROL" }, - { VK_MENU, "VK_MENU" }, - { VK_PAUSE, "VK_PAUSE" }, - { VK_CAPITAL, "VK_CAPITAL" }, - { VK_KANA, "VK_KANA" }, /* also VK_HANGUL */ - { 0, "" }, - { VK_JUNJA, "VK_JUNJA" }, - { VK_FINAL, "VK_FINAL" }, - { VK_KANJI, "VK_KANJI" }, /* also VK_HANJA */ - { 0, "" }, - { VK_ESCAPE, "VK_ESCAPE" }, - { VK_CONVERT, "VK_CONVERT" }, - { VK_NONCONVERT, "VK_NONCONVERT" }, - { VK_ACCEPT, "VK_ACCEPT" }, - { VK_MODECHANGE, "VK_MODECHANGE" }, - { VK_SPACE, "VK_SPACE" }, - { VK_PRIOR, "VK_PRIOR" }, - { VK_NEXT, "VK_NEXT" }, - { VK_END, "VK_END" }, - { VK_HOME, "VK_HOME" }, - { VK_LEFT, "VK_LEFT" }, - { VK_UP, "VK_UP" }, - { VK_RIGHT, "VK_RIGHT" }, - { VK_DOWN, "VK_DOWN" }, - { VK_SELECT, "VK_SELECT" }, - { VK_PRINT, "VK_PRINT" }, - { VK_EXECUTE, "VK_EXECUTE" }, - { VK_SNAPSHOT, "VK_SNAPSHOT" }, - { VK_INSERT, "VK_INSERT" }, - { VK_DELETE, "VK_DELETE" }, - { VK_HELP, "VK_HELP" }, - { VK_KEY_0, "VK_KEY_0" }, - { VK_KEY_1, "VK_KEY_1" }, - { VK_KEY_2, "VK_KEY_2" }, - { VK_KEY_3, "VK_KEY_3" }, - { VK_KEY_4, "VK_KEY_4" }, - { VK_KEY_5, "VK_KEY_5" }, - { VK_KEY_6, "VK_KEY_6" }, - { VK_KEY_7, "VK_KEY_7" }, - { VK_KEY_8, "VK_KEY_8" }, - { VK_KEY_9, "VK_KEY_9" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { VK_KEY_A, "VK_KEY_A" }, - { VK_KEY_B, "VK_KEY_B" }, - { VK_KEY_C, "VK_KEY_C" }, - { VK_KEY_D, "VK_KEY_D" }, - { VK_KEY_E, "VK_KEY_E" }, - { VK_KEY_F, "VK_KEY_F" }, - { VK_KEY_G, "VK_KEY_G" }, - { VK_KEY_H, "VK_KEY_H" }, - { VK_KEY_I, "VK_KEY_I" }, - { VK_KEY_J, "VK_KEY_J" }, - { VK_KEY_K, "VK_KEY_K" }, - { VK_KEY_L, "VK_KEY_L" }, - { VK_KEY_M, "VK_KEY_M" }, - { VK_KEY_N, "VK_KEY_N" }, - { VK_KEY_O, "VK_KEY_O" }, - { VK_KEY_P, "VK_KEY_P" }, - { VK_KEY_Q, "VK_KEY_Q" }, - { VK_KEY_R, "VK_KEY_R" }, - { VK_KEY_S, "VK_KEY_S" }, - { VK_KEY_T, "VK_KEY_T" }, - { VK_KEY_U, "VK_KEY_U" }, - { VK_KEY_V, "VK_KEY_V" }, - { VK_KEY_W, "VK_KEY_W" }, - { VK_KEY_X, "VK_KEY_X" }, - { VK_KEY_Y, "VK_KEY_Y" }, - { VK_KEY_Z, "VK_KEY_Z" }, - { VK_LWIN, "VK_LWIN" }, - { VK_RWIN, "VK_RWIN" }, - { VK_APPS, "VK_APPS" }, - { 0, "" }, - { VK_SLEEP, "VK_SLEEP" }, - { VK_NUMPAD0, "VK_NUMPAD0" }, - { VK_NUMPAD1, "VK_NUMPAD1" }, - { VK_NUMPAD2, "VK_NUMPAD2" }, - { VK_NUMPAD3, "VK_NUMPAD3" }, - { VK_NUMPAD4, "VK_NUMPAD4" }, - { VK_NUMPAD5, "VK_NUMPAD5" }, - { VK_NUMPAD6, "VK_NUMPAD6" }, - { VK_NUMPAD7, "VK_NUMPAD7" }, - { VK_NUMPAD8, "VK_NUMPAD8" }, - { VK_NUMPAD9, "VK_NUMPAD9" }, - { VK_MULTIPLY, "VK_MULTIPLY" }, - { VK_ADD, "VK_ADD" }, - { VK_SEPARATOR, "VK_SEPARATOR" }, - { VK_SUBTRACT, "VK_SUBTRACT" }, - { VK_DECIMAL, "VK_DECIMAL" }, - { VK_DIVIDE, "VK_DIVIDE" }, - { VK_F1, "VK_F1" }, - { VK_F2, "VK_F2" }, - { VK_F3, "VK_F3" }, - { VK_F4, "VK_F4" }, - { VK_F5, "VK_F5" }, - { VK_F6, "VK_F6" }, - { VK_F7, "VK_F7" }, - { VK_F8, "VK_F8" }, - { VK_F9, "VK_F9" }, - { VK_F10, "VK_F10" }, - { VK_F11, "VK_F11" }, - { VK_F12, "VK_F12" }, - { VK_F13, "VK_F13" }, - { VK_F14, "VK_F14" }, - { VK_F15, "VK_F15" }, - { VK_F16, "VK_F16" }, - { VK_F17, "VK_F17" }, - { VK_F18, "VK_F18" }, - { VK_F19, "VK_F19" }, - { VK_F20, "VK_F20" }, - { VK_F21, "VK_F21" }, - { VK_F22, "VK_F22" }, - { VK_F23, "VK_F23" }, - { VK_F24, "VK_F24" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { VK_NUMLOCK, "VK_NUMLOCK" }, - { VK_SCROLL, "VK_SCROLL" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { VK_LSHIFT, "VK_LSHIFT" }, - { VK_RSHIFT, "VK_RSHIFT" }, - { VK_LCONTROL, "VK_LCONTROL" }, - { VK_RCONTROL, "VK_RCONTROL" }, - { VK_LMENU, "VK_LMENU" }, - { VK_RMENU, "VK_RMENU" }, - { VK_BROWSER_BACK, "VK_BROWSER_BACK" }, - { VK_BROWSER_FORWARD, "VK_BROWSER_FORWARD" }, - { VK_BROWSER_REFRESH, "VK_BROWSER_REFRESH" }, - { VK_BROWSER_STOP, "VK_BROWSER_STOP" }, - { VK_BROWSER_SEARCH, "VK_BROWSER_SEARCH" }, - { VK_BROWSER_FAVORITES, "VK_BROWSER_FAVORITES" }, - { VK_BROWSER_HOME, "VK_BROWSER_HOME" }, - { VK_VOLUME_MUTE, "VK_VOLUME_MUTE" }, - { VK_VOLUME_DOWN, "VK_VOLUME_DOWN" }, - { VK_VOLUME_UP, "VK_VOLUME_UP" }, - { VK_MEDIA_NEXT_TRACK, "VK_MEDIA_NEXT_TRACK" }, - { VK_MEDIA_PREV_TRACK, "VK_MEDIA_PREV_TRACK" }, - { VK_MEDIA_STOP, "VK_MEDIA_STOP" }, - { VK_MEDIA_PLAY_PAUSE, "VK_MEDIA_PLAY_PAUSE" }, - { VK_LAUNCH_MAIL, "VK_LAUNCH_MAIL" }, - { VK_MEDIA_SELECT, "VK_MEDIA_SELECT" }, - { VK_LAUNCH_APP1, "VK_LAUNCH_APP1" }, - { VK_LAUNCH_APP2, "VK_LAUNCH_APP2" }, - { 0, "" }, - { 0, "" }, - { VK_OEM_1, "VK_OEM_1" }, - { VK_OEM_PLUS, "VK_OEM_PLUS" }, - { VK_OEM_COMMA, "VK_OEM_COMMA" }, - { VK_OEM_MINUS, "VK_OEM_MINUS" }, - { VK_OEM_PERIOD, "VK_OEM_PERIOD" }, - { VK_OEM_2, "VK_OEM_2" }, - { VK_OEM_3, "VK_OEM_3" }, - { VK_ABNT_C1, "VK_ABNT_C1" }, - { VK_ABNT_C2, "VK_ABNT_C2" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { VK_OEM_4, "VK_OEM_4" }, - { VK_OEM_5, "VK_OEM_5" }, - { VK_OEM_6, "VK_OEM_6" }, - { VK_OEM_7, "VK_OEM_7" }, - { VK_OEM_8, "VK_OEM_8" }, - { 0, "" }, - { 0, "" }, - { VK_OEM_102, "VK_OEM_102" }, - { 0, "" }, - { 0, "" }, - { VK_PROCESSKEY, "VK_PROCESSKEY" }, - { 0, "" }, - { VK_PACKET, "VK_PACKET" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { 0, "" }, - { VK_ATTN, "VK_ATTN" }, - { VK_CRSEL, "VK_CRSEL" }, - { VK_EXSEL, "VK_EXSEL" }, - { VK_EREOF, "VK_EREOF" }, - { VK_PLAY, "VK_PLAY" }, - { VK_ZOOM, "VK_ZOOM" }, - { VK_NONAME, "VK_NONAME" }, - { VK_PA1, "VK_PA1" }, - { VK_OEM_CLEAR, "VK_OEM_CLEAR" }, - { 0, "" } -}; - -const char* freerdp_keyboard_get_virtual_key_code_name(UINT32 vkcode) -{ - return VIRTUAL_KEY_CODE_TABLE[vkcode].name; -} - -UINT32 freerdp_keyboard_get_virtual_key_code_from_name(const char* vkcode_name) -{ - int i = 0; - for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++) - { - if (VIRTUAL_KEY_CODE_TABLE[i].name) - { - if (strcmp(vkcode_name, VIRTUAL_KEY_CODE_TABLE[i].name) == 0) - { - return VIRTUAL_KEY_CODE_TABLE[i].code; - } - } - } - return 0; -} diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index ecc43cd7a..eab316c45 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -23,6 +23,19 @@ #include #include +/** + * Key Flags + */ + +#define KBDEXT (USHORT) 0x0100 +#define KBDMULTIVK (USHORT) 0x0200 +#define KBDSPECIAL (USHORT) 0x0400 +#define KBDNUMPAD (USHORT) 0x0800 +#define KBDUNICODE (USHORT) 0x1000 +#define KBDINJECTEDVK (USHORT) 0x2000 +#define KBDMAPPEDVK (USHORT) 0x4000 +#define KBDBREAK (USHORT) 0x8000 + /* * Virtual Key Codes (Windows): * http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731/ @@ -688,4 +701,14 @@ #define KBD7_Y1D VK_PAUSE +/** + * Functions + */ + +WINPR_API char* GetVirtualKeyName(DWORD vkcode); +WINPR_API DWORD GetVirtualKeyCodeFromName(const char* vkname); + +WINPR_API DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType); +WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType); + #endif /* WINPR_INPUT_H */ diff --git a/winpr/libwinpr/input/keyboard.c b/winpr/libwinpr/input/keyboard.c index 6236c3d1a..8a53ec1ab 100644 --- a/winpr/libwinpr/input/keyboard.c +++ b/winpr/libwinpr/input/keyboard.c @@ -25,6 +25,313 @@ #include +/** + * Virtual Key Codes + */ + +struct _VIRTUAL_KEY_CODE +{ + DWORD code; /* Windows Virtual Key Code */ + const char* name; /* Virtual Key Code Name */ +}; +typedef struct _VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE; + +static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = +{ + { 0, NULL }, + { VK_LBUTTON, "VK_LBUTTON" }, + { VK_RBUTTON, "VK_RBUTTON" }, + { VK_CANCEL, "VK_CANCEL" }, + { VK_MBUTTON, "VK_MBUTTON" }, + { VK_XBUTTON1, "VK_XBUTTON1" }, + { VK_XBUTTON2, "VK_XBUTTON2" }, + { 0, NULL }, + { VK_BACK, "VK_BACK" }, + { VK_TAB, "VK_TAB" }, + { 0, NULL }, + { 0, NULL }, + { VK_CLEAR, "VK_CLEAR" }, + { VK_RETURN, "VK_RETURN" }, + { 0, NULL }, + { 0, NULL }, + { VK_SHIFT, "VK_SHIFT" }, + { VK_CONTROL, "VK_CONTROL" }, + { VK_MENU, "VK_MENU" }, + { VK_PAUSE, "VK_PAUSE" }, + { VK_CAPITAL, "VK_CAPITAL" }, + { VK_KANA, "VK_KANA" }, /* also VK_HANGUL */ + { 0, NULL }, + { VK_JUNJA, "VK_JUNJA" }, + { VK_FINAL, "VK_FINAL" }, + { VK_KANJI, "VK_KANJI" }, /* also VK_HANJA */ + { 0, NULL }, + { VK_ESCAPE, "VK_ESCAPE" }, + { VK_CONVERT, "VK_CONVERT" }, + { VK_NONCONVERT, "VK_NONCONVERT" }, + { VK_ACCEPT, "VK_ACCEPT" }, + { VK_MODECHANGE, "VK_MODECHANGE" }, + { VK_SPACE, "VK_SPACE" }, + { VK_PRIOR, "VK_PRIOR" }, + { VK_NEXT, "VK_NEXT" }, + { VK_END, "VK_END" }, + { VK_HOME, "VK_HOME" }, + { VK_LEFT, "VK_LEFT" }, + { VK_UP, "VK_UP" }, + { VK_RIGHT, "VK_RIGHT" }, + { VK_DOWN, "VK_DOWN" }, + { VK_SELECT, "VK_SELECT" }, + { VK_PRINT, "VK_PRINT" }, + { VK_EXECUTE, "VK_EXECUTE" }, + { VK_SNAPSHOT, "VK_SNAPSHOT" }, + { VK_INSERT, "VK_INSERT" }, + { VK_DELETE, "VK_DELETE" }, + { VK_HELP, "VK_HELP" }, + { VK_KEY_0, "VK_KEY_0" }, + { VK_KEY_1, "VK_KEY_1" }, + { VK_KEY_2, "VK_KEY_2" }, + { VK_KEY_3, "VK_KEY_3" }, + { VK_KEY_4, "VK_KEY_4" }, + { VK_KEY_5, "VK_KEY_5" }, + { VK_KEY_6, "VK_KEY_6" }, + { VK_KEY_7, "VK_KEY_7" }, + { VK_KEY_8, "VK_KEY_8" }, + { VK_KEY_9, "VK_KEY_9" }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { VK_KEY_A, "VK_KEY_A" }, + { VK_KEY_B, "VK_KEY_B" }, + { VK_KEY_C, "VK_KEY_C" }, + { VK_KEY_D, "VK_KEY_D" }, + { VK_KEY_E, "VK_KEY_E" }, + { VK_KEY_F, "VK_KEY_F" }, + { VK_KEY_G, "VK_KEY_G" }, + { VK_KEY_H, "VK_KEY_H" }, + { VK_KEY_I, "VK_KEY_I" }, + { VK_KEY_J, "VK_KEY_J" }, + { VK_KEY_K, "VK_KEY_K" }, + { VK_KEY_L, "VK_KEY_L" }, + { VK_KEY_M, "VK_KEY_M" }, + { VK_KEY_N, "VK_KEY_N" }, + { VK_KEY_O, "VK_KEY_O" }, + { VK_KEY_P, "VK_KEY_P" }, + { VK_KEY_Q, "VK_KEY_Q" }, + { VK_KEY_R, "VK_KEY_R" }, + { VK_KEY_S, "VK_KEY_S" }, + { VK_KEY_T, "VK_KEY_T" }, + { VK_KEY_U, "VK_KEY_U" }, + { VK_KEY_V, "VK_KEY_V" }, + { VK_KEY_W, "VK_KEY_W" }, + { VK_KEY_X, "VK_KEY_X" }, + { VK_KEY_Y, "VK_KEY_Y" }, + { VK_KEY_Z, "VK_KEY_Z" }, + { VK_LWIN, "VK_LWIN" }, + { VK_RWIN, "VK_RWIN" }, + { VK_APPS, "VK_APPS" }, + { 0, NULL }, + { VK_SLEEP, "VK_SLEEP" }, + { VK_NUMPAD0, "VK_NUMPAD0" }, + { VK_NUMPAD1, "VK_NUMPAD1" }, + { VK_NUMPAD2, "VK_NUMPAD2" }, + { VK_NUMPAD3, "VK_NUMPAD3" }, + { VK_NUMPAD4, "VK_NUMPAD4" }, + { VK_NUMPAD5, "VK_NUMPAD5" }, + { VK_NUMPAD6, "VK_NUMPAD6" }, + { VK_NUMPAD7, "VK_NUMPAD7" }, + { VK_NUMPAD8, "VK_NUMPAD8" }, + { VK_NUMPAD9, "VK_NUMPAD9" }, + { VK_MULTIPLY, "VK_MULTIPLY" }, + { VK_ADD, "VK_ADD" }, + { VK_SEPARATOR, "VK_SEPARATOR" }, + { VK_SUBTRACT, "VK_SUBTRACT" }, + { VK_DECIMAL, "VK_DECIMAL" }, + { VK_DIVIDE, "VK_DIVIDE" }, + { VK_F1, "VK_F1" }, + { VK_F2, "VK_F2" }, + { VK_F3, "VK_F3" }, + { VK_F4, "VK_F4" }, + { VK_F5, "VK_F5" }, + { VK_F6, "VK_F6" }, + { VK_F7, "VK_F7" }, + { VK_F8, "VK_F8" }, + { VK_F9, "VK_F9" }, + { VK_F10, "VK_F10" }, + { VK_F11, "VK_F11" }, + { VK_F12, "VK_F12" }, + { VK_F13, "VK_F13" }, + { VK_F14, "VK_F14" }, + { VK_F15, "VK_F15" }, + { VK_F16, "VK_F16" }, + { VK_F17, "VK_F17" }, + { VK_F18, "VK_F18" }, + { VK_F19, "VK_F19" }, + { VK_F20, "VK_F20" }, + { VK_F21, "VK_F21" }, + { VK_F22, "VK_F22" }, + { VK_F23, "VK_F23" }, + { VK_F24, "VK_F24" }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { VK_NUMLOCK, "VK_NUMLOCK" }, + { VK_SCROLL, "VK_SCROLL" }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { VK_LSHIFT, "VK_LSHIFT" }, + { VK_RSHIFT, "VK_RSHIFT" }, + { VK_LCONTROL, "VK_LCONTROL" }, + { VK_RCONTROL, "VK_RCONTROL" }, + { VK_LMENU, "VK_LMENU" }, + { VK_RMENU, "VK_RMENU" }, + { VK_BROWSER_BACK, "VK_BROWSER_BACK" }, + { VK_BROWSER_FORWARD, "VK_BROWSER_FORWARD" }, + { VK_BROWSER_REFRESH, "VK_BROWSER_REFRESH" }, + { VK_BROWSER_STOP, "VK_BROWSER_STOP" }, + { VK_BROWSER_SEARCH, "VK_BROWSER_SEARCH" }, + { VK_BROWSER_FAVORITES, "VK_BROWSER_FAVORITES" }, + { VK_BROWSER_HOME, "VK_BROWSER_HOME" }, + { VK_VOLUME_MUTE, "VK_VOLUME_MUTE" }, + { VK_VOLUME_DOWN, "VK_VOLUME_DOWN" }, + { VK_VOLUME_UP, "VK_VOLUME_UP" }, + { VK_MEDIA_NEXT_TRACK, "VK_MEDIA_NEXT_TRACK" }, + { VK_MEDIA_PREV_TRACK, "VK_MEDIA_PREV_TRACK" }, + { VK_MEDIA_STOP, "VK_MEDIA_STOP" }, + { VK_MEDIA_PLAY_PAUSE, "VK_MEDIA_PLAY_PAUSE" }, + { VK_LAUNCH_MAIL, "VK_LAUNCH_MAIL" }, + { VK_MEDIA_SELECT, "VK_MEDIA_SELECT" }, + { VK_LAUNCH_APP1, "VK_LAUNCH_APP1" }, + { VK_LAUNCH_APP2, "VK_LAUNCH_APP2" }, + { 0, NULL }, + { 0, NULL }, + { VK_OEM_1, "VK_OEM_1" }, + { VK_OEM_PLUS, "VK_OEM_PLUS" }, + { VK_OEM_COMMA, "VK_OEM_COMMA" }, + { VK_OEM_MINUS, "VK_OEM_MINUS" }, + { VK_OEM_PERIOD, "VK_OEM_PERIOD" }, + { VK_OEM_2, "VK_OEM_2" }, + { VK_OEM_3, "VK_OEM_3" }, + { VK_ABNT_C1, "VK_ABNT_C1" }, + { VK_ABNT_C2, "VK_ABNT_C2" }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { VK_OEM_4, "VK_OEM_4" }, + { VK_OEM_5, "VK_OEM_5" }, + { VK_OEM_6, "VK_OEM_6" }, + { VK_OEM_7, "VK_OEM_7" }, + { VK_OEM_8, "VK_OEM_8" }, + { 0, NULL }, + { 0, NULL }, + { VK_OEM_102, "VK_OEM_102" }, + { 0, NULL }, + { 0, NULL }, + { VK_PROCESSKEY, "VK_PROCESSKEY" }, + { 0, NULL }, + { VK_PACKET, "VK_PACKET" }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { 0, NULL }, + { VK_ATTN, "VK_ATTN" }, + { VK_CRSEL, "VK_CRSEL" }, + { VK_EXSEL, "VK_EXSEL" }, + { VK_EREOF, "VK_EREOF" }, + { VK_PLAY, "VK_PLAY" }, + { VK_ZOOM, "VK_ZOOM" }, + { VK_NONAME, "VK_NONAME" }, + { VK_PA1, "VK_PA1" }, + { VK_OEM_CLEAR, "VK_OEM_CLEAR" }, + { 0, NULL } +}; + +char* GetVirtualKeyName(DWORD vkcode) +{ + char* vkname; + + vkname = (char*) VIRTUAL_KEY_CODE_TABLE[vkcode].name; + + if (!vkname) + vkname = "VK_NONE"; + + return vkname; +} + +DWORD GetVirtualKeyCodeFromName(const char* vkname) +{ + int i; + + for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++) + { + if (VIRTUAL_KEY_CODE_TABLE[i].name) + { + if (strcmp(vkname, VIRTUAL_KEY_CODE_TABLE[i].name) == 0) + return VIRTUAL_KEY_CODE_TABLE[i].code; + } + } + + return VK_NONE; +} + +/** + * Virtual Scan Codes + */ + +/** + * Keyboard Type 4 + */ + DWORD KBD4T[128] = { KBD4_T00, @@ -289,6 +596,10 @@ DWORD KBD4X[128] = VK_NONE }; +/** + * Keyboard Type 7 + */ + DWORD KBD7T[128] = { KBD7_T00, @@ -552,3 +863,90 @@ DWORD KBD7X[128] = VK_NONE, VK_NONE }; + +DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType) +{ + DWORD vkcode; + + vkcode = VK_NONE; + + if ((dwKeyboardType != 4) && (dwKeyboardType != 7)) + dwKeyboardType = 4; + + if (dwKeyboardType == 4) + { + if (scancode & KBDEXT) + vkcode = KBD4X[scancode & 0x7F]; + else + vkcode = KBD4T[scancode & 0x7F]; + } + else if (dwKeyboardType == 7) + { + if (scancode & KBDEXT) + vkcode = KBD7X[scancode & 0x7F]; + else + vkcode = KBD7T[scancode & 0x7F]; + } + + return vkcode; +} + +DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType) +{ + int i; + DWORD scancode; + + scancode = 0; + + if ((dwKeyboardType != 4) && (dwKeyboardType != 7)) + dwKeyboardType = 4; + + if (dwKeyboardType == 4) + { + for (i = 0; i < 128; i++) + { + if (KBD4T[i] == vkcode) + { + scancode = i; + break; + } + } + + if (!scancode) + { + for (i = 0; i < 128; i++) + { + if (KBD4X[i] == vkcode) + { + scancode = i; + break; + } + } + } + } + else if (dwKeyboardType == 7) + { + for (i = 0; i < 128; i++) + { + if (KBD7T[i] == vkcode) + { + scancode = i; + break; + } + } + + if (!scancode) + { + for (i = 0; i < 128; i++) + { + if (KBD7X[i] == vkcode) + { + scancode = i; + break; + } + } + } + } + + return scancode; +} From 1dd901d611693e41ae2257dc9fc2bc4fad6c7553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 3 Mar 2013 17:43:06 -0500 Subject: [PATCH 08/18] libfreerdp-locale: fix loading virtual scancodes --- libfreerdp/locale/keyboard_x11.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index d94d6176e..ceab0d903 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -26,6 +26,7 @@ #include #include +#include #include "liblocale.h" @@ -471,9 +472,9 @@ const DWORD KEYCODE_TO_VKCODE_MACOSX[256] = UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]) { - UINT32 vkcode; - UINT32 keycode; - UINT32 keycode_to_vkcode[256]; + DWORD vkcode; + DWORD keycode; + DWORD keycode_to_vkcode[256]; ZeroMemory(keycode_to_vkcode, sizeof(keycode_to_vkcode)); ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); @@ -517,5 +518,15 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco } #endif + for (keycode = 0; keycode < 256; keycode++) + { + vkcode = keycode_to_vkcode[keycode]; + + if (vkcode >= 0xFF) + continue; + + x11_keycode_to_rdp_scancode[keycode] = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); + } + return keyboardLayoutId; } From 474f0469b46b2f8ebee91302f0b2482e1cea2dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 3 Mar 2013 18:13:12 -0500 Subject: [PATCH 09/18] libfreerdp-locale: add Mac OS X definitions --- libfreerdp/locale/keyboard_x11.c | 122 +++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index ceab0d903..6f420d577 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -208,6 +208,128 @@ char* freerdp_detect_keymap_from_xkb() #ifdef __APPLE__ +#define APPLE_VK_ANSI_A 0x00 +#define APPLE_VK_ANSI_S 0x01 +#define APPLE_VK_ANSI_D 0x02 +#define APPLE_VK_ANSI_F 0x03 +#define APPLE_VK_ANSI_H 0x04 +#define APPLE_VK_ANSI_G 0x05 +#define APPLE_VK_ANSI_Z 0x06 +#define APPLE_VK_ANSI_X 0x07 +#define APPLE_VK_ANSI_C 0x08 +#define APPLE_VK_ANSI_V 0x09 +#define APPLE_VK_ANSI_B 0x0B +#define APPLE_VK_ANSI_Q 0x0C +#define APPLE_VK_ANSI_W 0x0D +#define APPLE_VK_ANSI_E 0x0E +#define APPLE_VK_ANSI_R 0x0F +#define APPLE_VK_ANSI_Y 0x10 +#define APPLE_VK_ANSI_T 0x11 +#define APPLE_VK_ANSI_1 0x12 +#define APPLE_VK_ANSI_2 0x13 +#define APPLE_VK_ANSI_3 0x14 +#define APPLE_VK_ANSI_4 0x15 +#define APPLE_VK_ANSI_6 0x16 +#define APPLE_VK_ANSI_5 0x17 +#define APPLE_VK_ANSI_Equal 0x18 +#define APPLE_VK_ANSI_9 0x19 +#define APPLE_VK_ANSI_7 0x1A +#define APPLE_VK_ANSI_Minus 0x1B +#define APPLE_VK_ANSI_8 0x1C +#define APPLE_VK_ANSI_0 0x1D +#define APPLE_VK_ANSI_RightBracket 0x1E +#define APPLE_VK_ANSI_O 0x1F +#define APPLE_VK_ANSI_U 0x20 +#define APPLE_VK_ANSI_LeftBracket 0x21 +#define APPLE_VK_ANSI_I 0x22 +#define APPLE_VK_ANSI_P 0x23 +#define APPLE_VK_ANSI_L 0x25 +#define APPLE_VK_ANSI_J 0x26 +#define APPLE_VK_ANSI_Quote 0x27 +#define APPLE_VK_ANSI_K 0x28 +#define APPLE_VK_ANSI_Semicolon 0x29 +#define APPLE_VK_ANSI_Backslash 0x2A +#define APPLE_VK_ANSI_Comma 0x2B +#define APPLE_VK_ANSI_Slash 0x2C +#define APPLE_VK_ANSI_N 0x2D +#define APPLE_VK_ANSI_M 0x2E +#define APPLE_VK_ANSI_Period 0x2F +#define APPLE_VK_ANSI_Grave 0x32 +#define APPLE_VK_ANSI_KeypadDecimal 0x41 +#define APPLE_VK_ANSI_KeypadMultiply 0x43 +#define APPLE_VK_ANSI_KeypadPlus 0x45 +#define APPLE_VK_ANSI_KeypadClear 0x47 +#define APPLE_VK_ANSI_KeypadDivide 0x4B +#define APPLE_VK_ANSI_KeypadEnter 0x4C +#define APPLE_VK_ANSI_KeypadMinus 0x4E +#define APPLE_VK_ANSI_KeypadEquals 0x51 +#define APPLE_VK_ANSI_Keypad0 0x52 +#define APPLE_VK_ANSI_Keypad1 0x53 +#define APPLE_VK_ANSI_Keypad2 0x54 +#define APPLE_VK_ANSI_Keypad3 0x55 +#define APPLE_VK_ANSI_Keypad4 0x56 +#define APPLE_VK_ANSI_Keypad5 0x57 +#define APPLE_VK_ANSI_Keypad6 0x58 +#define APPLE_VK_ANSI_Keypad7 0x59 +#define APPLE_VK_ANSI_Keypad8 0x5B +#define APPLE_VK_ANSI_Keypad9 0x5C + +#define APPLE_VK_Return 0x24 +#define APPLE_VK_Tab 0x30 +#define APPLE_VK_Space 0x31 +#define APPLE_VK_Delete 0x33 +#define APPLE_VK_Escape 0x35 +#define APPLE_VK_Command 0x37 +#define APPLE_VK_Shift 0x38 +#define APPLE_VK_CapsLock 0x39 +#define APPLE_VK_Option 0x3A +#define APPLE_VK_Control 0x3B +#define APPLE_VK_RightShift 0x3C +#define APPLE_VK_RightOption 0x3D +#define APPLE_VK_RightControl 0x3E +#define APPLE_VK_Function 0x3F +#define APPLE_VK_F17 0x40 +#define APPLE_VK_VolumeUp 0x48 +#define APPLE_VK_VolumeDown 0x49 +#define APPLE_VK_Mute 0x4A +#define APPLE_VK_F18 0x4F +#define APPLE_VK_F19 0x50 +#define APPLE_VK_F20 0x5A +#define APPLE_VK_F5 0x60 +#define APPLE_VK_F6 0x61 +#define APPLE_VK_F7 0x62 +#define APPLE_VK_F3 0x63 +#define APPLE_VK_F8 0x64 +#define APPLE_VK_F9 0x65 +#define APPLE_VK_F11 0x67 +#define APPLE_VK_F13 0x69 +#define APPLE_VK_F16 0x6A +#define APPLE_VK_F14 0x6B +#define APPLE_VK_F10 0x6D +#define APPLE_VK_F12 0x6F +#define APPLE_VK_F15 0x71 +#define APPLE_VK_Help 0x72 +#define APPLE_VK_Home 0x73 +#define APPLE_VK_PageUp 0x74 +#define APPLE_VK_ForwardDelete 0x75 +#define APPLE_VK_F4 0x76 +#define APPLE_VK_End 0x77 +#define APPLE_VK_F2 0x78 +#define APPLE_VK_PageDown 0x79 +#define APPLE_VK_F1 0x7A +#define APPLE_VK_LeftArrow 0x7B +#define APPLE_VK_RightArrow 0x7C +#define APPLE_VK_DownArrow 0x7D +#define APPLE_VK_UpArrow 0x7E + +#define APPLE_VK_ISO_Section 0x0A + +#define APPLE_VK_JIS_Yen 0x5D +#define APPLE_VK_JIS_Underscore 0x5E +#define APPLE_VK_JIS_KeypadComma 0x5F +#define APPLE_VK_JIS_Eisu 0x66 +#define APPLE_VK_JIS_Kana 0x68 + const DWORD KEYCODE_TO_VKCODE_MACOSX[256] = { 0, /* 0 */ From 7d75343e8ec2b62c9d95dfb3e0ae5f75be039de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 3 Mar 2013 19:30:01 -0500 Subject: [PATCH 10/18] libfreerdp-locale: cleanup Mac OS X keycode mapping --- libfreerdp/locale/keyboard_x11.c | 392 +---------- winpr/include/winpr/input.h | 142 +++- winpr/libwinpr/input/CMakeLists.txt | 4 +- winpr/libwinpr/input/keycode.c | 312 +++++++++ winpr/libwinpr/input/scancode.c | 653 ++++++++++++++++++ .../input/{keyboard.c => virtualkey.c} | 626 ----------------- 6 files changed, 1113 insertions(+), 1016 deletions(-) create mode 100644 winpr/libwinpr/input/keycode.c create mode 100644 winpr/libwinpr/input/scancode.c rename winpr/libwinpr/input/{keyboard.c => virtualkey.c} (52%) diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index 6f420d577..5376ca915 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -206,392 +206,6 @@ char* freerdp_detect_keymap_from_xkb() return keymap; } -#ifdef __APPLE__ - -#define APPLE_VK_ANSI_A 0x00 -#define APPLE_VK_ANSI_S 0x01 -#define APPLE_VK_ANSI_D 0x02 -#define APPLE_VK_ANSI_F 0x03 -#define APPLE_VK_ANSI_H 0x04 -#define APPLE_VK_ANSI_G 0x05 -#define APPLE_VK_ANSI_Z 0x06 -#define APPLE_VK_ANSI_X 0x07 -#define APPLE_VK_ANSI_C 0x08 -#define APPLE_VK_ANSI_V 0x09 -#define APPLE_VK_ANSI_B 0x0B -#define APPLE_VK_ANSI_Q 0x0C -#define APPLE_VK_ANSI_W 0x0D -#define APPLE_VK_ANSI_E 0x0E -#define APPLE_VK_ANSI_R 0x0F -#define APPLE_VK_ANSI_Y 0x10 -#define APPLE_VK_ANSI_T 0x11 -#define APPLE_VK_ANSI_1 0x12 -#define APPLE_VK_ANSI_2 0x13 -#define APPLE_VK_ANSI_3 0x14 -#define APPLE_VK_ANSI_4 0x15 -#define APPLE_VK_ANSI_6 0x16 -#define APPLE_VK_ANSI_5 0x17 -#define APPLE_VK_ANSI_Equal 0x18 -#define APPLE_VK_ANSI_9 0x19 -#define APPLE_VK_ANSI_7 0x1A -#define APPLE_VK_ANSI_Minus 0x1B -#define APPLE_VK_ANSI_8 0x1C -#define APPLE_VK_ANSI_0 0x1D -#define APPLE_VK_ANSI_RightBracket 0x1E -#define APPLE_VK_ANSI_O 0x1F -#define APPLE_VK_ANSI_U 0x20 -#define APPLE_VK_ANSI_LeftBracket 0x21 -#define APPLE_VK_ANSI_I 0x22 -#define APPLE_VK_ANSI_P 0x23 -#define APPLE_VK_ANSI_L 0x25 -#define APPLE_VK_ANSI_J 0x26 -#define APPLE_VK_ANSI_Quote 0x27 -#define APPLE_VK_ANSI_K 0x28 -#define APPLE_VK_ANSI_Semicolon 0x29 -#define APPLE_VK_ANSI_Backslash 0x2A -#define APPLE_VK_ANSI_Comma 0x2B -#define APPLE_VK_ANSI_Slash 0x2C -#define APPLE_VK_ANSI_N 0x2D -#define APPLE_VK_ANSI_M 0x2E -#define APPLE_VK_ANSI_Period 0x2F -#define APPLE_VK_ANSI_Grave 0x32 -#define APPLE_VK_ANSI_KeypadDecimal 0x41 -#define APPLE_VK_ANSI_KeypadMultiply 0x43 -#define APPLE_VK_ANSI_KeypadPlus 0x45 -#define APPLE_VK_ANSI_KeypadClear 0x47 -#define APPLE_VK_ANSI_KeypadDivide 0x4B -#define APPLE_VK_ANSI_KeypadEnter 0x4C -#define APPLE_VK_ANSI_KeypadMinus 0x4E -#define APPLE_VK_ANSI_KeypadEquals 0x51 -#define APPLE_VK_ANSI_Keypad0 0x52 -#define APPLE_VK_ANSI_Keypad1 0x53 -#define APPLE_VK_ANSI_Keypad2 0x54 -#define APPLE_VK_ANSI_Keypad3 0x55 -#define APPLE_VK_ANSI_Keypad4 0x56 -#define APPLE_VK_ANSI_Keypad5 0x57 -#define APPLE_VK_ANSI_Keypad6 0x58 -#define APPLE_VK_ANSI_Keypad7 0x59 -#define APPLE_VK_ANSI_Keypad8 0x5B -#define APPLE_VK_ANSI_Keypad9 0x5C - -#define APPLE_VK_Return 0x24 -#define APPLE_VK_Tab 0x30 -#define APPLE_VK_Space 0x31 -#define APPLE_VK_Delete 0x33 -#define APPLE_VK_Escape 0x35 -#define APPLE_VK_Command 0x37 -#define APPLE_VK_Shift 0x38 -#define APPLE_VK_CapsLock 0x39 -#define APPLE_VK_Option 0x3A -#define APPLE_VK_Control 0x3B -#define APPLE_VK_RightShift 0x3C -#define APPLE_VK_RightOption 0x3D -#define APPLE_VK_RightControl 0x3E -#define APPLE_VK_Function 0x3F -#define APPLE_VK_F17 0x40 -#define APPLE_VK_VolumeUp 0x48 -#define APPLE_VK_VolumeDown 0x49 -#define APPLE_VK_Mute 0x4A -#define APPLE_VK_F18 0x4F -#define APPLE_VK_F19 0x50 -#define APPLE_VK_F20 0x5A -#define APPLE_VK_F5 0x60 -#define APPLE_VK_F6 0x61 -#define APPLE_VK_F7 0x62 -#define APPLE_VK_F3 0x63 -#define APPLE_VK_F8 0x64 -#define APPLE_VK_F9 0x65 -#define APPLE_VK_F11 0x67 -#define APPLE_VK_F13 0x69 -#define APPLE_VK_F16 0x6A -#define APPLE_VK_F14 0x6B -#define APPLE_VK_F10 0x6D -#define APPLE_VK_F12 0x6F -#define APPLE_VK_F15 0x71 -#define APPLE_VK_Help 0x72 -#define APPLE_VK_Home 0x73 -#define APPLE_VK_PageUp 0x74 -#define APPLE_VK_ForwardDelete 0x75 -#define APPLE_VK_F4 0x76 -#define APPLE_VK_End 0x77 -#define APPLE_VK_F2 0x78 -#define APPLE_VK_PageDown 0x79 -#define APPLE_VK_F1 0x7A -#define APPLE_VK_LeftArrow 0x7B -#define APPLE_VK_RightArrow 0x7C -#define APPLE_VK_DownArrow 0x7D -#define APPLE_VK_UpArrow 0x7E - -#define APPLE_VK_ISO_Section 0x0A - -#define APPLE_VK_JIS_Yen 0x5D -#define APPLE_VK_JIS_Underscore 0x5E -#define APPLE_VK_JIS_KeypadComma 0x5F -#define APPLE_VK_JIS_Eisu 0x66 -#define APPLE_VK_JIS_Kana 0x68 - -const DWORD KEYCODE_TO_VKCODE_MACOSX[256] = -{ - 0, /* 0 */ - 0, /* 1 */ - 0, /* 2 */ - 0, /* 3 */ - 0, /* 4 */ - 0, /* 5 */ - 0, /* 6 */ - 0, /* 7 */ - VK_KEY_A, /* 8 */ - VK_KEY_S, /* 9 */ - VK_KEY_D, /* 10 */ - VK_KEY_F, /* 11 */ - VK_KEY_H, /* 12 */ - VK_KEY_G, /* 13 */ - VK_KEY_Z, /* 14 */ - VK_KEY_X, /* 15 */ - VK_KEY_C, /* 16 */ - VK_KEY_V, /* 17 */ - VK_OEM_102, /* 18 */ - VK_KEY_B, /* 19 */ - VK_KEY_Q, /* 20 */ - VK_KEY_W, /* 21 */ - VK_KEY_E, /* 22 */ - VK_KEY_R, /* 23 */ - VK_KEY_Y, /* 24 */ - VK_KEY_T, /* 25 */ - VK_KEY_1, /* 26 */ - VK_KEY_2, /* 27 */ - VK_KEY_3, /* 28 */ - VK_KEY_4, /* 29 */ - VK_KEY_6, /* 30 */ - VK_KEY_5, /* 31 */ - VK_OEM_PLUS, /* 32 */ - VK_KEY_9, /* 33 */ - VK_KEY_7, /* 34 */ - VK_OEM_MINUS, /* 35 */ - VK_KEY_8, /* 36 */ - VK_KEY_0, /* 37 */ - VK_OEM_6, /* 38 */ - VK_KEY_O, /* 39 */ - VK_KEY_U, /* 40 */ - VK_OEM_4, /* 41 */ - VK_KEY_I, /* 42 */ - VK_KEY_P, /* 43 */ - VK_RETURN, /* 44 */ - VK_KEY_L, /* 45 */ - VK_KEY_J, /* 46 */ - VK_OEM_7, /* 47 */ - VK_KEY_K, /* 48 */ - VK_OEM_1, /* 49 */ - VK_OEM_5, /* 50 */ - VK_OEM_COMMA, /* 51 */ - VK_OEM_2, /* 52 */ - VK_KEY_N, /* 53 */ - VK_KEY_M, /* 54 */ - VK_OEM_PERIOD, /* 55 */ - VK_TAB, /* 56 */ - VK_SPACE, /* 57 */ - VK_OEM_3, /* 58 */ - VK_BACK, /* 59 */ - 0, /* 60 */ - VK_ESCAPE, /* 61 */ - 0, /* 62 */ - VK_LWIN, /* 63 */ - VK_LSHIFT, /* 64 */ - VK_CAPITAL, /* 65 */ - VK_LMENU, /* 66 */ - VK_LCONTROL, /* 67 */ - VK_RSHIFT, /* 68 */ - VK_RMENU, /* 69 */ - 0, /* 70 */ - VK_RWIN, /* 71 */ - 0, /* 72 */ - VK_DECIMAL, /* 73 */ - 0, /* 74 */ - VK_MULTIPLY, /* 75 */ - 0, /* 76 */ - VK_ADD, /* 77 */ - 0, /* 78 */ - VK_NUMLOCK, /* 79 */ - 0, /* 80 */ - 0, /* 81 */ - 0, /* 82 */ - VK_DIVIDE, /* 83 */ - VK_RETURN, /* 84 */ - 0, /* 85 */ - VK_SUBTRACT, /* 86 */ - 0, /* 87 */ - 0, /* 88 */ - 0, /* 89 */ - VK_NUMPAD0, /* 90 */ - VK_NUMPAD1, /* 91 */ - VK_NUMPAD2, /* 92 */ - VK_NUMPAD3, /* 93 */ - VK_NUMPAD4, /* 94 */ - VK_NUMPAD5, /* 95 */ - VK_NUMPAD6, /* 96 */ - VK_NUMPAD7, /* 97 */ - 0, /* 98 */ - VK_NUMPAD8, /* 99 */ - VK_NUMPAD9, /* 100 */ - 0, /* 101 */ - 0, /* 102 */ - 0, /* 103 */ - VK_F5, /* 104 */ - VK_F6, /* 105 */ - VK_F7, /* 106 */ - VK_F3, /* 107 */ - VK_F8, /* 108 */ - VK_F9, /* 109 */ - 0, /* 110 */ - VK_F11, /* 111 */ - 0, /* 112 */ - VK_SNAPSHOT, /* 113 */ - 0, /* 114 */ - VK_SCROLL, /* 115 */ - 0, /* 116 */ - VK_F10, /* 117 */ - 0, /* 118 */ - VK_F12, /* 119 */ - 0, /* 120 */ - VK_PAUSE, /* 121 */ - VK_INSERT, /* 122 */ - VK_HOME, /* 123 */ - VK_PRIOR, /* 124 */ - VK_DELETE, /* 125 */ - VK_F4, /* 126 */ - VK_END, /* 127 */ - VK_F2, /* 128 */ - VK_NEXT, /* 129 */ - VK_F1, /* 130 */ - VK_LEFT, /* 131 */ - VK_RIGHT, /* 132 */ - VK_DOWN, /* 133 */ - VK_UP, /* 134 */ - 0, /* 135 */ - 0, /* 136 */ - 0, /* 137 */ - 0, /* 138 */ - 0, /* 139 */ - 0, /* 140 */ - 0, /* 141 */ - 0, /* 142 */ - 0, /* 143 */ - 0, /* 144 */ - 0, /* 145 */ - 0, /* 146 */ - 0, /* 147 */ - 0, /* 148 */ - 0, /* 149 */ - 0, /* 150 */ - 0, /* 151 */ - 0, /* 152 */ - 0, /* 153 */ - 0, /* 154 */ - 0, /* 155 */ - 0, /* 156 */ - 0, /* 157 */ - 0, /* 158 */ - 0, /* 159 */ - 0, /* 160 */ - 0, /* 161 */ - 0, /* 162 */ - 0, /* 163 */ - 0, /* 164 */ - 0, /* 165 */ - 0, /* 166 */ - 0, /* 167 */ - 0, /* 168 */ - 0, /* 169 */ - 0, /* 170 */ - 0, /* 171 */ - 0, /* 172 */ - 0, /* 173 */ - 0, /* 174 */ - 0, /* 175 */ - 0, /* 176 */ - 0, /* 177 */ - 0, /* 178 */ - 0, /* 179 */ - 0, /* 180 */ - 0, /* 181 */ - 0, /* 182 */ - 0, /* 183 */ - 0, /* 184 */ - 0, /* 185 */ - 0, /* 186 */ - 0, /* 187 */ - 0, /* 188 */ - 0, /* 189 */ - 0, /* 190 */ - 0, /* 191 */ - 0, /* 192 */ - 0, /* 193 */ - 0, /* 194 */ - 0, /* 195 */ - 0, /* 196 */ - 0, /* 197 */ - 0, /* 198 */ - 0, /* 199 */ - 0, /* 200 */ - 0, /* 201 */ - 0, /* 202 */ - 0, /* 203 */ - 0, /* 204 */ - 0, /* 205 */ - 0, /* 206 */ - 0, /* 207 */ - 0, /* 208 */ - 0, /* 209 */ - 0, /* 210 */ - 0, /* 211 */ - 0, /* 212 */ - 0, /* 213 */ - 0, /* 214 */ - 0, /* 215 */ - 0, /* 216 */ - 0, /* 217 */ - 0, /* 218 */ - 0, /* 219 */ - 0, /* 220 */ - 0, /* 221 */ - 0, /* 222 */ - 0, /* 223 */ - 0, /* 224 */ - 0, /* 225 */ - 0, /* 226 */ - 0, /* 227 */ - 0, /* 228 */ - 0, /* 229 */ - 0, /* 230 */ - 0, /* 231 */ - 0, /* 232 */ - 0, /* 233 */ - 0, /* 234 */ - 0, /* 235 */ - 0, /* 236 */ - 0, /* 237 */ - 0, /* 238 */ - 0, /* 239 */ - 0, /* 240 */ - 0, /* 241 */ - 0, /* 242 */ - 0, /* 243 */ - 0, /* 244 */ - 0, /* 245 */ - 0, /* 246 */ - 0, /* 247 */ - 0, /* 248 */ - 0, /* 249 */ - 0, /* 250 */ - 0, /* 251 */ - 0, /* 252 */ - 0, /* 253 */ - 0, /* 254 */ - 0 /* 255 */ -}; - -#endif - UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]) { DWORD vkcode; @@ -602,9 +216,11 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); #ifdef __APPLE__ - /* Apple X11 breaks XKB detection */ - CopyMemory(keycode_to_vkcode, KEYCODE_TO_VKCODE_MACOSX, sizeof(keycode_to_vkcode)); + for (keycode = 0; keycode < 256; keycode++) + { + keycode_to_vkcode[keycode] = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_APPLE); + } #elif defined(WITH_SUN) { diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index eab316c45..67ab4995f 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -342,7 +342,7 @@ #define VK_DBE_HIRAGANA 0xFF /* - * Keyboard Scan Codes + * Virtual Scan Codes */ /** @@ -701,6 +701,142 @@ #define KBD7_Y1D VK_PAUSE +/** + * X11 Keycodes + */ + +/** + * Mac OS X + */ + +#define APPLE_VK_ANSI_A 0x00 +#define APPLE_VK_ANSI_S 0x01 +#define APPLE_VK_ANSI_D 0x02 +#define APPLE_VK_ANSI_F 0x03 +#define APPLE_VK_ANSI_H 0x04 +#define APPLE_VK_ANSI_G 0x05 +#define APPLE_VK_ANSI_Z 0x06 +#define APPLE_VK_ANSI_X 0x07 +#define APPLE_VK_ANSI_C 0x08 +#define APPLE_VK_ANSI_V 0x09 +#define APPLE_VK_ISO_Section 0x0A +#define APPLE_VK_ANSI_B 0x0B +#define APPLE_VK_ANSI_Q 0x0C +#define APPLE_VK_ANSI_W 0x0D +#define APPLE_VK_ANSI_E 0x0E +#define APPLE_VK_ANSI_R 0x0F +#define APPLE_VK_ANSI_Y 0x10 +#define APPLE_VK_ANSI_T 0x11 +#define APPLE_VK_ANSI_1 0x12 +#define APPLE_VK_ANSI_2 0x13 +#define APPLE_VK_ANSI_3 0x14 +#define APPLE_VK_ANSI_4 0x15 +#define APPLE_VK_ANSI_6 0x16 +#define APPLE_VK_ANSI_5 0x17 +#define APPLE_VK_ANSI_Equal 0x18 +#define APPLE_VK_ANSI_9 0x19 +#define APPLE_VK_ANSI_7 0x1A +#define APPLE_VK_ANSI_Minus 0x1B +#define APPLE_VK_ANSI_8 0x1C +#define APPLE_VK_ANSI_0 0x1D +#define APPLE_VK_ANSI_RightBracket 0x1E +#define APPLE_VK_ANSI_O 0x1F +#define APPLE_VK_ANSI_U 0x20 +#define APPLE_VK_ANSI_LeftBracket 0x21 +#define APPLE_VK_ANSI_I 0x22 +#define APPLE_VK_ANSI_P 0x23 +#define APPLE_VK_Return 0x24 +#define APPLE_VK_ANSI_L 0x25 +#define APPLE_VK_ANSI_J 0x26 +#define APPLE_VK_ANSI_Quote 0x27 +#define APPLE_VK_ANSI_K 0x28 +#define APPLE_VK_ANSI_Semicolon 0x29 +#define APPLE_VK_ANSI_Backslash 0x2A +#define APPLE_VK_ANSI_Comma 0x2B +#define APPLE_VK_ANSI_Slash 0x2C +#define APPLE_VK_ANSI_N 0x2D +#define APPLE_VK_ANSI_M 0x2E +#define APPLE_VK_ANSI_Period 0x2F +#define APPLE_VK_Tab 0x30 +#define APPLE_VK_Space 0x31 +#define APPLE_VK_ANSI_Grave 0x32 +#define APPLE_VK_Delete 0x33 +#define APPLE_VK_0x34 0x34 +#define APPLE_VK_Escape 0x35 +#define APPLE_VK_0x36 0x36 +#define APPLE_VK_Command 0x37 +#define APPLE_VK_Shift 0x38 +#define APPLE_VK_CapsLock 0x39 +#define APPLE_VK_Option 0x3A +#define APPLE_VK_Control 0x3B +#define APPLE_VK_RightShift 0x3C +#define APPLE_VK_RightOption 0x3D +#define APPLE_VK_RightControl 0x3E +#define APPLE_VK_Function 0x3F +#define APPLE_VK_F17 0x40 +#define APPLE_VK_ANSI_KeypadDecimal 0x41 +#define APPLE_VK_0x42 0x42 +#define APPLE_VK_ANSI_KeypadMultiply 0x43 +#define APPLE_VK_0x44 0x44 +#define APPLE_VK_ANSI_KeypadPlus 0x45 +#define APPLE_VK_0x46 0x46 +#define APPLE_VK_ANSI_KeypadClear 0x47 +#define APPLE_VK_VolumeUp 0x48 +#define APPLE_VK_VolumeDown 0x49 +#define APPLE_VK_Mute 0x4A +#define APPLE_VK_ANSI_KeypadDivide 0x4B +#define APPLE_VK_ANSI_KeypadEnter 0x4C +#define APPLE_VK_0x4D 0x4D +#define APPLE_VK_ANSI_KeypadMinus 0x4E +#define APPLE_VK_F18 0x4F +#define APPLE_VK_F19 0x50 +#define APPLE_VK_ANSI_KeypadEquals 0x51 +#define APPLE_VK_ANSI_Keypad0 0x52 +#define APPLE_VK_ANSI_Keypad1 0x53 +#define APPLE_VK_ANSI_Keypad2 0x54 +#define APPLE_VK_ANSI_Keypad3 0x55 +#define APPLE_VK_ANSI_Keypad4 0x56 +#define APPLE_VK_ANSI_Keypad5 0x57 +#define APPLE_VK_ANSI_Keypad6 0x58 +#define APPLE_VK_ANSI_Keypad7 0x59 +#define APPLE_VK_F20 0x5A +#define APPLE_VK_ANSI_Keypad8 0x5B +#define APPLE_VK_ANSI_Keypad9 0x5C +#define APPLE_VK_JIS_Yen 0x5D +#define APPLE_VK_JIS_Underscore 0x5E +#define APPLE_VK_JIS_KeypadComma 0x5F +#define APPLE_VK_F5 0x60 +#define APPLE_VK_F6 0x61 +#define APPLE_VK_F7 0x62 +#define APPLE_VK_F3 0x63 +#define APPLE_VK_F8 0x64 +#define APPLE_VK_F9 0x65 +#define APPLE_VK_JIS_Eisu 0x66 +#define APPLE_VK_F11 0x67 +#define APPLE_VK_JIS_Kana 0x68 +#define APPLE_VK_F13 0x69 +#define APPLE_VK_F16 0x6A +#define APPLE_VK_F14 0x6B +#define APPLE_VK_F10 0x6D +#define APPLE_VK_0x6C 0x6C +#define APPLE_VK_0x6E 0x6E +#define APPLE_VK_F12 0x6F +#define APPLE_VK_0x70 0x70 +#define APPLE_VK_F15 0x71 +#define APPLE_VK_Help 0x72 +#define APPLE_VK_Home 0x73 +#define APPLE_VK_PageUp 0x74 +#define APPLE_VK_ForwardDelete 0x75 +#define APPLE_VK_F4 0x76 +#define APPLE_VK_End 0x77 +#define APPLE_VK_F2 0x78 +#define APPLE_VK_PageDown 0x79 +#define APPLE_VK_F1 0x7A +#define APPLE_VK_LeftArrow 0x7B +#define APPLE_VK_RightArrow 0x7C +#define APPLE_VK_DownArrow 0x7D +#define APPLE_VK_UpArrow 0x7E + /** * Functions */ @@ -711,4 +847,8 @@ WINPR_API DWORD GetVirtualKeyCodeFromName(const char* vkname); WINPR_API DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType); WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType); +#define KEYCODE_TYPE_APPLE 0x00000001 + +WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags); + #endif /* WINPR_INPUT_H */ diff --git a/winpr/libwinpr/input/CMakeLists.txt b/winpr/libwinpr/input/CMakeLists.txt index a5705def1..295910635 100644 --- a/winpr/libwinpr/input/CMakeLists.txt +++ b/winpr/libwinpr/input/CMakeLists.txt @@ -19,7 +19,9 @@ set(MODULE_NAME "winpr-input") set(MODULE_PREFIX "WINPR_INPUT") set(${MODULE_PREFIX}_SRCS - keyboard.c) + virtualkey.c + scancode.c + keycode.c) add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" MONOLITHIC ${MONOLITHIC_BUILD} diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c new file mode 100644 index 000000000..8103bed00 --- /dev/null +++ b/winpr/libwinpr/input/keycode.c @@ -0,0 +1,312 @@ +/** + * WinPR: Windows Portable Runtime + * Keyboard Input + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +/** + * X11 Keycodes + */ + +/** + * Mac OS X + */ + +DWORD KEYCODE_TO_VKCODE_APPLE[256] = +{ + 0, /* 0 */ + 0, /* 1 */ + 0, /* 2 */ + 0, /* 3 */ + 0, /* 4 */ + 0, /* 5 */ + 0, /* 6 */ + 0, /* 7 */ + VK_KEY_A, /* APPLE_VK_ANSI_A (0x00) */ + VK_KEY_S, /* APPLE_VK_ANSI_S (0x01) */ + VK_KEY_D, /* APPLE_VK_ANSI_D (0x02) */ + VK_KEY_F, /* APPLE_VK_ANSI_F (0x03) */ + VK_KEY_H, /* APPLE_VK_ANSI_H (0x04) */ + VK_KEY_G, /* APPLE_VK_ANSI_G (0x05) */ + VK_KEY_Z, /* APPLE_VK_ANSI_Z (0x06) */ + VK_KEY_X, /* APPLE_VK_ANSI_X (0x07) */ + VK_KEY_C, /* APPLE_VK_ANSI_C (0x08) */ + VK_KEY_V, /* APPLE_VK_ANSI_V (0x09) */ + VK_OEM_102, /* APPLE_VK_ISO_Section (0x0A) */ + VK_KEY_B, /* APPLE_VK_ANSI_B (0x0B) */ + VK_KEY_Q, /* APPLE_VK_ANSI_Q (0x0C) */ + VK_KEY_W, /* APPLE_VK_ANSI_W (0x0D) */ + VK_KEY_E, /* APPLE_VK_ANSI_E (0x0E) */ + VK_KEY_R, /* APPLE_VK_ANSI_R (0x0F) */ + VK_KEY_Y, /* APPLE_VK_ANSI_Y (0x10) */ + VK_KEY_T, /* APPLE_VK_ANSI_T (0x11) */ + VK_KEY_1, /* APPLE_VK_ANSI_1 (0x12) */ + VK_KEY_2, /* APPLE_VK_ANSI_2 (0x13) */ + VK_KEY_3, /* APPLE_VK_ANSI_3 (0x14) */ + VK_KEY_4, /* APPLE_VK_ANSI_4 (0x15) */ + VK_KEY_6, /* APPLE_VK_ANSI_6 (0x16) */ + VK_KEY_5, /* APPLE_VK_ANSI_5 (0x17) */ + VK_OEM_PLUS, /* APPLE_VK_ANSI_Equal (0x18) */ + VK_KEY_9, /* APPLE_VK_ANSI_9 (0x19) */ + VK_KEY_7, /* APPLE_VK_ANSI_7 (0x1A) */ + VK_OEM_MINUS, /* APPLE_VK_ANSI_Minus (0x1B) */ + VK_KEY_8, /* APPLE_VK_ANSI_8 (0x1C) */ + VK_KEY_0, /* APPLE_VK_ANSI_0 (0x1D) */ + VK_OEM_6, /* APPLE_VK_ANSI_RightBracket (0x1E) */ + VK_KEY_O, /* APPLE_VK_ANSI_O (0x1F) */ + VK_KEY_U, /* APPLE_VK_ANSI_U (0x20) */ + VK_OEM_4, /* APPLE_VK_ANSI_LeftBracket (0x21) */ + VK_KEY_I, /* APPLE_VK_ANSI_I (0x22) */ + VK_KEY_P, /* APPLE_VK_ANSI_P (0x23) */ + VK_RETURN, /* APPLE_VK_Return (0x24) */ + VK_KEY_L, /* APPLE_VK_ANSI_L (0x25) */ + VK_KEY_J, /* APPLE_VK_ANSI_J (0x26) */ + VK_OEM_7, /* APPLE_VK_ANSI_Quote (0x27) */ + VK_KEY_K, /* APPLE_VK_ANSI_K (0x28) */ + VK_OEM_1, /* APPLE_VK_ANSI_Semicolon (0x29) */ + VK_OEM_5, /* APPLE_VK_ANSI_Backslash (0x2A) */ + VK_OEM_COMMA, /* APPLE_VK_ANSI_Comma (0x2B) */ + VK_OEM_2, /* APPLE_VK_ANSI_Slash (0x2C) */ + VK_KEY_N, /* APPLE_VK_ANSI_N (0x2D) */ + VK_KEY_M, /* APPLE_VK_ANSI_M (0x2E) */ + VK_OEM_PERIOD, /* APPLE_VK_ANSI_Period (0x2F) */ + VK_TAB, /* APPLE_VK_Tab (0x30) */ + VK_SPACE, /* APPLE_VK_Space (0x31) */ + VK_OEM_3, /* APPLE_VK_ANSI_Grave (0x32) */ + VK_BACK, /* APPLE_VK_Delete (0x33) */ + 0, /* APPLE_VK_0x34 (0x34) */ + VK_ESCAPE, /* APPLE_VK_Escape (0x35) */ + 0, /* APPLE_VK_0x36 (0x36) */ + VK_LWIN, /* APPLE_VK_Command (0x37) */ + VK_LSHIFT, /* APPLE_VK_Shift (0x38) */ + VK_CAPITAL, /* APPLE_VK_CapsLock (0x39) */ + VK_LMENU, /* APPLE_VK_Option (0x3A) */ + VK_LCONTROL, /* APPLE_VK_Control (0x3B) */ + VK_RSHIFT, /* APPLE_VK_RightShift (0x3C) */ + VK_RMENU, /* APPLE_VK_RightOption (0x3D) */ + 0, /* APPLE_VK_RightControl (0x3E) */ + VK_RWIN, /* APPLE_VK_Function (0x3F) */ + 0, /* APPLE_VK_F17 (0x40) */ + VK_DECIMAL, /* APPLE_VK_ANSI_KeypadDecimal (0x41) */ + 0, /* APPLE_VK_0x42 (0x42) */ + VK_MULTIPLY, /* APPLE_VK_ANSI_KeypadMultiply (0x43) */ + 0, /* APPLE_VK_0x44 (0x44) */ + VK_ADD, /* APPLE_VK_ANSI_KeypadPlus (0x45) */ + 0, /* APPLE_VK_0x46 (0x46) */ + VK_NUMLOCK, /* APPLE_VK_ANSI_KeypadClear (0x47) */ + 0, /* APPLE_VK_VolumeUp (0x48) */ + 0, /* APPLE_VK_VolumeDown (0x49) */ + 0, /* APPLE_VK_Mute (0x4A) */ + VK_DIVIDE, /* APPLE_VK_ANSI_KeypadDivide (0x4B) */ + VK_RETURN, /* APPLE_VK_ANSI_KeypadEnter (0x4C) */ + 0, /* APPLE_VK_0x4D (0x4D) */ + VK_SUBTRACT, /* APPLE_VK_ANSI_KeypadMinus (0x4E) */ + 0, /* APPLE_VK_F18 (0x4F) */ + 0, /* APPLE_VK_F19 (0x50) */ + 0, /* APPLE_VK_ANSI_KeypadEquals (0x51) */ + VK_NUMPAD0, /* APPLE_VK_ANSI_Keypad0 (0x52) */ + VK_NUMPAD1, /* APPLE_VK_ANSI_Keypad1 (0x53) */ + VK_NUMPAD2, /* APPLE_VK_ANSI_Keypad2 (0x54) */ + VK_NUMPAD3, /* APPLE_VK_ANSI_Keypad3 (0x55) */ + VK_NUMPAD4, /* APPLE_VK_ANSI_Keypad4 (0x56) */ + VK_NUMPAD5, /* APPLE_VK_ANSI_Keypad5 (0x57) */ + VK_NUMPAD6, /* APPLE_VK_ANSI_Keypad6 (0x58) */ + VK_NUMPAD7, /* APPLE_VK_ANSI_Keypad7 (0x59) */ + 0, /* APPLE_VK_F20 (0x5A) */ + VK_NUMPAD8, /* APPLE_VK_ANSI_Keypad8 (0x5B) */ + VK_NUMPAD9, /* APPLE_VK_ANSI_Keypad9 (0x5C) */ + 0, /* APPLE_VK_JIS_Yen (0x5D) */ + 0, /* APPLE_VK_JIS_Underscore (0x5E) */ + 0, /* APPLE_VK_JIS_KeypadComma (0x5F) */ + VK_F5, /* APPLE_VK_F5 (0x60) */ + VK_F6, /* APPLE_VK_F6 (0x61) */ + VK_F7, /* APPLE_VK_F7 (0x62) */ + VK_F3, /* APPLE_VK_F3 (0x63) */ + VK_F8, /* APPLE_VK_F8 (0x64) */ + VK_F9, /* APPLE_VK_F9 (0x65) */ + 0, /* APPLE_VK_JIS_Eisu (0x66) */ + VK_F11, /* APPLE_VK_F11 (0x67) */ + 0, /* APPLE_VK_JIS_Kana (0x68) */ + VK_SNAPSHOT, /* APPLE_VK_F13 (0x69) */ + 0, /* APPLE_VK_F16 (0x6A) */ + VK_SCROLL, /* APPLE_VK_F14 (0x6B) */ + 0, /* APPLE_VK_0x6C (0x6C) */ + VK_F10, /* APPLE_VK_F10 (0x6D) */ + 0, /* APPLE_VK_0x6E (0x6E) */ + VK_F12, /* APPLE_VK_F12 (0x6F) */ + 0, /* APPLE_VK_0x70 (0x70) */ + VK_PAUSE, /* APPLE_VK_F15 (0x71) */ + VK_INSERT, /* APPLE_VK_Help (0x72) */ + VK_HOME, /* APPLE_VK_Home (0x73) */ + VK_PRIOR, /* APPLE_VK_PageUp (0x74) */ + VK_DELETE, /* APPLE_VK_ForwardDelete (0x75) */ + VK_F4, /* APPLE_VK_F4 (0x76) */ + VK_END, /* APPLE_VK_End (0x77) */ + VK_F2, /* APPLE_VK_F2 (0x78) */ + VK_NEXT, /* APPLE_VK_PageDown (0x79) */ + VK_F1, /* APPLE_VK_F1 (0x7A) */ + VK_LEFT, /* APPLE_VK_LeftArrow (0x7B) */ + VK_RIGHT, /* APPLE_VK_RightArrow (0x7C) */ + VK_DOWN, /* APPLE_VK_DownArrow (0x7D) */ + VK_UP, /* APPLE_VK_UpArrow (0x7E) */ + 0, /* 135 */ + 0, /* 136 */ + 0, /* 137 */ + 0, /* 138 */ + 0, /* 139 */ + 0, /* 140 */ + 0, /* 141 */ + 0, /* 142 */ + 0, /* 143 */ + 0, /* 144 */ + 0, /* 145 */ + 0, /* 146 */ + 0, /* 147 */ + 0, /* 148 */ + 0, /* 149 */ + 0, /* 150 */ + 0, /* 151 */ + 0, /* 152 */ + 0, /* 153 */ + 0, /* 154 */ + 0, /* 155 */ + 0, /* 156 */ + 0, /* 157 */ + 0, /* 158 */ + 0, /* 159 */ + 0, /* 160 */ + 0, /* 161 */ + 0, /* 162 */ + 0, /* 163 */ + 0, /* 164 */ + 0, /* 165 */ + 0, /* 166 */ + 0, /* 167 */ + 0, /* 168 */ + 0, /* 169 */ + 0, /* 170 */ + 0, /* 171 */ + 0, /* 172 */ + 0, /* 173 */ + 0, /* 174 */ + 0, /* 175 */ + 0, /* 176 */ + 0, /* 177 */ + 0, /* 178 */ + 0, /* 179 */ + 0, /* 180 */ + 0, /* 181 */ + 0, /* 182 */ + 0, /* 183 */ + 0, /* 184 */ + 0, /* 185 */ + 0, /* 186 */ + 0, /* 187 */ + 0, /* 188 */ + 0, /* 189 */ + 0, /* 190 */ + 0, /* 191 */ + 0, /* 192 */ + 0, /* 193 */ + 0, /* 194 */ + 0, /* 195 */ + 0, /* 196 */ + 0, /* 197 */ + 0, /* 198 */ + 0, /* 199 */ + 0, /* 200 */ + 0, /* 201 */ + 0, /* 202 */ + 0, /* 203 */ + 0, /* 204 */ + 0, /* 205 */ + 0, /* 206 */ + 0, /* 207 */ + 0, /* 208 */ + 0, /* 209 */ + 0, /* 210 */ + 0, /* 211 */ + 0, /* 212 */ + 0, /* 213 */ + 0, /* 214 */ + 0, /* 215 */ + 0, /* 216 */ + 0, /* 217 */ + 0, /* 218 */ + 0, /* 219 */ + 0, /* 220 */ + 0, /* 221 */ + 0, /* 222 */ + 0, /* 223 */ + 0, /* 224 */ + 0, /* 225 */ + 0, /* 226 */ + 0, /* 227 */ + 0, /* 228 */ + 0, /* 229 */ + 0, /* 230 */ + 0, /* 231 */ + 0, /* 232 */ + 0, /* 233 */ + 0, /* 234 */ + 0, /* 235 */ + 0, /* 236 */ + 0, /* 237 */ + 0, /* 238 */ + 0, /* 239 */ + 0, /* 240 */ + 0, /* 241 */ + 0, /* 242 */ + 0, /* 243 */ + 0, /* 244 */ + 0, /* 245 */ + 0, /* 246 */ + 0, /* 247 */ + 0, /* 248 */ + 0, /* 249 */ + 0, /* 250 */ + 0, /* 251 */ + 0, /* 252 */ + 0, /* 253 */ + 0, /* 254 */ + 0 /* 255 */ +}; + +DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags) +{ + DWORD vkcode; + + vkcode = VK_NONE; + + if (dwFlags & KEYCODE_TYPE_APPLE) + { + if (keycode < 0xFF) + vkcode = KEYCODE_TO_VKCODE_APPLE[keycode & 0xFF]; + } + + if (!vkcode) + vkcode = VK_NONE; + + return vkcode; +} diff --git a/winpr/libwinpr/input/scancode.c b/winpr/libwinpr/input/scancode.c new file mode 100644 index 000000000..5711f789a --- /dev/null +++ b/winpr/libwinpr/input/scancode.c @@ -0,0 +1,653 @@ +/** + * WinPR: Windows Portable Runtime + * Keyboard Input + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +/** + * Virtual Scan Codes + */ + +/** + * Keyboard Type 4 + */ + +DWORD KBD4T[128] = +{ + KBD4_T00, + KBD4_T01, + KBD4_T02, + KBD4_T03, + KBD4_T04, + KBD4_T05, + KBD4_T06, + KBD4_T07, + KBD4_T08, + KBD4_T09, + KBD4_T0A, + KBD4_T0B, + KBD4_T0C, + KBD4_T0D, + KBD4_T0E, + KBD4_T0F, + KBD4_T10, + KBD4_T11, + KBD4_T12, + KBD4_T13, + KBD4_T14, + KBD4_T15, + KBD4_T16, + KBD4_T17, + KBD4_T18, + KBD4_T19, + KBD4_T1A, + KBD4_T1B, + KBD4_T1C, + KBD4_T1D, + KBD4_T1E, + KBD4_T1F, + KBD4_T20, + KBD4_T21, + KBD4_T22, + KBD4_T23, + KBD4_T24, + KBD4_T25, + KBD4_T26, + KBD4_T27, + KBD4_T28, + KBD4_T29, + KBD4_T2A, + KBD4_T2B, + KBD4_T2C, + KBD4_T2D, + KBD4_T2E, + KBD4_T2F, + KBD4_T30, + KBD4_T31, + KBD4_T32, + KBD4_T33, + KBD4_T34, + KBD4_T35, + KBD4_T36, + KBD4_T37, + KBD4_T38, + KBD4_T39, + KBD4_T3A, + KBD4_T3B, + KBD4_T3C, + KBD4_T3D, + KBD4_T3E, + KBD4_T3F, + KBD4_T40, + KBD4_T41, + KBD4_T42, + KBD4_T43, + KBD4_T44, + KBD4_T45, + KBD4_T46, + KBD4_T47, + KBD4_T48, + KBD4_T49, + KBD4_T4A, + KBD4_T4B, + KBD4_T4C, + KBD4_T4D, + KBD4_T4E, + KBD4_T4F, + KBD4_T50, + KBD4_T51, + KBD4_T52, + KBD4_T53, + KBD4_T54, + KBD4_T55, + KBD4_T56, + KBD4_T57, + KBD4_T58, + KBD4_T59, + KBD4_T5A, + KBD4_T5B, + KBD4_T5C, + KBD4_T5D, + KBD4_T5E, + KBD4_T5F, + KBD4_T60, + KBD4_T61, + KBD4_T62, + KBD4_T63, + KBD4_T64, + KBD4_T65, + KBD4_T66, + KBD4_T67, + KBD4_T68, + KBD4_T69, + KBD4_T6A, + KBD4_T6B, + KBD4_T6C, + KBD4_T6D, + KBD4_T6E, + KBD4_T6F, + KBD4_T70, + KBD4_T71, + KBD4_T72, + KBD4_T73, + KBD4_T74, + KBD4_T75, + KBD4_T76, + KBD4_T77, + KBD4_T78, + KBD4_T79, + KBD4_T7A, + KBD4_T7B, + KBD4_T7C, + KBD4_T7D, + KBD4_T7E, + KBD4_T7F +}; + +DWORD KBD4X[128] = +{ + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X10, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X19, + VK_NONE, + VK_NONE, + KBD4_X1C, + KBD4_X1D, + VK_NONE, + VK_NONE, + KBD4_X20, + KBD4_X21, + KBD4_X22, + VK_NONE, + KBD4_X24, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X2E, + VK_NONE, + KBD4_X30, + VK_NONE, + KBD4_X32, + VK_NONE, + VK_NONE, + KBD4_X35, + VK_NONE, + KBD4_X37, + KBD4_X38, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X46, + KBD4_X47, + KBD4_X48, + KBD4_X49, + VK_NONE, + KBD4_X4B, + VK_NONE, + KBD4_X4D, + VK_NONE, + KBD4_X4F, + KBD4_X50, + KBD4_X51, + KBD4_X52, + KBD4_X53, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X5B, + KBD4_X5C, + KBD4_X5D, + KBD4_X5E, + KBD4_X5F, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD4_X65, + KBD4_X66, + KBD4_X67, + KBD4_X68, + KBD4_X69, + KBD4_X6A, + KBD4_X6B, + KBD4_X6C, + KBD4_X6D, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE +}; + +/** + * Keyboard Type 7 + */ + +DWORD KBD7T[128] = +{ + KBD7_T00, + KBD7_T01, + KBD7_T02, + KBD7_T03, + KBD7_T04, + KBD7_T05, + KBD7_T06, + KBD7_T07, + KBD7_T08, + KBD7_T09, + KBD7_T0A, + KBD7_T0B, + KBD7_T0C, + KBD7_T0D, + KBD7_T0E, + KBD7_T0F, + KBD7_T10, + KBD7_T11, + KBD7_T12, + KBD7_T13, + KBD7_T14, + KBD7_T15, + KBD7_T16, + KBD7_T17, + KBD7_T18, + KBD7_T19, + KBD7_T1A, + KBD7_T1B, + KBD7_T1C, + KBD7_T1D, + KBD7_T1E, + KBD7_T1F, + KBD7_T20, + KBD7_T21, + KBD7_T22, + KBD7_T23, + KBD7_T24, + KBD7_T25, + KBD7_T26, + KBD7_T27, + KBD7_T28, + KBD7_T29, + KBD7_T2A, + KBD7_T2B, + KBD7_T2C, + KBD7_T2D, + KBD7_T2E, + KBD7_T2F, + KBD7_T30, + KBD7_T31, + KBD7_T32, + KBD7_T33, + KBD7_T34, + KBD7_T35, + KBD7_T36, + KBD7_T37, + KBD7_T38, + KBD7_T39, + KBD7_T3A, + KBD7_T3B, + KBD7_T3C, + KBD7_T3D, + KBD7_T3E, + KBD7_T3F, + KBD7_T40, + KBD7_T41, + KBD7_T42, + KBD7_T43, + KBD7_T44, + KBD7_T45, + KBD7_T46, + KBD7_T47, + KBD7_T48, + KBD7_T49, + KBD7_T4A, + KBD7_T4B, + KBD7_T4C, + KBD7_T4D, + KBD7_T4E, + KBD7_T4F, + KBD7_T50, + KBD7_T51, + KBD7_T52, + KBD7_T53, + KBD7_T54, + KBD7_T55, + KBD7_T56, + KBD7_T57, + KBD7_T58, + KBD7_T59, + KBD7_T5A, + KBD7_T5B, + KBD7_T5C, + KBD7_T5D, + KBD7_T5E, + KBD7_T5F, + KBD7_T60, + KBD7_T61, + KBD7_T62, + KBD7_T63, + KBD7_T64, + KBD7_T65, + KBD7_T66, + KBD7_T67, + KBD7_T68, + KBD7_T69, + KBD7_T6A, + KBD7_T6B, + KBD7_T6C, + KBD7_T6D, + KBD7_T6E, + KBD7_T6F, + KBD7_T70, + KBD7_T71, + KBD7_T72, + KBD7_T73, + KBD7_T74, + KBD7_T75, + KBD7_T76, + KBD7_T77, + KBD7_T78, + KBD7_T79, + KBD7_T7A, + KBD7_T7B, + KBD7_T7C, + KBD7_T7D, + KBD7_T7E, + KBD7_T7F +}; + +DWORD KBD7X[128] = +{ + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X10, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X19, + VK_NONE, + VK_NONE, + KBD7_X1C, + KBD7_X1D, + VK_NONE, + VK_NONE, + KBD7_X20, + KBD7_X21, + KBD7_X22, + VK_NONE, + KBD7_X24, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X2E, + VK_NONE, + KBD7_X30, + VK_NONE, + KBD7_X32, + KBD7_X33, + VK_NONE, + KBD7_X35, + VK_NONE, + KBD7_X37, + KBD7_X38, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X42, + KBD7_X43, + KBD7_X44, + VK_NONE, + KBD7_X46, + KBD7_X47, + KBD7_X48, + KBD7_X49, + VK_NONE, + KBD7_X4B, + VK_NONE, + KBD7_X4D, + VK_NONE, + KBD7_X4F, + KBD7_X50, + KBD7_X51, + KBD7_X52, + KBD7_X53, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X5B, + KBD7_X5C, + KBD7_X5D, + KBD7_X5E, + KBD7_X5F, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + KBD7_X65, + KBD7_X66, + KBD7_X67, + KBD7_X68, + KBD7_X69, + KBD7_X6A, + KBD7_X6B, + KBD7_X6C, + KBD7_X6D, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE, + VK_NONE +}; + +DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType) +{ + DWORD vkcode; + + vkcode = VK_NONE; + + if ((dwKeyboardType != 4) && (dwKeyboardType != 7)) + dwKeyboardType = 4; + + if (dwKeyboardType == 4) + { + if (scancode & KBDEXT) + vkcode = KBD4X[scancode & 0x7F]; + else + vkcode = KBD4T[scancode & 0x7F]; + } + else if (dwKeyboardType == 7) + { + if (scancode & KBDEXT) + vkcode = KBD7X[scancode & 0x7F]; + else + vkcode = KBD7T[scancode & 0x7F]; + } + + return vkcode; +} + +DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType) +{ + int i; + DWORD scancode; + + scancode = 0; + + if ((dwKeyboardType != 4) && (dwKeyboardType != 7)) + dwKeyboardType = 4; + + if (dwKeyboardType == 4) + { + for (i = 0; i < 128; i++) + { + if (KBD4T[i] == vkcode) + { + scancode = i; + break; + } + } + + if (!scancode) + { + for (i = 0; i < 128; i++) + { + if (KBD4X[i] == vkcode) + { + scancode = i; + break; + } + } + } + } + else if (dwKeyboardType == 7) + { + for (i = 0; i < 128; i++) + { + if (KBD7T[i] == vkcode) + { + scancode = i; + break; + } + } + + if (!scancode) + { + for (i = 0; i < 128; i++) + { + if (KBD7X[i] == vkcode) + { + scancode = i; + break; + } + } + } + } + + return scancode; +} diff --git a/winpr/libwinpr/input/keyboard.c b/winpr/libwinpr/input/virtualkey.c similarity index 52% rename from winpr/libwinpr/input/keyboard.c rename to winpr/libwinpr/input/virtualkey.c index 8a53ec1ab..93aee3610 100644 --- a/winpr/libwinpr/input/keyboard.c +++ b/winpr/libwinpr/input/virtualkey.c @@ -324,629 +324,3 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname) return VK_NONE; } -/** - * Virtual Scan Codes - */ - -/** - * Keyboard Type 4 - */ - -DWORD KBD4T[128] = -{ - KBD4_T00, - KBD4_T01, - KBD4_T02, - KBD4_T03, - KBD4_T04, - KBD4_T05, - KBD4_T06, - KBD4_T07, - KBD4_T08, - KBD4_T09, - KBD4_T0A, - KBD4_T0B, - KBD4_T0C, - KBD4_T0D, - KBD4_T0E, - KBD4_T0F, - KBD4_T10, - KBD4_T11, - KBD4_T12, - KBD4_T13, - KBD4_T14, - KBD4_T15, - KBD4_T16, - KBD4_T17, - KBD4_T18, - KBD4_T19, - KBD4_T1A, - KBD4_T1B, - KBD4_T1C, - KBD4_T1D, - KBD4_T1E, - KBD4_T1F, - KBD4_T20, - KBD4_T21, - KBD4_T22, - KBD4_T23, - KBD4_T24, - KBD4_T25, - KBD4_T26, - KBD4_T27, - KBD4_T28, - KBD4_T29, - KBD4_T2A, - KBD4_T2B, - KBD4_T2C, - KBD4_T2D, - KBD4_T2E, - KBD4_T2F, - KBD4_T30, - KBD4_T31, - KBD4_T32, - KBD4_T33, - KBD4_T34, - KBD4_T35, - KBD4_T36, - KBD4_T37, - KBD4_T38, - KBD4_T39, - KBD4_T3A, - KBD4_T3B, - KBD4_T3C, - KBD4_T3D, - KBD4_T3E, - KBD4_T3F, - KBD4_T40, - KBD4_T41, - KBD4_T42, - KBD4_T43, - KBD4_T44, - KBD4_T45, - KBD4_T46, - KBD4_T47, - KBD4_T48, - KBD4_T49, - KBD4_T4A, - KBD4_T4B, - KBD4_T4C, - KBD4_T4D, - KBD4_T4E, - KBD4_T4F, - KBD4_T50, - KBD4_T51, - KBD4_T52, - KBD4_T53, - KBD4_T54, - KBD4_T55, - KBD4_T56, - KBD4_T57, - KBD4_T58, - KBD4_T59, - KBD4_T5A, - KBD4_T5B, - KBD4_T5C, - KBD4_T5D, - KBD4_T5E, - KBD4_T5F, - KBD4_T60, - KBD4_T61, - KBD4_T62, - KBD4_T63, - KBD4_T64, - KBD4_T65, - KBD4_T66, - KBD4_T67, - KBD4_T68, - KBD4_T69, - KBD4_T6A, - KBD4_T6B, - KBD4_T6C, - KBD4_T6D, - KBD4_T6E, - KBD4_T6F, - KBD4_T70, - KBD4_T71, - KBD4_T72, - KBD4_T73, - KBD4_T74, - KBD4_T75, - KBD4_T76, - KBD4_T77, - KBD4_T78, - KBD4_T79, - KBD4_T7A, - KBD4_T7B, - KBD4_T7C, - KBD4_T7D, - KBD4_T7E, - KBD4_T7F -}; - -DWORD KBD4X[128] = -{ - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD4_X10, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD4_X19, - VK_NONE, - VK_NONE, - KBD4_X1C, - KBD4_X1D, - VK_NONE, - VK_NONE, - KBD4_X20, - KBD4_X21, - KBD4_X22, - VK_NONE, - KBD4_X24, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD4_X2E, - VK_NONE, - KBD4_X30, - VK_NONE, - KBD4_X32, - VK_NONE, - VK_NONE, - KBD4_X35, - VK_NONE, - KBD4_X37, - KBD4_X38, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD4_X46, - KBD4_X47, - KBD4_X48, - KBD4_X49, - VK_NONE, - KBD4_X4B, - VK_NONE, - KBD4_X4D, - VK_NONE, - KBD4_X4F, - KBD4_X50, - KBD4_X51, - KBD4_X52, - KBD4_X53, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD4_X5B, - KBD4_X5C, - KBD4_X5D, - KBD4_X5E, - KBD4_X5F, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD4_X65, - KBD4_X66, - KBD4_X67, - KBD4_X68, - KBD4_X69, - KBD4_X6A, - KBD4_X6B, - KBD4_X6C, - KBD4_X6D, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE -}; - -/** - * Keyboard Type 7 - */ - -DWORD KBD7T[128] = -{ - KBD7_T00, - KBD7_T01, - KBD7_T02, - KBD7_T03, - KBD7_T04, - KBD7_T05, - KBD7_T06, - KBD7_T07, - KBD7_T08, - KBD7_T09, - KBD7_T0A, - KBD7_T0B, - KBD7_T0C, - KBD7_T0D, - KBD7_T0E, - KBD7_T0F, - KBD7_T10, - KBD7_T11, - KBD7_T12, - KBD7_T13, - KBD7_T14, - KBD7_T15, - KBD7_T16, - KBD7_T17, - KBD7_T18, - KBD7_T19, - KBD7_T1A, - KBD7_T1B, - KBD7_T1C, - KBD7_T1D, - KBD7_T1E, - KBD7_T1F, - KBD7_T20, - KBD7_T21, - KBD7_T22, - KBD7_T23, - KBD7_T24, - KBD7_T25, - KBD7_T26, - KBD7_T27, - KBD7_T28, - KBD7_T29, - KBD7_T2A, - KBD7_T2B, - KBD7_T2C, - KBD7_T2D, - KBD7_T2E, - KBD7_T2F, - KBD7_T30, - KBD7_T31, - KBD7_T32, - KBD7_T33, - KBD7_T34, - KBD7_T35, - KBD7_T36, - KBD7_T37, - KBD7_T38, - KBD7_T39, - KBD7_T3A, - KBD7_T3B, - KBD7_T3C, - KBD7_T3D, - KBD7_T3E, - KBD7_T3F, - KBD7_T40, - KBD7_T41, - KBD7_T42, - KBD7_T43, - KBD7_T44, - KBD7_T45, - KBD7_T46, - KBD7_T47, - KBD7_T48, - KBD7_T49, - KBD7_T4A, - KBD7_T4B, - KBD7_T4C, - KBD7_T4D, - KBD7_T4E, - KBD7_T4F, - KBD7_T50, - KBD7_T51, - KBD7_T52, - KBD7_T53, - KBD7_T54, - KBD7_T55, - KBD7_T56, - KBD7_T57, - KBD7_T58, - KBD7_T59, - KBD7_T5A, - KBD7_T5B, - KBD7_T5C, - KBD7_T5D, - KBD7_T5E, - KBD7_T5F, - KBD7_T60, - KBD7_T61, - KBD7_T62, - KBD7_T63, - KBD7_T64, - KBD7_T65, - KBD7_T66, - KBD7_T67, - KBD7_T68, - KBD7_T69, - KBD7_T6A, - KBD7_T6B, - KBD7_T6C, - KBD7_T6D, - KBD7_T6E, - KBD7_T6F, - KBD7_T70, - KBD7_T71, - KBD7_T72, - KBD7_T73, - KBD7_T74, - KBD7_T75, - KBD7_T76, - KBD7_T77, - KBD7_T78, - KBD7_T79, - KBD7_T7A, - KBD7_T7B, - KBD7_T7C, - KBD7_T7D, - KBD7_T7E, - KBD7_T7F -}; - -DWORD KBD7X[128] = -{ - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD7_X10, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD7_X19, - VK_NONE, - VK_NONE, - KBD7_X1C, - KBD7_X1D, - VK_NONE, - VK_NONE, - KBD7_X20, - KBD7_X21, - KBD7_X22, - VK_NONE, - KBD7_X24, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD7_X2E, - VK_NONE, - KBD7_X30, - VK_NONE, - KBD7_X32, - KBD7_X33, - VK_NONE, - KBD7_X35, - VK_NONE, - KBD7_X37, - KBD7_X38, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD7_X42, - KBD7_X43, - KBD7_X44, - VK_NONE, - KBD7_X46, - KBD7_X47, - KBD7_X48, - KBD7_X49, - VK_NONE, - KBD7_X4B, - VK_NONE, - KBD7_X4D, - VK_NONE, - KBD7_X4F, - KBD7_X50, - KBD7_X51, - KBD7_X52, - KBD7_X53, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD7_X5B, - KBD7_X5C, - KBD7_X5D, - KBD7_X5E, - KBD7_X5F, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - KBD7_X65, - KBD7_X66, - KBD7_X67, - KBD7_X68, - KBD7_X69, - KBD7_X6A, - KBD7_X6B, - KBD7_X6C, - KBD7_X6D, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE, - VK_NONE -}; - -DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType) -{ - DWORD vkcode; - - vkcode = VK_NONE; - - if ((dwKeyboardType != 4) && (dwKeyboardType != 7)) - dwKeyboardType = 4; - - if (dwKeyboardType == 4) - { - if (scancode & KBDEXT) - vkcode = KBD4X[scancode & 0x7F]; - else - vkcode = KBD4T[scancode & 0x7F]; - } - else if (dwKeyboardType == 7) - { - if (scancode & KBDEXT) - vkcode = KBD7X[scancode & 0x7F]; - else - vkcode = KBD7T[scancode & 0x7F]; - } - - return vkcode; -} - -DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType) -{ - int i; - DWORD scancode; - - scancode = 0; - - if ((dwKeyboardType != 4) && (dwKeyboardType != 7)) - dwKeyboardType = 4; - - if (dwKeyboardType == 4) - { - for (i = 0; i < 128; i++) - { - if (KBD4T[i] == vkcode) - { - scancode = i; - break; - } - } - - if (!scancode) - { - for (i = 0; i < 128; i++) - { - if (KBD4X[i] == vkcode) - { - scancode = i; - break; - } - } - } - } - else if (dwKeyboardType == 7) - { - for (i = 0; i < 128; i++) - { - if (KBD7T[i] == vkcode) - { - scancode = i; - break; - } - } - - if (!scancode) - { - for (i = 0; i < 128; i++) - { - if (KBD7X[i] == vkcode) - { - scancode = i; - break; - } - } - } - } - - return scancode; -} From 0bff72935b2e35ecc7403464e3d8b08e77c1d944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 4 Mar 2013 17:19:33 -0500 Subject: [PATCH 11/18] libwinpr-input: add empty keycode map for evdev --- winpr/libwinpr/input/keycode.c | 264 +++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index 8103bed00..c64c3618a 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -293,6 +293,270 @@ DWORD KEYCODE_TO_VKCODE_APPLE[256] = 0 /* 255 */ }; +/** + * evdev (Linux) + */ + +DWORD KEYCODE_TO_VKCODE_EVDEV[256] = +{ + 0, /* 0 */ + 0, /* 1 */ + 0, /* 2 */ + 0, /* 3 */ + 0, /* 4 */ + 0, /* 5 */ + 0, /* 6 */ + 0, /* 7 */ + 0, /* 8 */ + 0, /* 9 */ + 0, /* 10 */ + 0, /* 11 */ + 0, /* 12 */ + 0, /* 13 */ + 0, /* 14 */ + 0, /* 15 */ + 0, /* 16 */ + 0, /* 17 */ + 0, /* 18 */ + 0, /* 19 */ + 0, /* 20 */ + 0, /* 21 */ + 0, /* 22 */ + 0, /* 23 */ + 0, /* 24 */ + 0, /* 25 */ + 0, /* 26 */ + 0, /* 27 */ + 0, /* 28 */ + 0, /* 29 */ + 0, /* 30 */ + 0, /* 31 */ + 0, /* 32 */ + 0, /* 33 */ + 0, /* 34 */ + 0, /* 35 */ + 0, /* 36 */ + 0, /* 37 */ + 0, /* 38 */ + 0, /* 39 */ + 0, /* 40 */ + 0, /* 41 */ + 0, /* 42 */ + 0, /* 43 */ + 0, /* 44 */ + 0, /* 45 */ + 0, /* 46 */ + 0, /* 47 */ + 0, /* 48 */ + 0, /* 49 */ + 0, /* 50 */ + 0, /* 51 */ + 0, /* 52 */ + 0, /* 53 */ + 0, /* 54 */ + 0, /* 55 */ + 0, /* 56 */ + 0, /* 57 */ + 0, /* 58 */ + 0, /* 59 */ + 0, /* 60 */ + 0, /* 61 */ + 0, /* 62 */ + 0, /* 63 */ + 0, /* 64 */ + 0, /* 65 */ + 0, /* 66 */ + 0, /* 67 */ + 0, /* 68 */ + 0, /* 69 */ + 0, /* 70 */ + 0, /* 71 */ + 0, /* 72 */ + 0, /* 73 */ + 0, /* 74 */ + 0, /* 75 */ + 0, /* 76 */ + 0, /* 77 */ + 0, /* 78 */ + 0, /* 79 */ + 0, /* 80 */ + 0, /* 81 */ + 0, /* 82 */ + 0, /* 83 */ + 0, /* 84 */ + 0, /* 85 */ + 0, /* 86 */ + 0, /* 87 */ + 0, /* 88 */ + 0, /* 89 */ + 0, /* 90 */ + 0, /* 91 */ + 0, /* 92 */ + 0, /* 93 */ + 0, /* 94 */ + 0, /* 95 */ + 0, /* 96 */ + 0, /* 97 */ + 0, /* 98 */ + 0, /* 99 */ + 0, /* 100 */ + 0, /* 101 */ + 0, /* 102 */ + 0, /* 103 */ + 0, /* 104 */ + 0, /* 105 */ + 0, /* 106 */ + 0, /* 107 */ + 0, /* 108 */ + 0, /* 109 */ + 0, /* 110 */ + 0, /* 111 */ + 0, /* 112 */ + 0, /* 113 */ + 0, /* 114 */ + 0, /* 115 */ + 0, /* 116 */ + 0, /* 117 */ + 0, /* 118 */ + 0, /* 119 */ + 0, /* 120 */ + 0, /* 121 */ + 0, /* 122 */ + 0, /* 123 */ + 0, /* 124 */ + 0, /* 125 */ + 0, /* 126 */ + 0, /* 127 */ + 0, /* 128 */ + 0, /* 129 */ + 0, /* 130 */ + 0, /* 131 */ + 0, /* 132 */ + 0, /* 133 */ + 0, /* 134 */ + 0, /* 135 */ + 0, /* 136 */ + 0, /* 137 */ + 0, /* 138 */ + 0, /* 139 */ + 0, /* 140 */ + 0, /* 141 */ + 0, /* 142 */ + 0, /* 143 */ + 0, /* 144 */ + 0, /* 145 */ + 0, /* 146 */ + 0, /* 147 */ + 0, /* 148 */ + 0, /* 149 */ + 0, /* 150 */ + 0, /* 151 */ + 0, /* 152 */ + 0, /* 153 */ + 0, /* 154 */ + 0, /* 155 */ + 0, /* 156 */ + 0, /* 157 */ + 0, /* 158 */ + 0, /* 159 */ + 0, /* 160 */ + 0, /* 161 */ + 0, /* 162 */ + 0, /* 163 */ + 0, /* 164 */ + 0, /* 165 */ + 0, /* 166 */ + 0, /* 167 */ + 0, /* 168 */ + 0, /* 169 */ + 0, /* 170 */ + 0, /* 171 */ + 0, /* 172 */ + 0, /* 173 */ + 0, /* 174 */ + 0, /* 175 */ + 0, /* 176 */ + 0, /* 177 */ + 0, /* 178 */ + 0, /* 179 */ + 0, /* 180 */ + 0, /* 181 */ + 0, /* 182 */ + 0, /* 183 */ + 0, /* 184 */ + 0, /* 185 */ + 0, /* 186 */ + 0, /* 187 */ + 0, /* 188 */ + 0, /* 189 */ + 0, /* 190 */ + 0, /* 191 */ + 0, /* 192 */ + 0, /* 193 */ + 0, /* 194 */ + 0, /* 195 */ + 0, /* 196 */ + 0, /* 197 */ + 0, /* 198 */ + 0, /* 199 */ + 0, /* 200 */ + 0, /* 201 */ + 0, /* 202 */ + 0, /* 203 */ + 0, /* 204 */ + 0, /* 205 */ + 0, /* 206 */ + 0, /* 207 */ + 0, /* 208 */ + 0, /* 209 */ + 0, /* 210 */ + 0, /* 211 */ + 0, /* 212 */ + 0, /* 213 */ + 0, /* 214 */ + 0, /* 215 */ + 0, /* 216 */ + 0, /* 217 */ + 0, /* 218 */ + 0, /* 219 */ + 0, /* 220 */ + 0, /* 221 */ + 0, /* 222 */ + 0, /* 223 */ + 0, /* 224 */ + 0, /* 225 */ + 0, /* 226 */ + 0, /* 227 */ + 0, /* 228 */ + 0, /* 229 */ + 0, /* 230 */ + 0, /* 231 */ + 0, /* 232 */ + 0, /* 233 */ + 0, /* 234 */ + 0, /* 235 */ + 0, /* 236 */ + 0, /* 237 */ + 0, /* 238 */ + 0, /* 239 */ + 0, /* 240 */ + 0, /* 241 */ + 0, /* 242 */ + 0, /* 243 */ + 0, /* 244 */ + 0, /* 245 */ + 0, /* 246 */ + 0, /* 247 */ + 0, /* 248 */ + 0, /* 249 */ + 0, /* 250 */ + 0, /* 251 */ + 0, /* 252 */ + 0, /* 253 */ + 0, /* 254 */ + 0 /* 255 */ +}; + DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags) { DWORD vkcode; From d4dc6b256e293b9c00310b6861c1a9827807ebb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 4 Mar 2013 18:27:31 -0500 Subject: [PATCH 12/18] libwinpr-input: prepare comments for evdev keycode map --- winpr/libwinpr/input/keycode.c | 491 +++++++++++++++++---------------- 1 file changed, 247 insertions(+), 244 deletions(-) diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index c64c3618a..80c0f8616 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -295,6 +295,9 @@ DWORD KEYCODE_TO_VKCODE_APPLE[256] = /** * evdev (Linux) + * + * Refer to X Keyboard Configuration Database: + * http://www.freedesktop.org/wiki/Software/XKeyboardConfig */ DWORD KEYCODE_TO_VKCODE_EVDEV[256] = @@ -308,251 +311,251 @@ DWORD KEYCODE_TO_VKCODE_EVDEV[256] = 0, /* 6 */ 0, /* 7 */ 0, /* 8 */ - 0, /* 9 */ - 0, /* 10 */ - 0, /* 11 */ - 0, /* 12 */ - 0, /* 13 */ - 0, /* 14 */ - 0, /* 15 */ - 0, /* 16 */ - 0, /* 17 */ - 0, /* 18 */ - 0, /* 19 */ - 0, /* 20 */ - 0, /* 21 */ - 0, /* 22 */ - 0, /* 23 */ - 0, /* 24 */ - 0, /* 25 */ - 0, /* 26 */ - 0, /* 27 */ - 0, /* 28 */ - 0, /* 29 */ - 0, /* 30 */ - 0, /* 31 */ - 0, /* 32 */ - 0, /* 33 */ - 0, /* 34 */ - 0, /* 35 */ - 0, /* 36 */ - 0, /* 37 */ - 0, /* 38 */ - 0, /* 39 */ - 0, /* 40 */ - 0, /* 41 */ - 0, /* 42 */ - 0, /* 43 */ - 0, /* 44 */ - 0, /* 45 */ - 0, /* 46 */ - 0, /* 47 */ - 0, /* 48 */ - 0, /* 49 */ - 0, /* 50 */ - 0, /* 51 */ - 0, /* 52 */ - 0, /* 53 */ - 0, /* 54 */ - 0, /* 55 */ - 0, /* 56 */ - 0, /* 57 */ - 0, /* 58 */ - 0, /* 59 */ - 0, /* 60 */ - 0, /* 61 */ - 0, /* 62 */ - 0, /* 63 */ - 0, /* 64 */ - 0, /* 65 */ - 0, /* 66 */ - 0, /* 67 */ - 0, /* 68 */ - 0, /* 69 */ - 0, /* 70 */ - 0, /* 71 */ - 0, /* 72 */ - 0, /* 73 */ - 0, /* 74 */ - 0, /* 75 */ - 0, /* 76 */ - 0, /* 77 */ - 0, /* 78 */ - 0, /* 79 */ - 0, /* 80 */ - 0, /* 81 */ - 0, /* 82 */ - 0, /* 83 */ - 0, /* 84 */ - 0, /* 85 */ - 0, /* 86 */ - 0, /* 87 */ - 0, /* 88 */ - 0, /* 89 */ - 0, /* 90 */ - 0, /* 91 */ - 0, /* 92 */ + 0, /* 9 */ + 0, /* 10 */ + 0, /* 11 */ + 0, /* 12 */ + 0, /* 13 */ + 0, /* 14 */ + 0, /* 15 */ + 0, /* 16 */ + 0, /* 17 */ + 0, /* 18 */ + 0, /* 19 */ + 0, /* 20 */ + 0, /* 21 */ + 0, /* 22 */ + 0, /* 23 */ + 0, /* 24 */ + 0, /* 25 */ + 0, /* 26 */ + 0, /* 27 */ + 0, /* 28 */ + 0, /* 29 */ + 0, /* 30 */ + 0, /* 31 */ + 0, /* 32 */ + 0, /* 33 */ + 0, /* 34 */ + 0, /* 35 */ + 0, /* 36 */ + 0, /* 37 */ + 0, /* 38 */ + 0, /* 39 */ + 0, /* 40 */ + 0, /* 41 */ + 0, /* 42 */ + 0, /* 43 */ + 0, /* 44 */ + 0, /* 45 */ + 0, /* 46 */ + 0, /* 47 */ + 0, /* 48 */ + 0, /* 49 */ + 0, /* 50 */ + 0, /* 51 */ + 0, /* 52 */ + 0, /* 53 */ + 0, /* 54 */ + 0, /* 55 */ + 0, /* 56 */ + 0, /* 57 */ + 0, /* 58 */ + 0, /* 59 */ + 0, /* 60 */ + 0, /* 61 */ + 0, /* 62 */ + 0, /* 63 */ + 0, /* 64 */ + 0, /* 65 */ + 0, /* 66 */ + 0, /* 67 */ + 0, /* 68 */ + 0, /* 69 */ + 0, /* 70 */ + 0, /* 71 */ + 0, /* 72 */ + 0, /* 73 */ + 0, /* 74 */ + 0, /* 75 */ + 0, /* 76 */ + 0, /* 77 */ + 0, /* 78 */ + 0, /* 79 */ + 0, /* 80 */ + 0, /* 81 */ + 0, /* 82 */ + 0, /* 83 */ + 0, /* 84 */ + 0, /* 85 */ + 0, /* 86 */ + 0, /* 87 */ + 0, /* 88 */ + 0, /* 89 */ + 0, /* 90 */ + 0, /* 91 */ + 0, /* 92 */ 0, /* 93 */ - 0, /* 94 */ - 0, /* 95 */ - 0, /* 96 */ - 0, /* 97 */ - 0, /* 98 */ - 0, /* 99 */ - 0, /* 100 */ - 0, /* 101 */ - 0, /* 102 */ - 0, /* 103 */ - 0, /* 104 */ - 0, /* 105 */ - 0, /* 106 */ - 0, /* 107 */ - 0, /* 108 */ - 0, /* 109 */ - 0, /* 110 */ - 0, /* 111 */ - 0, /* 112 */ - 0, /* 113 */ - 0, /* 114 */ - 0, /* 115 */ - 0, /* 116 */ - 0, /* 117 */ - 0, /* 118 */ - 0, /* 119 */ - 0, /* 120 */ - 0, /* 121 */ - 0, /* 122 */ - 0, /* 123 */ - 0, /* 124 */ - 0, /* 125 */ - 0, /* 126 */ - 0, /* 127 */ - 0, /* 128 */ - 0, /* 129 */ - 0, /* 130 */ - 0, /* 131 */ - 0, /* 132 */ - 0, /* 133 */ - 0, /* 134 */ - 0, /* 135 */ - 0, /* 136 */ - 0, /* 137 */ - 0, /* 138 */ - 0, /* 139 */ - 0, /* 140 */ - 0, /* 141 */ - 0, /* 142 */ - 0, /* 143 */ - 0, /* 144 */ - 0, /* 145 */ - 0, /* 146 */ - 0, /* 147 */ - 0, /* 148 */ - 0, /* 149 */ - 0, /* 150 */ - 0, /* 151 */ - 0, /* 152 */ - 0, /* 153 */ - 0, /* 154 */ - 0, /* 155 */ - 0, /* 156 */ - 0, /* 157 */ - 0, /* 158 */ - 0, /* 159 */ - 0, /* 160 */ - 0, /* 161 */ - 0, /* 162 */ - 0, /* 163 */ - 0, /* 164 */ - 0, /* 165 */ - 0, /* 166 */ - 0, /* 167 */ - 0, /* 168 */ - 0, /* 169 */ - 0, /* 170 */ - 0, /* 171 */ - 0, /* 172 */ - 0, /* 173 */ - 0, /* 174 */ - 0, /* 175 */ - 0, /* 176 */ - 0, /* 177 */ - 0, /* 178 */ - 0, /* 179 */ - 0, /* 180 */ - 0, /* 181 */ - 0, /* 182 */ - 0, /* 183 */ - 0, /* 184 */ - 0, /* 185 */ - 0, /* 186 */ - 0, /* 187 */ - 0, /* 188 */ - 0, /* 189 */ - 0, /* 190 */ - 0, /* 191 */ - 0, /* 192 */ - 0, /* 193 */ - 0, /* 194 */ - 0, /* 195 */ - 0, /* 196 */ - 0, /* 197 */ - 0, /* 198 */ - 0, /* 199 */ - 0, /* 200 */ - 0, /* 201 */ - 0, /* 202 */ - 0, /* 203 */ - 0, /* 204 */ - 0, /* 205 */ - 0, /* 206 */ - 0, /* 207 */ - 0, /* 208 */ - 0, /* 209 */ - 0, /* 210 */ - 0, /* 211 */ - 0, /* 212 */ - 0, /* 213 */ - 0, /* 214 */ - 0, /* 215 */ - 0, /* 216 */ - 0, /* 217 */ - 0, /* 218 */ - 0, /* 219 */ - 0, /* 220 */ - 0, /* 221 */ - 0, /* 222 */ - 0, /* 223 */ - 0, /* 224 */ - 0, /* 225 */ - 0, /* 226 */ - 0, /* 227 */ - 0, /* 228 */ - 0, /* 229 */ - 0, /* 230 */ - 0, /* 231 */ - 0, /* 232 */ - 0, /* 233 */ - 0, /* 234 */ - 0, /* 235 */ - 0, /* 236 */ - 0, /* 237 */ - 0, /* 238 */ - 0, /* 239 */ - 0, /* 240 */ - 0, /* 241 */ - 0, /* 242 */ - 0, /* 243 */ - 0, /* 244 */ - 0, /* 245 */ - 0, /* 246 */ - 0, /* 247 */ - 0, /* 248 */ - 0, /* 249 */ - 0, /* 250 */ - 0, /* 251 */ - 0, /* 252 */ - 0, /* 253 */ + 0, /* 94 */ + 0, /* 95 */ + 0, /* 96 */ + 0, /* 97 */ + 0, /* 98 */ + 0, /* 99 */ + 0, /* 100 */ + 0, /* 101 */ + 0, /* 102 */ + 0, /* 103 */ + 0, /* 104 */ + 0, /* 105 */ + 0, /* 106 */ + 0, /* 107 */ + 0, /* 108 */ + 0, /* KEY_LINEFEED 109 */ + 0, /* 110 */ + 0, /* 111 */ + 0, /* 112 */ + 0, /* 113 */ + 0, /* 114 */ + 0, /* 115 */ + 0, /* 116 */ + 0, /* 117 */ + 0, /* 118 */ + 0, /* 119 */ + 0, /* KEY_MACRO 120 */ + 0, /* 121 */ + 0, /* 122 */ + 0, /* 123 */ + 0, /* 124 */ + 0, /* 125 */ + 0, /* KEY_KPPLUSMINUS 126 */ + 0, /* 127 */ + 0, /* KEY_SCALE 128 */ + 0, /* KEY_KPCOMMA 129 */ + 0, /* 130 */ + 0, /* 131 */ + 0, /* 132 */ + 0, /* 133 */ + 0, /* 134 */ + 0, /* 135 */ + 0, /* 136 */ + 0, /* 137 */ + 0, /* 138 */ + 0, /* 139 */ + 0, /* 140 */ + 0, /* 141 */ + 0, /* 142 */ + 0, /* 143 */ + 0, /* 144 */ + 0, /* 145 */ + 0, /* 146 */ + 0, /* KEY_MENU 147 */ + 0, /* KEY_CALC 148 */ + 0, /* KEY_SETUP 149 */ + 0, /* KEY_SLEEP 150 */ + 0, /* KEY_WAKEUP 151 */ + 0, /* KEY_FILE 152 */ + 0, /* KEY_SEND 153 */ + 0, /* KEY_DELETEFILE 154 */ + 0, /* KEY_XFER 155 */ + 0, /* KEY_PROG1 156 */ + 0, /* KEY_PROG2 157 */ + 0, /* KEY_WWW 158 */ + 0, /* KEY_MSDOS 159 */ + 0, /* KEY_COFFEE 160 */ + 0, /* KEY_DIRECTION 161 */ + 0, /* KEY_CYCLEWINDOWS 162 */ + 0, /* KEY_MAIL 163 */ + 0, /* KEY_BOOKMARKS 164 */ + 0, /* KEY_COMPUTER 165 */ + 0, /* KEY_BACK 166 */ + 0, /* KEY_FORWARD 167 */ + 0, /* KEY_CLOSECD 168 */ + 0, /* KEY_EJECTCD 169 */ + 0, /* KEY_EJECTCLOSECD 170 */ + 0, /* KEY_NEXTSONG 171 */ + 0, /* KEY_PLAYPAUSE 172 */ + 0, /* KEY_PREVIOUSSONG 173 */ + 0, /* KEY_STOPCD 174 */ + 0, /* KEY_RECORD 175 */ + 0, /* KEY_REWIND 176 */ + 0, /* KEY_PHONE 177 */ + 0, /* KEY_ISO 178 */ + 0, /* KEY_CONFIG 179 */ + 0, /* KEY_HOMEPAGE 180 */ + 0, /* KEY_REFRESH 181 */ + 0, /* KEY_EXIT 182 */ + 0, /* KEY_MOVE 183 */ + 0, /* KEY_EDIT 184 */ + 0, /* KEY_SCROLLUP 185 */ + 0, /* KEY_SCROLLDOWN 186 */ + 0, /* KEY_KPLEFTPAREN 187 */ + 0, /* KEY_KPRIGHTPAREN 188 */ + 0, /* KEY_NEW 189 */ + 0, /* KEY_REDO 190 */ + 0, /* 191 */ + 0, /* 192 */ + 0, /* 193 */ + 0, /* 194 */ + 0, /* 195 */ + 0, /* 196 */ + 0, /* 197 */ + 0, /* 198 */ + 0, /* 199 */ + 0, /* 200 */ + 0, /* 201 */ + 0, /* 202 */ + 0, /* 203 */ + 0, /* 204 */ + 0, /* 205 */ + 0, /* 206 */ + 0, /* 207 */ + 0, /* KEY_PLAYCD 208 */ + 0, /* KEY_PAUSECD 209 */ + 0, /* KEY_PROG3 210 */ + 0, /* KEY_PROG4 211 */ + 0, /* KEY_DASHBOARD 212 */ + 0, /* KEY_SUSPEND 213 */ + 0, /* KEY_CLOSE 214 */ + 0, /* KEY_PLAY 215 */ + 0, /* KEY_FASTFORWARD 216 */ + 0, /* KEY_BASSBOOST 217 */ + 0, /* KEY_PRINT 218 */ + 0, /* KEY_HP 219 */ + 0, /* KEY_CAMERA 220 */ + 0, /* KEY_SOUND 221 */ + 0, /* KEY_QUESTION 222 */ + 0, /* KEY_EMAIL 223 */ + 0, /* KEY_CHAT 224 */ + 0, /* KEY_SEARCH 225 */ + 0, /* KEY_CONNECT 226 */ + 0, /* KEY_FINANCE 227 */ + 0, /* KEY_SPORT 228 */ + 0, /* KEY_SHOP 229 */ + 0, /* KEY_ALTERASE 230 */ + 0, /* KEY_CANCEL 231 */ + 0, /* KEY_BRIGHTNESSDOWN 232 */ + 0, /* KEY_BRIGHTNESSUP 233 */ + 0, /* KEY_MEDIA 234 */ + 0, /* KEY_SWITCHVIDEOMODE 235 */ + 0, /* KEY_KBDILLUMTOGGLE 236 */ + 0, /* KEY_KBDILLUMDOWN 237 */ + 0, /* KEY_KBDILLUMUP 238 */ + 0, /* KEY_SEND 239 */ + 0, /* KEY_REPLY 240 */ + 0, /* KEY_FORWARDMAIL 241 */ + 0, /* KEY_SAVE 242 */ + 0, /* KEY_DOCUMENTS 243 */ + 0, /* KEY_BATTERY 244 */ + 0, /* KEY_BLUETOOTH 245 */ + 0, /* KEY_WLAN 246 */ + 0, /* KEY_UWB 247 */ + 0, /* KEY_UNKNOWN 248 */ + 0, /* KEY_VIDEO_NEXT 249 */ + 0, /* KEY_VIDEO_PREV 250 */ + 0, /* KEY_BRIGHTNESS_CYCLE 251 */ + 0, /* KEY_BRIGHTNESS_ZERO 252 */ + 0, /* KEY_DISPLAY_OFF 253 */ 0, /* 254 */ 0 /* 255 */ }; From 6c40fde892ae8d833802b60a67661812acfd63a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 4 Mar 2013 20:37:44 -0500 Subject: [PATCH 13/18] libwinpr-input: map most evdev keycodes --- libfreerdp/locale/keyboard_xkbfile.c | 25 +++ winpr/include/winpr/input.h | 25 +-- winpr/libwinpr/input/keycode.c | 221 ++++++++++++++------------- winpr/libwinpr/input/scancode.c | 65 ++++---- 4 files changed, 186 insertions(+), 150 deletions(-) diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index e0efb22fd..1113a6141 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -202,6 +203,30 @@ UINT32 freerdp_keyboard_init_xkbfile(UINT32 keyboardLayoutId, RDP_SCANCODE x11_k freerdp_keyboard_load_map_from_xkbfile(display, x11_keycode_to_rdp_scancode); +#if 1 + //ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); + + { + DWORD keycode; + DWORD vkcode; + DWORD scancode; + + for (keycode = 0; keycode < 256; keycode++) + { + vkcode = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_EVDEV); + scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); + + if (x11_keycode_to_rdp_scancode[keycode] != scancode) + { + printf("mismatch keycode 0x%04X (%d) -> vkcode 0x%04X (%s) -> scancode 0x%04X, expected: 0x%04X\n", + keycode, keycode, vkcode, GetVirtualKeyName(vkcode & 0xFF), scancode, x11_keycode_to_rdp_scancode[keycode]); + } + + x11_keycode_to_rdp_scancode[keycode] = scancode; + } + } +#endif + XCloseDisplay(display); return keyboardLayoutId; diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 67ab4995f..3edfaadb4 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -420,19 +420,19 @@ #define KBD4_T44 VK_F10 #define KBD4_T45 VK_NUMLOCK #define KBD4_T46 VK_SCROLL -#define KBD4_T47 VK_HOME -#define KBD4_T48 VK_UP -#define KBD4_T49 VK_PRIOR +#define KBD4_T47 VK_NUMPAD7 /* VK_HOME */ +#define KBD4_T48 VK_NUMPAD8 /* VK_UP */ +#define KBD4_T49 VK_NUMPAD9 /* VK_PRIOR */ #define KBD4_T4A VK_SUBTRACT -#define KBD4_T4B VK_LEFT -#define KBD4_T4C VK_CLEAR -#define KBD4_T4D VK_RIGHT +#define KBD4_T4B VK_NUMPAD4 /* VK_LEFT */ +#define KBD4_T4C VK_NUMPAD5 /* VK_CLEAR */ +#define KBD4_T4D VK_NUMPAD6 /* VK_RIGHT */ #define KBD4_T4E VK_ADD -#define KBD4_T4F VK_END -#define KBD4_T50 VK_DOWN -#define KBD4_T51 VK_NEXT -#define KBD4_T52 VK_INSERT -#define KBD4_T53 VK_DELETE +#define KBD4_T4F VK_NUMPAD1 /* VK_END */ +#define KBD4_T50 VK_NUMPAD2 /* VK_DOWN */ +#define KBD4_T51 VK_NUMPAD3 /* VK_NEXT */ +#define KBD4_T52 VK_NUMPAD0 /* VK_INSERT */ +#define KBD4_T53 VK_DECIMAL /* VK_DELETE */ #define KBD4_T54 VK_SNAPSHOT #define KBD4_T55 VK_NONE #define KBD4_T56 VK_OEM_102 /* NE */ @@ -492,7 +492,7 @@ #define KBD4_X35 VK_DIVIDE #define KBD4_X37 VK_SNAPSHOT #define KBD4_X38 VK_RMENU -#define KBD4_X46 VK_CANCEL +#define KBD4_X46 VK_PAUSE /* VK_CANCEL */ #define KBD4_X47 VK_HOME #define KBD4_X48 VK_UP #define KBD4_X49 VK_PRIOR @@ -848,6 +848,7 @@ WINPR_API DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKey WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType); #define KEYCODE_TYPE_APPLE 0x00000001 +#define KEYCODE_TYPE_EVDEV 0x00000002 WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags); diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index 80c0f8616..9d93b35af 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -300,6 +300,8 @@ DWORD KEYCODE_TO_VKCODE_APPLE[256] = * http://www.freedesktop.org/wiki/Software/XKeyboardConfig */ +/* TODO: Finish Japanese Keyboard */ + DWORD KEYCODE_TO_VKCODE_EVDEV[256] = { 0, /* 0 */ @@ -311,117 +313,117 @@ DWORD KEYCODE_TO_VKCODE_EVDEV[256] = 0, /* 6 */ 0, /* 7 */ 0, /* 8 */ - 0, /* 9 */ - 0, /* 10 */ - 0, /* 11 */ - 0, /* 12 */ - 0, /* 13 */ - 0, /* 14 */ - 0, /* 15 */ - 0, /* 16 */ - 0, /* 17 */ - 0, /* 18 */ - 0, /* 19 */ - 0, /* 20 */ - 0, /* 21 */ - 0, /* 22 */ - 0, /* 23 */ - 0, /* 24 */ - 0, /* 25 */ - 0, /* 26 */ - 0, /* 27 */ - 0, /* 28 */ - 0, /* 29 */ - 0, /* 30 */ - 0, /* 31 */ - 0, /* 32 */ - 0, /* 33 */ - 0, /* 34 */ - 0, /* 35 */ - 0, /* 36 */ - 0, /* 37 */ - 0, /* 38 */ - 0, /* 39 */ - 0, /* 40 */ - 0, /* 41 */ - 0, /* 42 */ - 0, /* 43 */ - 0, /* 44 */ - 0, /* 45 */ - 0, /* 46 */ - 0, /* 47 */ - 0, /* 48 */ - 0, /* 49 */ - 0, /* 50 */ - 0, /* 51 */ - 0, /* 52 */ - 0, /* 53 */ - 0, /* 54 */ - 0, /* 55 */ - 0, /* 56 */ - 0, /* 57 */ - 0, /* 58 */ - 0, /* 59 */ - 0, /* 60 */ - 0, /* 61 */ - 0, /* 62 */ - 0, /* 63 */ - 0, /* 64 */ - 0, /* 65 */ - 0, /* 66 */ - 0, /* 67 */ - 0, /* 68 */ - 0, /* 69 */ - 0, /* 70 */ - 0, /* 71 */ - 0, /* 72 */ - 0, /* 73 */ - 0, /* 74 */ - 0, /* 75 */ - 0, /* 76 */ - 0, /* 77 */ - 0, /* 78 */ - 0, /* 79 */ - 0, /* 80 */ - 0, /* 81 */ - 0, /* 82 */ - 0, /* 83 */ - 0, /* 84 */ - 0, /* 85 */ - 0, /* 86 */ - 0, /* 87 */ - 0, /* 88 */ - 0, /* 89 */ - 0, /* 90 */ - 0, /* 91 */ + VK_ESCAPE, /* 9 */ + VK_KEY_1, /* 10 */ + VK_KEY_2, /* 11 */ + VK_KEY_3, /* 12 */ + VK_KEY_4, /* 13 */ + VK_KEY_5, /* 14 */ + VK_KEY_6, /* 15 */ + VK_KEY_7, /* 16 */ + VK_KEY_8, /* 17 */ + VK_KEY_9, /* 18 */ + VK_KEY_0, /* 19 */ + VK_OEM_MINUS, /* 20 */ + VK_OEM_PLUS, /* 21 */ + VK_BACK, /* 22 */ + VK_TAB, /* 23 */ + VK_KEY_Q, /* 24 */ + VK_KEY_W, /* 25 */ + VK_KEY_E, /* 26 */ + VK_KEY_R, /* 27 */ + VK_KEY_T, /* 28 */ + VK_KEY_Y, /* 29 */ + VK_KEY_U, /* 30 */ + VK_KEY_I, /* 31 */ + VK_KEY_O, /* 32 */ + VK_KEY_P, /* 33 */ + VK_OEM_4, /* 34 */ + VK_OEM_6, /* 35 */ + VK_RETURN, /* 36 */ + VK_LCONTROL, /* 37 */ + VK_KEY_A, /* 38 */ + VK_KEY_S, /* 39 */ + VK_KEY_D, /* 40 */ + VK_KEY_F, /* 41 */ + VK_KEY_G, /* 42 */ + VK_KEY_H, /* 43 */ + VK_KEY_J, /* 44 */ + VK_KEY_K, /* 45 */ + VK_KEY_L, /* 46 */ + VK_OEM_1, /* 47 */ + VK_OEM_7, /* 48 */ + VK_OEM_3, /* 49 */ + VK_LSHIFT, /* 50 */ + VK_OEM_5, /* 51 */ + VK_KEY_Z, /* 52 */ + VK_KEY_X, /* 53 */ + VK_KEY_C, /* 54 */ + VK_KEY_V, /* 55 */ + VK_KEY_B, /* 56 */ + VK_KEY_N, /* 57 */ + VK_KEY_M, /* 58 */ + VK_OEM_COMMA, /* 59 */ + VK_OEM_PERIOD, /* 60 */ + VK_OEM_2, /* 61 */ + VK_RSHIFT, /* 62 */ + VK_MULTIPLY, /* 63 */ + VK_LMENU, /* 64 */ + VK_SPACE, /* 65 */ + VK_CAPITAL, /* 66 */ + VK_F1, /* 67 */ + VK_F2, /* 68 */ + VK_F3, /* 69 */ + VK_F4, /* 70 */ + VK_F5, /* 71 */ + VK_F6, /* 72 */ + VK_F7, /* 73 */ + VK_F8, /* 74 */ + VK_F9, /* 75 */ + VK_F10, /* 76 */ + VK_NUMLOCK, /* 77 */ + VK_SCROLL, /* 78 */ + VK_NUMPAD7, /* 79 */ + VK_NUMPAD8, /* 80 */ + VK_NUMPAD9, /* 81 */ + VK_SUBTRACT, /* 82 */ + VK_NUMPAD4, /* 83 */ + VK_NUMPAD5, /* 84 */ + VK_NUMPAD6, /* 85 */ + VK_ADD, /* 86 */ + VK_NUMPAD1, /* 87 */ + VK_NUMPAD2, /* 88 */ + VK_NUMPAD3, /* 89 */ + VK_NUMPAD0, /* 90 */ + VK_DECIMAL, /* 91 */ 0, /* 92 */ 0, /* 93 */ - 0, /* 94 */ - 0, /* 95 */ - 0, /* 96 */ - 0, /* 97 */ + VK_OEM_102, /* 94 */ + VK_F11, /* 95 */ + VK_F12, /* 96 */ + VK_ABNT_C1, /* 97 */ 0, /* 98 */ 0, /* 99 */ 0, /* 100 */ 0, /* 101 */ 0, /* 102 */ 0, /* 103 */ - 0, /* 104 */ - 0, /* 105 */ - 0, /* 106 */ - 0, /* 107 */ - 0, /* 108 */ + VK_RETURN | KBDEXT, /* 104 */ + VK_RCONTROL | KBDEXT, /* 105 */ + VK_DIVIDE | KBDEXT, /* 106 */ + VK_SNAPSHOT | KBDEXT, /* 107 */ + VK_RMENU | KBDEXT, /* 108 */ 0, /* KEY_LINEFEED 109 */ - 0, /* 110 */ - 0, /* 111 */ - 0, /* 112 */ - 0, /* 113 */ - 0, /* 114 */ - 0, /* 115 */ - 0, /* 116 */ - 0, /* 117 */ - 0, /* 118 */ - 0, /* 119 */ + VK_HOME | KBDEXT, /* 110 */ + VK_UP | KBDEXT, /* 111 */ + VK_PRIOR | KBDEXT, /* 112 */ + VK_LEFT | KBDEXT, /* 113 */ + VK_RIGHT | KBDEXT, /* 114 */ + VK_END | KBDEXT, /* 115 */ + VK_DOWN | KBDEXT, /* 116 */ + VK_NEXT | KBDEXT, /* 117 */ + VK_INSERT | KBDEXT, /* 118 */ + VK_DELETE | KBDEXT, /* 119 */ 0, /* KEY_MACRO 120 */ 0, /* 121 */ 0, /* 122 */ @@ -429,15 +431,15 @@ DWORD KEYCODE_TO_VKCODE_EVDEV[256] = 0, /* 124 */ 0, /* 125 */ 0, /* KEY_KPPLUSMINUS 126 */ - 0, /* 127 */ + VK_PAUSE | KBDEXT, /* 127 */ 0, /* KEY_SCALE 128 */ - 0, /* KEY_KPCOMMA 129 */ + VK_ABNT_C2, /* KEY_KPCOMMA 129 */ 0, /* 130 */ 0, /* 131 */ 0, /* 132 */ - 0, /* 133 */ - 0, /* 134 */ - 0, /* 135 */ + VK_LWIN | KBDEXT, /* 133 */ + VK_RWIN | KBDEXT, /* 134 */ + VK_APPS | KBDEXT, /* 135 */ 0, /* 136 */ 0, /* 137 */ 0, /* 138 */ @@ -571,6 +573,11 @@ DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags) if (keycode < 0xFF) vkcode = KEYCODE_TO_VKCODE_APPLE[keycode & 0xFF]; } + else if (dwFlags & KEYCODE_TYPE_EVDEV) + { + if (keycode < 0xFF) + vkcode = KEYCODE_TO_VKCODE_EVDEV[keycode & 0xFF]; + } if (!vkcode) vkcode = VK_NONE; diff --git a/winpr/libwinpr/input/scancode.c b/winpr/libwinpr/input/scancode.c index 5711f789a..d4a92ca8e 100644 --- a/winpr/libwinpr/input/scancode.c +++ b/winpr/libwinpr/input/scancode.c @@ -294,7 +294,7 @@ DWORD KBD4X[128] = VK_NONE, VK_NONE, VK_NONE, - VK_NONE + VK_NONE, }; /** @@ -576,19 +576,18 @@ DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType) if (dwKeyboardType == 4) { - if (scancode & KBDEXT) - vkcode = KBD4X[scancode & 0x7F]; - else - vkcode = KBD4T[scancode & 0x7F]; + if (vkcode < 128) + vkcode = (scancode & KBDEXT) ? KBD4X[scancode] : KBD4T[scancode]; } else if (dwKeyboardType == 7) { - if (scancode & KBDEXT) - vkcode = KBD7X[scancode & 0x7F]; - else - vkcode = KBD7T[scancode & 0x7F]; + if (vkcode < 128) + vkcode = (scancode & KBDEXT) ? KBD7X[scancode] : KBD7T[scancode]; } + if (!vkcode) + vkcode = VK_NONE; + return vkcode; } @@ -604,20 +603,22 @@ DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType) if (dwKeyboardType == 4) { - for (i = 0; i < 128; i++) - { - if (KBD4T[i] == vkcode) - { - scancode = i; - break; - } - } - - if (!scancode) + if (vkcode & KBDEXT) { for (i = 0; i < 128; i++) { - if (KBD4X[i] == vkcode) + if (KBD4X[i] == (vkcode & 0xFF)) + { + scancode = (i | KBDEXT); + break; + } + } + } + else + { + for (i = 0; i < 128; i++) + { + if (KBD4T[i] == (vkcode & 0xFF)) { scancode = i; break; @@ -627,20 +628,22 @@ DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType) } else if (dwKeyboardType == 7) { - for (i = 0; i < 128; i++) - { - if (KBD7T[i] == vkcode) - { - scancode = i; - break; - } - } - - if (!scancode) + if (vkcode & KBDEXT) { for (i = 0; i < 128; i++) { - if (KBD7X[i] == vkcode) + if (KBD7X[i] == (vkcode & 0xFF)) + { + scancode = (i | KBDEXT); + break; + } + } + } + else + { + for (i = 0; i < 128; i++) + { + if (KBD7T[i] == (vkcode & 0xFF)) { scancode = i; break; From 1630b80bda168f40664c2b65b0e575626841075b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 4 Mar 2013 21:27:56 -0500 Subject: [PATCH 14/18] libwinpr-input: added more japanese definitions --- winpr/include/winpr/input.h | 28 ++++++++++++++++++++++------ winpr/libwinpr/input/keycode.c | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 3edfaadb4..4fd82e337 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -39,6 +39,7 @@ /* * Virtual Key Codes (Windows): * http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731/ + * http://msdn.microsoft.com/en-us/library/ms927178.aspx */ /* Mouse buttons */ @@ -290,7 +291,8 @@ #define VK_OEM_8 0xDF /* Used for miscellaneous characters; it can vary by keyboard. */ /* 0xE0 is reserved */ -/* 0xE1 is OEM specific */ + +#define VK_OEM_AX 0xE1 /* AX key on Japanese AX keyboard */ #define VK_OEM_102 0xE2 /* Windows 2000/XP: Either the angle bracket key or */ /* the backslash key on the RT 102-key keyboard */ @@ -317,10 +319,29 @@ #define VK_ZOOM 0xFB /* Zoom key */ #define VK_NONAME 0xFC /* Reserved */ #define VK_PA1 0xFD /* PA1 key */ +#define VK_OEM_PA1 0xFD /* PA1 key */ #define VK_OEM_CLEAR 0xFE /* Clear key */ #define VK_NONE 0xFF /* no key */ +/** + * For East Asian Input Method Editors (IMEs) + * the following additional virtual keyboard definitions must be observed. + */ + +#define VK_DBE_ALPHANUMERIC 0xF0 /* Changes the mode to alphanumeric. */ +#define VK_DBE_KATAKANA 0xF1 /* Changes the mode to Katakana. */ +#define VK_DBE_HIRAGANA 0xF2 /* Changes the mode to Hiragana. */ +#define VK_DBE_SBCSCHAR 0xF3 /* Changes the mode to single-byte characters. */ +#define VK_DBE_DBCSCHAR 0xF4 /* Changes the mode to double-byte characters. */ +#define VK_DBE_ROMAN 0xF5 /* Changes the mode to Roman characters. */ +#define VK_DBE_NOROMAN 0xF6 /* Changes the mode to non-Roman characters. */ +#define VK_DBE_ENTERWORDREGISTERMODE 0xF7 /* Activates the word registration dialog box. */ +#define VK_DBE_ENTERIMECONFIGMODE 0xF8 /* Activates a dialog box for setting up an IME environment. */ +#define VK_DBE_FLUSHSTRING 0xF9 /* Deletes the undetermined string without determining it. */ +#define VK_DBE_CODEINPUT 0xFA /* Changes the mode to code input. */ +#define VK_DBE_NOCODEINPUT 0xFB /* Changes the mode to no-code input. */ + /** * TODO: fix the following definitions */ @@ -332,14 +353,9 @@ #define VK_OEM_AUTO 0xFF #define VK_OEM_PA3 0xFF #define VK_OEM_RESET 0xFF -#define VK_OEM_PA1 0xFF #define VK_OEM_PA2 0xFF #define VK_POWER 0xFF #define VK_LAUNCH_MEDIA_SELECT 0xFF -#define VK_DBE_KATAKANA 0xFF -#define VK_DBE_ALPHANUMERIC 0xFF -#define VK_DBE_SBCSCHAR 0xFF -#define VK_DBE_HIRAGANA 0xFF /* * Virtual Scan Codes diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index 9d93b35af..9f96df0aa 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -405,7 +405,7 @@ DWORD KEYCODE_TO_VKCODE_EVDEV[256] = 0, /* 98 */ 0, /* 99 */ 0, /* 100 */ - 0, /* 101 */ + VK_DBE_HIRAGANA, /* 101 */ 0, /* 102 */ 0, /* 103 */ VK_RETURN | KBDEXT, /* 104 */ From 75f80d019892fdef224ef530055c2ba52c99e58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 6 Mar 2013 12:50:25 -0500 Subject: [PATCH 15/18] libfreerdp-locale: cleanup solaris code --- client/Windows/wf_event.c | 2 +- client/X11/xf_keyboard.c | 4 +-- include/freerdp/locale/keyboard.h | 2 +- include/freerdp/scancode.h | 1 - libfreerdp/locale/keyboard.c | 4 +-- libfreerdp/locale/keyboard_sun.c | 35 ++++++++++++++--------- libfreerdp/locale/keyboard_sun.h | 8 +++--- libfreerdp/locale/keyboard_x11.c | 33 ++++------------------ libfreerdp/locale/keyboard_x11.h | 2 +- libfreerdp/locale/keyboard_xkbfile.c | 42 ++++++---------------------- libfreerdp/locale/keyboard_xkbfile.h | 6 ++-- 11 files changed, 50 insertions(+), 89 deletions(-) diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index b837d19c0..0c7fd8bd3 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -41,7 +41,7 @@ extern HCURSOR g_default_cursor; LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) { wfInfo* wfi; - RDP_SCANCODE rdp_scancode; + DWORD rdp_scancode; rdpInput* input; PKBDLLHOOKSTRUCT p; diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 3640ed54d..7f4849d1f 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -68,7 +68,7 @@ void xf_kbd_unset_keypress(xfInfo* xfi, BYTE keycode) void xf_kbd_release_all_keypress(xfInfo* xfi) { int keycode; - RDP_SCANCODE rdp_scancode; + DWORD rdp_scancode; for (keycode = 0; keycode < ARRAYSIZE(xfi->pressed_keys); keycode++) { @@ -89,7 +89,7 @@ BOOL xf_kbd_key_pressed(xfInfo* xfi, KeySym keysym) void xf_kbd_send_key(xfInfo* xfi, BOOL down, BYTE keycode) { - RDP_SCANCODE rdp_scancode; + DWORD rdp_scancode; rdpInput* input; input = xfi->instance->input; diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index 1ba6e2158..08b5eab07 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -202,7 +202,7 @@ typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; FREERDP_API UINT32 freerdp_keyboard_init(UINT32 keyboardLayoutId); FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(UINT32 types); FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(UINT32 keyboardLayoutId); -FREERDP_API RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode); +FREERDP_API DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode); FREERDP_API UINT32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(UINT32 scancode, BOOL extended); #endif /* FREERDP_LOCALE_KEYBOARD_H */ diff --git a/include/freerdp/scancode.h b/include/freerdp/scancode.h index 88f893a0b..f0bc3286b 100644 --- a/include/freerdp/scancode.h +++ b/include/freerdp/scancode.h @@ -29,7 +29,6 @@ * The extended flag is for all practical an important 9th bit with a strange encoding - not just a modifier. */ -typedef UINT32 RDP_SCANCODE; /* Our own representation of a RDP protocol scancode */ #define RDP_SCANCODE_CODE(_rdp_scancode) ((BYTE)(_rdp_scancode & 0xFF)) #define RDP_SCANCODE_EXTENDED(_rdp_scancode) (((_rdp_scancode) & KBDEXT) ? TRUE : FALSE) #define MAKE_RDP_SCANCODE(_code, _extended) (((_code) & 0xFF) | ((_extended) ? KBDEXT : 0)) diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index aca2666fc..9bec2a9b3 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -42,7 +42,7 @@ #endif UINT32 RDP_SCANCODE_TO_X11_KEYCODE[256][2]; -RDP_SCANCODE X11_KEYCODE_TO_RDP_SCANCODE[256]; +DWORD X11_KEYCODE_TO_RDP_SCANCODE[256]; UINT32 freerdp_detect_keyboard(UINT32 keyboardLayoutID) { @@ -91,7 +91,7 @@ UINT32 freerdp_keyboard_init(UINT32 keyboardLayoutId) return keyboardLayoutId; } -RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode) +DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode) { DEBUG_KBD("x11 keycode: %02X -> rdp code: %02X%s", keycode, RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode]), diff --git a/libfreerdp/locale/keyboard_sun.c b/libfreerdp/locale/keyboard_sun.c index d0b7f7234..5f8b62e17 100644 --- a/libfreerdp/locale/keyboard_sun.c +++ b/libfreerdp/locale/keyboard_sun.c @@ -25,6 +25,8 @@ #include #include +#include + #include "liblocale.h" #include @@ -202,18 +204,12 @@ static const SOLARIS_KEYBOARD SOLARIS_KEYBOARD_TABLE[] = { 6, 272, "sun(type6)", KBD_PORTUGUESE_BRAZILIAN_ABNT } /* Brazil6_usb */ }; -UINT32 freerdp_detect_keyboard_type_and_layout_solaris(char* keyboard_type, int length) +int freerdp_get_solaris_keyboard_layout_and_type(int* type, int* layout) { FILE* kbd; - - int i; - int type = 0; - int layout = 0; - char* pch; char* beg; char* end; - char buffer[1024]; /* @@ -226,10 +222,13 @@ UINT32 freerdp_detect_keyboard_type_and_layout_solaris(char* keyboard_type, int rate(ms)=40 */ + *type = 0; + *layout = 0; + kbd = popen("kbd -t -l", "r"); if (kbd < 0) - return 0; + return -1; while (fgets(buffer, sizeof(buffer), kbd) != NULL) { @@ -238,27 +237,37 @@ UINT32 freerdp_detect_keyboard_type_and_layout_solaris(char* keyboard_type, int beg = pch + sizeof("type=") - 1; end = strchr(beg, '\n'); end[0] = '\0'; - type = atoi(beg); + *type = atoi(beg); } else if ((pch = strstr(buffer, "layout=")) != NULL) { beg = pch + sizeof("layout=") - 1; end = strchr(beg, ' '); end[0] = '\0'; - layout = atoi(beg); + *layout = atoi(beg); } } + pclose(kbd); + return 0; +} + +DWORD freerdp_detect_solaris_keyboard_layout() +{ + int i; + int type; + int layout; + + if (freerdp_get_solaris_keyboard_layout_and_type(&type, &layout) < 0) + return 0; + for (i = 0; i < ARRAYSIZE(SOLARIS_KEYBOARD_TABLE); i++) { if (SOLARIS_KEYBOARD_TABLE[i].type == type) { if (SOLARIS_KEYBOARD_TABLE[i].layout == layout) - { - strncpy(keyboard_type, SOLARIS_KEYBOARD_TABLE[i].xkbType, length); return SOLARIS_KEYBOARD_TABLE[i].keyboardLayoutId; - } } } diff --git a/libfreerdp/locale/keyboard_sun.h b/libfreerdp/locale/keyboard_sun.h index 985e1e3ac..b7dd5a80d 100644 --- a/libfreerdp/locale/keyboard_sun.h +++ b/libfreerdp/locale/keyboard_sun.h @@ -17,9 +17,9 @@ * limitations under the License. */ -#ifndef __LOCALE_KEYBOARD_SUN_H -#define __LOCALE_KEYBOARD_SUN_H +#ifndef FREERDP_LOCALE_KEYBOARD_SUN_H +#define FREERDP_LOCALE_KEYBOARD_SUN_H -UINT32 freerdp_detect_keyboard_type_and_layout_solaris(char* keyboard_type, int length); +DWORD freerdp_detect_solaris_keyboard_layout(); -#endif /* __LOCALE_KEYBOARD_SUN_H */ +#endif /* FREERDP_LOCALE_KEYBOARD_SUN_H */ diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index 5376ca915..b78922516 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -36,10 +36,6 @@ #include "keyboard_x11.h" #include "xkb_layout_ids.h" -#ifdef WITH_SUN -#include "keyboard_sun.h" -#endif - UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_variant) { char* pch; @@ -69,7 +65,7 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var if ((pch = strstr(buffer, "_XKB_RULES_NAMES_BACKUP(STRING) = ")) != NULL) { /* "rules" */ - pch = strchr(&buffer[34], ','); // We assume it is xorg + pch = strchr(&buffer[34], ','); /* We assume it is xorg */ pch += 1; /* "type" */ @@ -140,6 +136,7 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var variant = beg; } } + pclose(xprop); DEBUG_KBD("_XKB_RULES_NAMES layout: %s, variant: %s", layout, variant); @@ -206,34 +203,24 @@ char* freerdp_detect_keymap_from_xkb() return keymap; } -UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]) +UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) { DWORD vkcode; DWORD keycode; DWORD keycode_to_vkcode[256]; ZeroMemory(keycode_to_vkcode, sizeof(keycode_to_vkcode)); - ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); + ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(DWORD) * 256); #ifdef __APPLE__ - for (keycode = 0; keycode < 256; keycode++) { keycode_to_vkcode[keycode] = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_APPLE); } - -#elif defined(WITH_SUN) - { - char sunkeymap[32]; - - freerdp_detect_keyboard_type_and_layout_solaris(sunkeymap, sizeof(sunkeymap)); - freerdp_keyboard_load_map(keycode_to_vkcode, sunkeymap); - } #else { - char* keymap; - char* xkb_layout = 0; - char* xkb_variant = 0; + char* xkb_layout = NULL; + char* xkb_variant = NULL; if (keyboardLayoutId == 0) { @@ -245,14 +232,6 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco if (xkb_variant) free(xkb_variant); } - - keymap = freerdp_detect_keymap_from_xkb(); - - if (keymap) - { - freerdp_keyboard_load_maps(keycode_to_vkcode, keymap); - free(keymap); - } } #endif diff --git a/libfreerdp/locale/keyboard_x11.h b/libfreerdp/locale/keyboard_x11.h index 77dece1c9..b9c81d06d 100644 --- a/libfreerdp/locale/keyboard_x11.h +++ b/libfreerdp/locale/keyboard_x11.h @@ -20,6 +20,6 @@ #ifndef __LOCALE_KEYBOARD_X11_H #define __LOCALE_KEYBOARD_X11_H -UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]); +UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]); #endif /* __LOCALE_KEYBOARD_X11_H */ diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index 1113a6141..1a44d7c19 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -44,7 +44,7 @@ struct _XKB_KEY_NAME_SCANCODE { const char* xkb_keyname; /* XKB keyname */ - RDP_SCANCODE rdp_scancode; + DWORD rdp_scancode; }; typedef struct _XKB_KEY_NAME_SCANCODE XKB_KEY_NAME_SCANCODE; @@ -170,7 +170,7 @@ void* freerdp_keyboard_xkb_init() Display* display = XOpenDisplay(NULL); - if (display == NULL) + if (!display) return NULL; status = XkbQueryExtension(display, NULL, NULL, NULL, NULL, NULL); @@ -181,11 +181,11 @@ void* freerdp_keyboard_xkb_init() return (void*) display; } -UINT32 freerdp_keyboard_init_xkbfile(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]) +DWORD freerdp_keyboard_init_xkbfile(DWORD keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) { void* display; - ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); + ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(DWORD) * 256); display = freerdp_keyboard_xkb_init(); @@ -203,30 +203,6 @@ UINT32 freerdp_keyboard_init_xkbfile(UINT32 keyboardLayoutId, RDP_SCANCODE x11_k freerdp_keyboard_load_map_from_xkbfile(display, x11_keycode_to_rdp_scancode); -#if 1 - //ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); - - { - DWORD keycode; - DWORD vkcode; - DWORD scancode; - - for (keycode = 0; keycode < 256; keycode++) - { - vkcode = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_EVDEV); - scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); - - if (x11_keycode_to_rdp_scancode[keycode] != scancode) - { - printf("mismatch keycode 0x%04X (%d) -> vkcode 0x%04X (%s) -> scancode 0x%04X, expected: 0x%04X\n", - keycode, keycode, vkcode, GetVirtualKeyName(vkcode & 0xFF), scancode, x11_keycode_to_rdp_scancode[keycode]); - } - - x11_keycode_to_rdp_scancode[keycode] = scancode; - } - } -#endif - XCloseDisplay(display); return keyboardLayoutId; @@ -254,12 +230,12 @@ static char* comma_substring(char* s, int n) return s; } -UINT32 detect_keyboard_layout_from_xkbfile(void* display) +DWORD detect_keyboard_layout_from_xkbfile(void* display) { char* layout; char* variant; - UINT32 group = 0; - UINT32 keyboard_layout = 0; + DWORD group = 0; + DWORD keyboard_layout = 0; XkbRF_VarDefsRec rules_names; XKeyboardState coreKbdState; XkbStateRec state; @@ -295,7 +271,7 @@ UINT32 detect_keyboard_layout_from_xkbfile(void* display) return keyboard_layout; } -int freerdp_keyboard_load_map_from_xkbfile(void* display, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]) +int freerdp_keyboard_load_map_from_xkbfile(void* display, DWORD x11_keycode_to_rdp_scancode[256]) { int i, j; BOOL found; @@ -316,8 +292,6 @@ int freerdp_keyboard_load_map_from_xkbfile(void* display, RDP_SCANCODE x11_keyco if (strlen(xkb_keyname) < 1) continue; - printf("XKB KeyName: %s\n", xkb_keyname); - for (j = 0; j < ARRAYSIZE(XKB_KEY_NAME_SCANCODE_TABLE); j++) { if (!strcmp(xkb_keyname, XKB_KEY_NAME_SCANCODE_TABLE[j].xkb_keyname)) diff --git a/libfreerdp/locale/keyboard_xkbfile.h b/libfreerdp/locale/keyboard_xkbfile.h index 9205bd13d..06bdb9682 100644 --- a/libfreerdp/locale/keyboard_xkbfile.h +++ b/libfreerdp/locale/keyboard_xkbfile.h @@ -23,8 +23,8 @@ #include #include -UINT32 freerdp_keyboard_init_xkbfile(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]); -UINT32 detect_keyboard_layout_from_xkbfile(void* display); -int freerdp_keyboard_load_map_from_xkbfile(void* display, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]); +DWORD freerdp_keyboard_init_xkbfile(DWORD keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]); +DWORD detect_keyboard_layout_from_xkbfile(void* display); +int freerdp_keyboard_load_map_from_xkbfile(void* display, DWORD x11_keycode_to_rdp_scancode[256]); #endif /* __LOCALE_KEYBOARD_XKB_H */ From 24a1275c9191a46b8c9ab76318663121fb83520e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 6 Mar 2013 16:35:50 -0500 Subject: [PATCH 16/18] libfreerdp-locale: cleanup layout detection --- include/freerdp/locale/keyboard.h | 12 ++-- include/freerdp/locale/locale.h | 6 +- libfreerdp/locale/CMakeLists.txt | 6 +- libfreerdp/locale/keyboard.c | 84 ++++++++++++++++++++-------- libfreerdp/locale/keyboard_layout.c | 12 ++-- libfreerdp/locale/keyboard_x11.c | 69 +++-------------------- libfreerdp/locale/keyboard_x11.h | 8 +-- libfreerdp/locale/keyboard_xkbfile.c | 10 ++-- libfreerdp/locale/keyboard_xkbfile.h | 3 +- libfreerdp/locale/locale.c | 14 ++--- 10 files changed, 104 insertions(+), 120 deletions(-) diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index 08b5eab07..3e57e0b32 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -32,7 +32,7 @@ struct _RDP_KEYBOARD_LAYOUT { - UINT32 code; /* Keyboard layout code */ + DWORD code; /* Keyboard layout code */ char* name; /* Keyboard layout name */ }; typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; @@ -199,10 +199,10 @@ typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; #define KBD_TYPE_NOKIA_9140 0x00000006 /* Nokia 9140 and similar keyboards */ #define KBD_TYPE_JAPANESE 0x00000007 /* Japanese keyboard */ -FREERDP_API UINT32 freerdp_keyboard_init(UINT32 keyboardLayoutId); -FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(UINT32 types); -FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(UINT32 keyboardLayoutId); -FREERDP_API DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode); -FREERDP_API UINT32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(UINT32 scancode, BOOL extended); +FREERDP_API DWORD freerdp_keyboard_init(DWORD keyboardLayoutId); +FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types); +FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutId); +FREERDP_API DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode); +FREERDP_API DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL extended); #endif /* FREERDP_LOCALE_KEYBOARD_H */ diff --git a/include/freerdp/locale/locale.h b/include/freerdp/locale/locale.h index 54dfb391c..1c00601b4 100644 --- a/include/freerdp/locale/locale.h +++ b/include/freerdp/locale/locale.h @@ -230,8 +230,8 @@ #define YORUBA 0x046A #define ZULU 0x0435 -FREERDP_API UINT32 freerdp_get_system_locale_id(void); -FREERDP_API UINT32 freerdp_detect_keyboard_layout_from_system_locale(void); -FREERDP_API const char* freerdp_get_system_locale_name_from_id(UINT32 localeId); +FREERDP_API DWORD freerdp_get_system_locale_id(void); +FREERDP_API DWORD freerdp_detect_keyboard_layout_from_system_locale(void); +FREERDP_API const char* freerdp_get_system_locale_name_from_id(DWORD localeId); #endif /* FREERDP_LOCALE_H */ diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index e89dac395..a46a0822f 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -26,13 +26,11 @@ set(${MODULE_PREFIX}_SRCS liblocale.h) set(${MODULE_PREFIX}_X11_SRCS + keyboard_x11.c + keyboard_x11.h xkb_layout_ids.c xkb_layout_ids.h) -set(${MODULE_PREFIX}_X11_KEYMAP_SRCS - keyboard_x11.c - keyboard_x11.h) - set(${MODULE_PREFIX}_XKBFILE_SRCS keyboard_xkbfile.c keyboard_xkbfile.h) diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 9bec2a9b3..294cf7ca7 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -33,6 +33,7 @@ #include "liblocale.h" #ifdef WITH_X11 + #include "keyboard_x11.h" #ifdef WITH_XKBFILE @@ -41,43 +42,80 @@ #endif -UINT32 RDP_SCANCODE_TO_X11_KEYCODE[256][2]; +DWORD RDP_SCANCODE_TO_X11_KEYCODE[256][2]; DWORD X11_KEYCODE_TO_RDP_SCANCODE[256]; -UINT32 freerdp_detect_keyboard(UINT32 keyboardLayoutID) +int freerdp_detect_keyboard(DWORD* keyboardLayoutId) { - if (keyboardLayoutID != 0) - DEBUG_KBD("keyboard layout configuration: %X", keyboardLayoutID); + if (*keyboardLayoutId == 0) + freerdp_detect_keyboard_layout_from_xkb(keyboardLayoutId); - if (keyboardLayoutID == 0) - { - keyboardLayoutID = freerdp_detect_keyboard_layout_from_system_locale(); - DEBUG_KBD("detect_keyboard_layout_from_locale: %X", keyboardLayoutID); - } + if (*keyboardLayoutId == 0) + *keyboardLayoutId = freerdp_detect_keyboard_layout_from_system_locale(); - if (keyboardLayoutID == 0) - { - keyboardLayoutID = 0x0409; - DEBUG_KBD("using default keyboard layout: %X", keyboardLayoutID); - } + if (*keyboardLayoutId == 0) + *keyboardLayoutId = 0x0409; - return keyboardLayoutID; + return 0; } -UINT32 freerdp_keyboard_init(UINT32 keyboardLayoutId) +int freerdp_keyboard_init_apple(DWORD* keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) { - UINT32 keycode; + DWORD vkcode; + DWORD keycode; + DWORD keycode_to_vkcode[256]; + + ZeroMemory(keycode_to_vkcode, sizeof(keycode_to_vkcode)); + + for (keycode = 0; keycode < 256; keycode++) + { + vkcode = keycode_to_vkcode[keycode] = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_APPLE); + x11_keycode_to_rdp_scancode[keycode] = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); + } + + return 0; +} + +int freerdp_keyboard_init_x11_evdev(DWORD* keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) +{ + DWORD vkcode; + DWORD keycode; + DWORD keycode_to_vkcode[256]; + + ZeroMemory(keycode_to_vkcode, sizeof(keycode_to_vkcode)); + + for (keycode = 0; keycode < 256; keycode++) + { + vkcode = keycode_to_vkcode[keycode] = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_EVDEV); + x11_keycode_to_rdp_scancode[keycode] = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); + } + + return 0; +} + +DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) +{ + DWORD keycode; + int status = -1; + +#ifdef __APPLE__ + if (status < 0) + status = freerdp_keyboard_init_apple(&keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); +#endif #ifdef WITH_X11 #ifdef WITH_XKBFILE - keyboardLayoutId = freerdp_keyboard_init_xkbfile(keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); -#else - keyboardLayoutId = freerdp_keyboard_init_x11(keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); + if (status < 0) + status = freerdp_keyboard_init_xkbfile(&keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); #endif + if (status < 0) + status = freerdp_keyboard_init_x11_evdev(&keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); + #endif - keyboardLayoutId = freerdp_detect_keyboard(keyboardLayoutId); + + freerdp_detect_keyboard(&keyboardLayoutId); ZeroMemory(RDP_SCANCODE_TO_X11_KEYCODE, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); @@ -91,7 +129,7 @@ UINT32 freerdp_keyboard_init(UINT32 keyboardLayoutId) return keyboardLayoutId; } -DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode) +DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode) { DEBUG_KBD("x11 keycode: %02X -> rdp code: %02X%s", keycode, RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode]), @@ -100,7 +138,7 @@ DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UINT32 keycode) return X11_KEYCODE_TO_RDP_SCANCODE[keycode]; } -UINT32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(UINT32 scancode, BOOL extended) +DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL extended) { if (extended) return RDP_SCANCODE_TO_X11_KEYCODE[scancode][1]; diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index f84f6fe87..bbc5bbdbf 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -128,8 +128,8 @@ static const RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT_TABLE[] = struct _RDP_KEYBOARD_LAYOUT_VARIANT { - UINT32 code; /* Keyboard layout code */ - UINT32 id; /* Keyboard variant ID */ + DWORD code; /* Keyboard layout code */ + DWORD id; /* Keyboard variant ID */ const char* name; /* Keyboard layout variant name */ }; typedef struct _RDP_KEYBOARD_LAYOUT_VARIANT RDP_KEYBOARD_LAYOUT_VARIANT; @@ -185,7 +185,7 @@ static const RDP_KEYBOARD_LAYOUT_VARIANT RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[] = struct _RDP_KEYBOARD_IME { - UINT32 code; /* Keyboard layout code */ + DWORD code; /* Keyboard layout code */ const char* file; /* IME file */ const char* name; /* Keyboard layout name */ }; @@ -214,7 +214,7 @@ static const RDP_KEYBOARD_IME RDP_KEYBOARD_IME_TABLE[] = { KBD_CHINESE_TRADITIONAL_ALPHANUMERIC, "romanime.ime", "Chinese (Traditional) - Alphanumeric" } }; -RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(UINT32 types) +RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types) { int num, length, i; RDP_KEYBOARD_LAYOUT* layouts; @@ -256,12 +256,12 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(UINT32 types) } } - memset(&layouts[num], 0, sizeof(RDP_KEYBOARD_LAYOUT)); + ZeroMemory(&layouts[num], sizeof(RDP_KEYBOARD_LAYOUT)); return layouts; } -const char* freerdp_keyboard_get_layout_name_from_id(UINT32 keyboardLayoutID) +const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutID) { int i; diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index b78922516..0187de9bf 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -36,7 +36,7 @@ #include "keyboard_x11.h" #include "xkb_layout_ids.h" -UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_variant) +int freerdp_detect_keyboard_layout_from_xkb(DWORD* keyboardLayoutId) { char* pch; char* beg; @@ -45,7 +45,6 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var char buffer[1024]; char* layout = NULL; char* variant = NULL; - UINT32 keyboardLayoutId = 0; /* We start by looking for _XKB_RULES_NAMES_BACKUP which appears to be used by libxklavier */ @@ -90,17 +89,14 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var variant = beg; } } + pclose(xprop); DEBUG_KBD("_XKB_RULES_NAMES_BACKUP layout: %s, variant: %s", layout, variant); - keyboardLayoutId = find_keyboard_layout_in_xorg_rules(layout, variant); + *keyboardLayoutId = find_keyboard_layout_in_xorg_rules(layout, variant); - if (keyboardLayoutId > 0) - { - *xkb_layout = _strdup(layout); - *xkb_variant = _strdup(variant); - return keyboardLayoutId; - } + if (*keyboardLayoutId > 0) + return 0; /* Check _XKB_RULES_NAMES if _XKB_RULES_NAMES_BACKUP fails */ @@ -140,14 +136,10 @@ UINT32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var pclose(xprop); DEBUG_KBD("_XKB_RULES_NAMES layout: %s, variant: %s", layout, variant); - keyboardLayoutId = find_keyboard_layout_in_xorg_rules(layout, variant); + *keyboardLayoutId = find_keyboard_layout_in_xorg_rules(layout, variant); - if (keyboardLayoutId > 0) - { - *xkb_layout = _strdup(layout); - *xkb_variant = _strdup(variant); - return keyboardLayoutId; - } + if (*keyboardLayoutId > 0) + return *keyboardLayoutId; return 0; } @@ -202,48 +194,3 @@ char* freerdp_detect_keymap_from_xkb() return keymap; } - -UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) -{ - DWORD vkcode; - DWORD keycode; - DWORD keycode_to_vkcode[256]; - - ZeroMemory(keycode_to_vkcode, sizeof(keycode_to_vkcode)); - ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(DWORD) * 256); - -#ifdef __APPLE__ - for (keycode = 0; keycode < 256; keycode++) - { - keycode_to_vkcode[keycode] = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_APPLE); - } -#else - { - char* xkb_layout = NULL; - char* xkb_variant = NULL; - - if (keyboardLayoutId == 0) - { - keyboardLayoutId = freerdp_detect_keyboard_layout_from_xkb(&xkb_layout, &xkb_variant); - - if (xkb_layout) - free(xkb_layout); - - if (xkb_variant) - free(xkb_variant); - } - } -#endif - - for (keycode = 0; keycode < 256; keycode++) - { - vkcode = keycode_to_vkcode[keycode]; - - if (vkcode >= 0xFF) - continue; - - x11_keycode_to_rdp_scancode[keycode] = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); - } - - return keyboardLayoutId; -} diff --git a/libfreerdp/locale/keyboard_x11.h b/libfreerdp/locale/keyboard_x11.h index b9c81d06d..7567f6b45 100644 --- a/libfreerdp/locale/keyboard_x11.h +++ b/libfreerdp/locale/keyboard_x11.h @@ -17,9 +17,9 @@ * limitations under the License. */ -#ifndef __LOCALE_KEYBOARD_X11_H -#define __LOCALE_KEYBOARD_X11_H +#ifndef FREERDP_LOCALE_KEYBOARD_X11_H +#define FREERDP_LOCALE_KEYBOARD_X11_H -UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]); +int freerdp_detect_keyboard_layout_from_xkb(DWORD* keyboardLayoutId); -#endif /* __LOCALE_KEYBOARD_X11_H */ +#endif /* FREERDP_LOCALE_KEYBOARD_X11_H */ diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index 1a44d7c19..68e4a6f32 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -181,7 +181,7 @@ void* freerdp_keyboard_xkb_init() return (void*) display; } -DWORD freerdp_keyboard_init_xkbfile(DWORD keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) +int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) { void* display; @@ -192,12 +192,12 @@ DWORD freerdp_keyboard_init_xkbfile(DWORD keyboardLayoutId, DWORD x11_keycode_to if (!display) { DEBUG_KBD("Error initializing xkb"); - return 0; + return -1; } - if (keyboardLayoutId == 0) + if (*keyboardLayoutId == 0) { - keyboardLayoutId = detect_keyboard_layout_from_xkbfile(display); + *keyboardLayoutId = detect_keyboard_layout_from_xkbfile(display); DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboardLayoutId); } @@ -205,7 +205,7 @@ DWORD freerdp_keyboard_init_xkbfile(DWORD keyboardLayoutId, DWORD x11_keycode_to XCloseDisplay(display); - return keyboardLayoutId; + return 0; } /* return substring starting after nth comma, ending at following comma */ diff --git a/libfreerdp/locale/keyboard_xkbfile.h b/libfreerdp/locale/keyboard_xkbfile.h index 06bdb9682..a69209f1b 100644 --- a/libfreerdp/locale/keyboard_xkbfile.h +++ b/libfreerdp/locale/keyboard_xkbfile.h @@ -23,7 +23,8 @@ #include #include -DWORD freerdp_keyboard_init_xkbfile(DWORD keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]); +int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]); + DWORD detect_keyboard_layout_from_xkbfile(void* display); int freerdp_keyboard_load_map_from_xkbfile(void* display, DWORD x11_keycode_to_rdp_scancode[256]); diff --git a/libfreerdp/locale/locale.c b/libfreerdp/locale/locale.c index ba60498b3..6e530cbb1 100644 --- a/libfreerdp/locale/locale.c +++ b/libfreerdp/locale/locale.c @@ -35,7 +35,7 @@ struct _SYSTEM_LOCALE { char language[4]; /* Two or three letter language code */ char country[10]; /* Two or three letter country code (Sometimes with Cyrl_ prefix) */ - UINT32 code; /* 32-bit unsigned integer corresponding to the locale */ + DWORD code; /* 32-bit unsigned integer corresponding to the locale */ }; typedef struct _SYSTEM_LOCALE SYSTEM_LOCALE; @@ -249,7 +249,7 @@ static const SYSTEM_LOCALE SYSTEM_LOCALE_TABLE[] = struct _LOCALE_NAME { - UINT32 localeId; + DWORD localeId; const char* name; }; typedef struct _LOCALE_NAME LOCALE_NAME; @@ -459,8 +459,8 @@ static const LOCALE_NAME LOCALE_NAME_TABLE[] = struct _LOCALE_KEYBOARD_LAYOUTS { - UINT32 locale; /* Locale ID */ - UINT32 keyboardLayouts[5]; /* array of associated keyboard layouts */ + DWORD locale; /* Locale ID */ + DWORD keyboardLayouts[5]; /* array of associated keyboard layouts */ }; typedef struct _LOCALE_KEYBOARD_LAYOUTS LOCALE_KEYBOARD_LAYOUTS; @@ -692,7 +692,7 @@ SYSTEM_LOCALE* freerdp_detect_system_locale() return locale; } -UINT32 freerdp_get_system_locale_id() +DWORD freerdp_get_system_locale_id() { SYSTEM_LOCALE* locale; @@ -704,7 +704,7 @@ UINT32 freerdp_get_system_locale_id() return 0; } -const char* freerdp_get_system_locale_name_from_id(UINT32 localeId) +const char* freerdp_get_system_locale_name_from_id(DWORD localeId) { int index; @@ -717,7 +717,7 @@ const char* freerdp_get_system_locale_name_from_id(UINT32 localeId) return NULL; } -UINT32 freerdp_detect_keyboard_layout_from_system_locale() +DWORD freerdp_detect_keyboard_layout_from_system_locale() { int i, j; char language[4]; From 72957e39eb555995ee762570c0d39e76a6af3153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 6 Mar 2013 17:43:41 -0500 Subject: [PATCH 17/18] libwinpr-input: started mapping XKB keynames to virtual key codes --- include/freerdp/locale/locale.h | 2 +- libfreerdp/locale/keyboard.c | 4 +- libfreerdp/locale/keyboard_xkbfile.c | 17 ++-- libfreerdp/locale/keyboard_xkbfile.h | 2 +- libfreerdp/locale/locale.c | 26 +++-- winpr/include/winpr/input.h | 1 + winpr/libwinpr/input/virtualkey.c | 138 +++++++++++++++++++++++++++ 7 files changed, 169 insertions(+), 21 deletions(-) diff --git a/include/freerdp/locale/locale.h b/include/freerdp/locale/locale.h index 1c00601b4..c36c1027b 100644 --- a/include/freerdp/locale/locale.h +++ b/include/freerdp/locale/locale.h @@ -231,7 +231,7 @@ #define ZULU 0x0435 FREERDP_API DWORD freerdp_get_system_locale_id(void); -FREERDP_API DWORD freerdp_detect_keyboard_layout_from_system_locale(void); FREERDP_API const char* freerdp_get_system_locale_name_from_id(DWORD localeId); +FREERDP_API int freerdp_detect_keyboard_layout_from_system_locale(DWORD* keyboardLayoutId); #endif /* FREERDP_LOCALE_H */ diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 294cf7ca7..edcc39bd0 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -51,10 +51,10 @@ int freerdp_detect_keyboard(DWORD* keyboardLayoutId) freerdp_detect_keyboard_layout_from_xkb(keyboardLayoutId); if (*keyboardLayoutId == 0) - *keyboardLayoutId = freerdp_detect_keyboard_layout_from_system_locale(); + freerdp_detect_keyboard_layout_from_system_locale(keyboardLayoutId); if (*keyboardLayoutId == 0) - *keyboardLayoutId = 0x0409; + *keyboardLayoutId = ENGLISH_UNITED_STATES; return 0; } diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index 68e4a6f32..2215e6fc7 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -184,7 +184,7 @@ void* freerdp_keyboard_xkb_init() int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]) { void* display; - + ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(DWORD) * 256); display = freerdp_keyboard_xkb_init(); @@ -197,7 +197,7 @@ int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_ if (*keyboardLayoutId == 0) { - *keyboardLayoutId = detect_keyboard_layout_from_xkbfile(display); + detect_keyboard_layout_from_xkbfile(display, keyboardLayoutId); DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboardLayoutId); } @@ -211,7 +211,7 @@ int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_ /* return substring starting after nth comma, ending at following comma */ static char* comma_substring(char* s, int n) { - char *p; + char* p; if (!s) return ""; @@ -230,15 +230,14 @@ static char* comma_substring(char* s, int n) return s; } -DWORD detect_keyboard_layout_from_xkbfile(void* display) +int detect_keyboard_layout_from_xkbfile(void* display, DWORD* keyboardLayoutId) { char* layout; char* variant; DWORD group = 0; - DWORD keyboard_layout = 0; - XkbRF_VarDefsRec rules_names; - XKeyboardState coreKbdState; XkbStateRec state; + XKeyboardState coreKbdState; + XkbRF_VarDefsRec rules_names; DEBUG_KBD("display: %p", display); @@ -260,7 +259,7 @@ DWORD detect_keyboard_layout_from_xkbfile(void* display) DEBUG_KBD("layout: %s", layout ? layout : ""); DEBUG_KBD("variant: %s", variant ? variant : ""); - keyboard_layout = find_keyboard_layout_in_xorg_rules(layout, variant); + *keyboardLayoutId = find_keyboard_layout_in_xorg_rules(layout, variant); free(rules_names.model); free(rules_names.layout); @@ -268,7 +267,7 @@ DWORD detect_keyboard_layout_from_xkbfile(void* display) free(rules_names.options); } - return keyboard_layout; + return 0; } int freerdp_keyboard_load_map_from_xkbfile(void* display, DWORD x11_keycode_to_rdp_scancode[256]) diff --git a/libfreerdp/locale/keyboard_xkbfile.h b/libfreerdp/locale/keyboard_xkbfile.h index a69209f1b..9218f6378 100644 --- a/libfreerdp/locale/keyboard_xkbfile.h +++ b/libfreerdp/locale/keyboard_xkbfile.h @@ -25,7 +25,7 @@ int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_rdp_scancode[256]); -DWORD detect_keyboard_layout_from_xkbfile(void* display); +int detect_keyboard_layout_from_xkbfile(void* display, DWORD* keyboardLayoutId); int freerdp_keyboard_load_map_from_xkbfile(void* display, DWORD x11_keycode_to_rdp_scancode[256]); #endif /* __LOCALE_KEYBOARD_XKB_H */ diff --git a/libfreerdp/locale/locale.c b/libfreerdp/locale/locale.c index 6e530cbb1..4b7b5d41e 100644 --- a/libfreerdp/locale/locale.c +++ b/libfreerdp/locale/locale.c @@ -717,7 +717,7 @@ const char* freerdp_get_system_locale_name_from_id(DWORD localeId) return NULL; } -DWORD freerdp_detect_keyboard_layout_from_system_locale() +int freerdp_detect_keyboard_layout_from_system_locale(DWORD* keyboardLayoutId) { int i, j; char language[4]; @@ -727,12 +727,15 @@ DWORD freerdp_detect_keyboard_layout_from_system_locale() freerdp_get_system_language_and_country_codes(language, country); if ((strcmp(language, "C") == 0) || (strcmp(language, "POSIX") == 0)) - return ENGLISH_UNITED_STATES; /* U.S. Keyboard Layout */ + { + *keyboardLayoutId = ENGLISH_UNITED_STATES; /* U.S. Keyboard Layout */ + return 0; + } locale = freerdp_detect_system_locale(); - if (locale == NULL) - return 0; + if (!locale) + return -1; DEBUG_KBD("Found locale : %s_%s", locale->language, locale->country); @@ -741,6 +744,7 @@ DWORD freerdp_detect_keyboard_layout_from_system_locale() if (LOCALE_KEYBOARD_LAYOUTS_TABLE[i].locale == locale->code) { /* Locale found in list of default keyboard layouts */ + for (j = 0; j < 5; j++) { if (LOCALE_KEYBOARD_LAYOUTS_TABLE[i].keyboardLayouts[j] == ENGLISH_UNITED_STATES) @@ -753,7 +757,8 @@ DWORD freerdp_detect_keyboard_layout_from_system_locale() } else { - return LOCALE_KEYBOARD_LAYOUTS_TABLE[i].keyboardLayouts[j]; + *keyboardLayoutId = LOCALE_KEYBOARD_LAYOUTS_TABLE[i].keyboardLayouts[j]; + return 0; } } @@ -763,11 +768,16 @@ DWORD freerdp_detect_keyboard_layout_from_system_locale() */ if (j >= 1) - return ENGLISH_UNITED_STATES; - else + { + *keyboardLayoutId = ENGLISH_UNITED_STATES; return 0; + } + else + { + return -1; + } } } - return 0; /* Could not detect the current keyboard layout from locale */ + return -1; /* Could not detect the current keyboard layout from locale */ } diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 4fd82e337..87b0a8ea9 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -859,6 +859,7 @@ WINPR_API char* GetVirtualKeyName(DWORD vkcode); WINPR_API DWORD GetVirtualKeyCodeFromName(const char* vkname); +WINPR_API DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname); WINPR_API DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType); WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType); diff --git a/winpr/libwinpr/input/virtualkey.c b/winpr/libwinpr/input/virtualkey.c index 93aee3610..29dba4e6a 100644 --- a/winpr/libwinpr/input/virtualkey.c +++ b/winpr/libwinpr/input/virtualkey.c @@ -296,6 +296,129 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = { 0, NULL } }; +struct _XKB_KEYNAME +{ + const char* name; + DWORD vkcode; +}; +typedef struct _XKB_KEYNAME XKB_KEYNAME; + +XKB_KEYNAME XKB_KEYNAME_TABLE[] = +{ + { "BKSP", VK_BACK }, + { "TAB", VK_TAB }, + { "RTRN", VK_RETURN }, + { "LFSH", VK_LSHIFT }, + { "LALT", VK_LMENU }, + { "CAPS", VK_CAPITAL }, + { "ESC", VK_ESCAPE }, + { "SPCE", VK_SPACE }, + { "AE10", VK_KEY_0 }, + { "AE01", VK_KEY_1 }, + { "AE02", VK_KEY_2 }, + { "AE03", VK_KEY_3 }, + { "AE04", VK_KEY_4 }, + { "AE05", VK_KEY_5 }, + { "AE06", VK_KEY_6 }, + { "AE07", VK_KEY_7 }, + { "AE08", VK_KEY_8 }, + { "AE09", VK_KEY_9 }, + { "AC01", VK_KEY_A }, + { "AB05", VK_KEY_B }, + { "AB03", VK_KEY_C }, + { "AC03", VK_KEY_D }, + { "AD03", VK_KEY_E }, + { "AC04", VK_KEY_F }, + { "AC05", VK_KEY_G }, + { "AC06", VK_KEY_H }, + { "AD08", VK_KEY_I }, + { "AC07", VK_KEY_J }, + { "AC08", VK_KEY_K }, + { "AC09", VK_KEY_L }, + { "AB07", VK_KEY_M }, + { "AB06", VK_KEY_N }, + { "AD09", VK_KEY_O }, + { "AD10", VK_KEY_P }, + { "AD01", VK_KEY_Q }, + { "AD04", VK_KEY_R }, + { "AC02", VK_KEY_S }, + { "AD05", VK_KEY_T }, + { "AD07", VK_KEY_U }, + { "AB04", VK_KEY_V }, + { "AD02", VK_KEY_W }, + { "AB02", VK_KEY_X }, + { "AD06", VK_KEY_Y }, + { "AB01", VK_KEY_Z }, + { "KP0", VK_NUMPAD0 }, + { "KP1", VK_NUMPAD1 }, + { "KP2", VK_NUMPAD2 }, + { "KP3", VK_NUMPAD3 }, + { "KP4", VK_NUMPAD4 }, + { "KP5", VK_NUMPAD5 }, + { "KP6", VK_NUMPAD6 }, + { "KP7", VK_NUMPAD7 }, + { "KP8", VK_NUMPAD8 }, + { "KP9", VK_NUMPAD9 }, + { "KPMU", VK_MULTIPLY }, + { "KPAD", VK_ADD }, + { "KPSU", VK_SUBTRACT }, + { "KPDL", VK_DECIMAL }, + { "AB10", VK_OEM_2 }, + { "FK01", VK_F1 }, + { "FK02", VK_F2 }, + { "FK03", VK_F3 }, + { "FK04", VK_F4 }, + { "FK05", VK_F5 }, + { "FK06", VK_F6 }, + { "FK07", VK_F7 }, + { "FK08", VK_F8 }, + { "FK09", VK_F9 }, + { "FK10", VK_F10 }, + { "FK11", VK_F11 }, + { "FK12", VK_F12 }, + { "NMLK", VK_NUMLOCK }, + { "SCLK", VK_SCROLL }, + { "RTSH", VK_RSHIFT }, + { "LCTL", VK_LCONTROL }, + { "AC10", VK_OEM_1 }, + { "AE12", VK_OEM_PLUS }, + { "AB08", VK_OEM_COMMA }, + { "AE11", VK_OEM_MINUS }, + { "AB09", VK_OEM_PERIOD }, + { "TLDE", VK_OEM_3 }, + { "AB11", VK_ABNT_C1 }, + { "I129", VK_ABNT_C2 }, + { "AD11", VK_OEM_4 }, + { "BKSL", VK_OEM_5 }, + { "AD12", VK_OEM_6 }, + { "AC11", VK_OEM_7 }, + { "LSGT", VK_OEM_102 }, + { "KPEN", VK_RETURN | KBDEXT }, + { "PAUS", VK_PAUSE | KBDEXT }, + { "PGUP", VK_PRIOR | KBDEXT }, + { "PGDN", VK_NEXT | KBDEXT }, + { "END", VK_END | KBDEXT }, + { "HOME", VK_HOME | KBDEXT }, + { "LEFT", VK_LEFT | KBDEXT }, + { "UP", VK_UP | KBDEXT }, + { "RGHT", VK_RIGHT | KBDEXT }, + { "DOWN", VK_DOWN | KBDEXT }, + { "PRSC", VK_SNAPSHOT | KBDEXT }, + { "INS", VK_INSERT | KBDEXT }, + { "DELE", VK_DELETE | KBDEXT }, + { "LWIN", VK_LWIN | KBDEXT }, + { "RWIN", VK_RWIN | KBDEXT }, + { "COMP", VK_APPS | KBDEXT }, + { "KPDV", VK_DIVIDE | KBDEXT }, + { "RCTL", VK_RCONTROL | KBDEXT }, + { "RALT", VK_RMENU | KBDEXT } +// { "AE13", VK_BACKSLASH_JP }, // JP +// { "HKTG", VK_HIRAGANA }, // JP +// { "HENK", VK_CONVERT_JP }, // JP +// { "MUHE", VK_NONCONVERT_JP } // JP +// { "LVL3", 0x54} +}; + char* GetVirtualKeyName(DWORD vkcode) { char* vkname; @@ -324,3 +447,18 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname) return VK_NONE; } +DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname) +{ + int i; + + for (i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++) + { + if (XKB_KEYNAME_TABLE[i].name) + { + if (strcmp(xkbname, XKB_KEYNAME_TABLE[i].name) == 0) + return XKB_KEYNAME_TABLE[i].vkcode; + } + } + + return VK_NONE; +} From 32d9f76c418b013a578f350899f2a7699ee57554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 7 Mar 2013 13:56:00 -0500 Subject: [PATCH 18/18] libwinpr-input: fix virtual key code definitions --- include/freerdp/scancode.h | 4 +-- libfreerdp/locale/keyboard.c | 30 ++++++++--------- winpr/include/winpr/input.h | 53 ++++++++++++++++--------------- winpr/libwinpr/input/virtualkey.c | 12 ++++--- 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/include/freerdp/scancode.h b/include/freerdp/scancode.h index f0bc3286b..1199f0be7 100644 --- a/include/freerdp/scancode.h +++ b/include/freerdp/scancode.h @@ -148,8 +148,8 @@ #define RDP_SCANCODE_KANA_HANGUL MAKE_RDP_SCANCODE(0x72, FALSE) /* VK_KANA / VK_HANGUL (undocumented?) */ #define RDP_SCANCODE_ABNT_C1 MAKE_RDP_SCANCODE(0x73, FALSE) /* VK_ABNT_C1 JP OEM_102 */ #define RDP_SCANCODE_F24_JP MAKE_RDP_SCANCODE(0x76, FALSE) /* JP F24 */ -#define RDP_SCANCODE_CONVERT_JP MAKE_RDP_SCANCODE(0x79, FALSE) /* JP CONVERT */ -#define RDP_SCANCODE_NONCONVERT_JP MAKE_RDP_SCANCODE(0x7B, FALSE) /* JP NONCONVERT */ +#define RDP_SCANCODE_CONVERT_JP MAKE_RDP_SCANCODE(0x79, FALSE) /* JP VK_CONVERT */ +#define RDP_SCANCODE_NONCONVERT_JP MAKE_RDP_SCANCODE(0x7B, FALSE) /* JP VK_NONCONVERT */ #define RDP_SCANCODE_TAB_JP MAKE_RDP_SCANCODE(0x7C, FALSE) /* JP TAB */ #define RDP_SCANCODE_BACKSLASH_JP MAKE_RDP_SCANCODE(0x7D, FALSE) /* JP OEM_5 ('\') */ #define RDP_SCANCODE_ABNT_C2 MAKE_RDP_SCANCODE(0x7E, FALSE) /* VK_ABNT_C2, JP */ diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index edcc39bd0..dbb5dcedc 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -42,8 +42,8 @@ #endif -DWORD RDP_SCANCODE_TO_X11_KEYCODE[256][2]; -DWORD X11_KEYCODE_TO_RDP_SCANCODE[256]; +DWORD VIRTUAL_SCANCODE_TO_X11_KEYCODE[256][2]; +DWORD X11_KEYCODE_TO_VIRTUAL_SCANCODE[256]; int freerdp_detect_keyboard(DWORD* keyboardLayoutId) { @@ -100,30 +100,30 @@ DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) #ifdef __APPLE__ if (status < 0) - status = freerdp_keyboard_init_apple(&keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); + status = freerdp_keyboard_init_apple(&keyboardLayoutId, X11_KEYCODE_TO_VIRTUAL_SCANCODE); #endif #ifdef WITH_X11 #ifdef WITH_XKBFILE if (status < 0) - status = freerdp_keyboard_init_xkbfile(&keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); + status = freerdp_keyboard_init_xkbfile(&keyboardLayoutId, X11_KEYCODE_TO_VIRTUAL_SCANCODE); #endif if (status < 0) - status = freerdp_keyboard_init_x11_evdev(&keyboardLayoutId, X11_KEYCODE_TO_RDP_SCANCODE); + status = freerdp_keyboard_init_x11_evdev(&keyboardLayoutId, X11_KEYCODE_TO_VIRTUAL_SCANCODE); #endif freerdp_detect_keyboard(&keyboardLayoutId); - ZeroMemory(RDP_SCANCODE_TO_X11_KEYCODE, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); + ZeroMemory(VIRTUAL_SCANCODE_TO_X11_KEYCODE, sizeof(VIRTUAL_SCANCODE_TO_X11_KEYCODE)); - for (keycode = 0; keycode < ARRAYSIZE(RDP_SCANCODE_TO_X11_KEYCODE); keycode++) + for (keycode = 0; keycode < ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE); keycode++) { - RDP_SCANCODE_TO_X11_KEYCODE - [RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode])] - [RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? 1 : 0] = keycode; + VIRTUAL_SCANCODE_TO_X11_KEYCODE + [RDP_SCANCODE_CODE(X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode])] + [RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]) ? 1 : 0] = keycode; } return keyboardLayoutId; @@ -132,16 +132,16 @@ DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode) { DEBUG_KBD("x11 keycode: %02X -> rdp code: %02X%s", keycode, - RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode]), - RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? " extended" : ""); + RDP_SCANCODE_CODE(X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]), + RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]) ? " extended" : ""); - return X11_KEYCODE_TO_RDP_SCANCODE[keycode]; + return X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]; } DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL extended) { if (extended) - return RDP_SCANCODE_TO_X11_KEYCODE[scancode][1]; + return VIRTUAL_SCANCODE_TO_X11_KEYCODE[scancode][1]; else - return RDP_SCANCODE_TO_X11_KEYCODE[scancode][0]; + return VIRTUAL_SCANCODE_TO_X11_KEYCODE[scancode][0]; } diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 87b0a8ea9..3c22ec6d2 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -154,6 +154,8 @@ /* 0x5E is reserved */ +#define VK_POWER 0x5E /* Power key */ + #define VK_SLEEP 0x5F /* Computer Sleep key */ /* Numeric keypad digits, the last four bits of the code represent the corresponding digit */ @@ -249,6 +251,7 @@ #define VK_LAUNCH_MAIL 0xB4 /* Windows 2000/XP: Start Mail key */ #define VK_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ +#define VK_LAUNCH_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ #define VK_LAUNCH_APP1 0xB6 /* Windows 2000/XP: Start Application 1 key */ #define VK_LAUNCH_APP2 0xB7 /* Windows 2000/XP: Start Application 2 key */ @@ -311,18 +314,31 @@ /* 0xE8 is unassigned */ /* 0xE9 to 0xF5 are OEM specific */ -#define VK_ATTN 0xF6 /* Attn key */ -#define VK_CRSEL 0xF7 /* CrSel key */ -#define VK_EXSEL 0xF8 /* ExSel key */ -#define VK_EREOF 0xF9 /* Erase EOF key */ -#define VK_PLAY 0xFA /* Play key */ -#define VK_ZOOM 0xFB /* Zoom key */ -#define VK_NONAME 0xFC /* Reserved */ -#define VK_PA1 0xFD /* PA1 key */ -#define VK_OEM_PA1 0xFD /* PA1 key */ -#define VK_OEM_CLEAR 0xFE /* Clear key */ +#define VK_OEM_RESET 0xE9 +#define VK_OEM_JUMP 0xEA +#define VK_OEM_PA1 0xEB +#define VK_OEM_PA2 0xEC +#define VK_OEM_PA3 0xED +#define VK_OEM_WSCTRL 0xEE +#define VK_OEM_CUSEL 0xEF +#define VK_OEM_ATTN 0xF0 +#define VK_OEM_FINISH 0xF1 +#define VK_OEM_COPY 0xF2 +#define VK_OEM_AUTO 0xF3 +#define VK_OEM_ENLW 0xF4 +#define VK_OEM_BACKTAB 0xF5 -#define VK_NONE 0xFF /* no key */ +#define VK_ATTN 0xF6 /* Attn key */ +#define VK_CRSEL 0xF7 /* CrSel key */ +#define VK_EXSEL 0xF8 /* ExSel key */ +#define VK_EREOF 0xF9 /* Erase EOF key */ +#define VK_PLAY 0xFA /* Play key */ +#define VK_ZOOM 0xFB /* Zoom key */ +#define VK_NONAME 0xFC /* Reserved */ +#define VK_PA1 0xFD /* PA1 key */ +#define VK_OEM_CLEAR 0xFE /* Clear key */ + +#define VK_NONE 0xFF /* no key */ /** * For East Asian Input Method Editors (IMEs) @@ -342,21 +358,6 @@ #define VK_DBE_CODEINPUT 0xFA /* Changes the mode to code input. */ #define VK_DBE_NOCODEINPUT 0xFB /* Changes the mode to no-code input. */ -/** - * TODO: fix the following definitions - */ - -#define VK_OEM_WSCTRL 0xFF -#define VK_OEM_FINISH 0xFF -#define VK_OEM_JUMP 0xFF -#define VK_OEM_BACKTAB 0xFF -#define VK_OEM_AUTO 0xFF -#define VK_OEM_PA3 0xFF -#define VK_OEM_RESET 0xFF -#define VK_OEM_PA2 0xFF -#define VK_POWER 0xFF -#define VK_LAUNCH_MEDIA_SELECT 0xFF - /* * Virtual Scan Codes */ diff --git a/winpr/libwinpr/input/virtualkey.c b/winpr/libwinpr/input/virtualkey.c index 29dba4e6a..d5f8dd17b 100644 --- a/winpr/libwinpr/input/virtualkey.c +++ b/winpr/libwinpr/input/virtualkey.c @@ -411,11 +411,15 @@ XKB_KEYNAME XKB_KEYNAME_TABLE[] = { "COMP", VK_APPS | KBDEXT }, { "KPDV", VK_DIVIDE | KBDEXT }, { "RCTL", VK_RCONTROL | KBDEXT }, - { "RALT", VK_RMENU | KBDEXT } + { "RALT", VK_RMENU | KBDEXT }, + + /* Japanese */ + + { "HENK", VK_CONVERT }, + { "MUHE", VK_NONCONVERT }, + { "HKTG", VK_DBE_KATAKANA }, + // { "AE13", VK_BACKSLASH_JP }, // JP -// { "HKTG", VK_HIRAGANA }, // JP -// { "HENK", VK_CONVERT_JP }, // JP -// { "MUHE", VK_NONCONVERT_JP } // JP // { "LVL3", 0x54} };