Changeset 32874 in vbox for trunk/src/VBox/Frontends/Common
- Timestamp:
- Oct 1, 2010 4:50:10 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 66352
- Location:
- trunk/src/VBox/Frontends/Common/VBoxKeyboard
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/Common/VBoxKeyboard/keyboard-tables.h
r30787 r32874 237 237 }; 238 238 239 #include "xkbtoscan.h" 240 239 241 #endif /* !___VBox_keyboard_tables_h */ 240 242 -
trunk/src/VBox/Frontends/Common/VBoxKeyboard/keyboard.c
r30787 r32874 42 42 #include <X11/Xatom.h> 43 43 #include <X11/keysym.h> 44 #include <X11/XKBlib.h> 44 45 #include <X11/Xlib.h> 45 46 #include <X11/Xresource.h> … … 545 546 546 547 /** 548 * Checks for the XKB extension, and if it is found initialises the X11 keycode 549 * to XT scan code mapping by looking at the XKB names for each keycode. 550 */ 551 static unsigned 552 X11DRV_InitKeyboardByXkb(Display *pDisplay) 553 { 554 int major = XkbMajorVersion, minor = XkbMinorVersion; 555 XkbDescPtr pKBDesc; 556 if (!XkbLibraryVersion(&major, &minor)) 557 return 0; 558 if (!XkbQueryExtension(pDisplay, NULL, NULL, &major, &minor, NULL)) 559 return 0; 560 pKBDesc = XkbGetKeyboard(pDisplay, XkbAllComponentsMask, XkbUseCoreKbd); 561 if (!pKBDesc) 562 return 0; 563 if (XkbGetNames(pDisplay, XkbKeyNamesMask, pKBDesc) != Success) 564 return 0; 565 { 566 unsigned i, j; 567 568 memset(keyc2scan, 0, sizeof(keyc2scan)); 569 for (i = pKBDesc->min_key_code; i < pKBDesc->max_key_code; ++i) 570 for (j = 0; j < sizeof(xkbMap) / sizeof(xkbMap[0]); ++j) 571 if (!memcmp(xkbMap[j].cszName, 572 &pKBDesc->names->keys->name[i * XKB_NAME_SIZE], 573 XKB_NAME_SIZE)) 574 { 575 keyc2scan[i] = xkbMap[j].uScan; 576 break; 577 } 578 } 579 XkbFreeNames(pKBDesc, XkbKeyNamesMask, True); 580 XkbFreeKeyboard(pKBDesc, XkbAllComponentsMask, True); 581 return 1; 582 } 583 584 /** 547 585 * Initialise the X11 keyboard driver by finding which X11 keycodes correspond 548 586 * to which PC scan codes. If the keyboard being used is not a PC keyboard, … … 567 605 * @param byTypeOK diagnostic - set to one if detection by type 568 606 * succeeded, and to 0 otherwise 607 * @param byXkbOK diagnostic - set to one if detection using XKB 608 * succeeded, and to 0 otherwise 569 609 * @param remapScancode array of tuples that remap the keycode (first 570 610 * part) to a scancode (second part) 571 611 */ 572 unsigned X11DRV_InitKeyboard(Display *display, unsigned *byLayoutOK, unsigned *byTypeOK, int (*remapScancodes)[2]) 573 { 574 unsigned byLayout; 575 unsigned byType; 612 unsigned X11DRV_InitKeyboard(Display *display, unsigned *byLayoutOK, 613 unsigned *byTypeOK, unsigned *byXkbOK, 614 int (*remapScancodes)[2]) 615 { 616 unsigned byLayout, byType, byXkb; 576 617 577 618 byLayout = X11DRV_InitKeyboardByLayout(display); … … 582 623 if (byTypeOK) 583 624 *byTypeOK = byType; 625 626 byXkb = X11DRV_InitKeyboardByXkb(display); 627 if (byXkbOK) 628 *byXkbOK = byXkb; 584 629 585 630 /* Remap keycodes after initialization. Remapping stops after an
Note:
See TracChangeset
for help on using the changeset viewer.