Changeset 21711 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 17, 2009 8:49:59 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobalSettings.h
r15664 r21711 47 47 QString languageId; 48 48 QString maxGuestRes; 49 QString remapScancodes; 49 50 bool trayIconEnabled; 50 51 bool dockPreviewEnabled; … … 63 64 Q_PROPERTY (QString languageId READ languageId WRITE setLanguageId) 64 65 Q_PROPERTY (QString maxGuestRes READ maxGuestRes WRITE setMaxGuestRes) 66 Q_PROPERTY (QString remapScancodes READ remapScancodes WRITE setRemapScancodes) 65 67 Q_PROPERTY (bool trayIconEnabled READ trayIconEnabled WRITE setTrayIconEnabled) 66 68 Q_PROPERTY (bool dockPreviewEnabled READ dockPreviewEnabled WRITE setDockPreviewEnabled) … … 106 108 mData()->maxGuestRes = aMaxGuestRes; 107 109 } 110 111 QString remapScancodes() const { return data()->remapScancodes; } 112 void setRemapScancodes (const QString &aRemapScancodes) 113 { 114 mData()->remapScancodes = aRemapScancodes; 115 } 116 108 117 109 118 bool trayIconEnabled() const { return data()->trayIconEnabled; } -
trunk/src/VBox/Frontends/VirtualBox/include/XKeyboard.h
r8155 r21711 24 24 #define __XKeyboard_h__ 25 25 26 #include <QString> 27 26 28 // initialize the X keyboard subsystem 27 bool initXKeyboard(Display *dpy);29 void initMappedX11Keyboard(Display *pDisplay, QString remapScancodes); 28 30 // our custom keyboard handler 29 31 unsigned handleXKeyEvent(XEvent *event); -
trunk/src/VBox/Frontends/VirtualBox/src/QIHotKeyEdit.cpp
r19066 r21711 23 23 #include "QIHotKeyEdit.h" 24 24 #include "VBoxDefs.h" 25 #include "VBoxGlobal.h" 25 26 26 27 /* Qt includes */ … … 119 120 #ifdef Q_WS_X11 120 121 /* Initialize the X keyboard subsystem */ 121 initXKeyboard (QX11Info::display()); 122 initMappedX11Keyboard(QX11Info::display(), 123 vboxGlobal().settings().publicProperty ("GUI/RemapScancodes")); 122 124 #endif 123 125 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r21520 r21711 797 797 #ifdef Q_WS_X11 798 798 /* initialize the X keyboard subsystem */ 799 initXKeyboard (QX11Info::display()); 799 initMappedX11Keyboard(QX11Info::display(), 800 vboxGlobal().settings().publicProperty ("GUI/RemapScancodes")); 800 801 #endif 801 802 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobalSettings.cpp
r20977 r21711 60 60 languageId = QString::null; 61 61 maxGuestRes = "auto"; 62 remapScancodes = QString::null; 62 63 trayIconEnabled = false; 63 64 dockPreviewEnabled = true; … … 71 72 languageId = that.languageId; 72 73 maxGuestRes = that.maxGuestRes; 74 remapScancodes = that.remapScancodes; 73 75 trayIconEnabled = that.trayIconEnabled; 74 76 dockPreviewEnabled = that.dockPreviewEnabled; … … 87 89 languageId == that.languageId && 88 90 maxGuestRes == that.maxGuestRes && 91 remapScancodes == that.remapScancodes && 89 92 trayIconEnabled == that.trayIconEnabled 90 93 && dockPreviewEnabled == that.dockPreviewEnabled … … 115 118 { "GUI/LanguageID", "languageId", gVBoxLangIDRegExp, true }, 116 119 { "GUI/MaxGuestResolution", "maxGuestRes", "\\d*[1-9]\\d*,\\d*[1-9]\\d*|any|auto", true }, 120 { "GUI/RemapScancodes", "remapScancodes", "(\\d+=\\d+,)*\\d+=\\d+", true }, 117 121 { "GUI/TrayIcon/Enabled", "trayIconEnabled", "true|false", true }, 118 122 #ifdef Q_WS_MAC -
trunk/src/VBox/Frontends/VirtualBox/src/X11/XKeyboard-new.cpp
r12500 r21711 23 23 #define LOG_GROUP LOG_GROUP_GUI 24 24 25 #include <QString> 26 #include <QStringList> 25 27 #include <X11/Xlib.h> 26 28 #include <X11/keysym.h> … … 187 189 * mappings. 188 190 */ 189 bool initXKeyboard(Display *dpy )190 { 191 X11DRV_InitKeyboard(dpy, &gfByLayoutOK, &gfByTypeOK );191 bool initXKeyboard(Display *dpy, int (*remapScancodes)[2]) 192 { 193 X11DRV_InitKeyboard(dpy, &gfByLayoutOK, &gfByTypeOK, remapScancodes); 192 194 /* It will almost always work to some extent */ 193 195 return true; … … 203 205 if ((1 == gfByLayoutOK) && (gfByTypeOK != 1)) 204 206 dumpType(dpy); 205 if ((gfByLayoutOK != 1) && (gfByTypeOK != 1)) 207 if ((gfByLayoutOK != 1) && (gfByTypeOK != 1)) { 206 208 LogRel(("Failed to recognize the keyboard mapping or to guess it based on\n" 207 209 "the keyboard layout. It is very likely that some keys will not\n" … … 210 212 "about your keyboard type, its layout and other relevant\n" 211 213 "information such as whether you are using a remote X server or\n" 212 "something similar.\n")); 214 "something similar. \n")); 215 unsigned *keyc2scan=X11DRV_getKeyc2scan(); 216 217 LogRel(("The keycode-to-scancode table is: %d=%d",0,keyc2scan[0])); 218 for(int i=1; i<256; i++) 219 LogRel((",%d=%d",i,keyc2scan[i])); 220 LogRel(("\n")); 221 } 213 222 } 214 223 … … 234 243 return 8; 235 244 } 245 246 /** 247 * Initialize X11 keyboard including the remapping specified in the 248 * global property GUI/RemapScancodes. This property is a string of 249 * comma-seperated x=y pairs, where x is the X11 keycode and y is the 250 * keyboard scancode that is emitted when the key attached to the X11 251 * keycode is pressed. 252 */ 253 void initMappedX11Keyboard(Display *pDisplay, QString remapScancodes) 254 { 255 int (*scancodes)[2] = NULL; 256 int (*scancodesTail)[2] = NULL; 257 258 if(remapScancodes != QString::null) { 259 QStringList tuples = remapScancodes.split(",", QString::SkipEmptyParts); 260 scancodes = scancodesTail = new int [tuples.size()+1][2]; 261 for (int i = 0; i < tuples.size(); ++i) { 262 QStringList keyc2scan = tuples.at(i).split("="); 263 (*scancodesTail)[0] = keyc2scan.at(0).toUInt(); 264 (*scancodesTail)[1] = keyc2scan.at(1).toUInt(); 265 /* Do not advance on (ignore) identity mappings as this is 266 the stop signal to initXKeyboard and friends */ 267 if((*scancodesTail)[0] != (*scancodesTail)[1]) 268 scancodesTail++; 269 } 270 (*scancodesTail)[0] = (*scancodesTail)[1] = 0; 271 } 272 /* initialize the X keyboard subsystem */ 273 initXKeyboard (pDisplay ,scancodes); 274 275 if(scancodes) delete scancodes; 276 } -
trunk/src/VBox/Frontends/VirtualBox/src/X11/keyboard-new.c
r16459 r21711 55 55 #include <stdio.h> 56 56 57 #define KEYC2SCAN_SIZE 256 58 57 59 /** 58 60 * Array containing the current mapping of keycodes to scan codes, detected 59 61 * using the keyboard layout algorithm in X11DRV_InitKeyboardByLayout. 60 62 */ 61 static unsigned keyc2scan[256]; 62 /** 63 * Whether a keyboard was detected with a well-known keycode to scan code 64 * mapping. 65 */ 66 static unsigned use_builtin_table = 0; 67 /** The index of the well-known keycode to scan code mapping in our table. */ 68 static unsigned builtin_table_number; 63 static unsigned keyc2scan[KEYC2SCAN_SIZE]; 69 64 /** Whether to output basic debugging information to standard output */ 70 65 static int log_kb_1 = 0; … … 126 121 } 127 122 if (keysym != 0 && scan == 0) 128 {129 if (use_builtin_table != 0)130 scan = main_keyboard_type_scans[builtin_table_number][code];131 else132 123 scan = keyc2scan[code]; 133 } 124 134 125 return scan; 135 126 } … … 440 431 ) 441 432 found = 1; 442 use_builtin_table = found;443 433 if (found != 0) 444 builtin_table_number = i - 1;434 memcpy(keyc2scan, main_keyboard_type_scans[i - 1], KEYC2SCAN_SIZE); 445 435 return found; 446 436 } … … 464 454 * @returns 1 if the layout found was optimal, 0 if it was not. This is 465 455 * for diagnostic purposes 466 * @param display a pointer to the X11 display 467 * @param byLayoutOK diagnostic - set to one if detection by layout 468 * succeeded, and to 0 otherwise 469 * @param byTypeOK diagnostic - set to one if detection by type 470 * succeeded, and to 0 otherwise 471 */ 472 unsigned X11DRV_InitKeyboard(Display *display, unsigned *byLayoutOK, unsigned *byTypeOK) 473 { 474 unsigned byLayout = X11DRV_InitKeyboardByLayout(display); 475 unsigned byType = X11DRV_InitKeyboardByType(display); 456 * @param display a pointer to the X11 display 457 * @param byLayoutOK diagnostic - set to one if detection by layout 458 * succeeded, and to 0 otherwise 459 * @param byTypeOK diagnostic - set to one if detection by type 460 * succeeded, and to 0 otherwise 461 * @param remapScancode array of tuples that remap the keycode (first 462 * part) to a scancode (second part) 463 */ 464 unsigned X11DRV_InitKeyboard(Display *display, unsigned *byLayoutOK, unsigned *byTypeOK, int (*remapScancodes)[2]) 465 { 466 unsigned byLayout; 467 unsigned byType; 468 469 byLayout = X11DRV_InitKeyboardByLayout(display); 476 470 *byLayoutOK = byLayout; 477 *byTypeOK = byType; 471 472 byType = X11DRV_InitKeyboardByType(display); 473 *byTypeOK = byType; 474 475 /* Remap keycodes after initialization. Remapping stops after an 476 identity mapping is seen */ 477 if(remapScancodes != NULL) 478 for(; (*remapScancodes)[0] != (*remapScancodes)[1]; remapScancodes++) 479 keyc2scan[(*remapScancodes)[0]] = (*remapScancodes)[1]; 480 478 481 return (byLayout || byType) ? 1 : 0; 479 482 } 483 484 /** 485 * Returns the keycode to scancode array 486 */ 487 unsigned *X11DRV_getKeyc2scan() 488 { 489 return keyc2scan; 490 } -
trunk/src/VBox/Frontends/VirtualBox/src/X11/keyboard.h
r12498 r21711 44 44 #endif 45 45 #ifdef VBOX_HAVE_VISIBILITY_HIDDEN 46 extern CCALL __attribute__((visibility("default"))) unsigned X11DRV_InitKeyboard(Display *dpy, unsigned *byLayoutOK, unsigned *byTypeOK); 46 extern CCALL __attribute__((visibility("default"))) unsigned *X11DRV_getKeyc2scan(); 47 extern CCALL __attribute__((visibility("default"))) unsigned X11DRV_InitKeyboard(Display *dpy, unsigned *byLayoutOK, unsigned *byTypeOK, int (*remapScancodes)[2]); 47 48 extern CCALL __attribute__((visibility("default"))) unsigned X11DRV_KeyEvent(Display *dpy, KeyCode code); 48 49 #else 49 extern CCALL unsigned X11DRV_InitKeyboard(Display *dpy, unsigned *byLayoutOK, unsigned *byTypeOK); 50 extern CCALL unsigned *X11DRV_getKeyc2scan(); 51 extern CCALL unsigned X11DRV_InitKeyboard(Display *dpy, unsigned *byLayoutOK, unsigned *byTypeOK, int (*remapScancodes)[2]); 50 52 extern CCALL unsigned X11DRV_KeyEvent(Display *dpy, KeyCode code); 51 53 #endif
Note:
See TracChangeset
for help on using the changeset viewer.