1 | /* $Id: MouseImpl.h 46937 2013-07-03 13:42:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2011 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 | #include "EventImpl.h"
|
---|
25 | #include <VBox/vmm/pdmdrv.h>
|
---|
26 |
|
---|
27 | /** Maximum number of devices supported */
|
---|
28 | enum { MOUSE_MAX_DEVICES = 3 };
|
---|
29 | /** Mouse driver instance data. */
|
---|
30 | typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
|
---|
31 |
|
---|
32 | class ATL_NO_VTABLE Mouse :
|
---|
33 | public VirtualBoxBase
|
---|
34 | , VBOX_SCRIPTABLE_IMPL(IMouse)
|
---|
35 | {
|
---|
36 | public:
|
---|
37 |
|
---|
38 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Mouse, IMouse)
|
---|
39 |
|
---|
40 | DECLARE_NOT_AGGREGATABLE(Mouse)
|
---|
41 |
|
---|
42 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
43 |
|
---|
44 | BEGIN_COM_MAP(Mouse)
|
---|
45 | VBOX_DEFAULT_INTERFACE_ENTRIES(IMouse)
|
---|
46 | END_COM_MAP()
|
---|
47 |
|
---|
48 | DECLARE_EMPTY_CTOR_DTOR (Mouse)
|
---|
49 |
|
---|
50 | HRESULT FinalConstruct();
|
---|
51 | void FinalRelease();
|
---|
52 |
|
---|
53 | // public initializer/uninitializer for internal purposes only
|
---|
54 | HRESULT init(Console *parent);
|
---|
55 | void uninit();
|
---|
56 |
|
---|
57 | // IMouse properties
|
---|
58 | STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
|
---|
59 | STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
|
---|
60 | STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
|
---|
61 |
|
---|
62 | // IMouse methods
|
---|
63 | STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
|
---|
64 | LONG buttonState);
|
---|
65 | STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
|
---|
66 | LONG buttonState);
|
---|
67 | STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
|
---|
68 |
|
---|
69 | static const PDMDRVREG DrvReg;
|
---|
70 |
|
---|
71 | Console *getParent() const
|
---|
72 | {
|
---|
73 | return mParent;
|
---|
74 | }
|
---|
75 |
|
---|
76 | /** notify the front-end of guest capability changes */
|
---|
77 | void onVMMDevGuestCapsChange(uint32_t fCaps)
|
---|
78 | {
|
---|
79 | mfVMMDevGuestCaps = fCaps;
|
---|
80 | sendMouseCapsNotifications();
|
---|
81 | }
|
---|
82 |
|
---|
83 | private:
|
---|
84 |
|
---|
85 | static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
86 | static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool);
|
---|
87 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
88 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
89 |
|
---|
90 | HRESULT updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
|
---|
91 | HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
|
---|
92 | int32_t dw, uint32_t fButtons);
|
---|
93 | HRESULT reportAbsEventToMouseDev(int32_t mouseXAbs, int32_t mouseYAbs,
|
---|
94 | int32_t dz, int32_t dw, uint32_t fButtons);
|
---|
95 | HRESULT reportAbsEventToVMMDev(int32_t mouseXAbs, int32_t mouseYAbs);
|
---|
96 | HRESULT reportAbsEvent(int32_t mouseXAbs, int32_t mouseYAbs,
|
---|
97 | int32_t dz, int32_t dw, uint32_t fButtons,
|
---|
98 | bool fUsesVMMDevEvent);
|
---|
99 | HRESULT convertDisplayRes(LONG x, LONG y, int32_t *pcX, int32_t *pcY,
|
---|
100 | bool *pfValid);
|
---|
101 |
|
---|
102 | void getDeviceCaps(bool *pfAbs, bool *pfRel);
|
---|
103 | void sendMouseCapsNotifications(void);
|
---|
104 | bool guestNeedsHostCursor(void);
|
---|
105 | bool vmmdevCanAbs(void);
|
---|
106 | bool deviceCanAbs(void);
|
---|
107 | bool supportsAbs(void);
|
---|
108 | bool supportsRel(void);
|
---|
109 |
|
---|
110 | Console * const mParent;
|
---|
111 | /** Pointer to the associated mouse driver. */
|
---|
112 | struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
|
---|
113 |
|
---|
114 | uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
|
---|
115 | int32_t mcLastAbsX;
|
---|
116 | int32_t mcLastAbsY;
|
---|
117 | uint32_t mfLastButtons;
|
---|
118 |
|
---|
119 | const ComObjPtr<EventSource> mEventSource;
|
---|
120 | VBoxEventDesc mMouseEvent;
|
---|
121 |
|
---|
122 | void fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw, LONG Buttons);
|
---|
123 | };
|
---|
124 |
|
---|
125 | #endif // !____H_MOUSEIMPL
|
---|
126 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|