VirtualBox

Changeset 4574 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 6, 2007 2:33:17 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
24198
Message:

Linux host keyboard handler: fixed support for Brazilian, Belgian, US intl and US dvorak keyboards. Added support for multimedia keys.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/linux
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard.c

    r3976 r4574  
    2323 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
    2424 */
    25 /* our master define to make this module usable outside wine */
    26 
     25
     26/* our master define to make this module usable outside of Wine */
    2727#define OUTOFWINE
    2828
     
    136136 /* a    s    d    f    g    h    j    k    l    ;    '    \ */
    137137   0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2B,
     138#ifndef OUTOFWINE
    138139 /* \      z    x    c    v    b    n    m    ,    .    / */
    139140   0x5e,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
    140141   0x56, /* the 102nd key (actually to the right of l-shift) */
    141 };
    142 
     142#else
     143/* innotek FIX */
     144 /* \      z    x    c    v    b    n    m    ,    .    / */
     145   0x56,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
     146   0x73, /* the extra key on the Brazilian keyboard. */
     147#endif
     148};
     149
     150#ifndef OUTOFWINE
     151/* innotek FIX - a dvorak keyboard uses standard scan codes. */
    143152static const WORD main_key_scan_dvorak[MAIN_LEN] =
    144153{
     
    153162   0x56 /* the 102nd key (actually to the right of l-shift) */
    154163};
    155 
     164#endif
     165
     166#ifdef OUTOFWINE
     167/* What is this supposed to be?  This is just the same as the qwerty layout, with one key
     168   in a different place. */
     169#endif
    156170static const WORD main_key_scan_qwerty_jp106[MAIN_LEN] =
    157171{
     
    300314};
    301315
     316#ifdef OUTOFWINE
     317/* innotek FIX */
     318/*** United States keyboard layout (dvorak version with phantom key) */
     319static const char main_key_US_dvorak_phantom[MAIN_LEN][4] =
     320{
     321 "`~","1!","2@","3#","4$","5%","6^","7&","8*","9(","0)","[{","]}",
     322 "'\"",",<",".>","pP","yY","fF","gG","cC","rR","lL","/?","=+",
     323 "aA","oO","eE","uU","iI","dD","hH","tT","nN","sS","-_","\\|",
     324 ";:","qQ","jJ","kK","xX","bB","mM","wW","vV","zZ",
     325 "<>" /* the phantom key */
     326};
     327#endif
     328
    302329/*** British keyboard layout */
    303330static const char main_key_UK[MAIN_LEN][4] =
     
    603630static const char main_key_BE[MAIN_LEN][4] =
    604631{
     632#ifndef OUTOFWINE
    605633 "","&1|","é2@","\"3#","'4","(5","§6^","è7","!8","ç9{","à0}",")°","-_",
    606634 "aA","zZ","eE¤","rR","tT","yY","uU","iI","oO","pP","^¨[","$*]",
     
    608636 "wW","xX","cC","vV","bB","nN",",?",";.",":/","=+~",
    609637 "<>\\"
     638#else
     639/* innotek FIX */
     640/* I wonder how much of this Wine code has been properly tested?  There are many
     641   seemingly duplicate layouts, and while many specify three or four keysyms per
     642   key, the code choked on all keys in this layout containing more than two
     643   keysyms.  I suspect that many of these maps only work by luck. */
     644 "²³","&1","é2","\"3","'4","(5","§6","è7","!8","ç9","à0",")°","-_",
     645 "aA","zZ","eE","rR","tT","yY","uU","iI","oO","pP","^¨","$*",
     646 "qQ","sS","dD","fF","gG","hH","jJ","kK","lL","mM","ù%","µ£",
     647 "wW","xX","cC","vV","bB","nN",",?",";.",":/","=+",
     648 "<>"
     649#endif
    610650};
    611651
     
    718758};
    719759
     760#ifndef OUTOFWINE
    720761/*** US international keyboard layout (contributed by Gustavo Noronha ([email protected])) */
    721762static const char main_key_US_intl[MAIN_LEN][4] =
     
    726767  "zZ", "xX", "cC", "vV", "bB", "nN", "mM", ",<", ".>", "/?"
    727768};
     769#else
     770/* innotek FIX */
     771/*** US international keyboard layout (contributed by Gustavo Noronha ([email protected])) */
     772static const char main_key_US_intl[MAIN_LEN][4] =
     773{
     774  "`~", "1!", "2@", "3#", "4$", "5%", "6^", "7&", "8*", "9(", "0)", "-_", "=+",
     775  "qQ", "wW", "eE", "rR", "tT", "yY", "uU", "iI", "oO", "pP", "[{", "]}",
     776  "aA", "sS", "dD", "fF", "gG", "hH", "jJ", "kK", "lL", ";:", "´¨",
     777  "\\|", "zZ", "xX", "cC", "vV", "bB", "nN", "mM", ",<", ".>", "/?"
     778};
     779
     780/*** US international keyboard layout with phantom key (contributed by Gustavo Noronha ([email protected])) */
     781static const char main_key_US_intl_phantom[MAIN_LEN][4] =
     782{
     783  "`~", "1!", "2@", "3#", "4$", "5%", "6^", "7&", "8*", "9(", "0)", "-_", "=+",
     784  "qQ", "wW", "eE", "rR", "tT", "yY", "uU", "iI", "oO", "pP", "[{", "]}",
     785  "aA", "sS", "dD", "fF", "gG", "hH", "jJ", "kK", "lL", ";:", "´¨",
     786  "\\|", "zZ", "xX", "cC", "vV", "bB", "nN", "mM", ",<", ".>", "/?",
     787  "<>" /* the phantom key */
     788};
     789#endif
    728790
    729791/*** Slovak keyboard layout (see cssk_ibm(sk_qwerty) in xkbsel)
     
    923985 {0x0409, "United States keyboard layout", &main_key_US, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    924986 {0x0409, "United States keyboard layout (phantom key version)", &main_key_US_phantom, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     987#ifndef OUTOFWINE
    925988 {0x0409, "United States keyboard layout (dvorak)", &main_key_US_dvorak, &main_key_scan_dvorak, &main_key_vkey_dvorak},
    926989 {0x0409, "United States International keyboard layout", &main_key_US_intl, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     990#else
     991/* innotek FIX */
     992 {0x0409, "United States keyboard layout (dvorak)", &main_key_US_dvorak, &main_key_scan_qwerty, &main_key_vkey_dvorak},
     993 {0x0409, "United States keyboard layout (dvorak, phantom key version)", &main_key_US_dvorak_phantom, &main_key_scan_qwerty, &main_key_vkey_dvorak},
     994 {0x0409, "United States International keyboard layout", &main_key_US_intl, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     995 {0x0409, "United States International keyboard layout (phantom key version)", &main_key_US_intl_phantom, &main_key_scan_qwerty, &main_key_vkey_qwerty},
     996#endif
    927997 {0x0809, "British keyboard layout", &main_key_UK, &main_key_scan_qwerty, &main_key_vkey_qwerty},
    928998 {0x0407, "German keyboard layout", &main_key_DE, &main_key_scan_qwerty, &main_key_vkey_qwertz},
     
    10701140    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FF58 */
    10711141    /* misc keys */
    1072     /*?*/ 0, 0x137, /*?*/ 0, 0x152, 0x00, 0x00, 0x00, 0x15D,      /* FF60 */
     1142#ifdef OUTOFWINE
     1143/* innotek FIX */
     1144    /*?*/ 0, 0x137, /*?*/ 0, 0x152, 0x00, 0x00, 0x00, 0x15D,     /* FF60 */
     1145#else
     1146    /*?*/ 0, 0x137, /*?*/ 0, 0x152, 0x00, 0x00, 0x00, 0x00,      /* FF60 */
     1147#endif
    10731148    /*?*/ 0, /*?*/ 0, 0x38, 0x146, 0x00, 0x00, 0x00, 0x00,       /* FF68 */
    10741149    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FF70 */
     
    10801155    0x4D, 0x50, 0x49, 0x51, 0x4F, 0x4C, 0x52, 0x53,              /* FF98 */
    10811156    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FFA0 */
     1157#ifdef OUTOFWINE
     1158/* innotek FIX */
     1159    0x00, 0x00, 0x37, 0x4E, 0x53, 0x4A, 0x7e, 0x135,             /* FFA8 */
     1160#else
    10821161    0x00, 0x00, 0x37, 0x4E, 0x53, 0x4A, 0x53, 0x135,             /* FFA8 */
     1162#endif
    10831163    0x52, 0x4F, 0x50, 0x51, 0x4B, 0x4C, 0x4D, 0x47,              /* FFB0 */
    10841164    0x48, 0x49, 0x00, 0x00, 0x00, 0x00,                          /* FFB8 */
     
    10911171    /* modifier keys */
    10921172    0x00, 0x2A, 0x36, 0x1D, 0x11D, 0x3A, 0x00, 0x38,             /* FFE0 */
    1093     0x138, 0x38, 0x138, 0x15B, 0x15C, 0x00, 0x00, 0x00,            /* FFE8 */
     1173#ifdef OUTOFWINE
     1174/* innotek FIX */
     1175    0x138, 0x38, 0x138, 0x15B, 0x15C, 0x00, 0x00, 0x00,          /* FFE8 */
     1176#else
     1177    0x138, 0x38, 0x138, 0x00, 0x00, 0x00, 0x00, 0x00,            /* FFE8 */
     1178#endif
    10941179    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,              /* FFF0 */
    10951180    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x153              /* FFF8 */
    10961181};
    10971182
     1183#ifndef OUTOFWINE
    10981184static const WORD xfree86_vendor_key_vkey[256] =
    10991185{
     
    11351221    0, 0, 0, 0, 0, 0, 0, 0                                      /* 1008FFF8 */
    11361222};
     1223#else /* OUTOFWINE defined */
     1224/* innotek FIX */
     1225/* This list was put together using /usr/include/X11/XF86keysym.h and
     1226   http://www.win.tue.nl/~aeb/linux/kbd/scancodes-6.html.  It has not yet
     1227   been extensively tested.  The scancodes are those used by MicroSoft
     1228   keyboards. */
     1229static const WORD xfree86_vendor_key_scan[256] =
     1230{
     1231    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF00 */
     1232    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF08 */
     1233 /*    Vol-   Mute   Vol+   Play   Stop   Track- Track+ */
     1234    0, 0x12e, 0x120, 0x130, 0x122, 0x124, 0x110, 0x119,         /* 1008FF10 */
     1235 /* Home   E-mail    Search */
     1236    0x132, 0x16c, 0, 0x165, 0, 0, 0, 0,                         /* 1008FF18 */
     1237 /* Calndr PwrDown            Back   Forward */
     1238    0x115, 0x15e, 0, 0, 0, 0, 0x16a, 0x169,                     /* 1008FF20 */
     1239 /* Stop   Refresh Power Wake            Sleep */
     1240    0x168, 0x167, 0x15e, 0x163, 0, 0, 0, 0x15f,                 /* 1008FF28 */
     1241 /* Favrts Pause  Media  MyComp */
     1242    0x166, 0x122, 0x16d, 0x16b, 0, 0, 0, 0,                     /* 1008FF30 */
     1243    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF38 */
     1244    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF40 */
     1245    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF48 */
     1246 /* AppL   AppR         Calc      Close  Copy */
     1247    0x109, 0x11e, 0, 0, 0x121, 0, 0x140, 0x118,                 /* 1008FF50 */
     1248 /* Cut          Docmnts Excel */
     1249    0x117, 0, 0, 0x105, 0x114, 0, 0, 0,                         /* 1008FF58 */
     1250 /*    LogOff */
     1251    0, 0x116, 0, 0, 0, 0, 0, 0,                                 /* 1008FF60 */
     1252 /*       OffcHm Open      Paste */
     1253    0, 0, 0x13c, 0x13f, 0, 0x10a, 0, 0,                         /* 1008FF68 */
     1254 /*       Reply  Refresh         Save */
     1255    0, 0, 0x141, 0x167, 0, 0, 0, 0x157,                         /* 1008FF70 */
     1256 /* ScrlUp ScrlDn    Send   Spell        TaskPane */
     1257    0x10b, 0x18b, 0, 0x143, 0x123, 0, 0, 0x13d,                 /* 1008FF78 */
     1258    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF80 */
     1259 /*    Word */
     1260    0, 0x113, 0, 0, 0, 0, 0, 0,                                 /* 1008FF88 */
     1261 /* MailFwd MyPics MyMusic*/
     1262    0x142, 0x164, 0x13c, 0, 0, 0, 0, 0,                         /* 1008FF90 */
     1263    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FF98 */
     1264    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFA0 */
     1265    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFA8 */
     1266    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFB0 */
     1267    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFB8 */
     1268    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFC0 */
     1269    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFC8 */
     1270    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFD0 */
     1271    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFD8 */
     1272    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFE0 */
     1273    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFE8 */
     1274    0, 0, 0, 0, 0, 0, 0, 0,                                     /* 1008FFF0 */
     1275    0, 0, 0, 0, 0, 0, 0, 0                                      /* 1008FFF8 */
     1276};
     1277#endif /* OUTOFWINE defined */
    11371278
    11381279#ifndef OUTOFWINE
     
    15201661  int max_score = 0, ismatch = 0;
    15211662  char ckey[256][4];
     1663#ifdef OUTOFWINE
     1664/* innotek FIX */
     1665  /* The Wine algorithm is incapable of distinguishing the dvorak and the querty layout,
     1666     which have the same keys in a different sequence.  Based on the assumption that
     1667     scan codes are laid out more or less sequentially, we keep a track of how many
     1668     of our detected scan codes are out of order as an additional matching criterium. */
     1669  int misorder, last_match, least_misorder = 256;
     1670#endif
    15221671
    15231672  syms = keysyms_per_keycode;
     
    15611710    lkey = main_key_tab[current].key;
    15621711    pkey = -1;
     1712#ifdef OUTOFWINE
     1713/* innotek FIX - dvorak layout */
     1714    last_match = 0;
     1715    misorder = 0;
     1716#endif
    15631717    for (keyc = min_keycode; keyc <= max_keycode; keyc++) {
    15641718      if (ckey[keyc][0]) {
     
    15771731          if (ok > 0) {
    15781732            score += ok;
     1733#ifdef OUTOFWINE
     1734/* innotek FIX - dvorak layout */
     1735            if (key < last_match)
     1736            {
     1737              ++misorder;
     1738            }
     1739            last_match = key;
     1740#endif
    15791741            break;
    15801742          }
     
    15971759      }
    15981760    }
     1761#ifndef OUTOFWINE
    15991762    TRACE("matches=%d, mismatches=%d, seq=%d, score=%d\n",
    16001763           match, mismatch, seq, score);
    16011764    if ((score > max_score) ||
    16021765        ((score == max_score) && (seq > max_seq))) {
     1766#else
     1767/* innotek FIX - dvorak layout */
     1768    TRACE("matches=%d, mismatches=%d, seq=%d, score=%d, misorder = %d\n",
     1769           match, mismatch, seq, score, misorder);
     1770    if ((score > max_score) ||
     1771        ((score == max_score) && (seq > max_seq)) ||
     1772        ((score == max_score) && (seq == max_seq) &&
     1773         (misorder < least_misorder))) {
     1774#endif
    16031775      /* best match so far */
    16041776      kbd_layout = current;
     
    16061778      max_seq = seq;
    16071779      ismatch = !mismatch;
     1780#ifdef OUTOFWINE
     1781/* innotek FIX - dvorak layout */
     1782      least_misorder = misorder;
     1783#endif
    16081784    }
    16091785  }
     
    17281904                vkey |= 0x100;
    17291905#else
    1730                 /* @michael: this needs to be investigated and improved on. */
    1731                 scan = 0x100;
     1906/* innotek FIX - multimedia/internet keys */
     1907                /* @michael: this needs to be tested and completed some day. */
     1908                scan = xfree86_vendor_key_scan[keysym & 0xff];
    17321909#endif
    17331910            } else if (keysym == 0x20) {                 /* Spacebar */
     
    17371914                scan = 0x39;
    17381915#ifdef OUTOFWINE
     1916/* innotek FIX - AltGr support */
    17391917            } else if (keysym == 0xFE03) {               /* ISO level3 shift, aka AltGr */
    17401918                scan = 0x138;
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard_outofwine.h

    r3948 r4574  
    7070
    7171/* debug macros */
     72#if 0
     73# include <stdio.h>
     74# define noop printf
     75#else
    7276inline static void noop(char *arg, ...)
    7377{
    7478}
     79#endif
    7580
    7681#define TRACE noop
Note: See TracChangeset for help on using the changeset viewer.

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