VirtualBox

Changeset 52400 in vbox for trunk/src


Ignore:
Timestamp:
Aug 18, 2014 6:04:00 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95562
Message:

6813 KeyboardImpl.cpp changes

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/KeyboardImpl.h

    r49386 r52400  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919#define ____H_KEYBOARDIMPL
    2020
    21 #include "VirtualBoxBase.h"
     21#include "KeyboardWrap.h"
    2222#include "ConsoleEvents.h"
    2323#include "EventImpl.h"
     
    3434    KeyboardEvent() : scan(-1) {}
    3535    KeyboardEvent(int _scan) : scan(_scan) {}
    36     bool isValid()
     36    bool i_isValid()
    3737    {
    3838        return (scan & ~0x80) && !(scan & ~0xFF);
     
    4646
    4747class ATL_NO_VTABLE Keyboard :
    48     public VirtualBoxBase,
    49     VBOX_SCRIPTABLE_IMPL(IKeyboard)
     48    public KeyboardWrap
    5049{
    5150public:
    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()
    6251
    6352    DECLARE_EMPTY_CTOR_DTOR(Keyboard)
     
    7059    void uninit();
    7160
    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 
    8061    static const PDMDRVREG  DrvReg;
    8162
    82     Console *getParent() const
     63    Console *i_getParent() const
    8364    {
    8465        return mParent;
     
    8768private:
    8869
    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);
    9485
    9586    Console * const         mParent;
  • trunk/src/VBox/Main/src-client/KeyboardImpl.cpp

    r51612 r52400  
    150150 *
    151151 * @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 */
     154HRESULT Keyboard::putScancode(LONG aScancode)
     155{
     156    std::vector<LONG> scancodes;
     157    scancodes.resize(1);
     158    scancodes[0] = aScancode;
     159    return putScancodes(scancodes, NULL);
    159160}
    160161
     
    163164 *
    164165 * @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 */
     171HRESULT 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];
    181178
    182179    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    196193        }
    197194    }
     195
    198196    /* No enabled keyboard - throw the input away. */
    199197    if (!pUpPort)
    200198    {
    201         if (codesStored)
    202             *codesStored = (uint32_t)keys.size();
     199        if (aCodesStored)
     200            *aCodesStored = (uint32_t)aScancodes.size();
    203201        return S_OK;
    204202    }
     
    207205
    208206    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;
    218212
    219213    VBoxEventDesc evDesc;
     
    236230 *
    237231 */
    238 STDMETHODIMP Keyboard::PutCAD()
    239 {
    240     static com::SafeArray<LONG> cadSequence(8);
     232HRESULT Keyboard::putCAD()
     233{
     234    static std::vector<LONG> cadSequence;
     235    cadSequence.resize(8);
    241236
    242237    cadSequence[0] = 0x1d; // Ctrl down
     
    249244    cadSequence[7] = 0x9d; // Ctrl up
    250245
    251     return PutScancodes(ComSafeArrayAsInParam(cadSequence), NULL);
     246    return putScancodes(cadSequence, NULL);
    252247}
    253248
     
    258253 *
    259254 */
    260 STDMETHODIMP Keyboard::ReleaseKeys()
    261 {
    262     com::SafeArray<LONG> scancodes(1);
     255HRESULT Keyboard::releaseKeys()
     256{
     257    std::vector<LONG> scancodes;
     258    scancodes.resize(1);
    263259    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
     264HRESULT Keyboard::getEventSource(ComPtr<IEventSource> &aEventSource)
     265{
     266    // No need to lock - lifetime constant
     267    mEventSource.queryInterfaceTo(aEventSource.asOutParam());
    276268
    277269    return S_OK;
     
    281273// private methods
    282274//
    283 
    284 DECLCALLBACK(void) Keyboard::keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
     275DECLCALLBACK(void) Keyboard::i_keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
    285276{
    286277    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));
    290281}
    291282
     
    293284 * @interface_method_impl{PDMIKEYBOARDCONNECTOR,pfnSetActive}
    294285 */
    295 DECLCALLBACK(void) Keyboard::keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive)
     286DECLCALLBACK(void) Keyboard::i_keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive)
    296287{
    297288    PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector);
     
    306297 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    307298 */
    308 DECLCALLBACK(void *) Keyboard::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     299DECLCALLBACK(void *) Keyboard::i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    309300{
    310301    PPDMDRVINS          pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
     
    323314 * @param   pDrvIns     The driver instance data.
    324315 */
    325 DECLCALLBACK(void) Keyboard::drvDestruct(PPDMDRVINS pDrvIns)
     316DECLCALLBACK(void) Keyboard::i_drvDestruct(PPDMDRVINS pDrvIns)
    326317{
    327318    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
     
    338329                break;
    339330            }
    340         pThis->pKeyboard->mpVMMDev = NULL;
     331            pThis->pKeyboard->mpVMMDev = NULL;
    341332    }
    342333}
     
    347338 * @copydoc FNPDMDRVCONSTRUCT
    348339 */
    349 DECLCALLBACK(int) Keyboard::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
     340DECLCALLBACK(int) Keyboard::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    350341{
    351342    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     
    365356     * IBase.
    366357     */
    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;
    371362
    372363    /*
     
    429420    sizeof(DRVMAINKEYBOARD),
    430421    /* pfnConstruct */
    431     Keyboard::drvConstruct,
     422    Keyboard::i_drvConstruct,
    432423    /* pfnDestruct */
    433     Keyboard::drvDestruct,
     424    Keyboard::i_drvDestruct,
    434425    /* pfnRelocate */
    435426    NULL,
  • trunk/src/VBox/Main/src-client/xpcom/module.cpp

    r52232 r52400  
    6464
    6565#ifndef VBOX_COM_INPROC_API_CLIENT
    66 NS_DECL_CLASSINFO(Keyboard)
    67 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
    6866NS_DECL_CLASSINFO(RemoteUSBDevice)
    6967NS_IMPL_THREADSAFE_ISUPPORTS2_CI(RemoteUSBDevice, IHostUSBDevice, IUSBDevice)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette