Changeset 11661 in vbox for trunk/src/VBox/Frontends/VBoxBFE
- Timestamp:
- Aug 26, 2008 1:49:29 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxBFE
- Files:
-
- 3 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)();
Note:
See TracChangeset
for help on using the changeset viewer.