Changeset 11661 in vbox
- Timestamp:
- Aug 26, 2008 1:49:29 PM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBFE/COMDefs.h
r11659 r11661 74 74 #endif /* !RT_OS_WINDOWS */ 75 75 76 #define ComSafeArrayIn(aType, aArg) unsigned aArg##Size, aType *aArg 77 #define ComSafeArrayInIsNull(aArg) (aArg == NULL) 78 #define ComSafeArrayInArg(aArg) aArg##Size, aArg 79 #define ComSafeArrayAsInParam(aArray) \ 80 (aArray).size(), aArray.raw() 81 82 83 namespace com 84 { 85 template<class T> class SafeArray { 86 T t; 87 public: 88 SafeArray (size_t aSize) {} 89 SafeArray (ComSafeArrayIn (T, aArg)) {} 90 T &operator[] (size_t aIdx) { return t; } 91 size_t size() const { return 0; } 92 T *raw() { return &t; } 93 }; 94 } 76 95 #endif -
trunk/src/VBox/Frontends/VBoxBFE/KeyboardImpl.cpp
r11659 r11661 25 25 #else 26 26 # include <VBox/com/defs.h> 27 //# include <VBox/com/array.h> 27 28 #endif 28 29 #include <VBox/pdm.h> … … 99 100 * 100 101 * @returns COM status code 101 * @param scancodes Pointer to the first scancode 102 * @param count Number of scancodes 102 * @param scancodes Safe array of scancodes 103 103 * @param codesStored Address of variable to store the number 104 104 * of scancodes that were sent to the keyboard. 105 105 This value can be NULL. 106 106 */ 107 STDMETHODIMP Keyboard::PutScancodes(LONG *scancodes, 108 ULONG count, 107 STDMETHODIMP Keyboard::PutScancodes(ComSafeArrayIn (LONG, scancodes), 109 108 ULONG *codesStored) 110 109 { 111 if ( !scancodes)110 if (ComSafeArrayInIsNull(scancodes)) 112 111 return E_INVALIDARG; 113 112 if (!mpDrv) 114 113 return S_OK; 115 114 116 LONG *currentScancode = scancodes;115 com::SafeArray <LONG> keys(ComSafeArrayInArg(scancodes)); 117 116 int rcVBox = VINF_SUCCESS; 118 117 119 for (uint32_t i = 0; (i < count) && VBOX_SUCCESS(rcVBox); i++, currentScancode++)120 { 121 rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, *(uint8_t*)currentScancode);118 for (uint32_t i = 0; (i < keys.size()) && VBOX_SUCCESS(rcVBox); i++) 119 { 120 rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, (uint8_t)keys[i]); 122 121 } 123 122 … … 127 126 /// @todo is it actually possible that not all scancodes can be transmitted? 128 127 if (codesStored) 129 *codesStored = count;128 *codesStored = keys.size(); 130 129 131 130 return S_OK; … … 141 140 STDMETHODIMP Keyboard::PutCAD() 142 141 { 143 static LONG cadSequence[] = {144 0x1d, // Ctrl down145 0x38, // Altdown146 0x53, // Deldown147 0xd3, // Del up148 0xb8, // Altup149 0x9d // Ctrlup150 };151 152 return PutScancodes ( cadSequence, ELEMENTS(cadSequence), NULL);142 static com::SafeArray<LONG> cadSequence(6); 143 144 cadSequence[0] = 0x1d; // Ctrl down 145 cadSequence[1] = 0x38; // Alt down 146 cadSequence[2] = 0x53; // Del down 147 cadSequence[3] = 0xd3; // Del up 148 cadSequence[4] = 0xb8; // Alt up 149 cadSequence[5] = 0x9d; // Ctrl up 150 151 return PutScancodes (ComSafeArrayAsInParam(cadSequence), NULL); 153 152 } 154 153 -
trunk/src/VBox/Frontends/VBoxBFE/KeyboardImpl.h
r11659 r11661 48 48 49 49 STDMETHOD(PutScancode)(LONG scancode); 50 STDMETHOD(PutScancodes)(LONG *scancodes, 51 ULONG count, 50 STDMETHOD(PutScancodes)(ComSafeArrayIn (LONG, scancodes), 52 51 ULONG *codesStored); 53 52 STDMETHOD(PutCAD)(); -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r11659 r11661 4742 4742 case SDLK_F10: case SDLK_F11: case SDLK_F12: 4743 4743 { 4744 /* send Ctrl-Alt-Fx to guest */ 4745 static LONG keySequence[] = { 4746 0x1d, // Ctrl down 4747 0x38, // Alt down 4748 0x00, // Fx down (placeholder) 4749 0x00, // Fx up (placeholder) 4750 0xb8, // Alt up 4751 0x9d // Ctrl up 4752 }; 4753 4754 /* put in the right Fx key */ 4755 keySequence[2] = Keyevent2Keycode(pEv); 4756 keySequence[3] = keySequence[2] + 0x80; 4757 4758 gKeyboard->PutScancodes(keySequence, ELEMENTS(keySequence), NULL); 4744 // /* send Ctrl-Alt-Fx to guest */ 4745 com::SafeArray<LONG> keys(6); 4746 4747 keys[0] = 0x1d; // Ctrl down 4748 keys[1] = 0x38; // Alt down 4749 keys[2] = Keyevent2Keycode(pEv); // Fx down 4750 keys[3] = keys[2] + 0x80; // Fx up 4751 keys[4] = 0xb8; // Alt up 4752 keys[5] = 0x9d; // Ctrl up 4753 4754 gKeyboard->PutScancodes(ComSafeArrayAsInParam(keys), NULL); 4759 4755 return VINF_SUCCESS; 4760 4756 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r11659 r11661 1388 1388 if (ke->key() >= Key_F1 && ke->key() <= Key_F12) 1389 1389 { 1390 LONG combo [6];1390 QValueVector <LONG> combo (6); 1391 1391 combo [0] = 0x1d; /* Ctrl down */ 1392 1392 combo [1] = 0x38; /* Alt down */ … … 1408 1408 1409 1409 CKeyboard keyboard = mConsole.GetKeyboard(); 1410 keyboard.PutScancodes (combo , 6);1410 keyboard.PutScancodes (combo); 1411 1411 } 1412 1412 else if (ke->key() == Key_Home) … … 2615 2615 #endif 2616 2616 2617 keyboard.PutScancodes (codes, count); 2617 std::vector <LONG> tmp(codes, &codes[count]); 2618 QValueVector <LONG> scancodes (tmp); 2619 keyboard.PutScancodes (scancodes); 2618 2620 2619 2621 /* grab the key from Qt */ … … 3185 3187 fSentRESEND = true; 3186 3188 } 3187 LONG codes [2];3189 QValueVector <LONG> codes (2); 3188 3190 codes[0] = 0xE0; 3189 3191 codes[1] = i | 0x80; 3190 keyboard.PutScancodes (codes , 2);3192 keyboard.PutScancodes (codes); 3191 3193 } 3192 3194 mPressedKeys [i] = 0; … … 3215 3217 AssertMsg (mAttached, ("Console must be attached")); 3216 3218 3217 LONG codes [2];3219 QValueVector <LONG> codes (2); 3218 3220 CKeyboard keyboard = mConsole.GetKeyboard(); 3219 3221 for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); ++ i) … … 3234 3236 if (!(ns & IsExtKeyPressed)) 3235 3237 codes [1] |= 0x80; 3236 keyboard.PutScancodes (codes , 2);3238 keyboard.PutScancodes (codes); 3237 3239 } 3238 3240 } -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp
r11659 r11661 1426 1426 if (ke->key() >= Qt::Key_F1 && ke->key() <= Qt::Key_F12) 1427 1427 { 1428 LONG combo [6];1428 QVector <LONG> combo (6); 1429 1429 combo [0] = 0x1d; /* Ctrl down */ 1430 1430 combo [1] = 0x38; /* Alt down */ … … 1446 1446 1447 1447 CKeyboard keyboard = mConsole.GetKeyboard(); 1448 keyboard.PutScancodes (combo , 6);1448 keyboard.PutScancodes (combo); 1449 1449 } 1450 1450 else if (ke->key() == Qt::Key_Home) … … 2657 2657 #endif 2658 2658 2659 keyboard.PutScancodes (codes, count); 2659 std::vector <LONG> scancodes(codes, &codes[count]); 2660 keyboard.PutScancodes (QVector<LONG>::fromStdVector(scancodes)); 2660 2661 2661 2662 /* grab the key from Qt */ … … 3226 3227 fSentRESEND = true; 3227 3228 } 3228 LONG codes [2];3229 QVector <LONG> codes (2); 3229 3230 codes[0] = 0xE0; 3230 3231 codes[1] = i | 0x80; 3231 keyboard.PutScancodes (codes , 2);3232 keyboard.PutScancodes (codes); 3232 3233 } 3233 3234 mPressedKeys [i] = 0; … … 3256 3257 AssertMsg (mAttached, ("Console must be attached")); 3257 3258 3258 LONG codes [2];3259 QVector <LONG> codes (2); 3259 3260 CKeyboard keyboard = mConsole.GetKeyboard(); 3260 3261 for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); ++ i) … … 3275 3276 if (!(ns & IsExtKeyPressed)) 3276 3277 codes [1] |= 0x80; 3277 keyboard.PutScancodes (codes , 2);3278 keyboard.PutScancodes (codes); 3278 3279 } 3279 3280 } -
trunk/src/VBox/Main/KeyboardImpl.cpp
r11659 r11661 25 25 #include "Logging.h" 26 26 27 #include <VBox/com/array.h> 27 28 #include <VBox/pdmdrv.h> 28 29 #include <iprt/asm.h> … … 148 149 This value can be NULL. 149 150 */ 150 STDMETHODIMP Keyboard::PutScancodes(LONG *scancodes, 151 ULONG count, 151 STDMETHODIMP Keyboard::PutScancodes(ComSafeArrayIn (LONG, scancodes), 152 152 ULONG *codesStored) 153 153 { 154 if ( !scancodes)154 if (ComSafeArrayInIsNull(scancodes)) 155 155 return E_INVALIDARG; 156 156 … … 160 160 CHECK_CONSOLE_DRV (mpDrv); 161 161 162 LONG *currentScancode = scancodes;162 com::SafeArray <LONG> keys(ComSafeArrayInArg(scancodes)); 163 163 int rcVBox = VINF_SUCCESS; 164 164 165 for (uint32_t i = 0; (i < count) && VBOX_SUCCESS(rcVBox); i++, currentScancode++)166 { 167 rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, *(uint8_t*)currentScancode);165 for (uint32_t i = 0; (i < keys.size()) && VBOX_SUCCESS(rcVBox); i++) 166 { 167 rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, (uint8_t)keys[i]); 168 168 } 169 169 … … 174 174 /// @todo is it actually possible that not all scancodes can be transmitted? 175 175 if (codesStored) 176 *codesStored = count;176 *codesStored = keys.size(); 177 177 178 178 return S_OK; … … 188 188 STDMETHODIMP Keyboard::PutCAD() 189 189 { 190 static LONG cadSequence[] = {191 0x1d, // Ctrl down192 0x38, // Altdown193 0x53, // Deldown194 0xd3, // Del up195 0xb8, // Altup196 0x9d // Ctrlup197 };198 199 return PutScancodes ( cadSequence, ELEMENTS(cadSequence), NULL);190 static com::SafeArray<LONG> cadSequence(6); 191 192 cadSequence[0] = 0x1d; // Ctrl down 193 cadSequence[1] = 0x38; // Alt down 194 cadSequence[2] = 0x53; // Del down 195 cadSequence[3] = 0xd3; // Del up 196 cadSequence[4] = 0xb8; // Alt up 197 cadSequence[5] = 0x9d; // Ctrl up 198 199 return PutScancodes (ComSafeArrayAsInParam(cadSequence), NULL); 200 200 } 201 201 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r11659 r11661 7707 7707 <interface 7708 7708 name="IKeyboard" extends="$unknown" 7709 uuid=" FD443EC1-000A-4F5B-9282-D72760A66916"7709 uuid="2d1a531b-4c6e-49cc-8af6-5c857b78b5d7" 7710 7710 wsmap="managed" 7711 7711 > … … 7724 7724 <method name="putScancodes"> 7725 7725 <desc>Sends an array of scancode to the keyboard.</desc> 7726 <param name="scancodes" type="long" dir="in" array="count"/> 7727 <param name="count" type="unsigned long" dir="in"/> 7726 <param name="scancodes" type="long" dir="in" safearray="yes"/> 7728 7727 <param name="codesStored" type="unsigned long" dir="return"/> 7729 7728 </method> -
trunk/src/VBox/Main/include/KeyboardImpl.h
r11659 r11661 72 72 73 73 STDMETHOD(PutScancode)(LONG scancode); 74 STDMETHOD(PutScancodes)(LONG *scancodes, 75 ULONG count, 74 STDMETHOD(PutScancodes)(ComSafeArrayIn (LONG, scancodes), 76 75 ULONG *codesStored); 77 76 STDMETHOD(PutCAD)();
Note:
See TracChangeset
for help on using the changeset viewer.