Changeset 16693 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 11, 2009 8:26:17 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r16691 r16693 556 556 tstDarwinKeyboard4_SOURCES = \ 557 557 src/darwin/tstDarwinKeyboard.cpp \ 558 src/darwin/DarwinKeyboard.cpp 559 tstDarwinKeyboard4_LDFLAGS = -framework IOKit -framework Carbon 558 src/darwin/DarwinKeyboard.cpp \ 559 src/darwin/VBoxCocoaApplication.m 560 tstDarwinKeyboard4_LDFLAGS = -framework IOKit -framework Carbon -framework AppKit 560 561 tstDarwinKeyboard4_LIBS = \ 561 562 $(LIB_RUNTIME) -
trunk/src/VBox/Frontends/VirtualBox/include/DarwinKeyboard.h
r16469 r16693 43 43 44 44 unsigned DarwinKeycodeToSet1Scancode(unsigned uKeyCode); 45 UInt32 DarwinAdjustModifierMask(UInt32 fModifiers );45 UInt32 DarwinAdjustModifierMask(UInt32 fModifiers, const void *pvCocoaEvent); 46 46 unsigned DarwinModifierMaskToSet1Scancode(UInt32 fModifiers); 47 47 unsigned DarwinModifierMaskToDarwinKeycode(UInt32 fModifiers); -
trunk/src/VBox/Frontends/VirtualBox/include/QIHotKeyEdit.h
r16610 r16693 88 88 static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData); 89 89 # endif 90 bool darwinKeyboardEvent ( EventRef inEvent);90 bool darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent); 91 91 #endif 92 92 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r16691 r16693 164 164 bool x11Event (XEvent *event); 165 165 #elif defined(Q_WS_MAC) 166 bool darwinKeyboardEvent ( EventRef inEvent);166 bool darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent); 167 167 void darwinGrabKeyboardEvents (bool fGrab); 168 168 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/QIHotKeyEdit.cpp
r16691 r16693 677 677 UInt32 EventClass = ::GetEventClass (inEvent); 678 678 if (EventClass == kEventClassKeyboard) 679 return edit->darwinKeyboardEvent ( inEvent);679 return edit->darwinKeyboardEvent (pvCocoaEvent, inEvent); 680 680 return false; 681 681 } … … 690 690 if (EventClass == kEventClassKeyboard) 691 691 { 692 if (edit->darwinKeyboardEvent ( inEvent))692 if (edit->darwinKeyboardEvent (NULL, inEvent)) 693 693 return 0; 694 694 } … … 697 697 # endif /* !QT_MAC_USE_COCOA */ 698 698 699 bool QIHotKeyEdit::darwinKeyboardEvent ( EventRef inEvent)699 bool QIHotKeyEdit::darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent) 700 700 { 701 701 #if 0 /* for debugging */ … … 719 719 sizeof (modifierMask), NULL, &modifierMask); 720 720 721 modifierMask = ::DarwinAdjustModifierMask (modifierMask );721 modifierMask = ::DarwinAdjustModifierMask (modifierMask, pvCocoaEvent); 722 722 UInt32 changed = mDarwinKeyModifiers ^ modifierMask; 723 723 mDarwinKeyModifiers = modifierMask; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r16691 r16693 151 151 if (eventClass == kEventClassKeyboard) 152 152 { 153 if (view->darwinKeyboardEvent ( inEvent))153 if (view->darwinKeyboardEvent (pvCocoaEvent, inEvent)) 154 154 return true; 155 155 } … … 196 196 if (eventClass == kEventClassKeyboard) 197 197 { 198 if (view->darwinKeyboardEvent ( inEvent))198 if (view->darwinKeyboardEvent (NULL, inEvent)) 199 199 return 0; 200 200 } … … 239 239 if (eventClass == kEventClassKeyboard) 240 240 { 241 if (view->darwinKeyboardEvent ( inEvent))241 if (view->darwinKeyboardEvent (NULL, inEvent)) 242 242 return true; 243 243 } … … 2193 2193 * it receives a raw keyboard event. 2194 2194 * 2195 * @param pvCocoaEvent The Cocoa keyboard event. Can be NULL in some configs. 2195 2196 * @param inEvent The keyboard event. 2196 2197 * 2197 2198 * @return true if the key was processed, false if it wasn't processed and should be passed on. 2198 2199 */ 2199 bool VBoxConsoleView::darwinKeyboardEvent ( EventRef inEvent)2200 bool VBoxConsoleView::darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent) 2200 2201 { 2201 2202 bool ret = false; … … 2237 2238 ::GetEventParameter (inEvent, kEventParamKeyModifiers, typeUInt32, NULL, 2238 2239 sizeof (newMask), NULL, &newMask); 2239 newMask = ::DarwinAdjustModifierMask (newMask );2240 newMask = ::DarwinAdjustModifierMask (newMask, pvCocoaEvent); 2240 2241 UInt32 changed = newMask ^ mDarwinKeyModifiers; 2241 2242 if (changed) -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/DarwinKeyboard.cpp
r16469 r16693 20 20 * additional information or have any questions. 21 21 */ 22 23 24 25 #define USE_HID_FOR_MODIFIERS26 27 22 28 23 /******************************************************************************* … … 39 34 #endif 40 35 41 #ifdef USE_HID_FOR_MODIFIERS 36 #ifdef RT_ARCH_X86 37 # define USE_HID_FOR_MODIFIERS 42 38 # include <mach/mach.h> 43 39 # include <mach/mach_error.h> … … 51 47 #include <ApplicationServices/ApplicationServices.h> 52 48 #include <Carbon/Carbon.h> 49 50 #ifndef USE_HID_FOR_MODIFIERS 51 # include "VBoxCocoaApplication.h" 52 #endif 53 53 54 54 55 __BEGIN_DECLS … … 972 973 * @returns left/right adjusted fModifiers. 973 974 * @param fModifiers The mask to adjust. 974 */ 975 UInt32 DarwinAdjustModifierMask(UInt32 fModifiers) 976 { 977 #ifdef USE_HID_FOR_MODIFIERS 978 /* 979 * Update the keyboard cache. 980 */ 981 darwinHIDKeyboardCacheUpdate(); 982 975 * @param pvCocoaEvent The associated Cocoa keyboard event. This is NULL 976 * when using HID for modifier corrections. 977 * 978 */ 979 UInt32 DarwinAdjustModifierMask(UInt32 fModifiers, const void *pvCocoaEvent) 980 { 983 981 /* 984 982 * Check if there is anything to adjust and perform the adjustment. … … 986 984 if (fModifiers & (shiftKey | rightShiftKey | controlKey | rightControlKey | optionKey | rightOptionKey | cmdKey | kEventKeyModifierRightCmdKeyMask)) 987 985 { 988 const UInt32 fHIDModifiers = g_fHIDModifierMask; 986 #ifndef USE_HID_FOR_MODIFIERS 987 /* 988 * Convert the Cocoa modifiers to Carbon ones. 989 */ 990 AssertPtr(pvCocoaEvent); 991 VBoxCocoaApplication_printEvent("dbg-adjMods: ", pvCocoaEvent); 992 uint32_t fAltModifiers = VBoxCocoaApplication_getEventModifierFlagsXlated(pvCocoaEvent); 993 994 #else /* USE_HID_FOR_MODIFIERS */ 995 /* 996 * Update the keyboard cache. 997 */ 998 darwinHIDKeyboardCacheUpdate(); 999 const UInt32 fAltModifiers = g_fHIDModifierMask; 1000 1001 #endif /* USE_HID_FOR_MODIFIERS */ 989 1002 #ifdef DEBUG_PRINTF 990 RTPrintf("dbg-f HIDModifier=%#x fModifiers=%#x", fHIDModifiers, fModifiers);1003 RTPrintf("dbg-fAltModifiers=%#x fModifiers=%#x", fAltModifiers, fModifiers); 991 1004 #endif 992 1005 if ( (fModifiers & (rightShiftKey | shiftKey)) 993 && (f HIDModifiers & (rightShiftKey | shiftKey)))1006 && (fAltModifiers & (rightShiftKey | shiftKey))) 994 1007 { 995 1008 fModifiers &= ~(rightShiftKey | shiftKey); 996 fModifiers |= f HIDModifiers & (rightShiftKey | shiftKey);1009 fModifiers |= fAltModifiers & (rightShiftKey | shiftKey); 997 1010 } 998 1011 999 1012 if ( (fModifiers & (rightControlKey | controlKey)) 1000 && (f HIDModifiers & (rightControlKey | controlKey)))1013 && (fAltModifiers & (rightControlKey | controlKey))) 1001 1014 { 1002 1015 fModifiers &= ~(rightControlKey | controlKey); 1003 fModifiers |= f HIDModifiers & (rightControlKey | controlKey);1016 fModifiers |= fAltModifiers & (rightControlKey | controlKey); 1004 1017 } 1005 1018 1006 1019 if ( (fModifiers & (optionKey | rightOptionKey)) 1007 && (f HIDModifiers & (optionKey | rightOptionKey)))1020 && (fAltModifiers & (optionKey | rightOptionKey))) 1008 1021 { 1009 1022 fModifiers &= ~(optionKey | rightOptionKey); 1010 fModifiers |= f HIDModifiers & (optionKey | rightOptionKey);1023 fModifiers |= fAltModifiers & (optionKey | rightOptionKey); 1011 1024 } 1012 1025 1013 1026 if ( (fModifiers & (cmdKey | kEventKeyModifierRightCmdKeyMask)) 1014 && (f HIDModifiers & (cmdKey | kEventKeyModifierRightCmdKeyMask)))1027 && (fAltModifiers & (cmdKey | kEventKeyModifierRightCmdKeyMask))) 1015 1028 { 1016 1029 fModifiers &= ~(cmdKey | kEventKeyModifierRightCmdKeyMask); 1017 fModifiers |= f HIDModifiers & (cmdKey | kEventKeyModifierRightCmdKeyMask);1030 fModifiers |= fAltModifiers & (cmdKey | kEventKeyModifierRightCmdKeyMask); 1018 1031 } 1019 1032 #ifdef DEBUG_PRINTF 1020 RTPrintf(" -> %#x ", fModifiers);1033 RTPrintf(" -> %#x\n", fModifiers); 1021 1034 #endif 1022 1035 } 1023 #endif /* USE_HID_FOR_MODIFIERS */1024 1025 1036 return fModifiers; 1026 1037 } -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.h
r16691 r16693 85 85 void VBoxCocoaApplication_setCallback(uint32_t fMask, PFNVBOXCACALLBACK pfnCallback, void *pvUser); 86 86 void VBoxCocoaApplication_unsetCallback(uint32_t fMask, PFNVBOXCACALLBACK pfnCallback, void *pvUser); 87 unsigned long VBoxCocoaApplication_getEventModifierFlags(const void *pvEvent); 88 uint32_t VBoxCocoaApplication_getEventModifierFlagsXlated(const void *pvEvent); 87 89 const char *VBoxCocoaApplication_eventTypeName(unsigned long eEvtType); 88 90 void VBoxCocoaApplication_printEvent(const char *pszPrefix, const void *pvEvent); 91 89 92 90 93 /** @} */ -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.m
r16691 r16693 25 25 *******************************************************************************/ 26 26 #include "VBoxCocoaApplication.h" 27 #include "DarwinKeyboard.h" 27 28 #include <iprt/assert.h> 28 29 #import <AppKit/NSEvent.h> … … 193 194 { 194 195 [g_pVBoxCocoaApp unsetCallback:fMask :pfnCallback :pvUser]; 196 } 197 198 199 /** 200 * Calls the -(NSUInteger)modifierFlags method on a NSEvent object. 201 * 202 * @return The Cocoa event modifier mask. 203 * @param pvEvent The NSEvent object. 204 */ 205 unsigned long VBoxCocoaApplication_getEventModifierFlags(const void *pvEvent) 206 { 207 NSEvent *pEvent = (NSEvent *)pvEvent; 208 return [pEvent modifierFlags]; 209 } 210 211 212 /** 213 * Calls the -(NSUInteger)modifierFlags method on a NSEvent object and 214 * converts the flags to carbon style. 215 * 216 * @return The Carbon modifier mask. 217 * @param pvEvent The NSEvent object. 218 */ 219 uint32_t VBoxCocoaApplication_getEventModifierFlagsXlated(const void *pvEvent) 220 { 221 NSEvent *pEvent = (NSEvent *)pvEvent; 222 NSUInteger fCocoa = [pEvent modifierFlags]; 223 uint32_t fCarbon = 0; 224 if (fCocoa) 225 { 226 if (fCocoa & NSAlphaShiftKeyMask) 227 fCarbon |= alphaLock; 228 if (fCocoa & (NSShiftKeyMask | NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK)) 229 { 230 if (fCocoa & (NX_DEVICERSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK)) 231 { 232 if (fCocoa & NX_DEVICERSHIFTKEYMASK) 233 fCarbon |= rightShiftKey; 234 if (fCocoa & NX_DEVICELSHIFTKEYMASK) 235 fCarbon |= shiftKey; 236 } 237 else 238 fCarbon |= shiftKey; 239 } 240 241 if (fCocoa & (NSControlKeyMask | NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK)) 242 { 243 if (fCocoa & (NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK)) 244 { 245 if (fCocoa & NX_DEVICERCTLKEYMASK) 246 fCarbon |= rightControlKey; 247 if (fCocoa & NX_DEVICELCTLKEYMASK) 248 fCarbon |= controlKey; 249 } 250 else 251 fCarbon |= controlKey; 252 } 253 254 if (fCocoa & (NSAlternateKeyMask | NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK)) 255 { 256 if (fCocoa & (NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK)) 257 { 258 if (fCocoa & NX_DEVICERALTKEYMASK) 259 fCarbon |= rightOptionKey; 260 if (fCocoa & NX_DEVICELALTKEYMASK) 261 fCarbon |= optionKey; 262 } 263 else 264 fCarbon |= optionKey; 265 } 266 267 if (fCocoa & (NSCommandKeyMask | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK)) 268 { 269 if (fCocoa & (NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK)) 270 { 271 if (fCocoa & NX_DEVICERCMDKEYMASK) 272 fCarbon |= kEventKeyModifierRightCmdKeyMask; 273 if (fCocoa & NX_DEVICELCMDKEYMASK) 274 fCarbon |= cmdKey; 275 } 276 else 277 fCarbon |= cmdKey; 278 } 279 280 //if (fCocoa & NSNumericPadKeyMask) 281 // fCarbon |= ???; 282 283 //if (fCocoa & NSHelpKeyMask) 284 // fCarbon |= ???; 285 286 //if (fCocoa & NSFunctionKeyMask) 287 // fCarbon |= ???; 288 } 289 290 return fCarbon; 195 291 } 196 292
Note:
See TracChangeset
for help on using the changeset viewer.