- Timestamp:
- Jul 31, 2007 5:41:28 PM (17 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r3925 r3945 41 41 42 42 PROGRAMS = VirtualBox 43 DLLS.linux = VBoxKeyboard 43 44 44 45 INSTALLS = VirtualBox.nls 46 47 VBoxKeyboard_TEMPLATE = VBOXR3 48 VBoxKeyboard_SOURCES = \ 49 src/linux/keyboard.c 50 VBoxKeyboard_CFLAGS = -fPIC 45 51 46 52 VirtualBox_TEMPLATE = VBOXQTGUIEXE … … 146 152 147 153 VirtualBox_SOURCES.linux = \ 148 src/linux/XKeyboard.cpp \ 149 src/linux/keyboard.c 154 src/linux/XKeyboard.cpp 150 155 151 156 VirtualBox_SOURCES.darwin = \ … … 206 211 $(PATH_SDK_DXSDK_LIB)/ddraw.lib \ 207 212 $(PATH_SDK_DXSDK_LIB)/dxguid.lib 213 VirtualBox_LIBS.linux = $(PATH_DLL)/VBoxKeyboard$(VBOX_SUFF_DLL) 214 208 215 209 216 ifdef VBOX_WITH_DEBUGGER_GUI -
trunk/src/VBox/Frontends/VirtualBox/include/XKeyboard.h
r3701 r3945 44 44 int getKeysymsPerKeycode(); 45 45 46 // initialize the X keyboard subsystem, safe for use on remote X servers47 bool initXKeyboardSafe(Display *dpy);48 // our custom keyboard handler, safe for use on remote X servers49 void handleXKeyEventSafe(Display *dpy, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo);50 // returns the number of keysyms per keycode (only valid after initXKeyboard()), safe51 // for use on remote X servers52 int getKeysymsPerKeycodeSafe();53 54 55 46 #endif // __XKeyboard_h__ -
trunk/src/VBox/Frontends/VirtualBox/src/linux/XKeyboard.cpp
r3908 r3945 32 32 #endif 33 33 34 //35 // global variables36 //37 38 Display *dpy_global;39 BYTE InputKeyStateTable[256];40 41 34 // WINE keyboard prototypes 42 35 extern "C" 43 36 { 44 void X11DRV_InitKeyboard( BYTE *key_state_table);45 void X11DRV_KeyEvent( XKeyEvent *event, WINEKEYBOARDINFO *wKbInfo);37 void X11DRV_InitKeyboard(Display *dpy); 38 void X11DRV_KeyEvent(Display *dpy, XEvent *event, WINEKEYBOARDINFO *wKbInfo); 46 39 int X11DRV_GetKeysymsPerKeycode(); 47 40 } … … 58 51 bool initXKeyboard(Display *dpy) 59 52 { 60 // update the global display pointer 61 dpy_global = dpy; 62 X11DRV_InitKeyboard(InputKeyStateTable); 53 X11DRV_InitKeyboard(dpy); 63 54 return true; 64 55 } … … 69 60 void handleXKeyEvent(Display *dpy, XEvent *event, WINEKEYBOARDINFO *wineKbdInfo) 70 61 { 71 // update the global display pointer72 dpy_global = dpy;73 62 // call the WINE event handler 74 X11DRV_KeyEvent( (XKeyEvent*)event, wineKbdInfo);63 X11DRV_KeyEvent(dpy, event, wineKbdInfo); 75 64 } 76 65 -
trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard.c
r3938 r3945 23 23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 24 24 */ 25 / / our master define to make this module usable outside wine25 /* our master define to make this module usable outside wine */ 26 26 27 27 #define OUTOFWINE … … 30 30 #include "keyboard_outofwine.h" 31 31 int use_xkb = 1; 32 #endif / / OUTOFWINE defined32 #endif /* OUTOFWINE defined */ 33 33 34 34 #ifndef OUTOFWINE 35 35 #include "config.h" 36 #endif / / OUTOFWINE not defined36 #endif /* OUTOFWINE not defined */ 37 37 38 38 #include <X11/Xatom.h> … … 66 66 WINE_DEFAULT_DEBUG_CHANNEL(keyboard); 67 67 WINE_DECLARE_DEBUG_CHANNEL(key); 68 #endif // OUTOFWINE not defined69 68 70 69 typedef union … … 88 87 unsigned long lp2; 89 88 } KEYLP; 89 #endif /* OUTOFWINE not defined */ 90 90 91 91 92 /* key state table bits: … … 96 97 BYTE key_state_table[256]; 97 98 99 #ifndef OUTOFWINE 98 100 static BYTE TrackSysKey = 0; /* determine whether ALT key up will cause a WM_SYSKEYUP 99 101 or a WM_KEYUP message */ 102 #endif 100 103 101 104 static int min_keycode, max_keycode, keysyms_per_keycode; … … 108 111 109 112 #ifdef OUTOFWINE 110 // Global variable to store the current display pointer which is defined 111 // and updated in XKeyboard.cpp. 112 // The wine keyboard handler isn't reentrant anyway... 113 extern Display *dpy_global; 113 /* Global variable to store the current display pointer which is defined 114 * and updated in XKeyboard.cpp. 115 * The wine keyboard handler isn't reentrant anyway... */ 116 Display *dpy_global; 117 114 118 inline static Display *thread_display(void) { return dpy_global; } 115 / /@@@AH without this, the event time calculations are all wrong. To fix it,116 // we also gotta supply GetCurrentTime 119 /* @@@AH without this, the event time calculations are all wrong. To fix it, 120 * we also gotta supply GetCurrentTime */ 117 121 unsigned int X11DRV_server_startticks = 0; 118 // our structure used to return keyboard event information119 typedef struct _WINEKEYBOARDINFO120 {121 unsigned short wVk;122 unsigned short wScan;123 unsigned long dwFlags;124 unsigned long time;125 } WINEKEYBOARDINFO;126 122 static WINEKEYBOARDINFO *wineKeyboardInfo = NULL; 127 123 #endif … … 1176 1172 } 1177 1173 1174 #ifndef OUTOFWINE 1178 1175 static BOOL NumState=FALSE, CapsState=FALSE; 1176 #endif 1179 1177 1180 1178 … … 1182 1180 * X11DRV_send_keyboard_input 1183 1181 */ 1184 void X11DRV_send_keyboard_input( WORD wVk, WORD wScan, DWORD dwFlags, DWORD time,1182 static void X11DRV_send_keyboard_input( WORD wVk, WORD wScan, DWORD dwFlags, DWORD time, 1185 1183 DWORD dwExtraInfo, UINT injected_flags ) 1186 1184 { … … 1272 1270 } 1273 1271 SERVER_END_REQ; 1274 #else / / OUTOFWINE defined1275 / / fill out our global structure1272 #else /* OUTOFWINE defined */ 1273 /* fill out our global structure */ 1276 1274 wineKeyboardInfo->wVk = wVk; 1277 1275 wineKeyboardInfo->wScan = wScan; 1278 1276 wineKeyboardInfo->dwFlags = dwFlags; 1279 1277 wineKeyboardInfo->time = time; 1280 #endif / / OUTOFWINE defined1278 #endif /* OUTOFWINE defined */ 1281 1279 } 1282 1280 1283 1281 1282 #ifndef OUTOFWINE 1284 1283 /********************************************************************** 1285 1284 * KEYBOARD_GenerateMsg … … 1328 1327 } 1329 1328 } 1329 #endif /* OUTOFWINE not defined */ 1330 1330 1331 1331 /*********************************************************************** … … 1350 1350 } 1351 1351 1352 #ifndef OUTOFWINE 1352 1353 /*********************************************************************** 1353 1354 * X11DRV_KeymapNotify … … 1362 1363 { 1363 1364 int i, j, alt, control, shift; 1364 #ifndef OUTOFWINE1365 1365 DWORD time = GetCurrentTime(); 1366 #else // OUTOFWINE defined1367 // @@@AH todo!1368 DWORD time = 0;1369 #endif // OUTOFWINE defined1370 1366 1371 1367 alt = control = shift = 0; … … 1391 1387 KEYBOARD_UpdateOneState( VK_SHIFT, shift, time ); 1392 1388 } 1389 #endif /* OUTOFWINE defined */ 1393 1390 1394 1391 /*********************************************************************** … … 1399 1396 #ifndef OUTOFWINE 1400 1397 void X11DRV_KeyEvent( HWND hwnd, XEvent *xev ) 1401 #else / / OUTOFWINE defined1402 void X11DRV_KeyEvent( XEvent *xev, WINEKEYBOARDINFO *wKbInfo)1403 #endif / / OUTOFWINE defined1398 #else /* OUTOFWINE defined */ 1399 void X11DRV_KeyEvent(Display *dpy, XEvent *xev, WINEKEYBOARDINFO *wKbInfo) 1400 #endif /* OUTOFWINE defined */ 1404 1401 { 1405 1402 XKeyEvent *event = &xev->xkey; … … 1412 1409 XIC xic = X11DRV_get_ic( hwnd ); 1413 1410 DWORD event_time = EVENT_x11_time_to_win32_time(event->time); 1414 #else // OUTOFWINE defined 1415 // @@@AH do we need support for XIM? 1411 Status status = 0; 1412 #else /* OUTOFWINE defined */ 1413 Status status = 0; 1414 /* @@@AH do we need support for XIM? */ 1416 1415 XIC xic = 0; 1417 // set our global pointer for the return data structure 1418 // and initialize it with zeroes for the case of early return 1419 // (this will mean that the event cannot be converted to a scancode) 1416 /* We don't use this anyway. */ 1417 DWORD event_time = 0; 1418 dpy_global = dpy; 1419 /* set our global pointer for the return data structure 1420 * and initialize it with zeroes for the case of early return 1421 * (this will mean that the event cannot be converted to a scancode) */ 1420 1422 wineKeyboardInfo = wKbInfo; 1421 1423 memset( wineKeyboardInfo, 0, sizeof( wineKeyboardInfo ) ); 1422 // We don't use this anyway. 1423 DWORD event_time = 0; 1424 #endif // OUTOFWINE defined 1425 Status status = 0; 1424 #endif /* OUTOFWINE defined */ 1426 1425 1427 1426 TRACE_(key)("type %d, window %lx, state 0x%04x, keycode 0x%04x\n", … … 1447 1446 return; 1448 1447 } 1449 #endif / / OUTOFWINE not defined1448 #endif /* OUTOFWINE not defined */ 1450 1449 1451 1450 /* If XKB extensions are used, the state mask for AltGr will use the group … … 1486 1485 if (vkey) 1487 1486 { 1488 /// @todo (dmik): 1489 // KEYBOARD_GenerateMsg() does not work property because 1490 // send_keyboard_input() modifies our static WINEKEYBOARDINFO struct 1491 // directly, w/o any buffering. Moreover the purpose of 1492 // KEYBOARD_GenerateMsg() is not completely clear for me; in our case 1493 // it seems to be unnecessary, so disable the code below. 1494 // switch (vkey & 0xff) 1495 // { 1496 // case VK_NUMLOCK: 1497 // KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, event->type, event_time ); 1498 // break; 1499 // case VK_CAPITAL: 1500 // TRACE("Caps Lock event. (type %d). State before : %#.2x\n",event->type,key_state_table[vkey]); 1501 // KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, event->type, event_time ); 1502 // TRACE("State after : %#.2x\n",key_state_table[vkey]); 1503 // break; 1504 // default: 1505 // /* Adjust the NUMLOCK state if it has been changed outside wine */ 1506 // if (!(key_state_table[VK_NUMLOCK] & 0x01) != !(event->state & NumLockMask)) 1507 // { 1508 // TRACE("Adjusting NumLock state.\n"); 1509 // KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyPress, event_time ); 1510 // KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyRelease, event_time ); 1511 // } 1512 // /* Adjust the CAPSLOCK state if it has been changed outside wine */ 1513 // if (!(key_state_table[VK_CAPITAL] & 0x01) != !(event->state & LockMask)) 1514 // { 1515 // TRACE("Adjusting Caps Lock state.\n"); 1516 // KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyPress, event_time ); 1517 // KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyRelease, event_time ); 1518 // } 1519 // /* Not Num nor Caps : end of intermediary states for both. */ 1520 // NumState = FALSE; 1521 // CapsState = FALSE; 1487 /** @todo (dmik): 1488 * KEYBOARD_GenerateMsg() does not work property because 1489 * send_keyboard_input() modifies our static WINEKEYBOARDINFO struct 1490 * directly, w/o any buffering. Moreover the purpose of 1491 * KEYBOARD_GenerateMsg() is not completely clear for me; in our case 1492 * it seems to be unnecessary, so disable the code below. */ 1493 #ifndef OUTOFWINE 1494 switch (vkey & 0xff) 1495 { 1496 case VK_NUMLOCK: 1497 KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, event->type, event_time ); 1498 break; 1499 case VK_CAPITAL: 1500 TRACE("Caps Lock event. (type %d). State before : %#.2x\n",event->type,key_state_table[vkey]); 1501 KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, event->type, event_time ); 1502 TRACE("State after : %#.2x\n",key_state_table[vkey]); 1503 break; 1504 default: 1505 /* Adjust the NUMLOCK state if it has been changed outside wine */ 1506 if (!(key_state_table[VK_NUMLOCK] & 0x01) != !(event->state & NumLockMask)) 1507 { 1508 TRACE("Adjusting NumLock state.\n"); 1509 KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyPress, event_time ); 1510 KEYBOARD_GenerateMsg( VK_NUMLOCK, 0x45, KeyRelease, event_time ); 1511 } 1512 /* Adjust the CAPSLOCK state if it has been changed outside wine */ 1513 if (!(key_state_table[VK_CAPITAL] & 0x01) != !(event->state & LockMask)) 1514 { 1515 TRACE("Adjusting Caps Lock state.\n"); 1516 KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyPress, event_time ); 1517 KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, KeyRelease, event_time ); 1518 } 1519 /* Not Num nor Caps : end of intermediary states for both. */ 1520 NumState = FALSE; 1521 CapsState = FALSE; 1522 #endif /* OUTOFWINE not defined */ 1522 1523 1523 1524 bScan = keyc2scan[event->keycode] & 0xFF; … … 1529 1530 1530 1531 X11DRV_send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time, 0, 0 ); 1531 // } 1532 #ifndef OUTOFWINE 1533 } 1534 #endif 1532 1535 } 1533 1536 } … … 1598 1601 /* right now, we just find an absolute match for defined positions */ 1599 1602 /* (undefined positions are ignored, so if it's defined as "3#" in */ 1600 /* the table, it's okay that the X server has "3# �", for example) */1603 /* the table, it's okay that the X server has "3#£", for example) */ 1601 1604 /* however, the score will be higher for longer matches */ 1602 1605 for (key = 0; key < MAIN_LEN; key++) { … … 1651 1654 * X11DRV_InitKeyboard 1652 1655 */ 1653 void X11DRV_InitKeyboard(void) 1654 { 1655 Display *display = thread_display(); 1656 void X11DRV_InitKeyboard(Display *display) 1657 { 1656 1658 KeySym *ksp; 1657 1659 XModifierKeymap *mmp; … … 1665 1667 char vkey_used[256] = { 0 }; 1666 1668 1669 dpy_global = display; 1667 1670 wine_tsx11_lock(); 1668 1671 XDisplayKeycodes(display, &min_keycode, &max_keycode); … … 1825 1828 if (!vkey) 1826 1829 { 1827 / / @@@AH VBOX hack for AltGr1830 /* @@@AH VBOX hack for AltGr */ 1828 1831 if (e2.keycode == 0x71) 1829 1832 { … … 1881 1884 if (!ksname) ksname = "NoSymbol"; 1882 1885 1883 / / @@@AH VBOX hack for AltGr1886 /* @@@AH VBOX hack for AltGr */ 1884 1887 if (keyc == 0x71) 1885 1888 { … … 2369 2372 return 0; 2370 2373 } 2371 #endif / / OUTOFWINE not defined2374 #endif /* OUTOFWINE not defined */ 2372 2375 2373 2376 /*********************************************************************** … … 2388 2391 #endif 2389 2392 case 0x1000FE27 : /* Xfree's XK_Dacute_accent */ 2390 return 0xb4; /* '' */2393 return (char)0xb4; /* '' */ 2391 2394 #ifdef XK_dead_circumflex 2392 2395 case XK_dead_circumflex: … … 2403 2406 #endif 2404 2407 case 0x1000FE22 : /* Xfree's XK_Ddiaeresis */ 2405 return 0xa8; /* ': */2408 return (char)0xa8; /* ': */ 2406 2409 #ifdef XK_dead_cedilla 2407 2410 case XK_dead_cedilla : 2408 return 0xb8; /* ', */2411 return (char)0xb8; /* ', */ 2409 2412 #endif 2410 2413 #ifdef XK_dead_macron … … 2414 2417 #ifdef XK_dead_breve 2415 2418 case XK_dead_breve : 2416 return 0xa2; /* '( */2419 return (char)0xa2; /* '( */ 2417 2420 #endif 2418 2421 #ifdef XK_dead_abovedot 2419 2422 case XK_dead_abovedot : 2420 return 0xff; /* '. */2423 return (char)0xff; /* '. */ 2421 2424 #endif 2422 2425 #ifdef XK_dead_abovering … … 2426 2429 #ifdef XK_dead_doubleacute 2427 2430 case XK_dead_doubleacute : 2428 return 0xbd; /* '" */2431 return (char)0xbd; /* '" */ 2429 2432 #endif 2430 2433 #ifdef XK_dead_caron 2431 2434 case XK_dead_caron : 2432 return 0xb7; /* '< */2435 return (char)0xb7; /* '< */ 2433 2436 #endif 2434 2437 #ifdef XK_dead_ogonek 2435 2438 case XK_dead_ogonek : 2436 return 0xb2; /* '; */2439 return (char)0xb2; /* '; */ 2437 2440 #endif 2438 2441 /* FIXME: I don't know this three. … … 2708 2711 wine_tsx11_unlock(); 2709 2712 } 2710 #else / / OUTOFWINE defined2713 #else /* OUTOFWINE defined */ 2711 2714 int X11DRV_GetKeysymsPerKeycode() 2712 2715 { 2713 2716 return keysyms_per_keycode; 2714 2717 } 2715 #endif / / OUTOFWINE defined2718 #endif /* OUTOFWINE defined */ -
trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard_outofwine.h
r2529 r3945 20 20 #define __H_KEYBOARD_OUTOFWINE 21 21 22 // type definitions 22 #define HAVE_X11_XKBLIB_H 23 24 #include <X11/Xatom.h> 25 #include <X11/keysym.h> 26 #include <X11/Xlib.h> 27 #include <X11/Xresource.h> 28 #include <X11/Xutil.h> 29 #ifdef HAVE_X11_XKBLIB_H 30 #include <X11/XKBlib.h> 31 #endif 32 33 #include <ctype.h> 34 #include <stdarg.h> 35 #include <string.h> 36 37 /** Our structure used to return keyboard event information */ 38 typedef struct _WINEKEYBOARDINFO 39 { 40 unsigned short wVk; 41 unsigned short wScan; 42 unsigned long dwFlags; 43 unsigned long time; 44 } WINEKEYBOARDINFO; 45 46 /* Exported definitions */ 47 extern __attribute__((visibility("default"))) void X11DRV_InitKeyboard(Display *dpy); 48 extern __attribute__((visibility("default"))) void X11DRV_KeyEvent(Display *dpy, XEvent *event, 49 WINEKEYBOARDINFO *wKbInfo); 50 extern __attribute__((visibility("default"))) int X11DRV_GetKeysymsPerKeycode(void); 51 52 /* type definitions */ 23 53 typedef unsigned char BYTE, *LPBYTE; 24 54 typedef unsigned short WORD; … … 32 62 #define TRUE 1 33 63 34 // debug macros 35 #define TRACE 36 //#define TRACE printf 37 #define TRACE_(a) 38 //#define TRACE_(ch) printf 64 /* debug macros */ 65 inline static void noop(char *arg, ...) 66 { 67 } 68 69 #define TRACE(...) 70 /* #define TRACE printf */ 71 #define TRACE_(a) noop 72 /* #define TRACE_(ch) printf */ 39 73 #define TRACE_ON(a) 0 40 #define WARN 41 #define ERR 42 43 / / @@@AH do we need semaphore protection?74 #define WARN(...) 75 #define ERR(...) 76 77 /* @@@AH do we need semaphore protection? */ 44 78 #define wine_tsx11_lock(a) 45 79 #define wine_tsx11_unlock(a) 46 80 47 / / global wine defines81 /* global wine defines */ 48 82 #define HAVE_XKB 49 83 50 / /51 //x11drv.h52 //53 54 55 / /56 //user.h57 //58 59 60 / /61 //winuser.h62 //84 /* 85 * x11drv.h 86 */ 87 88 89 /* 90 * user.h 91 */ 92 93 94 /* 95 * winuser.h 96 */ 63 97 64 98 … … 246 280 #define VK_OEM_CLEAR 0xFE 247 281 248 / / ...282 /* ... */ 249 283 250 284 /* keybd_event flags */ … … 252 286 #define KEYEVENTF_KEYUP 0x0002 253 287 254 / / end of winuser.h255 256 257 #endif / / __H_KEYBOARD_OUTOFWINE288 /* end of winuser.h */ 289 290 291 #endif /* __H_KEYBOARD_OUTOFWINE */ -
trunk/src/VBox/Installer/linux/Makefile.kmk
r3906 r3945 48 48 VBoxDD.so \ 49 49 VBoxDD2.so \ 50 VBoxKeyboard.so \ 50 51 VBoxManage \ 51 52 VBoxREM.so \
Note:
See TracChangeset
for help on using the changeset viewer.