VirtualBox

Changeset 2529 in vbox for trunk/src


Ignore:
Timestamp:
May 8, 2007 8:47:31 AM (18 years ago)
Author:
vboxsync
Message:

Reactivated and updated the Wine keyboard code for VirtualBox on remote X11 displays

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r2478 r2529  
    148148        src/VBoxFBDDRAW.cpp
    149149
    150 ifdef XKEYBOARD_NEW
    151 VirtualBox_SOURCES.linux = \
    152         src/linux/XKeyboardNew.cpp
    153 else
    154150VirtualBox_SOURCES.linux = \
    155151        src/linux/XKeyboard.cpp \
    156         src/linux/keyboard.c
    157 endif
     152        src/linux/keyboard.c \
     153        src/linux/XKeyboardNew.cpp
    158154
    159155VirtualBox_SOURCES.darwin = \
  • trunk/src/VBox/Frontends/VirtualBox/include/XKeyboard.h

    r382 r2529  
    4444int getKeysymsPerKeycode();
    4545
     46// initialize the X keyboard subsystem, safe for use on remote X servers
     47bool initXKeyboardSafe(Display *dpy);
     48// our custom keyboard handler, safe for use on remote X servers
     49void handleXKeyEventSafe(Display *dpy, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo);
     50// returns the number of keysyms per keycode (only valid after initXKeyboard()), safe
     51// for use on remote X servers
     52int getKeysymsPerKeycodeSafe();
     53
    4654
    4755#endif // __XKeyboard_h__
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/XKeyboard.cpp

    r382 r2529  
    5151 * within our environment.
    5252 */
    53 bool initXKeyboard(Display *dpy)
     53bool initXKeyboardSafe(Display *dpy)
    5454{
    5555    // update the global display pointer
     
    6363 * possible to undo the dreaded scancode to X11 conversion. Sigh!
    6464 */
    65 void handleXKeyEvent(Display *dpy, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo)
     65void handleXKeyEventSafe(Display *dpy, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo)
    6666{
    6767    // update the global display pointer
     
    7171}
    7272
    73 int getKeysymsPerKeycode()
     73int getKeysymsPerKeycodeSafe()
    7474{
    7575    return X11DRV_GetKeysymsPerKeycode();
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/XKeyboardNew.cpp

    r1558 r2529  
    2424#include <XKeyboard.h>
    2525#include <cstring>
     26#include <cstdlib>
    2627
    2728#define LOG_GROUP LOG_GROUP_GUI
     
    5354
    5455static int keysyms_per_keycode;  /** Number of keyboard language layouts the host has */
     56static bool remote_display = false;  /** Are we displaying on a remote X server? */
    5557
    5658/**
    57  * Find out how many different language mappings there are for this keyboard.  This is needed
     59 * Check whether we are running on a local or on a remote X server, and find out how many
     60 * different language mappings there are for this keyboard.  This last is needed
    5861 * so that Dmitry can press <hostkey>+Q while using his Cyrillic keyboard layout :)
    5962 */
     
    6265    int min, max;
    6366    KeySym *syms;
     67
     68    /* If we are displaying on a remote display then fall back to old Wine-based code. */
     69    if (DisplayString(dpy)[0] != ':')
     70    {
     71        remote_display = true;
     72        Log(("initXKeyboard: remote display detected\n"));
     73        return initXKeyboardSafe(dpy);
     74    }
     75    Log(("initXKeyboard: remote display not detected\n"));
    6476    /* Find out how approximately how many keys there are on the keyboard, needed for the next
    6577       call */
     
    7688 * Convert X11 keycodes back to scancodes.
    7789 */
    78 void handleXKeyEvent(Display * /* dpy */, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo)
     90void handleXKeyEvent(Display * dpy, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo)
    7991{
    8092    unsigned int uKeyCode = event->xkey.keycode;
     93
     94    if (remote_display == true)
     95    {
     96        handleXKeyEventSafe(dpy, event, wineKbdInfo);
     97        return;
     98    }
    8199    memset(reinterpret_cast<void *>(wineKbdInfo), 0, sizeof(WINEKEYBOARDINFO));
    82100    /* Basic scancodes are translated to keycodes by adding 8, so we just subtract again. */
     
    107125int getKeysymsPerKeycode()
    108126{
     127    if (remote_display == true)
     128        return getKeysymsPerKeycodeSafe();
    109129    return keysyms_per_keycode;
    110130}
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard.c

    r382 r2529  
    2121 * You should have received a copy of the GNU Lesser General Public
    2222 * License along with this library; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
    2424 */
    25 
    26 // our master define to make this module usable outside wide
     25// our master define to make this module usable outside wine
     26
    2727#define OUTOFWINE
    2828
     
    3030#include "keyboard_outofwine.h"
    3131int use_xkb = 1;
    32 #endif
     32#endif // OUTOFWINE defined
    3333
    3434#ifndef OUTOFWINE
    3535#include "config.h"
    36 #endif
     36#endif // OUTOFWINE not defined
    3737
    3838#include <X11/Xatom.h>
     
    4141#include <X11/Xresource.h>
    4242#include <X11/Xutil.h>
    43 #ifdef HAVE_XKB
     43#ifdef HAVE_X11_XKBLIB_H
    4444#include <X11/XKBlib.h>
    4545#endif
     
    6060#include "win.h"
    6161#include "x11drv.h"
     62#include "wine/server.h"
    6263#include "wine/unicode.h"
    6364#include "wine/debug.h"
     
    6566WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
    6667WINE_DECLARE_DEBUG_CHANNEL(key);
    67 WINE_DECLARE_DEBUG_CHANNEL(dinput);
    68 #endif // OUTOFWINE
     68#endif // OUTOFWINE not defined
     69
     70typedef union
     71{
     72    struct
     73    {
     74#ifndef BITFIELDS_BIGENDIAN
     75        unsigned long count : 16;
     76#endif
     77        unsigned long code : 8;
     78        unsigned long extended : 1;
     79        unsigned long unused : 2;
     80        unsigned long win_internal : 2;
     81        unsigned long context : 1;
     82        unsigned long previous : 1;
     83        unsigned long transition : 1;
     84#ifdef BITFIELDS_BIGENDIAN
     85        unsigned long count : 16;
     86#endif
     87    } lp1;
     88    unsigned long lp2;
     89} KEYLP;
     90
     91/* key state table bits:
     92  0x80 -> key is pressed
     93  0x40 -> key got pressed since last time
     94  0x01 -> key is toggled
     95*/
     96BYTE key_state_table[256];
     97
     98static BYTE TrackSysKey = 0; /* determine whether ALT key up will cause a WM_SYSKEYUP
     99                                or a WM_KEYUP message */
    69100
    70101static int min_keycode, max_keycode, keysyms_per_keycode;
    71102static WORD keyc2vkey[256], keyc2scan[256];
    72103
    73 static LPBYTE pKeyStateTable;
    74104static int NumLockMask, AltGrMask; /* mask in the XKeyEvent state */
    75105static int kcControl, kcAlt, kcShift, kcNumLock, kcCapsLock; /* keycodes */
     
    139169};
    140170
     171static const WORD main_key_scan_qwerty_jp106[MAIN_LEN] =
     172{
     173  /* this is my (106-key) keyboard layout, sorry if it doesn't quite match yours */
     174 /* 1    2    3    4    5    6    7    8    9    0    -    ^    \ */
     175   0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x29,
     176 /* q    w    e    r    t    y    u    i    o    p    @    [ */
     177   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,
     178 /* a    s    d    f    g    h    j    k    l    ;    :    ] */
     179   0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2B,
     180 /* z    x    c    v    b    n    m    ,    .    / */
     181   0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
     182   0x56 /* the 102nd key (actually to the right of l-shift) */
     183};
     184
     185
    141186static const WORD main_key_vkey_qwerty[MAIN_LEN] =
    142187{
    143188/* NOTE: this layout must concur with the scan codes layout above */
    144    VK_OEM_3,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_MINUS,VK_OEM_PLUS,
    145    VK_Q,VK_W,VK_E,VK_R,VK_T,VK_Y,VK_U,VK_I,VK_O,VK_P,VK_OEM_4,VK_OEM_6,
    146    VK_A,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_OEM_1,VK_OEM_7,VK_OEM_5,
    147    VK_Z,VK_X,VK_C,VK_V,VK_B,VK_N,VK_M,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
     189   VK_OEM_3,'1','2','3','4','5','6','7','8','9','0',VK_OEM_MINUS,VK_OEM_PLUS,
     190   'Q','W','E','R','T','Y','U','I','O','P',VK_OEM_4,VK_OEM_6,
     191   'A','S','D','F','G','H','J','K','L',VK_OEM_1,VK_OEM_7,VK_OEM_5,
     192   'Z','X','C','V','B','N','M',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
    148193   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
    149194};
    150195
     196static const WORD main_key_vkey_qwerty_jp106[MAIN_LEN] =
     197{
     198/* NOTE: this layout must concur with the scan codes layout above */
     199   '1','2','3','4','5','6','7','8','9','0',VK_OEM_MINUS,VK_OEM_PLUS,VK_OEM_3,
     200   'Q','W','E','R','T','Y','U','I','O','P',VK_OEM_4,VK_OEM_6,
     201   'A','S','D','F','G','H','J','K','L',VK_OEM_1,VK_OEM_7,VK_OEM_5,
     202   'Z','X','C','V','B','N','M',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
     203   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
     204};
     205
    151206static const WORD main_key_vkey_qwerty_v2[MAIN_LEN] =
    152207{
    153208/* NOTE: this layout must concur with the scan codes layout above */
    154    VK_OEM_5,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_PLUS,VK_OEM_4,
    155    VK_Q,VK_W,VK_E,VK_R,VK_T,VK_Y,VK_U,VK_I,VK_O,VK_P,VK_OEM_6,VK_OEM_1,
    156    VK_A,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_OEM_3,VK_OEM_7,VK_OEM_2,
    157    VK_Z,VK_X,VK_C,VK_V,VK_B,VK_N,VK_M,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_MINUS,
     209   VK_OEM_5,'1','2','3','4','5','6','7','8','9','0',VK_OEM_PLUS,VK_OEM_4,
     210   'Q','W','E','R','T','Y','U','I','O','P',VK_OEM_6,VK_OEM_1,
     211   'A','S','D','F','G','H','J','K','L',VK_OEM_3,VK_OEM_7,VK_OEM_2,
     212   'Z','X','C','V','B','N','M',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_MINUS,
    158213   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
    159214};
     
    162217{
    163218/* NOTE: this layout must concur with the scan codes layout above */
    164    VK_OEM_3,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_MINUS,VK_OEM_PLUS,
    165    VK_Q,VK_W,VK_E,VK_R,VK_T,VK_Z,VK_U,VK_I,VK_O,VK_P,VK_OEM_4,VK_OEM_6,
    166    VK_A,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_OEM_1,VK_OEM_7,VK_OEM_5,
    167    VK_Y,VK_X,VK_C,VK_V,VK_B,VK_N,VK_M,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
     219   VK_OEM_3,'1','2','3','4','5','6','7','8','9','0',VK_OEM_MINUS,VK_OEM_PLUS,
     220   'Q','W','E','R','T','Z','U','I','O','P',VK_OEM_4,VK_OEM_6,
     221   'A','S','D','F','G','H','J','K','L',VK_OEM_1,VK_OEM_7,VK_OEM_5,
     222   'Y','X','C','V','B','N','M',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
    168223   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
    169224};
     
    172227{
    173228/* NOTE: this layout must concur with the scan codes layout above */
    174    VK_OEM_3,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_MINUS,VK_OEM_PLUS,
    175    VK_Q,VK_W,VK_E,VK_R,VK_T,VK_Z,VK_U,VK_I,VK_O,VK_P,VK_OEM_4,VK_OEM_6,
    176    VK_A,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_OEM_1,VK_OEM_7,VK_OEM_5,
    177    VK_OEM_102,VK_Y,VK_X,VK_C,VK_V,VK_B,VK_N,VK_M,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2
     229   VK_OEM_3,'1','2','3','4','5','6','7','8','9','0',VK_OEM_MINUS,VK_OEM_PLUS,
     230   'Q','W','E','R','T','Z','U','I','O','P',VK_OEM_4,VK_OEM_6,
     231   'A','S','D','F','G','H','J','K','L',VK_OEM_1,VK_OEM_7,VK_OEM_5,
     232   VK_OEM_102,'Y','X','C','V','B','N','M',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2
    178233};
    179234
     
    181236{
    182237/* NOTE: this layout must concur with the scan codes layout above */
    183    VK_OEM_3,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_MINUS,VK_OEM_PLUS,
    184    VK_Q,VK_W,VK_E,VK_R,VK_T,VK_Y,VK_U,VK_I,VK_O,VK_P,VK_OEM_4,VK_OEM_6,
    185    VK_A,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_OEM_1,VK_OEM_8,VK_OEM_5,
    186    VK_OEM_7,VK_Z,VK_X,VK_C,VK_V,VK_B,VK_N,VK_M,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
     238   VK_OEM_3,'1','2','3','4','5','6','7','8','9','0',VK_OEM_MINUS,VK_OEM_PLUS,
     239   'Q','W','E','R','T','Y','U','I','O','P',VK_OEM_4,VK_OEM_6,
     240   'A','S','D','F','G','H','J','K','L',VK_OEM_1,VK_OEM_8,VK_OEM_5,
     241   VK_OEM_7,'Z','X','C','V','B','N','M',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
    187242   VK_OEM_102, /* the 102nd key (actually to the right of l-shift) */
    188243};
     
    191246{
    192247/* NOTE: this layout must concur with the scan codes layout above */
    193    VK_OEM_7,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_4,VK_OEM_PLUS,
    194    VK_A,VK_Z,VK_E,VK_R,VK_T,VK_Y,VK_U,VK_I,VK_O,VK_P,VK_OEM_6,VK_OEM_1,
    195    VK_Q,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_M,VK_OEM_3,VK_OEM_5,
    196    VK_W,VK_X,VK_C,VK_V,VK_B,VK_N,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,VK_OEM_8,
     248   VK_OEM_7,'1','2','3','4','5','6','7','8','9','0',VK_OEM_4,VK_OEM_PLUS,
     249   'A','Z','E','R','T','Y','U','I','O','P',VK_OEM_6,VK_OEM_1,
     250   'Q','S','D','F','G','H','J','K','L','M',VK_OEM_3,VK_OEM_5,
     251   'W','X','C','V','B','N',VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,VK_OEM_8,
    197252   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
    198253};
     
    201256{
    202257/* NOTE: this layout must concur with the scan codes layout above */
    203    VK_OEM_3,VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_4,VK_OEM_6,
    204    VK_OEM_7,VK_OEM_COMMA,VK_OEM_PERIOD,VK_P,VK_Y,VK_F,VK_G,VK_C,VK_R,VK_L,VK_OEM_2,VK_OEM_PLUS,
    205    VK_A,VK_O,VK_E,VK_U,VK_I,VK_D,VK_H,VK_T,VK_N,VK_S,VK_OEM_MINUS,VK_OEM_5,
    206    VK_OEM_1,VK_Q,VK_J,VK_K,VK_X,VK_B,VK_M,VK_W,VK_V,VK_Z,
     258   VK_OEM_3,'1','2','3','4','5','6','7','8','9','0',VK_OEM_4,VK_OEM_6,
     259   VK_OEM_7,VK_OEM_COMMA,VK_OEM_PERIOD,'P','Y','F','G','C','R','L',VK_OEM_2,VK_OEM_PLUS,
     260   'A','O','E','U','I','D','H','T','N','S',VK_OEM_MINUS,VK_OEM_5,
     261   VK_OEM_1,'Q','J','K','X','B','M','W','V','Z',
    207262   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
    208263};
     
    270325};
    271326
    272 /*** French keyboard layout (contributed by Eric Pouech) */
     327/*** French keyboard layout (setxkbmap fr) */
    273328static const char main_key_FR[MAIN_LEN][4] =
    274329{
    275  "²","&1","é2~","\"3#","'4{","(5[","-6|","è7`","_8\\","ç9^±","à0@",")°]","=+}",
    276  "aA","zZ","eE¿","rR","tT","yY","uU","iI","oO","pP","^¨","$£¤",
    277  "qQ","sSß","dD","fF","gG","hH","jJ","kK","lL","mM","ù%","*µ",
     330 "²","&1","é2","\"3","'4","(5","-6","è7","_8","ç9","à0",")°","=+",
     331 "aA","zZ","eE","rR","tT","yY","uU","iI","oO","pP","^¨","$£",
     332 "qQ","sS","dD","fF","gG","hH","jJ","kK","lL","mM","ù%","*µ",
    278333 "wW","xX","cC","vV","bB","nN",",?",";.",":/","!§",
    279334 "<>"
     
    290345};
    291346
    292 /*** German keyboard layout (contributed by Ulrich Weigand) */
     347/*** German keyboard layout (setxkbmap de) */
    293348static const char main_key_DE[MAIN_LEN][4] =
    294349{
    295  "^°","1!","2\"²","3§³","4$","5%","6&","7/{","8([","9)]","0=}","ß?\\","'`",
    296  "qQ@","wW","eE€","rR","tT","zZ","uU","iI","oO","pP","üÜ","+*~",
    297  "aA","sS","dD","fF","gG","hH","jJ","kK","lL","öÖ","äÄ","#´",
    298  "yY","xX","cC","vV","bB","nN","mMµ",",;",".:","-_",
     350 "^°","1!","2\"","3§","4$","5%","6&","7/","8(","9)","0=","ß?","´`",
     351 "qQ","wW","eE","rR","tT","zZ","uU","iI","oO","pP","üÜ","+*",
     352 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","öÖ","äÄ","#'",
     353 "yY","xX","cC","vV","bB","nN","mM",",;",".:","-_",
    299354 "<>|"
    300355};
     
    319374};
    320375
    321 /*** Swiss German keyboard layout (contributed by Jonathan Naylor) */
     376/*** Swiss German keyboard layout (setxkbmap ch -variant de) */
    322377static const char main_key_SG[MAIN_LEN][4] =
    323378{
    324  "§°","1+|","2\"@","3*#","4ç","5%","6&¬","7/¦","8(¢","9)","0=","'?´","^`~",
    325  "qQ","wW","eE","rR","tT","zZ","uU","iI","oO","pP","üè[","¨!]",
    326  "aA","sS","dD","fF","gG","hH","jJ","kK","lL","öé","äà{","$£}",
     379 "§°","1+","2\"","3*","4ç","5%","6&","7/","8(","9)","0=","'?","^`",
     380 "qQ","wW","eE","rR","tT","zZ","uU","iI","oO","pP","üè","¨!",
     381 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","öé","äà","$£",
    327382 "yY","xX","cC","vV","bB","nN","mM",",;",".:","-_",
    328  "<>\\"
    329 };
    330 
    331 /*** Swiss French keyboard layout (contributed by Philippe Froidevaux) */
     383 "<>"
     384};
     385
     386/*** Swiss French keyboard layout (setxkbmap ch -variant fr) */
    332387static const char main_key_SF[MAIN_LEN][4] =
    333388{
    334  "§°","1+|","2\"@","3*#","4ç","5%","6&¬","7/¦","8(¢","9)","0=","'?´","^`~",
    335  "qQ","wW","eE","rR","tT","zZ","uU","iI","oO","pP","èü[","¨!]",
    336  "aA","sS","dD","fF","gG","hH","jJ","kK","lL","éö","àä{","$£}",
     389 "§°","1+","2\"","3*","4ç","5%","6&","7/","8(","9)","0=","'?","^`",
     390 "qQ","wW","eE","rR","tT","zZ","uU","iI","oO","pP","èü","¨!",
     391 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","éö","àä","$£",
    337392 "yY","xX","cC","vV","bB","nN","mM",",;",".:","-_",
    338  "<>\\"
     393 "<>"
    339394};
    340395
     
    369424};
    370425
    371 /*** Estonian keyboard layout (contributed by Raul Metsma zombi82@hot.ee) */
     426/*** Estonian keyboard layout (setxkbmap ee) */
    372427static const char main_key_ET[MAIN_LEN][4] =
    373428{
    374  "·~","1!","2\"@","3#£","4¤$","5%","6&","7/{","8([","9)]","0=}","+?\\","´`",
    375  "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","üÜ","õÕ§",
    376  "aA","sS","dD","fF","gG","hH","jJ","kK","lL","öÖ","äÄ","'*½",
     429 "·~","1!","2\"","3#","4¤","5%","6&","7/","8(","9)","0=","+?","´`",
     430 "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","üÜ","õÕ",
     431 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","öÖ","äÄ","'*",
    377432 "zZ","xX","cC","vV","bB","nN","mM",",;",".:","-_",
    378  "<>|"
    379 };
    380 
    381 /*** Canadian French keyboard layout */
     433 "<>"
     434};
     435
     436/*** Canadian French keyboard layout (setxkbmap ca_enhanced) */
    382437static const char main_key_CF[MAIN_LEN][4] =
    383438{
     
    389444};
    390445
     446/*** Canadian French keyboard layout (setxkbmap ca -variant fr) */
     447static const char main_key_CA_fr[MAIN_LEN][4] =
     448{
     449 "#|","1!","2\"","3/","4$","5%","6?","7&","8*","9(","0)","-_","=+",
     450 "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","^^","¸¨",
     451 "aA","sS","dD","fF","gG","hH","jJ","kK","lL",";:","``","<>",
     452 "zZ","xX","cC","vV","bB","nN","mM",",'",".","éÉ",
     453 "«»"
     454};
     455
     456/*** Canadian keyboard layout (setxkbmap ca) */
     457static const char main_key_CA[MAIN_LEN][4] =
     458{
     459 "/\\","1!¹¡","2@²","3#³£","4$¼¤","5%½","6?¾","7&","8*","9(","0)","-_","=+",
     460 "qQ","wW","eE","rR","tT","yY","uU","iI","oOøØ","pPþÞ","^¨¨","çÇ~",
     461 "aAæÆ","sSߧ","dDðÐ","fF","gG","hH","jJ","kK","lL",";:´","èÈ","àÀ",
     462 "zZ","xX","cC¢©","vV","bB","nN","mMµº",",'",".\"·÷","éÉ",
     463 "ùÙ"
     464};
     465
    391466/*** Portuguese keyboard layout (setxkbmap pt) */
    392467static const char main_key_PT[MAIN_LEN][4] =
     
    509584};
    510585
     586/*** Ukrainian keyboard layout KOI8-U by O. Nykyforchyn */
     587/***  (as it appears on most of keyboards sold today)   */
     588static const char main_key_UA_std[MAIN_LEN][4] =
     589{
     590 "­½","1!","2\"","3'","4;","5%","6:","7?","8*","9(","0)","-_","=+",
     591 "Êê","Ãã","Õõ","Ëë","Åå","Îî","Çç","Ûû","Ýý","Úú","Èè","§·",
     592 "Ææ","¦¶","×÷","Áá","Ðð","Òò","Ïï","Ìì","Ää","Öö","¤´","\\/",
     593 "Ññ","Þþ","Óó","Íí","Éé","Ôô","Øø","Ââ","Àà",".,",
     594 "<>" /* the phantom key */
     595};
     596
     597/*** Russian keyboard layout KOI8-R (pair to the previous) */
     598static const char main_key_RU_std[MAIN_LEN][4] =
     599{
     600 "£³","1!","2\"","3'","4;","5%","6:","7?","8*","9(","0)","-_","=+",
     601 "Êê","Ãã","Õõ","Ëë","Åå","Îî","Çç","Ûû","Ýý","Úú","Èè","ßÿ",
     602 "Ææ","Ùù","×÷","Áá","Ðð","Òò","Ïï","Ìì","Ää","Öö","Üü","\\/",
     603 "Ññ","Þþ","Óó","Íí","Éé","Ôô","Øø","Ââ","Àà",".,",
     604 "<>" /* the phantom key */
     605};
     606
    511607/*** Spanish keyboard layout (setxkbmap es) */
    512608static const char main_key_ES[MAIN_LEN][4] =
     
    529625};
    530626
    531 /*** Hungarian keyboard layout (contributed by Zoltán Kovács) */
     627/*** Hungarian keyboard layout (setxkbmap hu) */
    532628static const char main_key_HU[MAIN_LEN][4] =
    533629{
    534  "0§","1'~","2\"·","3+^","4!¢","5%°","6/²","7=`","8(ÿ","9)´","öÖ½","üܨ","óÓ¸",
    535  "qQ\\","wW|","eE","rR","tT","zZ","uU","iIÍ","oOø","pP","õÕ÷","úÚ×",
    536  "aA","sSð","dDÐ","fF[","gG]","hH","jJí","kK³","lL£","éÉ$","áÁß","ûÛ¤",
    537  "yY>","xX#","cC&","vV@","bB{","nN}","mM",",?;",".:>","-_*",
    538  "íÍ<"
     630 "0§","1'","2\"","3+","4!","5%","6/","7=","8(","9)","öÖ","üÜ","óÓ",
     631 "qQ","wW","eE","rR","tT","zZ","uU","iI","oO","pP","õÕ","úÚ",
     632 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","éÉ","áÁ","ûÛ",
     633 "yY","xX","cC","vV","bB","nN","mM",",?",".:","-_",
     634 "íÍ"
    539635};
    540636
     
    559655};
    560656
     657/*** Serbian keyboard layout (setxkbmap sr) ***/
     658static const char main_key_SR[MAIN_LEN][4] =
     659{
     660 "`~","1!","2\"","3#","4$","5%","6&","7/","8(","9)","0=","'?","+*",
     661 "©¹","ªº","Åå","Òò","Ôô","Úú","Õõ","Éé","Ïï","Ðð","Ûû","[]",
     662 "Áá","Óó","Ää","Ææ","Çç","Èè","¨¸","Ëë","Ìì","Þþ","«»","-_",
     663 "¡±","¯¿","Ãã","×÷","Ââ","Îî","Íí",",;",".:","Öö",
     664 "<>" /* the phantom key */
     665};
     666
     667/*** Serbian keyboard layout (setxkbmap us,sr) ***/
     668static const char main_key_US_SR[MAIN_LEN][4] =
     669{
     670 "`~","1!","2@2\"","3#","4$","5%","6^6&","7&7/","8*8(","9(9)","0)0=","-_'?","=++*",
     671 "qQ©¹","wWªº","eEÅå","rRÒò","tTÔô","yYÚú","uUÕõ","iIÉé","oOÏï","pPÐð","[{Ûû","]}[]",
     672 "aAÁá","sSÓó","dDÄä","fFÆæ","gGÇç","hHÈè","jJ¨¸","kKËë","lLÌì",";:Þþ","'\"«»","\\|-_",
     673 "zZ¡±","xX¯¿","cCÃã","vV×÷","bBÂâ","nNÎî","mMÍí",",<,;",".>.:","/?Öö",
     674 "<>" /* the phantom key */
     675};
     676
    561677/*** Croatian keyboard layout specific for me <[email protected]> ***/
    562678static const char main_key_HR_jelly[MAIN_LEN][4] =
     
    605721 "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","´`","[{",
    606722 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","çÇ","~^","]}",
    607  "zZ","xX","cC","vV","bB","nN","mM",",<",".>",";:","/?",
    608  "\\|"
     723 "\\|","zZ","xX","cC","vV","bB","nN","mM",",<",".>",";:","/?",
    609724};
    610725
     
    615730 "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","4`","[{*",
    616731 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","gG","~^","]}:",
    617  "zZ","xX","cC","vV","bB","nN","mM",",<",".>",";:","/?0",
    618  "\\|"
     732 "\\|","zZ","xX","cC","vV","bB","nN","mM",",<",".>",";:","/?0"
    619733};
    620734
     
    630744/*** Slovak keyboard layout (see cssk_ibm(sk_qwerty) in xkbsel)
    631745  - dead_abovering replaced with degree - no symbol in iso8859-2
    632   - brokenbar replaced with bar                 */
     746  - brokenbar replaced with bar                                 */
    633747static const char main_key_SK[MAIN_LEN][4] =
    634748{
     
    690804};
    691805
    692 /*** Lithuanian (Baltic) keyboard layout (pc/lt in XFree86 4.3.0, contributed by Nerijus Baliûnas) */
     806/*** Lithuanian keyboard layout (setxkbmap lt) */
    693807static const char main_key_LT_B[MAIN_LEN][4] =
    694808{
     
    696810 "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","[{","]}",
    697811 "aA","sS","dD","fF","gG","hH","jJ","kK","lL",";:","'\"",
    698  "zZ","xX","cC","vV","bB","nN","mM",",<",".>","/?"
     812 "zZ","xX","cC","vV","bB","nN","mM",",<",".>","/?",
     813 "ª¬"
    699814};
    700815
     
    706821"aAæ","sSß","dD","fF","gG","hH","jJ","kK","lL","þÞ","iÝ",",;`",
    707822"zZ","xX","cC","vV","bB","nN","mM","öÖ","çÇ",".:"
     823};
     824
     825/*** Turkish keyboard layout (setxkbmap tr) */
     826static const char main_key_TR[MAIN_LEN][4] =
     827{
     828"\"\\","1!","2'","3^","4+","5%","6&","7/","8(","9)","0=","*?","-_",
     829"qQ","wW","eE","rR","tT","yY","uU","\xb9I","oO","pP","\xbb\xab","üÜ",
     830"aA","sS","dD","fF","gG","hH","jJ","kK","lL","\xba\xaa","i\0",",;",
     831"zZ","xX","cC","vV","bB","nN","mM","öÖ","çÇ",".:",
     832"<>"
     833};
     834
     835/*** Turkish F keyboard layout (setxkbmap trf) */
     836static const char main_key_TR_F[MAIN_LEN][4] =
     837{
     838"+*","1!","2\"","3^#","4$","5%","6&","7'","8(","9)","0=","/?","-_",
     839"fF","gG","\xbb\xab","\xb9I","oO","dD","rR","nN","hH","pP","qQ","wW",
     840"uU","i\0","eE","aA","üÜ","tT","kK","mM","lL","yY","\xba\xaa","xX",
     841"jJ","öÖ","vV","cC","çÇ","zZ","sS","bB",".:",",;",
     842"<>"
    708843};
    709844
     
    757892 "aA¿Ä","sS˦","dD¡¯","fF´â","gGà¬","hHéç","jJèë","kKÒÉ","lLÊÈ",";:Ç«","\'\"§.","\\|£¥",
    758893 "zZ¼(","xX»)","cCá©","vVÍÎ","bBÚ","nN×ì","mM·?",",<Á²",".>ãÌ","/?½Æ"
    759 };
     894}; 
    760895
    761896/*** VNC keyboard layout */
     
    769904static const WORD main_key_vkey_vnc[MAIN_LEN] =
    770905{
    771    VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_MINUS,VK_OEM_PLUS,VK_OEM_4,VK_OEM_6,VK_OEM_1,VK_OEM_7,VK_OEM_3,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,VK_OEM_5,
    772    VK_A,VK_B,VK_C,VK_D,VK_E,VK_F,VK_G,VK_H,VK_I,VK_J,VK_K,VK_L,VK_M,VK_N,VK_O,VK_P,VK_Q,VK_R,VK_S,VK_T,VK_U,VK_V,VK_W,VK_X,VK_Y,VK_Z,
     906   '1','2','3','4','5','6','7','8','9','0',VK_OEM_MINUS,VK_OEM_PLUS,VK_OEM_4,VK_OEM_6,VK_OEM_1,VK_OEM_7,VK_OEM_3,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,VK_OEM_5,
     907   'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
    773908   VK_OEM_102
    774909};
     
    818953 {0x040c, "French keyboard layout", &main_key_FR, &main_key_scan_qwerty, &main_key_vkey_azerty},
    819954 {0x0c0c, "Canadian French keyboard layout", &main_key_CF, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     955 {0x0c0c, "Canadian French keyboard layout (CA_fr)", &main_key_CA_fr, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     956 {0x0c0c, "Canadian keyboard layout", &main_key_CA, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    820957 {0x080c, "Belgian keyboard layout", &main_key_BE, &main_key_scan_qwerty, &main_key_vkey_azerty},
    821958 {0x0816, "Portuguese keyboard layout", &main_key_PT, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     
    832969 {0x0419, "Russian phonetic keyboard layout", &main_key_RU_phonetic, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    833970 {0x0422, "Ukrainian keyboard layout KOI8-U", &main_key_UA, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     971 {0x0422, "Ukrainian keyboard layout (standard)", &main_key_UA_std, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     972 {0x0419, "Russian keyboard layout (standard)", &main_key_RU_std, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    834973 {0x040a, "Spanish keyboard layout", &main_key_ES, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    835974 {0x0410, "Italian keyboard layout", &main_key_IT, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     
    838977 {0x0415, "Polish (programmer's) keyboard layout", &main_key_PL, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    839978 {0x0424, "Slovenian keyboard layout", &main_key_SI, &main_key_scan_qwerty, &main_key_vkey_qwertz},
     979 {0x0c1a, "Serbian keyboard layout sr", &main_key_SR, &main_key_scan_qwerty, &main_key_vkey_qwerty}, /* LANG_SERBIAN,SUBLANG_SERBIAN_CYRILLIC */
     980 {0x0c1a, "Serbian keyboard layout us,sr", &main_key_US_SR, &main_key_scan_qwerty, &main_key_vkey_qwerty}, /* LANG_SERBIAN,SUBLANG_SERBIAN_CYRILLIC */
    840981 {0x041a, "Croatian keyboard layout", &main_key_HR, &main_key_scan_qwerty, &main_key_vkey_qwertz},
    841982 {0x041a, "Croatian keyboard layout (specific)", &main_key_HR_jelly, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    842  {0xe0010411, "Japanese 106 keyboard layout", &main_key_JA_jp106, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    843  {0xe0010411, "Japanese pc98x1 keyboard layout", &main_key_JA_pc98x1, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     983 {0x0411, "Japanese 106 keyboard layout", &main_key_JA_jp106, &main_key_scan_qwerty_jp106, &main_key_vkey_qwerty_jp106},
     984 {0x0411, "Japanese pc98x1 keyboard layout", &main_key_JA_pc98x1, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    844985 {0x041b, "Slovak keyboard layout", &main_key_SK, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    845986 {0x041b, "Slovak and Czech keyboard layout without dead keys", &main_key_SK_prog, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     
    850991 {0x0427, "Lithuanian (Baltic) keyboard layout", &main_key_LT_B, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    851992 {0x041f, "Turkish keyboard layout", &main_key_TK, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     993 {0x041f, "Turkish keyboard layout tr", &main_key_TR, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     994 {0x041f, "Turkish keyboard layout trf", &main_key_TR_F, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    852995 {0x040d, "Israelian keyboard layout", &main_key_IL, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    853996 {0x040d, "Israelian phonetic keyboard layout", &main_key_IL_phonetic, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     
    8911034    0, 0, 0, 0, 0, 0, 0, 0,                                     /* FF58 */
    8921035    /* misc keys */
    893     VK_SELECT, VK_SNAPSHOT, VK_EXECUTE, VK_INSERT, 0, 0, 0,     /* FF60 */
    894     VK_APPS,
    895     VK_CANCEL, VK_HELP, VK_CANCEL, VK_CANCEL, 0, 0, 0, 0,       /* FF68 */
     1036    VK_SELECT, VK_SNAPSHOT, VK_EXECUTE, VK_INSERT, 0,0,0, VK_APPS, /* FF60 */
     1037    0, VK_CANCEL, VK_HELP, VK_CANCEL, 0, 0, 0, 0,               /* FF68 */
    8961038    0, 0, 0, 0, 0, 0, 0, 0,                                     /* FF70 */
    8971039    /* keypad keys */
     
    9011043    0, 0, 0, 0, 0, VK_HOME, VK_LEFT, VK_UP,                     /* FF90 */
    9021044    VK_RIGHT, VK_DOWN, VK_PRIOR, VK_NEXT,                       /* FF98 */
    903     VK_END, 0, VK_INSERT, VK_DELETE,
     1045    VK_END, VK_CLEAR, VK_INSERT, VK_DELETE,
    9041046    0, 0, 0, 0, 0, 0, 0, 0,                                     /* FFA0 */
    9051047    0, 0, VK_MULTIPLY, VK_ADD,                                  /* FFA8 */
     
    9071049    VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,             /* FFB0 */
    9081050    VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
    909     VK_NUMPAD8, VK_NUMPAD9, 0, 0, 0, 0,                         /* FFB8 */
     1051    VK_NUMPAD8, VK_NUMPAD9, 0, 0, 0, VK_OEM_NEC_EQUAL,          /* FFB8 */
    9101052    /* function keys */
    9111053    VK_F1, VK_F2,
    9121054    VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10,    /* FFC0 */
    913     VK_F11, VK_F12, VK_LWIN /*VK_F13*/, VK_RWIN /*VK_F14*/,     /* FFC8 */
    914     VK_F15, VK_F16, 0, 0,
     1055    VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, 0, 0,       /* FFC8 */
    9151056    0, 0, 0, 0, 0, 0, 0, 0,                                     /* FFD0 */
    9161057    0, 0, 0, 0, 0, 0, 0, 0,                                     /* FFD8 */
     
    9421083    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FF58 */
    9431084    /* misc keys */
    944     /*?*/ 0, 0x137, /*?*/ 0, 0x152, 0x00, 0x00, 0x00, 0x15D,     /* FF60 */
     1085    /*?*/ 0, 0x137, /*?*/ 0, 0x152, 0x00, 0x00, 0x00, 0x00,      /* FF60 */
    9451086    /*?*/ 0, /*?*/ 0, 0x38, 0x146, 0x00, 0x00, 0x00, 0x00,       /* FF68 */
    9461087    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FF70 */
     
    9521093    0x4D, 0x50, 0x49, 0x51, 0x4F, 0x4C, 0x52, 0x53,              /* FF98 */
    9531094    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FFA0 */
    954     0x00, 0x00, 0x37, 0x4E, /*?*/ 0, 0x4A, 0x53, 0x135,          /* FFA8 */
     1095    0x00, 0x00, 0x37, 0x4E, 0x53, 0x4A, 0x53, 0x135,             /* FFA8 */
    9551096    0x52, 0x4F, 0x50, 0x51, 0x4B, 0x4C, 0x4D, 0x47,              /* FFB0 */
    9561097    0x48, 0x49, 0x00, 0x00, 0x00, 0x00,                          /* FFB8 */
     
    9581099    0x3B, 0x3C,
    9591100    0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44,              /* FFC0 */
    960     0x57, 0x58, 0x15B, 0x15C, 0x00, 0x00, 0x00, 0x00,            /* FFC8 */
     1101    0x57, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FFC8 */
    9611102    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FFD0 */
    9621103    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FFD8 */
     
    9681109};
    9691110
     1111static const WORD xfree86_vendor_key_vkey[256] =
     1112{
     1113    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF00 */
     1114    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF08 */
     1115    0, VK_VOLUME_DOWN, VK_VOLUME_MUTE, VK_VOLUME_UP,            /* 1008FF10 */
     1116    VK_MEDIA_PLAY_PAUSE, VK_MEDIA_STOP,
     1117    VK_MEDIA_PREV_TRACK, VK_MEDIA_NEXT_TRACK,
     1118    0, VK_LAUNCH_MAIL, 0, VK_BROWSER_SEARCH,                    /* 1008FF18 */
     1119    0, 0, 0, VK_BROWSER_HOME,
     1120    0, 0, 0, 0, 0, 0, VK_BROWSER_BACK, VK_BROWSER_FORWARD,      /* 1008FF20 */
     1121    VK_BROWSER_STOP, VK_BROWSER_REFRESH, 0, 0, 0, 0, 0, 0,      /* 1008FF28 */
     1122    VK_BROWSER_FAVORITES, 0, VK_LAUNCH_MEDIA_SELECT, 0,         /* 1008FF30 */
     1123    0, 0, 0, 0,
     1124    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF38 */
     1125    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF40 */
     1126    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF48 */
     1127    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF50 */
     1128    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF58 */
     1129    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF60 */
     1130    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF68 */
     1131    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF70 */
     1132    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF78 */
     1133    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF80 */
     1134    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF88 */
     1135    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF90 */
     1136    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF98 */
     1137    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFA0 */
     1138    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFA8 */
     1139    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFB0 */
     1140    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFB8 */
     1141    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFC0 */
     1142    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFC8 */
     1143    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFD0 */
     1144    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFD8 */
     1145    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFE0 */
     1146    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFE8 */
     1147    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFF0 */
     1148    0, 0, 0, 0, 0, 0, 0, 0                                      /* 1008FFF8 */
     1149};
    9701150
    9711151/* Returns the Windows virtual key code associated with the X event <e> */
     
    9741154{
    9751155    KeySym keysym = 0;
    976 
    977     if (xic)
    978         XmbLookupString(xic, e, NULL, 0, &keysym, NULL);
     1156    Status status;
     1157    char buf[24];
     1158
     1159    /* Clients should pass only KeyPress events to XmbLookupString */
     1160    if (xic && e->type == KeyPress)
     1161        XmbLookupString(xic, e, buf, sizeof(buf), &keysym, &status);
    9791162    else
    980         XLookupString(e, NULL, 0, &keysym, NULL);
    981 
    982     if ((keysym >= 0xFFAE) && (keysym <= 0xFFB9) && (keysym != 0xFFAF)
    983         && (e->state & NumLockMask))
     1163        XLookupString(e, buf, sizeof(buf), &keysym, NULL);
     1164
     1165    if ((e->state & NumLockMask) &&
     1166        (keysym == XK_KP_Separator || keysym == XK_KP_Decimal ||
     1167         (keysym >= XK_KP_0 && keysym <= XK_KP_9)))
    9841168        /* Only the Keypad keys 0-9 and . send different keysyms
    9851169         * depending on the NumLock state */
     
    9931177static BOOL NumState=FALSE, CapsState=FALSE;
    9941178
     1179
    9951180/***********************************************************************
    996  *           send_keyboard_input
     1181 *           X11DRV_send_keyboard_input
    9971182 */
    998 static void send_keyboard_input( WORD wVk, WORD wScan, DWORD dwFlags, DWORD time )
     1183void X11DRV_send_keyboard_input( WORD wVk, WORD wScan, DWORD dwFlags, DWORD time,
     1184                                 DWORD dwExtraInfo, UINT injected_flags )
    9991185{
    10001186#ifndef OUTOFWINE
    1001     INPUT input;
    1002 
    1003     input.type             = WINE_INTERNAL_INPUT_KEYBOARD;
    1004     input.u.ki.wVk         = wVk;
    1005     input.u.ki.wScan       = wScan;
    1006     input.u.ki.dwFlags     = dwFlags;
    1007     input.u.ki.time        = time;
    1008     input.u.ki.dwExtraInfo = 0;
    1009     SendInput( 1, &input, sizeof(input) );
    1010 #else
     1187    UINT message;
     1188    KEYLP keylp;
     1189    KBDLLHOOKSTRUCT hook;
     1190    WORD wVkStripped;
     1191
     1192    wVk = LOBYTE(wVk);
     1193
     1194    /* strip left/right for menu, control, shift */
     1195    if (wVk == VK_LMENU || wVk == VK_RMENU)
     1196        wVkStripped = VK_MENU;
     1197    else if (wVk == VK_LCONTROL || wVk == VK_RCONTROL)
     1198        wVkStripped = VK_CONTROL;
     1199    else if (wVk == VK_LSHIFT || wVk == VK_RSHIFT)
     1200        wVkStripped = VK_SHIFT;
     1201    else
     1202        wVkStripped = wVk;
     1203
     1204    keylp.lp2 = 0;
     1205    keylp.lp1.count = 1;
     1206    keylp.lp1.code = wScan;
     1207    keylp.lp1.extended = (dwFlags & KEYEVENTF_EXTENDEDKEY) != 0;
     1208    keylp.lp1.win_internal = 0; /* this has something to do with dialogs,
     1209                                * don't remember where I read it - AK */
     1210                                /* it's '1' under windows, when a dialog box appears
     1211                                 * and you press one of the underlined keys - DF*/
     1212
     1213    /* note that there is a test for all this */
     1214    if (dwFlags & KEYEVENTF_KEYUP )
     1215    {
     1216        message = WM_KEYUP;
     1217        if ((key_state_table[VK_MENU] & 0x80) &&
     1218            ((wVkStripped == VK_MENU) || (wVkStripped == VK_CONTROL)
     1219             || !(key_state_table[VK_CONTROL] & 0x80)))
     1220        {
     1221            if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
     1222                (wVkStripped != VK_MENU)) /* <ALT>-down...<something else>-up */
     1223                message = WM_SYSKEYUP;
     1224            TrackSysKey = 0;
     1225        }
     1226        key_state_table[wVk] &= ~0x80;
     1227        key_state_table[wVkStripped] &= ~0x80;
     1228        keylp.lp1.previous = 1;
     1229        keylp.lp1.transition = 1;
     1230    }
     1231    else
     1232    {
     1233        keylp.lp1.previous = (key_state_table[wVk] & 0x80) != 0;
     1234        keylp.lp1.transition = 0;
     1235        if (!(key_state_table[wVk] & 0x80)) key_state_table[wVk] ^= 0x01;
     1236        key_state_table[wVk] |= 0xc0;
     1237        key_state_table[wVkStripped] |= 0xc0;
     1238
     1239        message = WM_KEYDOWN;
     1240        if ((key_state_table[VK_MENU] & 0x80) && !(key_state_table[VK_CONTROL] & 0x80))
     1241        {
     1242            message = WM_SYSKEYDOWN;
     1243            TrackSysKey = wVkStripped;
     1244        }
     1245    }
     1246
     1247    keylp.lp1.context = (key_state_table[VK_MENU] & 0x80) != 0; /* 1 if alt */
     1248
     1249    TRACE_(key)(" wParam=%04x, lParam=%08lx, InputKeyState=%x\n",
     1250                wVk, keylp.lp2, key_state_table[wVk] );
     1251
     1252    hook.vkCode      = wVk;
     1253    hook.scanCode    = wScan;
     1254    hook.flags       = (keylp.lp2 >> 24) | injected_flags;
     1255    hook.time        = time;
     1256    hook.dwExtraInfo = dwExtraInfo;
     1257    if (HOOK_CallHooks( WH_KEYBOARD_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) return;
     1258
     1259    SERVER_START_REQ( send_hardware_message )
     1260    {
     1261        req->id       = (injected_flags & LLKHF_INJECTED) ? 0 : GetCurrentThreadId();
     1262        req->win      = 0;
     1263        req->msg      = message;
     1264        req->wparam   = wVk;
     1265        req->lparam   = keylp.lp2;
     1266        req->x        = cursor_pos.x;
     1267        req->y        = cursor_pos.y;
     1268        req->time     = time;
     1269        req->info     = dwExtraInfo;
     1270        wine_server_call( req );
     1271    }
     1272    SERVER_END_REQ;
     1273#else // OUTOFWINE defined
    10111274    // fill out our global structure
    10121275    wineKeyboardInfo->wVk = wVk;
     
    10141277    wineKeyboardInfo->dwFlags = dwFlags;
    10151278    wineKeyboardInfo->time = time;
    1016 #endif
     1279#endif // OUTOFWINE defined
    10171280}
    10181281
    10191282
    10201283/**********************************************************************
    1021  *      KEYBOARD_GenerateMsg
     1284 *              KEYBOARD_GenerateMsg
    10221285 *
    10231286 * Generate Down+Up messages when NumLock or CapsLock is pressed.
     
    10361299       And from there, a 'release' event will switch off the toggle key. */
    10371300    *State=FALSE;
    1038     TRACE("INTERM : don\'t treat release of toggle key. InputKeyStateTable[%#x] = %#x\n",vkey,pKeyStateTable[vkey]);
     1301    TRACE("INTERM : don't treat release of toggle key. key_state_table[%#x] = %#x\n",
     1302          vkey,key_state_table[vkey]);
    10391303  } else
    10401304    {
    10411305        down = (vkey==VK_NUMLOCK ? KEYEVENTF_EXTENDEDKEY : 0);
    10421306        up = (vkey==VK_NUMLOCK ? KEYEVENTF_EXTENDEDKEY : 0) | KEYEVENTF_KEYUP;
    1043         if ( pKeyStateTable[vkey] & 0x1 ) /* it was ON */
     1307        if ( key_state_table[vkey] & 0x1 ) /* it was ON */
    10441308          {
    10451309            if (Evtype!=KeyPress)
    10461310              {
    10471311                TRACE("ON + KeyRelease => generating DOWN and UP messages.\n");
    1048                 send_keyboard_input( vkey, scan, down, event_time );
    1049                 send_keyboard_input( vkey, scan, up, event_time );
     1312                X11DRV_send_keyboard_input( vkey, scan, down, event_time, 0, 0 );
     1313                X11DRV_send_keyboard_input( vkey, scan, up, event_time, 0, 0 );
    10501314                *State=FALSE;
    1051                 pKeyStateTable[vkey] &= ~0x01; /* Toggle state to off. */
     1315                key_state_table[vkey] &= ~0x01; /* Toggle state to off. */
    10521316              }
    10531317          }
     
    10561320            {
    10571321              TRACE("OFF + Keypress => generating DOWN and UP messages.\n");
    1058               send_keyboard_input( vkey, scan, down, event_time );
    1059               send_keyboard_input( vkey, scan, up, event_time );
     1322              X11DRV_send_keyboard_input( vkey, scan, down, event_time, 0, 0 );
     1323              X11DRV_send_keyboard_input( vkey, scan, up, event_time, 0, 0 );
    10601324              *State=TRUE; /* Goes to intermediary state before going to ON */
    1061               pKeyStateTable[vkey] |= 0x01; /* Toggle state to on. */
     1325              key_state_table[vkey] |= 0x01; /* Toggle state to on. */
    10621326            }
    10631327    }
     
    10731337{
    10741338    /* Do something if internal table state != X state for keycode */
    1075     if (((pKeyStateTable[vkey] & 0x80)!=0) != state)
     1339    if (((key_state_table[vkey] & 0x80)!=0) != state)
    10761340    {
    10771341        TRACE("Adjusting state for vkey %#.2x. State before %#.2x\n",
    1078               vkey, pKeyStateTable[vkey]);
     1342              vkey, key_state_table[vkey]);
    10791343
    10801344        /* Fake key being pressed inside wine */
    1081         send_keyboard_input( vkey, 0, state? 0 : KEYEVENTF_KEYUP, time );
    1082 
    1083         TRACE("State after %#.2x\n",pKeyStateTable[vkey]);
     1345        X11DRV_send_keyboard_input( vkey, 0, state? 0 : KEYEVENTF_KEYUP, time, 0, 0 );
     1346
     1347        TRACE("State after %#.2x\n",key_state_table[vkey]);
    10841348    }
    10851349}
     
    10941358 * Toggle keys are handled in HandleEvent.
    10951359 */
    1096 void X11DRV_KeymapNotify( HWND hwnd, XKeymapEvent *event )
     1360void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
    10971361{
    10981362    int i, j, alt, control, shift;
    10991363#ifndef OUTOFWINE
    11001364    DWORD time = GetCurrentTime();
    1101 #else
     1365#else // OUTOFWINE defined
    11021366    // @@@AH todo!
    11031367    DWORD time = 0;
    1104 #endif
     1368#endif // OUTOFWINE defined
    11051369
    11061370    alt = control = shift = 0;
    1107     for (i = 0; i < 32; i++)
     1371    /* the minimum keycode is always greater or equal to 8, so we can
     1372     * skip the first 8 values, hence start at 1
     1373     */
     1374    for (i = 1; i < 32; i++)
    11081375    {
    1109         if (!event->key_vector[i]) continue;
     1376        if (!event->xkeymap.key_vector[i]) continue;
    11101377        for (j = 0; j < 8; j++)
    11111378        {
    1112             if (!(event->key_vector[i] & (1<<j))) continue;
     1379            if (!(event->xkeymap.key_vector[i] & (1<<j))) continue;
    11131380            switch(keyc2vkey[(i * 8) + j] & 0xff)
    11141381            {
     
    11301397 */
    11311398#ifndef OUTOFWINE
    1132 void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event )
    1133 #else
    1134 void X11DRV_KeyEvent(XKeyEvent *event, WINEKEYBOARDINFO *wKbInfo)
    1135 #endif
    1136 {
     1399void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
     1400#else // OUTOFWINE defined
     1401void X11DRV_KeyEvent(XEvent *xev, WINEKEYBOARDINFO *wKbInfo)
     1402#endif // OUTOFWINE defined
     1403{
     1404    XKeyEvent *event = &xev->xkey;
    11371405    char Str[24];
    11381406    KeySym keysym = 0;
     
    11421410#ifndef OUTOFWINE
    11431411    XIC xic = X11DRV_get_ic( hwnd );
    1144 #else
     1412    DWORD event_time = EVENT_x11_time_to_win32_time(event->time);
     1413#else // OUTOFWINE defined
    11451414    // @@@AH do we need support for XIM?
    11461415    XIC xic = 0;
     
    11501419    wineKeyboardInfo = wKbInfo;
    11511420    memset( wineKeyboardInfo, 0, sizeof( wineKeyboardInfo ) );
    1152 #endif
    1153     DWORD event_time = event->time - X11DRV_server_startticks;
     1421    // We don't use this anyway.
     1422    DWORD event_time = 0;
     1423#endif // OUTOFWINE defined
    11541424    Status status = 0;
    11551425
     
    11581428
    11591429    wine_tsx11_lock();
    1160     if (xic)
     1430    /* Clients should pass only KeyPress events to XmbLookupString */
     1431    if (xic && event->type == KeyPress)
    11611432        ascii_chars = XmbLookupString(xic, event, Str, sizeof(Str), &keysym, &status);
    11621433    else
    11631434        ascii_chars = XLookupString(event, Str, sizeof(Str), &keysym, NULL);
    11641435    wine_tsx11_unlock();
    1165 
    1166     /* Ignore some unwanted events */
    1167 // @@@AH VBOX AltGr hack
    1168 //    if (((keysym >= XK_ISO_Lock && keysym <= XK_ISO_Last_Group_Lock) ||
    1169 //         keysym == XK_Mode_switch) && (keysym != XK_ISO_Level3_Shift))
    1170 /// @todo (dmik):
    1171 //      the above |if| is too dangerous because it disables many key events
    1172 //      (for example, both Shift release events when Left Shift + Right Shift
    1173 //      is configured as a mode (group) switch.
    1174     if (keysym == XK_Mode_switch)
    1175     {
    1176         wine_tsx11_lock();
    1177         TRACE("Ignoring %s keyboard event\n", XKeysymToString(keysym));
    1178         wine_tsx11_unlock();
    1179         return;
    1180     }
    11811436
    11821437    TRACE_(key)("state = %X nbyte = %d, status 0x%x\n", event->state, ascii_chars, status);
     
    11911446        return;
    11921447    }
    1193 #endif
     1448#endif // OUTOFWINE not defined
    11941449
    11951450    /* If XKB extensions are used, the state mask for AltGr will use the group
     
    12071462    Str[ascii_chars] = '\0';
    12081463    if (TRACE_ON(key)){
    1209         char  *ksname;
     1464        const char *ksname;
    12101465
    12111466        wine_tsx11_lock();
     
    12421497//      break;
    12431498//    case VK_CAPITAL:
    1244 //      TRACE("Caps Lock event. (type %d). State before : %#.2x\n",event->type,pKeyStateTable[vkey]);
     1499//      TRACE("Caps Lock event. (type %d). State before : %#.2x\n",event->type,key_state_table[vkey]);
    12451500//      KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, event->type, event_time );
    1246 //      TRACE("State after : %#.2x\n",pKeyStateTable[vkey]);
     1501//      TRACE("State after : %#.2x\n",key_state_table[vkey]);
    12471502//      break;
    12481503//    default:
    12491504//        /* Adjust the NUMLOCK state if it has been changed outside wine */
    1250 //  if (!(pKeyStateTable[VK_NUMLOCK] & 0x01) != !(event->state & NumLockMask))
    1251 //    {
    1252 //      TRACE("Adjusting NumLock state.\n");
    1253 //      KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyPress, event_time );
    1254 //      KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyRelease, event_time );
    1255 //    }
     1505//      if (!(key_state_table[VK_NUMLOCK] & 0x01) != !(event->state & NumLockMask))
     1506//        {
     1507//          TRACE("Adjusting NumLock state.\n");
     1508//          KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyPress, event_time );
     1509//          KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyRelease, event_time );
     1510//        }
    12561511//        /* Adjust the CAPSLOCK state if it has been changed outside wine */
    1257 //  if (!(pKeyStateTable[VK_CAPITAL] & 0x01) != !(event->state & LockMask))
    1258 //    {
     1512//      if (!(key_state_table[VK_CAPITAL] & 0x01) != !(event->state & LockMask))
     1513//        {
    12591514//              TRACE("Adjusting Caps Lock state.\n");
    1260 //      KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyPress, event_time );
    1261 //      KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyRelease, event_time );
    1262 //    }
    1263 //  /* Not Num nor Caps : end of intermediary states for both. */
    1264 //  NumState = FALSE;
    1265 //  CapsState = FALSE;
     1515//          KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyPress, event_time );
     1516//          KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyRelease, event_time );
     1517//        }
     1518//      /* Not Num nor Caps : end of intermediary states for both. */
     1519//      NumState = FALSE;
     1520//      CapsState = FALSE;
    12661521
    12671522        bScan = keyc2scan[event->keycode] & 0xFF;
     
    12721527        if ( vkey & 0x100 )              dwFlags |= KEYEVENTF_EXTENDEDKEY;
    12731528
    1274         send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time );
     1529        X11DRV_send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time, 0, 0 );
    12751530//    }
    12761531   }
     
    12781533
    12791534/**********************************************************************
    1280  *      X11DRV_KEYBOARD_DetectLayout
     1535 *              X11DRV_KEYBOARD_DetectLayout
    12811536 *
    12821537 * Called from X11DRV_InitKeyboard
     
    12911546  unsigned current, match, mismatch, seq, i, syms;
    12921547  int score, keyc, key, pkey, ok;
    1293   KeySym keysym;
     1548  KeySym keysym = 0;
    12941549  const char (*lkey)[MAIN_LEN][4];
    12951550  unsigned max_seq = 0;
    12961551  int max_score = 0, ismatch = 0;
    1297   char ckey[4] =
    1298   {0, 0, 0, 0};
     1552  char ckey[256][4];
    12991553
    13001554  syms = keysyms_per_keycode;
     
    13031557    syms = 4;
    13041558  }
     1559
     1560  memset( ckey, 0, sizeof(ckey) );
     1561  for (keyc = min_keycode; keyc <= max_keycode; keyc++) {
     1562      /* get data for keycode from X server */
     1563      for (i = 0; i < syms; i++) {
     1564        if (!(keysym = XKeycodeToKeysym (display, keyc, i))) continue;
     1565        /* Allow both one-byte and two-byte national keysyms */
     1566        if ((keysym < 0x8000) && (keysym != ' '))
     1567        {
     1568#ifdef HAVE_XKB
     1569            if (!use_xkb || !XkbTranslateKeySym(display, &keysym, 0, &ckey[keyc][i], 1, NULL))
     1570#endif
     1571            {
     1572                TRACE("XKB could not translate keysym %ld\n", keysym);
     1573                /* FIXME: query what keysym is used as Mode_switch, fill XKeyEvent
     1574                 * with appropriate ShiftMask and Mode_switch, use XLookupString
     1575                 * to get character in the local encoding.
     1576                 */
     1577                ckey[keyc][i] = keysym & 0xFF;
     1578            }
     1579        }
     1580        else {
     1581          ckey[keyc][i] = KEYBOARD_MapDeadKeysym(keysym);
     1582        }
     1583      }
     1584  }
     1585
    13051586  for (current = 0; main_key_tab[current].comment; current++) {
    13061587    TRACE("Attempting to match against \"%s\"\n", main_key_tab[current].comment);
     
    13121593    pkey = -1;
    13131594    for (keyc = min_keycode; keyc <= max_keycode; keyc++) {
    1314       /* get data for keycode from X server */
    1315       for (i = 0; i < syms; i++) {
    1316         keysym = XKeycodeToKeysym (display, keyc, i);
    1317         /* Allow both one-byte and two-byte national keysyms */
    1318         if ((keysym < 0x8000) && (keysym != ' '))
    1319         {
    1320 #ifdef HAVE_XKB
    1321             if (!use_xkb || !XkbTranslateKeySym(display, &keysym, 0, &ckey[i], 1, NULL))
    1322 #endif
    1323             {
    1324                 TRACE("XKB could not translate keysym %ld\n", keysym);
    1325                 /* FIXME: query what keysym is used as Mode_switch, fill XKeyEvent
    1326                  * with appropriate ShiftMask and Mode_switch, use XLookupString
    1327                  * to get character in the local encoding.
    1328                  */
    1329                 ckey[i] = keysym & 0xFF;
    1330             }
    1331         }
    1332         else {
    1333           ckey[i] = KEYBOARD_MapDeadKeysym(keysym);
    1334         }
    1335       }
    1336       if (ckey[0]) {
     1595      if (ckey[keyc][0]) {
    13371596        /* search for a match in layout table */
    13381597        /* right now, we just find an absolute match for defined positions */
    13391598        /* (undefined positions are ignored, so if it's defined as "3#" in */
    1340         /* the table, it's okay that the X server has "3#£", for example) */
     1599        /* the table, it's okay that the X server has "3#�", for example) */
    13411600        /* however, the score will be higher for longer matches */
    13421601        for (key = 0; key < MAIN_LEN; key++) {
    13431602          for (ok = 0, i = 0; (ok >= 0) && (i < syms); i++) {
    1344             if ((*lkey)[key][i] && ((*lkey)[key][i] == ckey[i]))
     1603            if ((*lkey)[key][i] && ((*lkey)[key][i] == ckey[keyc][i]))
    13451604              ok++;
    1346             if ((*lkey)[key][i] && ((*lkey)[key][i] != ckey[i]))
     1605            if ((*lkey)[key][i] && ((*lkey)[key][i] != ckey[keyc][i]))
    13471606              ok = -1;
    13481607          }
     
    13601619        } else {
    13611620          /* print spaces instead of \0's */
    1362           for (i = 0; i < sizeof(ckey); i++) if (!ckey[i]) ckey[i] = ' ';
    1363           TRACE_(key)("mismatch for keysym 0x%04lX, keycode %d, got %c%c%c%c\n",
    1364                       keysym, keyc, ckey[0], ckey[1], ckey[2], ckey[3]);
    1365           mismatch++;
    1366           score -= syms;
     1621          char str[5];
     1622          for (i = 0; i < 4; i++) str[i] = ckey[keyc][i] ? ckey[keyc][i] : ' ';
     1623          str[4] = 0;
     1624          TRACE_(key)("mismatch for keysym 0x%04lX, keycode %d, got %s\n", keysym, keyc, str );
     1625          mismatch++;
     1626          score -= syms;
    13671627        }
    13681628      }
     
    13881648
    13891649/**********************************************************************
    1390  *      InitKeyboard (X11DRV.@)
     1650 *              X11DRV_InitKeyboard
    13911651 */
    1392 void X11DRV_InitKeyboard( BYTE *key_state_table )
     1652void X11DRV_InitKeyboard(void)
    13931653{
    13941654    Display *display = thread_display();
     
    14021662    char ckey[4]={0,0,0,0};
    14031663    const char (*lkey)[MAIN_LEN][4];
    1404 
    1405     pKeyStateTable = key_state_table;
     1664    char vkey_used[256] = { 0 };
    14061665
    14071666    wine_tsx11_lock();
     
    14471706
    14481707    OEMvkey = VK_OEM_8; /* next is available.  */
     1708    memset(keyc2vkey, 0, sizeof(keyc2vkey));
    14491709    for (keyc = min_keycode; keyc <= max_keycode; keyc++)
    14501710    {
     
    14641724                /* set extended bit when necessary */
    14651725                if (scan & 0x100) vkey |= 0x100;
     1726            } else if ((keysym >> 8) == 0x1008FF) { /* XFree86 vendor keys */
     1727                vkey = xfree86_vendor_key_vkey[keysym & 0xff];
     1728                /* All vendor keys are extended with a scan code of 0 per testing on WinXP */
     1729                scan = 0x100;
     1730                vkey |= 0x100;
    14661731            } else if (keysym == 0x20) {                 /* Spacebar */
    14671732                vkey = VK_SPACE;
     
    14921757                for (ok=(*lkey)[keyn][i=0]; ok&&(i<4); i++)
    14931758                  if ((*lkey)[keyn][i] && (*lkey)[keyn][i]!=ckey[i]) ok=0;
     1759                if (!ok) i--; /* we overshot */
    14941760                if (ok||(i>maxlen)) {
    14951761                  maxlen=i; maxval=keyn;
     
    15051771              }
    15061772            }
    1507 #if 0 /* this breaks VK_OEM_x VKeys in some layout tables by inserting
    1508        * a VK code into a not appropriate place.
    1509        */
    1510             /* find a suitable layout-dependent VK code */
    1511             /* (most Winelib apps ought to be able to work without layout tables!) */
    1512             for (i = 0; (i < keysyms_per_keycode) && (!vkey); i++)
     1773        }
     1774        TRACE("keycode %04x => vkey %04x\n", e2.keycode, vkey);
     1775        keyc2vkey[e2.keycode] = vkey;
     1776        keyc2scan[e2.keycode] = scan;
     1777        if ((vkey & 0xff) && vkey_used[(vkey & 0xff)])
     1778            WARN("vkey %04x is being used by more than one keycode\n", vkey);
     1779        vkey_used[(vkey & 0xff)] = 1;
     1780    } /* for */
     1781
     1782#define VKEY_IF_NOT_USED(vkey) (vkey_used[(vkey)] ? 0 : (vkey_used[(vkey)] = 1, (vkey)))
     1783    for (keyc = min_keycode; keyc <= max_keycode; keyc++)
     1784    {
     1785        vkey = keyc2vkey[keyc] & 0xff;
     1786        if (vkey)
     1787            continue;
     1788
     1789        e2.keycode = (KeyCode)keyc;
     1790        keysym = XLookupKeysym(&e2, 0);
     1791        if (!keysym)
     1792           continue;
     1793
     1794        /* find a suitable layout-dependent VK code */
     1795        /* (most Winelib apps ought to be able to work without layout tables!) */
     1796        for (i = 0; (i < keysyms_per_keycode) && (!vkey); i++)
     1797        {
     1798            keysym = XLookupKeysym(&e2, i);
     1799            if ((keysym >= XK_0 && keysym <= XK_9)
     1800                || (keysym >= XK_A && keysym <= XK_Z)) {
     1801                vkey = VKEY_IF_NOT_USED(keysym);
     1802            }
     1803        }
     1804
     1805        for (i = 0; (i < keysyms_per_keycode) && (!vkey); i++)
     1806        {
     1807            keysym = XLookupKeysym(&e2, i);
     1808            switch (keysym)
    15131809            {
    1514                 keysym = XLookupKeysym(&e2, i);
    1515                 if ((keysym >= VK_0 && keysym <= VK_9)
    1516                     || (keysym >= VK_A && keysym <= VK_Z)) {
    1517                     vkey = keysym;
    1518                 }
     1810            case ';':             vkey = VKEY_IF_NOT_USED(VK_OEM_1); break;
     1811            case '/':             vkey = VKEY_IF_NOT_USED(VK_OEM_2); break;
     1812            case '`':             vkey = VKEY_IF_NOT_USED(VK_OEM_3); break;
     1813            case '[':             vkey = VKEY_IF_NOT_USED(VK_OEM_4); break;
     1814            case '\\':            vkey = VKEY_IF_NOT_USED(VK_OEM_5); break;
     1815            case ']':             vkey = VKEY_IF_NOT_USED(VK_OEM_6); break;
     1816            case '\'':            vkey = VKEY_IF_NOT_USED(VK_OEM_7); break;
     1817            case ',':             vkey = VKEY_IF_NOT_USED(VK_OEM_COMMA); break;
     1818            case '.':             vkey = VKEY_IF_NOT_USED(VK_OEM_PERIOD); break;
     1819            case '-':             vkey = VKEY_IF_NOT_USED(VK_OEM_MINUS); break;
     1820            case '+':             vkey = VKEY_IF_NOT_USED(VK_OEM_PLUS); break;
    15191821            }
    1520 
    1521             for (i = 0; (i < keysyms_per_keycode) && (!vkey); i++)
     1822        }
     1823
     1824        if (!vkey)
     1825        {
     1826            /* Others keys: let's assign OEM virtual key codes in the allowed range,
     1827             * that is ([0xba,0xc0], [0xdb,0xe4], 0xe6 (given up) et [0xe9,0xf5]) */
     1828            do
    15221829            {
    1523                 keysym = XLookupKeysym(&e2, i);
    1524                 switch (keysym)
    1525                 {
    1526                 case ';':             vkey = VK_OEM_1; break;
    1527                 case '/':             vkey = VK_OEM_2; break;
    1528                 case '`':             vkey = VK_OEM_3; break;
    1529                 case '[':             vkey = VK_OEM_4; break;
    1530                 case '\\':            vkey = VK_OEM_5; break;
    1531                 case ']':             vkey = VK_OEM_6; break;
    1532                 case '\'':            vkey = VK_OEM_7; break;
    1533                 case ',':             vkey = VK_OEM_COMMA; break;
    1534                 case '.':             vkey = VK_OEM_PERIOD; break;
    1535                 case '-':             vkey = VK_OEM_MINUS; break;
    1536                 case '+':             vkey = VK_OEM_PLUS; break;
    1537                 }
    1538             }
    1539 #endif
    1540             if (!vkey)
    1541             {
    1542                 // @@@AH VBOX hack for AltGr
    1543                 if (e2.keycode == 0x71)
    1544                 {
    1545                     TRACE("VBOX HACK, mapping keycode 0x71 to scancode %X\n", VK_MENU);
    1546                     vkey = VK_MENU | 0x100;
    1547                 } else {
    1548                 /* Others keys: let's assign OEM virtual key codes in the allowed range,
    1549                  * that is ([0xba,0xc0], [0xdb,0xe4], 0xe6 (given up) et [0xe9,0xf5]) */
    15501830                switch (++OEMvkey)
    15511831                {
     
    15541834                case 0xf6 : OEMvkey=0xf5; WARN("No more OEM vkey available!\n");
    15551835                }
    1556 
    1557                 vkey = OEMvkey;
    1558 
    1559                 if (TRACE_ON(keyboard))
     1836            } while (OEMvkey < 0xf5 && vkey_used[OEMvkey]);
     1837
     1838            vkey = VKEY_IF_NOT_USED(OEMvkey);
     1839
     1840            if (TRACE_ON(keyboard))
     1841            {
     1842                TRACE("OEM specific virtual key %X assigned to keycode %X:\n",
     1843                                 OEMvkey, e2.keycode);
     1844                TRACE("(");
     1845                for (i = 0; i < keysyms_per_keycode; i += 1)
    15601846                {
    1561                     TRACE("OEM specific virtual key %X assigned to keycode %X:\n",
    1562                                      OEMvkey, e2.keycode);
    1563                     TRACE("(");
    1564                     for (i = 0; i < keysyms_per_keycode; i += 1)
    1565                     {
    1566                         char    *ksname;
    1567 
    1568                         keysym = XLookupKeysym(&e2, i);
    1569                         ksname = XKeysymToString(keysym);
    1570                         if (!ksname)
    1571                             ksname = "NoSymbol";
    1572                         TRACE( "%lX (%s) ", keysym, ksname);
    1573                     }
    1574                     TRACE(")\n");
     1847                    const char *ksname;
     1848
     1849                    keysym = XLookupKeysym(&e2, i);
     1850                    ksname = XKeysymToString(keysym);
     1851                    if (!ksname)
     1852                        ksname = "NoSymbol";
     1853                    TRACE( "%lX (%s) ", keysym, ksname);
    15751854                }
    1576             }}
     1855                TRACE(")\n");
     1856            }
    15771857        }
    1578         TRACE("keycode %04x => vkey %04x\n", e2.keycode, vkey);
    1579         keyc2vkey[e2.keycode] = vkey;
    1580         keyc2scan[e2.keycode] = scan;
     1858
     1859        if (vkey)
     1860        {
     1861            TRACE("keycode %04x => vkey %04x\n", e2.keycode, vkey);
     1862            keyc2vkey[e2.keycode] = vkey;
     1863        }
    15811864    } /* for */
     1865#undef VKEY_IF_NOT_USED
    15821866
    15831867    /* If some keys still lack scancodes, assign some arbitrary ones to them now */
    15841868    for (scan = 0x60, keyc = min_keycode; keyc <= max_keycode; keyc++)
    15851869      if (keyc2vkey[keyc]&&!keyc2scan[keyc]) {
    1586         char *ksname;
     1870        const char *ksname;
    15871871        keysym = XKeycodeToKeysym(display, keyc, 0);
    15881872        ksname = XKeysymToString(keysym);
     
    16151899
    16161900#ifndef OUTOFWINE
     1901/**********************************************************************
     1902 *              GetAsyncKeyState (X11DRV.@)
     1903 */
     1904SHORT X11DRV_GetAsyncKeyState(INT key)
     1905{
     1906    SHORT retval;
     1907
     1908    X11DRV_MsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_KEY, 0 );
     1909
     1910    retval = ((key_state_table[key] & 0x40) ? 0x0001 : 0) |
     1911             ((key_state_table[key] & 0x80) ? 0x8000 : 0);
     1912    key_state_table[key] &= ~0x40;
     1913    TRACE_(key)("(%x) -> %x\n", key, retval);
     1914    return retval;
     1915}
     1916
     1917
    16171918/***********************************************************************
    1618  *      GetKeyboardLayoutList (X11DRV.@)
     1919 *              GetKeyboardLayoutList (X11DRV.@)
    16191920 */
    16201921UINT X11DRV_GetKeyboardLayoutList(INT size, HKL *hkl)
     
    16331934    {
    16341935        if (hkl)
    1635             hkl[i] = (HKL)main_key_tab[i].lcid;
     1936        {
     1937            ULONG_PTR layout = main_key_tab[i].lcid;
     1938            LANGID langid;
     1939
     1940            /* see comment for GetKeyboardLayout */
     1941            langid = PRIMARYLANGID(LANGIDFROMLCID(layout));
     1942            if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
     1943                layout |= 0xe001 << 16; /* FIXME */
     1944            else
     1945                layout |= layout << 16;
     1946
     1947            hkl[i] = (HKL)layout;
     1948        }
    16361949    }
    16371950    return i;
     
    16401953
    16411954/***********************************************************************
    1642  *      GetKeyboardLayout (X11DRV.@)
     1955 *              GetKeyboardLayout (X11DRV.@)
    16431956 */
    16441957HKL X11DRV_GetKeyboardLayout(DWORD dwThreadid)
    16451958{
    1646     DWORD layout;
     1959    ULONG_PTR layout;
    16471960    LANGID langid;
    16481961
    1649     if (dwThreadid)
    1650         FIXME("couldn't return keyboard layout for thread %04lx\n", dwThreadid);
     1962    if (dwThreadid && dwThreadid != GetCurrentThreadId())
     1963        FIXME("couldn't return keyboard layout for thread %04x\n", dwThreadid);
    16511964
    16521965#if 0
     
    16621975    layout = GetUserDefaultLCID();
    16631976#endif
    1664     /*
     1977    /* 
    16651978     * Microsoft Office expects this value to be something specific
    16661979     * for Japanese and Korean Windows with an IME the value is 0xe001
     
    16711984    if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
    16721985        layout |= 0xe001 << 16; /* FIXME */
     1986    else
     1987        layout |= layout << 16;
    16731988
    16741989    return (HKL)layout;
     
    16771992
    16781993/***********************************************************************
    1679  *      GetKeyboardLayoutName (X11DRV.@)
     1994 *              GetKeyboardLayoutName (X11DRV.@)
    16801995 */
    16811996BOOL X11DRV_GetKeyboardLayoutName(LPWSTR name)
     
    16862001
    16872002    layout = main_key_tab[kbd_layout].lcid;
    1688     /* see comment above */
     2003    /* see comment for GetKeyboardLayout */
    16892004    langid = PRIMARYLANGID(LANGIDFROMLCID(layout));
    16902005    if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
    16912006        layout |= 0xe001 << 16; /* FIXME */
     2007    else
     2008        layout |= layout << 16;
    16922009
    16932010    sprintfW(name, formatW, layout);
     
    16982015
    16992016/***********************************************************************
    1700  *      LoadKeyboardLayout (X11DRV.@)
     2017 *              LoadKeyboardLayout (X11DRV.@)
    17012018 */
    17022019HKL X11DRV_LoadKeyboardLayout(LPCWSTR name, UINT flags)
     
    17092026
    17102027/***********************************************************************
    1711  *      UnloadKeyboardLayout (X11DRV.@)
     2028 *              UnloadKeyboardLayout (X11DRV.@)
    17122029 */
    17132030BOOL X11DRV_UnloadKeyboardLayout(HKL hkl)
     
    17202037
    17212038/***********************************************************************
    1722  *      ActivateKeyboardLayout (X11DRV.@)
     2039 *              ActivateKeyboardLayout (X11DRV.@)
    17232040 */
    17242041HKL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags)
     
    17332050 *           X11DRV_MappingNotify
    17342051 */
    1735 void X11DRV_MappingNotify( XMappingEvent *event )
     2052void X11DRV_MappingNotify( HWND dummy, XEvent *event )
    17362053{
    17372054    HWND hwnd;
    17382055
    17392056    wine_tsx11_lock();
    1740     XRefreshKeyboardMapping(event);
     2057    XRefreshKeyboardMapping(&event->xmapping);
    17412058    wine_tsx11_unlock();
    1742     X11DRV_InitKeyboard( pKeyStateTable );
     2059    X11DRV_InitKeyboard();
    17432060
    17442061    hwnd = GetFocus();
     
    17502067
    17512068/***********************************************************************
    1752  *      VkKeyScanEx (X11DRV.@)
     2069 *              VkKeyScanEx (X11DRV.@)
    17532070 *
    17542071 * Note: Windows ignores HKL parameter and uses current active layout instead
     
    17632080    SHORT ret;
    17642081
     2082    /* FIXME: what happens if wChar is not a Latin1 character and CP_UNIXCP
     2083     * is UTF-8 (multibyte encoding)?
     2084     */
    17652085    if (!WideCharToMultiByte(CP_UNIXCP, 0, &wChar, 1, &cChar, 1, NULL, NULL))
    17662086    {
     
    17782098    keycode = XKeysymToKeycode(display, keysym);  /* keysym -> keycode */
    17792099    if (!keycode)
    1780     { /* It didn't work ... let's try with deadchar code. */
     2100    {
     2101        if (keysym >= 0xFF00) /* Windows returns 0x0240 + cChar in this case */
     2102        {
     2103            ret = 0x0240 + cChar; /* 0x0200 indicates a control character */
     2104            TRACE(" ... returning ctrl char %#.2x\n", ret);
     2105            wine_tsx11_unlock();
     2106            return ret;
     2107        }
     2108        /* It didn't work ... let's try with deadchar code. */
    17812109        TRACE("retrying with | 0xFE00\n");
    17822110        keycode = XKeysymToKeycode(display, keysym | 0xFE00);
     
    18332161
    18342162/***********************************************************************
    1835  *      MapVirtualKeyEx (X11DRV.@)
     2163 *              MapVirtualKeyEx (X11DRV.@)
    18362164 */
    18372165UINT X11DRV_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl)
     
    18462174
    18472175        switch(wMapType) {
    1848                 case 0:   { /* vkey-code to scan-code */
     2176                case 0: { /* vkey-code to scan-code */
    18492177                        /* let's do vkey -> keycode -> scan */
    18502178                        int keyc;
     
    19062234                        if (!e.keycode)
    19072235                        {
    1908                           WARN("Unknown virtual key %X !!! \n", wCode);
     2236                          WARN("Unknown virtual key %X !!!\n", wCode);
    19092237                          wine_tsx11_unlock();
    19102238                          return 0; /* whatever */
     
    19242252
    19252253                case 3:   /* **NT only** scan-code to vkey-code but distinguish between  */
    1926                       /*             left and right  */
     2254                          /*             left and right  */
    19272255                          FIXME(" stub for NT\n");
    19282256                          return 0;
     
    19362264
    19372265/***********************************************************************
    1938  *      GetKeyNameText (X11DRV.@)
     2266 *              GetKeyNameText (X11DRV.@)
    19392267 */
    19402268INT X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize)
     
    20262354  }
    20272355
    2028   /* Finally issue FIXME for unknown keys   */
    2029 
    2030   FIXME("(%08lx,%p,%d): unsupported key, vkey=%04x, ansi=%04x\n",lParam,lpBuffer,nSize,vkey,ansi);
     2356  /* Finally issue WARN for unknown keys   */
     2357
     2358  WARN("(%08x,%p,%d): unsupported key, vkey=%04x, ansi=%04x\n",lParam,lpBuffer,nSize,vkey,ansi);
    20312359  if (lpBuffer && nSize)
    20322360    *lpBuffer = 0;
    20332361  return 0;
    20342362}
    2035 #endif // OUTOFWINE
     2363#endif // OUTOFWINE not defined
    20362364
    20372365/***********************************************************************
    2038  *      X11DRV_KEYBOARD_MapDeadKeysym
     2366 *              X11DRV_KEYBOARD_MapDeadKeysym
    20392367 */
    20402368static char KEYBOARD_MapDeadKeysym(KeySym keysym)
     
    20472375#endif
    20482376            case 0x1000FE7E : /* Xfree's XK_Dtilde */
    2049                 return '~';   /* '? */
     2377                return '~';     /* '? */
    20502378#ifdef XK_dead_acute
    20512379            case XK_dead_acute :
    20522380#endif
    20532381            case 0x1000FE27 : /* Xfree's XK_Dacute_accent */
    2054                 return 0xb4;  /* '' */
     2382                return 0xb4;    /* '' */
    20552383#ifdef XK_dead_circumflex
    20562384            case XK_dead_circumflex:
    20572385#endif
    20582386            case 0x1000FE5E : /* Xfree's XK_Dcircumflex_accent */
    2059                 return '^';   /* '> */
     2387                return '^';     /* '> */
    20602388#ifdef XK_dead_grave
    20612389            case XK_dead_grave :
    20622390#endif
    20632391            case 0x1000FE60 : /* Xfree's XK_Dgrave_accent */
    2064                 return '`';   /* '! */
     2392                return '`';     /* '! */
    20652393#ifdef XK_dead_diaeresis
    20662394            case XK_dead_diaeresis :
    20672395#endif
    20682396            case 0x1000FE22 : /* Xfree's XK_Ddiaeresis */
    2069                 return 0xa8;  /* ': */
     2397                return 0xa8;    /* ': */
    20702398#ifdef XK_dead_cedilla
    20712399            case XK_dead_cedilla :
    2072                 return 0xb8;   /* ', */
     2400                return 0xb8;    /* ', */
    20732401#endif
    20742402#ifdef XK_dead_macron
    20752403            case XK_dead_macron :
    2076                 return '-';    /* 'm isn't defined on iso-8859-x */
     2404                return '-';     /* 'm isn't defined on iso-8859-x */
    20772405#endif
    20782406#ifdef XK_dead_breve
    20792407            case XK_dead_breve :
    2080                 return 0xa2;   /* '( */
     2408                return 0xa2;    /* '( */
    20812409#endif
    20822410#ifdef XK_dead_abovedot
    20832411            case XK_dead_abovedot :
    2084                 return 0xff;   /* '. */
     2412                return 0xff;    /* '. */
    20852413#endif
    20862414#ifdef XK_dead_abovering
    20872415            case XK_dead_abovering :
    2088                 return '0';    /* '0 isn't defined on iso-8859-x */
     2416                return '0';     /* '0 isn't defined on iso-8859-x */
    20892417#endif
    20902418#ifdef XK_dead_doubleacute
    20912419            case XK_dead_doubleacute :
    2092                 return 0xbd;   /* '" */
     2420                return 0xbd;    /* '" */
    20932421#endif
    20942422#ifdef XK_dead_caron
    20952423            case XK_dead_caron :
    2096                 return 0xb7;   /* '< */
     2424                return 0xb7;    /* '< */
    20972425#endif
    20982426#ifdef XK_dead_ogonek
    20992427            case XK_dead_ogonek :
    2100                 return 0xb2;   /* '; */
     2428                return 0xb2;    /* '; */
    21012429#endif
    21022430/* FIXME: I don't know this three.
     
    21152443#ifndef OUTOFWINE
    21162444/***********************************************************************
    2117  *      ToUnicodeEx (X11DRV.@)
     2445 *              ToUnicodeEx (X11DRV.@)
    21182446 *
    21192447 * The ToUnicode function translates the specified virtual-key code and keyboard
     
    21222450 * If the specified key is a dead key, the return value is negative. Otherwise,
    21232451 * it is one of the following values:
    2124  * Value    Meaning
    2125  * 0    The specified virtual key has no translation for the current state of the keyboard.
    2126  * 1    One Windows character was copied to the buffer.
    2127  * 2    Two characters were copied to the buffer. This usually happens when a
     2452 * Value        Meaning
     2453 * 0    The specified virtual key has no translation for the current state of the keyboard.
     2454 * 1    One Windows character was copied to the buffer.
     2455 * 2    Two characters were copied to the buffer. This usually happens when a
    21282456 *      dead-key character (accent or diacritic) stored in the keyboard layout cannot
    21292457 *      be composed with the specified virtual key to form a single character.
     
    21432471    HWND focus;
    21442472    XIC xic;
     2473    Status status;
    21452474
    21462475    if (scanCode & 0x8000)
     
    21522481    if (hkl != X11DRV_GetKeyboardLayout(0))
    21532482        FIXME("keyboard layout %p is not supported\n", hkl);
     2483
     2484    if ((lpKeyState[VK_MENU] & 0x80) && (lpKeyState[VK_CONTROL] & 0x80))
     2485    {
     2486        TRACE("Ctrl+Alt+[key] won't generate a character\n");
     2487        return 0;
     2488    }
    21542489
    21552490    e.display = display;
     
    22052540      }
    22062541
     2542    if (virtKey >= VK_LEFT && virtKey <= VK_DOWN)
     2543        e.keycode = XKeysymToKeycode(e.display, virtKey - VK_LEFT + XK_Left);
     2544
    22072545    if ((virtKey>=VK_NUMPAD0) && (virtKey<=VK_NUMPAD9))
    22082546        e.keycode = XKeysymToKeycode(e.display, virtKey-VK_NUMPAD0+XK_KP_0);
     
    22112549        e.keycode = XKeysymToKeycode(e.display, XK_KP_Decimal);
    22122550
     2551    if (virtKey==VK_SEPARATOR)
     2552        e.keycode = XKeysymToKeycode(e.display, XK_KP_Separator);
     2553
    22132554    if (!e.keycode && virtKey != VK_NONAME)
    22142555      {
    2215         WARN("Unknown virtual key %X !!! \n",virtKey);
     2556        WARN("Unknown virtual key %X !!!\n", virtKey);
    22162557        wine_tsx11_unlock();
    2217         return virtKey; /* whatever */
     2558        return 0;
    22182559      }
    22192560    else TRACE("Found keycode %d (0x%2X)\n",e.keycode,e.keycode);
     
    22222563                e.type, e.window, e.state, e.keycode);
    22232564
     2565    /* Clients should pass only KeyPress events to XmbLookupString,
     2566     * e.type was set to KeyPress above.
     2567     */
    22242568    if (xic)
    2225         ret = XmbLookupString(xic, &e, lpChar, sizeof(lpChar), &keysym, NULL);
     2569        ret = XmbLookupString(xic, &e, lpChar, sizeof(lpChar), &keysym, &status);
    22262570    else
    22272571        ret = XLookupString(&e, lpChar, sizeof(lpChar), &keysym, NULL);
     
    22292573
    22302574    if (ret == 0)
    2231         {
    2232         BYTE dead_char;
     2575    {
     2576        char dead_char;
    22332577
    22342578#ifdef XK_EuroSign
     
    22422586        }
    22432587#endif
     2588        /* Special case: X turns shift-tab into ISO_Left_Tab. */
     2589        /* Here we change it back. */
     2590        if (keysym == XK_ISO_Left_Tab)
     2591        {
     2592            bufW[0] = 0x09;
     2593            ret = 1;
     2594            goto found;
     2595        }
     2596
    22442597        dead_char = KEYBOARD_MapDeadKeysym(keysym);
    22452598        if (dead_char)
    2246             {
     2599        {
    22472600            MultiByteToWideChar(CP_UNIXCP, 0, &dead_char, 1, bufW, bufW_size);
    22482601            ret = -1;
    2249             }
     2602            goto found;
     2603        }
     2604
     2605        if (keysym >= 0x01000100 && keysym <= 0x0100ffff)
     2606        {
     2607            /* Unicode direct mapping */
     2608            bufW[0] = keysym & 0xffff;
     2609            ret = 1;
     2610            goto found;
     2611        }
     2612        else if ((keysym >> 8) == 0x1008FF) {
     2613            bufW[0] = 0;
     2614            ret = 0;
     2615            goto found;
     2616        }
    22502617        else
    22512618            {
    2252             char  *ksname;
     2619            const char *ksname;
    22532620
    22542621            wine_tsx11_lock();
     
    22592626            if ((keysym >> 8) != 0xff)
    22602627                {
    2261                 ERR("Please report: no char for keysym %04lX (%s) :\n",
     2628                WARN("no char for keysym %04lX (%s) :\n",
    22622629                    keysym, ksname);
    2263                 ERR("(virtKey=%X,scanCode=%X,keycode=%X,state=%X)\n",
     2630                WARN("virtKey=%X, scanCode=%X, keycode=%X, state=%X\n",
    22642631                    virtKey, scanCode, e.keycode, e.state);
    22652632                }
     
    23032670        }
    23042671
     2672        /* Hack to detect an XLookupString hard-coded to Latin1 */
     2673        if (ret == 1 && keysym >= 0x00a0 && keysym <= 0x00ff && (BYTE)lpChar[0] == keysym)
     2674        {
     2675            bufW[0] = (BYTE)lpChar[0];
     2676            goto found;
     2677        }
     2678
    23052679        /* perform translation to unicode */
    23062680        if(ret)
     
    23182692
    23192693/***********************************************************************
    2320  *      Beep (X11DRV.@)
     2694 *              Beep (X11DRV.@)
    23212695 */
    23222696void X11DRV_Beep(void)
     
    23262700    wine_tsx11_unlock();
    23272701}
    2328 #endif // OUTOFWINE
    2329 
    2330 #ifdef OUTOFWINE
     2702#else // OUTOFWINE defined
    23312703int X11DRV_GetKeysymsPerKeycode()
    23322704{
    23332705    return keysyms_per_keycode;
    23342706}
    2335 #endif
     2707#endif // OUTOFWINE defined
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard_outofwine.h

    r382 r2529  
    2424typedef unsigned short WORD;
    2525typedef unsigned long DWORD;
     26typedef unsigned int UINT;
    2627typedef long BOOL;
    2728typedef DWORD LCID;
     
    8990#define VK_PAUSE            0x13
    9091#define VK_CAPITAL          0x14
    91 /*                          0x15-0x19  Reserved for Kanji systems */
     92
     93#define VK_KANA             0x15
     94#define VK_HANGEUL          0x15
     95#define VK_HANGUL           0x15
     96#define VK_JUNJA            0x17
     97#define VK_FINAL            0x18
     98#define VK_HANJA            0x19
     99#define VK_KANJI            0x19
     100
    92101/*                          0x1A       Undefined */
    93102#define VK_ESCAPE           0x1B
    94 /*                          0x1C-0x1F  Reserved for Kanji systems */
     103
     104#define VK_CONVERT          0x1C
     105#define VK_NONCONVERT       0x1D
     106#define VK_ACCEPT           0x1E
     107#define VK_MODECHANGE       0x1F
     108
    95109#define VK_SPACE            0x20
    96110#define VK_PRIOR            0x21
     
    109123#define VK_DELETE           0x2E
    110124#define VK_HELP             0x2F
    111 #define VK_0                0x30
    112 #define VK_1                0x31
    113 #define VK_2                0x32
    114 #define VK_3                0x33
    115 #define VK_4                0x34
    116 #define VK_5                0x35
    117 #define VK_6                0x36
    118 #define VK_7                0x37
    119 #define VK_8                0x38
    120 #define VK_9                0x39
     125/* VK_0 - VK-9              0x30-0x39  Use ASCII instead */
    121126/*                          0x3A-0x40  Undefined */
    122 #define VK_A                0x41
    123 #define VK_B                0x42
    124 #define VK_C                0x43
    125 #define VK_D                0x44
    126 #define VK_E                0x45
    127 #define VK_F                0x46
    128 #define VK_G                0x47
    129 #define VK_H                0x48
    130 #define VK_I                0x49
    131 #define VK_J                0x4A
    132 #define VK_K                0x4B
    133 #define VK_L                0x4C
    134 #define VK_M                0x4D
    135 #define VK_N                0x4E
    136 #define VK_O                0x4F
    137 #define VK_P                0x50
    138 #define VK_Q                0x51
    139 #define VK_R                0x52
    140 #define VK_S                0x53
    141 #define VK_T                0x54
    142 #define VK_U                0x55
    143 #define VK_V                0x56
    144 #define VK_W                0x57
    145 #define VK_X                0x58
    146 #define VK_Y                0x59
    147 #define VK_Z                0x5A
    148 
     127/* VK_A - VK_Z              0x41-0x5A  Use ASCII instead */
    149128#define VK_LWIN             0x5B
    150129#define VK_RWIN             0x5C
    151130#define VK_APPS             0x5D
    152 /*                          0x5E-0x5F Unassigned */
     131/*                          0x5E Unassigned */
     132#define VK_SLEEP            0x5F
    153133#define VK_NUMPAD0          0x60
    154134#define VK_NUMPAD1          0x61
     
    194174#define VK_NUMLOCK          0x90
    195175#define VK_SCROLL           0x91
    196 /*                          0x92-0x9F  Unassigned */
     176#define VK_OEM_NEC_EQUAL    0x92
     177#define VK_OEM_FJ_JISHO     0x92
     178#define VK_OEM_FJ_MASSHOU   0x93
     179#define VK_OEM_FJ_TOUROKU   0x94
     180#define VK_OEM_FJ_LOYA      0x95
     181#define VK_OEM_FJ_ROYA      0x96
     182/*                          0x97-0x9F  Unassigned */
    197183/*
    198184 * differencing between right and left shift/control/alt key.
     
    205191#define VK_LMENU            0xA4
    206192#define VK_RMENU            0xA5
    207 /*                          0xA6-0xB9  Unassigned */
     193
     194#define VK_BROWSER_BACK        0xA6
     195#define VK_BROWSER_FORWARD     0xA7
     196#define VK_BROWSER_REFRESH     0xA8
     197#define VK_BROWSER_STOP        0xA9
     198#define VK_BROWSER_SEARCH      0xAA
     199#define VK_BROWSER_FAVORITES   0xAB
     200#define VK_BROWSER_HOME        0xAC
     201#define VK_VOLUME_MUTE         0xAD
     202#define VK_VOLUME_DOWN         0xAE
     203#define VK_VOLUME_UP           0xAF
     204#define VK_MEDIA_NEXT_TRACK    0xB0
     205#define VK_MEDIA_PREV_TRACK    0xB1
     206#define VK_MEDIA_STOP          0xB2
     207#define VK_MEDIA_PLAY_PAUSE    0xB3
     208#define VK_LAUNCH_MAIL         0xB4
     209#define VK_LAUNCH_MEDIA_SELECT 0xB5
     210#define VK_LAUNCH_APP1         0xB6
     211#define VK_LAUNCH_APP2         0xB7
     212
     213/*                          0xB8-0xB9  Unassigned */
    208214#define VK_OEM_1            0xBA
    209215#define VK_OEM_PLUS         0xBB
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette