- Timestamp:
- Aug 18, 2014 6:04:00 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95562
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/KeyboardImpl.h
r49386 r52400 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 #define ____H_KEYBOARDIMPL 20 20 21 #include " VirtualBoxBase.h"21 #include "KeyboardWrap.h" 22 22 #include "ConsoleEvents.h" 23 23 #include "EventImpl.h" … … 34 34 KeyboardEvent() : scan(-1) {} 35 35 KeyboardEvent(int _scan) : scan(_scan) {} 36 bool i sValid()36 bool i_isValid() 37 37 { 38 38 return (scan & ~0x80) && !(scan & ~0xFF); … … 46 46 47 47 class ATL_NO_VTABLE Keyboard : 48 public VirtualBoxBase, 49 VBOX_SCRIPTABLE_IMPL(IKeyboard) 48 public KeyboardWrap 50 49 { 51 50 public: 52 53 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Keyboard, IKeyboard)54 55 DECLARE_NOT_AGGREGATABLE(Keyboard)56 57 DECLARE_PROTECT_FINAL_CONSTRUCT()58 59 BEGIN_COM_MAP(Keyboard)60 VBOX_DEFAULT_INTERFACE_ENTRIES(IKeyboard)61 END_COM_MAP()62 51 63 52 DECLARE_EMPTY_CTOR_DTOR(Keyboard) … … 70 59 void uninit(); 71 60 72 STDMETHOD(PutScancode)(LONG scancode);73 STDMETHOD(PutScancodes)(ComSafeArrayIn(LONG, scancodes),74 ULONG *codesStored);75 STDMETHOD(PutCAD)();76 STDMETHOD(ReleaseKeys)();77 78 STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);79 80 61 static const PDMDRVREG DrvReg; 81 62 82 Console * getParent() const63 Console *i_getParent() const 83 64 { 84 65 return mParent; … … 87 68 private: 88 69 89 static DECLCALLBACK(void) keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds); 90 static DECLCALLBACK(void) keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive); 91 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID); 92 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags); 93 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns); 70 // Wrapped Keyboard properties 71 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource); 72 HRESULT putScancode(LONG aScancode); 73 HRESULT putScancodes(const std::vector<LONG> &aScancodes, 74 ULONG *aCodesStored); 75 76 // Wrapped Keyboard members 77 HRESULT putCAD(); 78 HRESULT releaseKeys(); 79 80 static DECLCALLBACK(void) i_keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds); 81 static DECLCALLBACK(void) i_keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive); 82 static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID); 83 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags); 84 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns); 94 85 95 86 Console * const mParent; -
trunk/src/VBox/Main/src-client/KeyboardImpl.cpp
r51612 r52400 150 150 * 151 151 * @returns COM status code 152 * @param scancode The scancode to send 153 */ 154 STDMETHODIMP Keyboard::PutScancode(LONG scancode) 155 { 156 com::SafeArray<LONG> scancodes(1); 157 scancodes[0] = scancode; 158 return PutScancodes(ComSafeArrayAsInParam(scancodes), NULL); 152 * @param aScancode The scancode to send 153 */ 154 HRESULT Keyboard::putScancode(LONG aScancode) 155 { 156 std::vector<LONG> scancodes; 157 scancodes.resize(1); 158 scancodes[0] = aScancode; 159 return putScancodes(scancodes, NULL); 159 160 } 160 161 … … 163 164 * 164 165 * @returns COM status code 165 * @param scancodes Pointer to the first scancode 166 * @param count Number of scancodes 167 * @param codesStored Address of variable to store the number 168 * of scancodes that were sent to the keyboard. 169 This value can be NULL. 170 */ 171 STDMETHODIMP Keyboard::PutScancodes(ComSafeArrayIn(LONG, scancodes), 172 ULONG *codesStored) 173 { 174 if (ComSafeArrayInIsNull(scancodes)) 175 return E_INVALIDARG; 176 177 AutoCaller autoCaller(this); 178 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 179 180 com::SafeArray<LONG> keys(ComSafeArrayInArg(scancodes)); 166 * @param aScancodes Pointer to the first scancode 167 * @param aCodesStored Address of variable to store the number 168 * of scancodes that were sent to the keyboard. 169 This value can be NULL. 170 */ 171 HRESULT Keyboard::putScancodes(const std::vector<LONG> &aScancodes, 172 ULONG *aCodesStored) 173 { 174 com::SafeArray<LONG> keys; 175 keys.resize(aScancodes.size()); 176 for (size_t i = 0; i < aScancodes.size(); ++i) 177 keys[i] = aScancodes[i]; 181 178 182 179 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 196 193 } 197 194 } 195 198 196 /* No enabled keyboard - throw the input away. */ 199 197 if (!pUpPort) 200 198 { 201 if ( codesStored)202 * codesStored = (uint32_t)keys.size();199 if (aCodesStored) 200 *aCodesStored = (uint32_t)aScancodes.size(); 203 201 return S_OK; 204 202 } … … 207 205 208 206 uint32_t sent; 209 for (sent = 0; (sent < keys.size()) && RT_SUCCESS(vrc); sent++) 210 vrc = pUpPort->pfnPutEventScan(pUpPort, (uint8_t)keys[sent]); 211 212 if (codesStored) 213 *codesStored = sent; 214 215 /* Only signal the keys in the event which have been actually sent. */ 216 com::SafeArray<LONG> keysSent(sent); 217 memcpy(keysSent.raw(), keys.raw(), sent*sizeof(LONG)); 207 for (sent = 0; (sent < aScancodes.size()) && RT_SUCCESS(vrc); ++sent) 208 vrc = pUpPort->pfnPutEventScan(pUpPort, (uint8_t)aScancodes[sent]); 209 210 if (aCodesStored) 211 *aCodesStored = sent; 218 212 219 213 VBoxEventDesc evDesc; … … 236 230 * 237 231 */ 238 STDMETHODIMP Keyboard::PutCAD() 239 { 240 static com::SafeArray<LONG> cadSequence(8); 232 HRESULT Keyboard::putCAD() 233 { 234 static std::vector<LONG> cadSequence; 235 cadSequence.resize(8); 241 236 242 237 cadSequence[0] = 0x1d; // Ctrl down … … 249 244 cadSequence[7] = 0x9d; // Ctrl up 250 245 251 return PutScancodes(ComSafeArrayAsInParam(cadSequence), NULL);246 return putScancodes(cadSequence, NULL); 252 247 } 253 248 … … 258 253 * 259 254 */ 260 STDMETHODIMP Keyboard::ReleaseKeys() 261 { 262 com::SafeArray<LONG> scancodes(1); 255 HRESULT Keyboard::releaseKeys() 256 { 257 std::vector<LONG> scancodes; 258 scancodes.resize(1); 263 259 scancodes[0] = 0xFC; /* Magic scancode, see PS/2 and USB keyboard devices. */ 264 return PutScancodes(ComSafeArrayAsInParam(scancodes), NULL); 265 } 266 267 STDMETHODIMP Keyboard::COMGETTER(EventSource)(IEventSource ** aEventSource) 268 { 269 CheckComArgOutPointerValid(aEventSource); 270 271 AutoCaller autoCaller(this); 272 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 273 274 // no need to lock - lifetime constant 275 mEventSource.queryInterfaceTo(aEventSource); 260 return putScancodes(scancodes, NULL); 261 } 262 263 264 HRESULT Keyboard::getEventSource(ComPtr<IEventSource> &aEventSource) 265 { 266 // No need to lock - lifetime constant 267 mEventSource.queryInterfaceTo(aEventSource.asOutParam()); 276 268 277 269 return S_OK; … … 281 273 // private methods 282 274 // 283 284 DECLCALLBACK(void) Keyboard::keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds) 275 DECLCALLBACK(void) Keyboard::i_keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds) 285 276 { 286 277 PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector); 287 pDrv->pKeyboard-> getParent()->i_onKeyboardLedsChange(RT_BOOL(enmLeds & PDMKEYBLEDS_NUMLOCK),288 RT_BOOL(enmLeds & PDMKEYBLEDS_CAPSLOCK),289 RT_BOOL(enmLeds & PDMKEYBLEDS_SCROLLLOCK));278 pDrv->pKeyboard->i_getParent()->i_onKeyboardLedsChange(RT_BOOL(enmLeds & PDMKEYBLEDS_NUMLOCK), 279 RT_BOOL(enmLeds & PDMKEYBLEDS_CAPSLOCK), 280 RT_BOOL(enmLeds & PDMKEYBLEDS_SCROLLLOCK)); 290 281 } 291 282 … … 293 284 * @interface_method_impl{PDMIKEYBOARDCONNECTOR,pfnSetActive} 294 285 */ 295 DECLCALLBACK(void) Keyboard:: keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive)286 DECLCALLBACK(void) Keyboard::i_keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive) 296 287 { 297 288 PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector); … … 306 297 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 307 298 */ 308 DECLCALLBACK(void *) Keyboard:: drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)299 DECLCALLBACK(void *) Keyboard::i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID) 309 300 { 310 301 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); … … 323 314 * @param pDrvIns The driver instance data. 324 315 */ 325 DECLCALLBACK(void) Keyboard:: drvDestruct(PPDMDRVINS pDrvIns)316 DECLCALLBACK(void) Keyboard::i_drvDestruct(PPDMDRVINS pDrvIns) 326 317 { 327 318 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); … … 338 329 break; 339 330 } 340 pThis->pKeyboard->mpVMMDev = NULL;331 pThis->pKeyboard->mpVMMDev = NULL; 341 332 } 342 333 } … … 347 338 * @copydoc FNPDMDRVCONSTRUCT 348 339 */ 349 DECLCALLBACK(int) Keyboard:: drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)340 DECLCALLBACK(int) Keyboard::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) 350 341 { 351 342 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); … … 365 356 * IBase. 366 357 */ 367 pDrvIns->IBase.pfnQueryInterface = Keyboard::drvQueryInterface;368 369 pThis->IConnector.pfnLedStatusChange =keyboardLedStatusChange;370 pThis->IConnector.pfnSetActive = Keyboard::keyboardSetActive;358 pDrvIns->IBase.pfnQueryInterface = Keyboard::i_drvQueryInterface; 359 360 pThis->IConnector.pfnLedStatusChange = i_keyboardLedStatusChange; 361 pThis->IConnector.pfnSetActive = Keyboard::i_keyboardSetActive; 371 362 372 363 /* … … 429 420 sizeof(DRVMAINKEYBOARD), 430 421 /* pfnConstruct */ 431 Keyboard:: drvConstruct,422 Keyboard::i_drvConstruct, 432 423 /* pfnDestruct */ 433 Keyboard:: drvDestruct,424 Keyboard::i_drvDestruct, 434 425 /* pfnRelocate */ 435 426 NULL, -
trunk/src/VBox/Main/src-client/xpcom/module.cpp
r52232 r52400 64 64 65 65 #ifndef VBOX_COM_INPROC_API_CLIENT 66 NS_DECL_CLASSINFO(Keyboard)67 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)68 66 NS_DECL_CLASSINFO(RemoteUSBDevice) 69 67 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(RemoteUSBDevice, IHostUSBDevice, IUSBDevice)
Note:
See TracChangeset
for help on using the changeset viewer.