Changeset 26834 in vbox for trunk/src/VBox/Frontends/VBoxBFE/MouseImpl.h
- Timestamp:
- Feb 26, 2010 12:10:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBFE/MouseImpl.h
r26173 r26834 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox frontends: Basic Frontend (BFE): 4 * Declaration of Mouse class 3 * VirtualBox VBoxBFE/COM class implementation 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 23 #define ____H_MOUSEIMPL 25 24 26 #include <VBox/pdm.h> 25 #include "VirtualBoxBase.h" 26 #ifndef VBOXBFE_WITHOUT_COM 27 # include "ConsoleEvents.h" 28 #endif 29 #include "ConsoleImpl.h" 30 #include <VBox/pdmdrv.h> 27 31 28 32 /** Simple mouse event class. */ … … 30 34 { 31 35 public: 32 MouseEvent() : dx(0), dy(0), dz(0), state(-1) {}33 MouseEvent(int _dx, int _dy, int _dz, int _state) :34 dx(_dx), dy(_dy), dz(_dz), state(_state) {}36 MouseEvent() : dx(0), dy(0), dz(0), dw(0), state(-1) {} 37 MouseEvent(int32_t _dx, int32_t _dy, int32_t _dz, int32_t _dw, int32_t _state) : 38 dx(_dx), dy(_dy), dz(_dz), dw(_dw), state(_state) {} 35 39 bool isValid() 36 40 { 37 41 return state != -1; 38 42 } 39 // not logical to be int but that's how it's defined in QEMU 40 /** @todo r=bird: and what is the logical declaration then? We'll be using int32_t btw. */ 41 int dx, dy, dz; 42 int state; 43 /* Note: dw is the horizontal scroll wheel */ 44 int32_t dx, dy, dz, dw; 45 int32_t state; 46 }; 47 #ifndef VBOXBFE_WITHOUT_COM 48 // template instantiation 49 typedef ConsoleEventBuffer<MouseEvent> MouseEventBuffer; 50 #endif 51 52 enum 53 { 54 MOUSE_DEVCAP_RELATIVE = 1, 55 MOUSE_DEVCAP_ABSOLUTE = 2 43 56 }; 44 57 45 class Mouse 58 class ATL_NO_VTABLE Mouse : 59 public VirtualBoxBase 60 #ifndef VBOXBFE_WITHOUT_COM 61 , 62 public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>, 63 public VirtualBoxSupportTranslation<Mouse>, 64 VBOX_SCRIPTABLE_IMPL(IMouse) 65 #endif 46 66 { 47 67 public: 48 68 49 Mouse() : fAbsolute(false), fNeedsHostCursor(false), mpDrv(NULL), uHostCaps(0) {} 69 #ifndef VBOXBFE_WITHOUT_COM 70 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse) 71 72 DECLARE_NOT_AGGREGATABLE(Mouse) 73 74 DECLARE_PROTECT_FINAL_CONSTRUCT() 75 76 BEGIN_COM_MAP(Mouse) 77 COM_INTERFACE_ENTRY (ISupportErrorInfo) 78 COM_INTERFACE_ENTRY (IMouse) 79 COM_INTERFACE_ENTRY2 (IDispatch, IMouse) 80 END_COM_MAP() 81 #endif 82 83 DECLARE_EMPTY_CTOR_DTOR (Mouse) 84 85 HRESULT FinalConstruct(); 86 void FinalRelease(); 87 88 // public initializer/uninitializer for internal purposes only 89 HRESULT init(Console *parent); 90 void uninit(); 91 92 // IMouse properties 93 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported); 94 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported); 95 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor); 50 96 51 97 // IMouse methods 52 int PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG buttonState); 53 int PutMouseEventAbsolute(LONG x, LONG y, LONG dz, LONG buttonState); 98 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw, 99 LONG buttonState); 100 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw, 101 LONG buttonState); 54 102 55 int setAbsoluteCoordinates(bool fAbsolute); 56 int setNeedsHostCursor(bool fNeedsHostCursor); 57 #ifdef RT_OS_L4 58 // So far L4Con does not support an own mouse pointer. 59 bool getAbsoluteCoordinates() { return false; } 60 #else 61 bool getAbsoluteCoordinates() { return fAbsolute; } 62 #endif 63 bool getNeedsHostCursor() { return fNeedsHostCursor; } 64 int setHostCursor(bool enable); 103 // for VirtualBoxSupportErrorInfoImpl 104 static const wchar_t *getComponentName() { return L"Mouse"; } 65 105 66 106 static const PDMDRVREG DrvReg; 107 108 #ifndef VBOXBFE_WITHOUT_COM 109 Console *getParent() const 110 { 111 return mParent; 112 } 113 #endif 114 115 // for VMMDevInterface 116 void onVMMDevCanAbsChange(bool canAbs) 117 { 118 fVMMDevCanAbs = canAbs; 119 sendMouseCapsCallback(); 120 } 121 122 void onVMMDevNeedsHostChange(bool needsHost) 123 { 124 fVMMDevNeedsHostCursor = needsHost; 125 sendMouseCapsCallback(); 126 } 67 127 68 128 private: 69 129 70 130 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID); 131 static DECLCALLBACK(void) mouseAbsModeChange (PPDMIMOUSECONNECTOR pInterface, bool fAbs); 71 132 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags); 72 133 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns); 134 135 int getVMMDevMouseCaps(uint32_t *pfCaps); 136 int setVMMDevMouseCaps(uint32_t fCaps); 137 int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz, 138 int32_t dw, uint32_t fButtons); 139 int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs, 140 int32_t dz, int32_t dw, uint32_t fButtons); 141 int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs); 142 int convertDisplayWidth(LONG x, uint32_t *pcX); 143 int convertDisplayHeight(LONG y, uint32_t *pcY); 144 145 void sendMouseCapsCallback(void); 73 146 74 /** Guest supports absolute coordinates */ 75 bool fAbsolute; 76 /** Guest is not able to draw a cursor itself */ 77 bool fNeedsHostCursor; 147 #ifdef VBOXBFE_WITHOUT_COM 148 Console *mParent; 149 #else 150 const ComObjPtr<Console, ComWeakRef> mParent; 151 #endif 78 152 /** Pointer to the associated mouse driver. */ 79 153 struct DRVMAINMOUSE *mpDrv; 80 /** Host capabilities */ 154 81 155 LONG uHostCaps; 156 LONG uDevCaps; 157 bool fVMMDevCanAbs; 158 bool fVMMDevNeedsHostCursor; 159 uint32_t mLastAbsX; 160 uint32_t mLastAbsY; 161 uint32_t mLastButtons; 82 162 }; 83 163 164 #ifdef VBOXBFE_WITHOUT_COM 84 165 extern Mouse *gMouse; 166 #endif 85 167 86 168 #endif // !____H_MOUSEIMPL 169 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.