/* $Id: MouseImpl.h 26834 2010-02-26 12:10:36Z vboxsync $ */ /** @file * VirtualBox VBoxBFE/COM class implementation */ /* * Copyright (C) 2006-2008 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. */ #ifndef ____H_MOUSEIMPL #define ____H_MOUSEIMPL #include "VirtualBoxBase.h" #ifndef VBOXBFE_WITHOUT_COM # include "ConsoleEvents.h" #endif #include "ConsoleImpl.h" #include /** Simple mouse event class. */ class MouseEvent { public: MouseEvent() : dx(0), dy(0), dz(0), dw(0), state(-1) {} MouseEvent(int32_t _dx, int32_t _dy, int32_t _dz, int32_t _dw, int32_t _state) : dx(_dx), dy(_dy), dz(_dz), dw(_dw), state(_state) {} bool isValid() { return state != -1; } /* Note: dw is the horizontal scroll wheel */ int32_t dx, dy, dz, dw; int32_t state; }; #ifndef VBOXBFE_WITHOUT_COM // template instantiation typedef ConsoleEventBuffer MouseEventBuffer; #endif enum { MOUSE_DEVCAP_RELATIVE = 1, MOUSE_DEVCAP_ABSOLUTE = 2 }; class ATL_NO_VTABLE Mouse : public VirtualBoxBase #ifndef VBOXBFE_WITHOUT_COM , public VirtualBoxSupportErrorInfoImpl, public VirtualBoxSupportTranslation, VBOX_SCRIPTABLE_IMPL(IMouse) #endif { public: #ifndef VBOXBFE_WITHOUT_COM VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse) DECLARE_NOT_AGGREGATABLE(Mouse) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(Mouse) COM_INTERFACE_ENTRY (ISupportErrorInfo) COM_INTERFACE_ENTRY (IMouse) COM_INTERFACE_ENTRY2 (IDispatch, IMouse) END_COM_MAP() #endif DECLARE_EMPTY_CTOR_DTOR (Mouse) HRESULT FinalConstruct(); void FinalRelease(); // public initializer/uninitializer for internal purposes only HRESULT init(Console *parent); void uninit(); // IMouse properties STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported); STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported); STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor); // IMouse methods STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw, LONG buttonState); STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw, LONG buttonState); // for VirtualBoxSupportErrorInfoImpl static const wchar_t *getComponentName() { return L"Mouse"; } static const PDMDRVREG DrvReg; #ifndef VBOXBFE_WITHOUT_COM Console *getParent() const { return mParent; } #endif // for VMMDevInterface void onVMMDevCanAbsChange(bool canAbs) { fVMMDevCanAbs = canAbs; sendMouseCapsCallback(); } void onVMMDevNeedsHostChange(bool needsHost) { fVMMDevNeedsHostCursor = needsHost; sendMouseCapsCallback(); } private: static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID); static DECLCALLBACK(void) mouseAbsModeChange (PPDMIMOUSECONNECTOR pInterface, bool fAbs); static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags); static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns); int getVMMDevMouseCaps(uint32_t *pfCaps); int setVMMDevMouseCaps(uint32_t fCaps); int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz, int32_t dw, uint32_t fButtons); int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs, int32_t dz, int32_t dw, uint32_t fButtons); int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs); int convertDisplayWidth(LONG x, uint32_t *pcX); int convertDisplayHeight(LONG y, uint32_t *pcY); void sendMouseCapsCallback(void); #ifdef VBOXBFE_WITHOUT_COM Console *mParent; #else const ComObjPtr mParent; #endif /** Pointer to the associated mouse driver. */ struct DRVMAINMOUSE *mpDrv; LONG uHostCaps; LONG uDevCaps; bool fVMMDevCanAbs; bool fVMMDevNeedsHostCursor; uint32_t mLastAbsX; uint32_t mLastAbsY; uint32_t mLastButtons; }; #ifdef VBOXBFE_WITHOUT_COM extern Mouse *gMouse; #endif #endif // !____H_MOUSEIMPL /* vi: set tabstop=4 shiftwidth=4 expandtab: */