- Timestamp:
- Sep 16, 2008 3:43:14 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4/src/linux
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/src/linux/XKeyboard-new.cpp
r9991 r12495 92 92 XDisplayKeycodes(display, &minKey, &maxKey); 93 93 for (int i = minKey; i < maxKey; ++i) 94 scanToKeycode[X11DRV_KeyEvent( i)] = i;94 scanToKeycode[X11DRV_KeyEvent(display, i)] = i; 95 95 LogRel(("\"")); 96 96 printKey(display, scanToKeycode[0x29]); /* `~ */ … … 149 149 for (unsigned i = 0; i < 256; ++i) 150 150 { 151 LogRel(("0x%x", X11DRV_KeyEvent( i)));151 LogRel(("0x%x", X11DRV_KeyEvent(display, i))); 152 152 if (i < 255) 153 153 LogRel((", ")); … … 218 218 { 219 219 // call the WINE event handler 220 return X11DRV_KeyEvent(event->xkey. keycode);220 return X11DRV_KeyEvent(event->xkey.display, event->xkey.keycode); 221 221 } 222 222 -
trunk/src/VBox/Frontends/VirtualBox4/src/linux/keyboard-new.c
r12410 r12495 95 95 96 96 /** 97 * Translate a keycode in a key event to a scan code, using the lookup table 98 * which we constructed earlier or a well-known mapping from our mapping 99 * table. 97 * Translate a keycode in a key event to a scan code. If the keycode maps 98 * to a key symbol which is in the same place on all PC keyboards, look it 99 * up by symbol in one of our hard-coded translation tables. It it maps to 100 * a symbol which can be in a different place on different PC keyboards, look 101 * it up by keycode using either the lookup table which we constructed 102 * earlier, or using a hard-coded table if we know what type of keyboard is 103 * in use. 100 104 * 101 105 * @returns the scan code number, with 0x100 added for extended scan codes … … 103 107 */ 104 108 105 unsigned X11DRV_KeyEvent( KeyCode code)109 unsigned X11DRV_KeyEvent(Display *display, KeyCode code) 106 110 { 107 unsigned key; 108 if (use_builtin_table != 0) 109 key = main_keyboard_type_scans[builtin_table_number][code]; 110 else 111 key = keyc2scan[code]; 112 return key; 111 unsigned scan; 112 KeySym keysym = XKeycodeToKeysym(display, code, 0); 113 scan = 0; 114 if (keysym) /* otherwise, keycode not used */ 115 { 116 if ((keysym >> 8) == 0xFF) /* non-character key */ 117 scan = nonchar_key_scan[keysym & 0xff]; 118 else if ((keysym >> 8) == 0x1008FF) /* XFree86 vendor keys */ 119 scan = xfree86_vendor_key_scan[keysym & 0xff]; 120 else if ((keysym >> 8) == 0x1005FF) /* Sun keys */ 121 scan = sun_key_scan[keysym & 0xff]; 122 else if (keysym == 0x20) /* Spacebar */ 123 scan = 0x39; 124 else if (keysym == 0xFE03) /* ISO level3 shift, aka AltGr */ 125 scan = 0x138; 126 else if (use_builtin_table != 0) 127 scan = main_keyboard_type_scans[builtin_table_number][code]; 128 else 129 scan = keyc2scan[code]; 130 } 131 return scan; 113 132 } 114 133 … … 304 323 if (keysym) /* otherwise, keycode not used */ 305 324 { 306 if ((keysym >> 8) == 0xFF) /* non-character key */ 307 { 308 scan = nonchar_key_scan[keysym & 0xff]; 309 /* set extended bit when necessary */ 310 } else if ((keysym >> 8) == 0x1008FF) { /* XFree86 vendor keys */ 311 /* VirtualBox FIX - multimedia/internet keys */ 312 scan = xfree86_vendor_key_scan[keysym & 0xff]; 313 } else if ((keysym >> 8) == 0x1005FF) { /* Sun keys */ 314 scan = sun_key_scan[keysym & 0xff]; 315 } else if (keysym == 0x20) { /* Spacebar */ 316 scan = 0x39; 317 /* VirtualBox FIX - AltGr support */ 318 } else if (keysym == 0xFE03) { /* ISO level3 shift, aka AltGr */ 319 scan = 0x138; 320 } else { 325 /* Skip over keysyms which we look up on the fly */ 326 if ( (0xFF != (keysym >> 8)) /* Non-character key */ 327 && (0x1008FF != (keysym >> 8)) /* XFree86 vendor keys */ 328 && (0x1005FF != (keysym >> 8)) /* Sun keys */ 329 && (0x20 != keysym) /* Spacebar */ 330 && (0xFE03 != keysym) /* ISO level3 shift, aka AltGr */ 331 ) { 321 332 unsigned found = 0; 322 333 … … 335 346 /* got it */ 336 347 scan = main_key_scan[keyn - 1]; 337 if (keyn != 48) /* don't count the 102nd key */ 348 /* We keep track of the number of keys that we found a 349 * match for to see if the layout is optimal or not. 350 * We ignore the 102nd key though (key number 48), since 351 * not all keyboards have it. */ 352 if (keyn != 48) 338 353 ++matches; 339 354 } -
trunk/src/VBox/Frontends/VirtualBox4/src/linux/keyboard.h
r11982 r12495 45 45 #ifdef VBOX_HAVE_VISIBILITY_HIDDEN 46 46 extern CCALL __attribute__((visibility("default"))) unsigned X11DRV_InitKeyboard(Display *dpy, unsigned *byLayoutOK, unsigned *byTypeOK); 47 extern CCALL __attribute__((visibility("default"))) unsigned X11DRV_KeyEvent( KeyCode code);47 extern CCALL __attribute__((visibility("default"))) unsigned X11DRV_KeyEvent(Display *dpy, KeyCode code); 48 48 #else 49 49 extern CCALL unsigned X11DRV_InitKeyboard(Display *dpy, unsigned *byLayoutOK, unsigned *byTypeOK); 50 extern CCALL unsigned X11DRV_KeyEvent( KeyCode code);50 extern CCALL unsigned X11DRV_KeyEvent(Display *dpy, KeyCode code); 51 51 #endif 52 52
Note:
See TracChangeset
for help on using the changeset viewer.