VirtualBox

source: vbox/trunk/src/VBox/Main/include/MouseImpl.h@ 35638

Last change on this file since 35638 was 35638, checked in by vboxsync, 14 years ago

Main. QT/FE: fix long standing COM issue

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: MouseImpl.h 35638 2011-01-19 19:10:49Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2008 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_MOUSEIMPL
19#define ____H_MOUSEIMPL
20
21#include "VirtualBoxBase.h"
22#include "ConsoleEvents.h"
23#include "ConsoleImpl.h"
24#ifndef VBOXBFE_WITHOUT_COM
25#include "EventImpl.h"
26#endif
27#include <VBox/vmm/pdmdrv.h>
28
29/** Maximum number of devices supported */
30enum { MOUSE_MAX_DEVICES = 3 };
31/** Mouse driver instance data. */
32typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
33
34class ATL_NO_VTABLE Mouse :
35 public VirtualBoxBase
36#ifndef VBOXBFE_WITHOUT_COM
37 , VBOX_SCRIPTABLE_IMPL(IMouse)
38#endif
39{
40public:
41
42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Mouse, IMouse)
43
44 DECLARE_NOT_AGGREGATABLE(Mouse)
45
46 DECLARE_PROTECT_FINAL_CONSTRUCT()
47
48 BEGIN_COM_MAP(Mouse)
49 VBOX_DEFAULT_INTERFACE_ENTRIES(IMouse)
50 END_COM_MAP()
51
52 DECLARE_EMPTY_CTOR_DTOR (Mouse)
53
54 HRESULT FinalConstruct();
55 void FinalRelease();
56
57 // public initializer/uninitializer for internal purposes only
58 HRESULT init(Console *parent);
59 void uninit();
60
61 // IMouse properties
62 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
63 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
64 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
65
66 // IMouse methods
67 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
68 LONG buttonState);
69 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
70 LONG buttonState);
71#ifndef VBOXBFE_WITHOUT_COM
72 STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
73#endif
74
75 static const PDMDRVREG DrvReg;
76
77 Console *getParent() const
78 {
79 return mParent;
80 }
81
82 /** notify the front-end of guest capability changes */
83 void onVMMDevGuestCapsChange(uint32_t fCaps)
84 {
85 mfVMMDevGuestCaps = fCaps;
86 sendMouseCapsNotifications();
87 }
88
89private:
90
91 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
92 static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs);
93 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
94 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
95
96 HRESULT updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
97 HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
98 int32_t dw, uint32_t fButtons);
99 HRESULT reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
100 int32_t dz, int32_t dw, uint32_t fButtons);
101 HRESULT reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
102 HRESULT reportAbsEvent(uint32_t mouseXAbs, uint32_t mouseYAbs,
103 int32_t dz, int32_t dw, uint32_t fButtons,
104 bool fUsesVMMDevEvent);
105 HRESULT convertDisplayRes(LONG x, LONG y, int32_t *pcX, int32_t *pcY,
106 bool *pfValid);
107
108 void getDeviceCaps(bool *pfAbs, bool *pfRel);
109 void sendMouseCapsNotifications(void);
110 bool guestNeedsHostCursor(void);
111 bool vmmdevCanAbs(void);
112 bool deviceCanAbs(void);
113 bool supportsAbs(void);
114 bool supportsRel(void);
115
116#ifdef VBOXBFE_WITHOUT_COM
117 Console *mParent;
118#else
119 Console * const mParent;
120#endif
121 /** Pointer to the associated mouse driver. */
122 struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
123
124 uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
125 uint32_t mcLastAbsX;
126 uint32_t mcLastAbsY;
127 uint32_t mfLastButtons;
128
129#ifndef VBOXBFE_WITHOUT_COM
130 const ComObjPtr<EventSource> mEventSource;
131 VBoxEventDesc mMouseEvent;
132#endif
133};
134
135#ifdef VBOXBFE_WITHOUT_COM
136/** @todo make this a member of Console */
137extern Mouse *gMouse;
138
139/** @todo can we get these from the API somehow? */
140enum
141{
142 MouseButtonState_LeftButton = 1,
143 MouseButtonState_RightButton = 2,
144 MouseButtonState_MiddleButton = 4,
145 MouseButtonState_XButton1 = 8,
146 MouseButtonState_XButton2 = 16,
147};
148#endif
149
150#endif // !____H_MOUSEIMPL
151/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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