1 | /* $Id: MouseImpl.h 76487 2018-12-27 03:31:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 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 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "MouseWrap.h"
|
---|
25 | #include "ConsoleImpl.h"
|
---|
26 | #include "EventImpl.h"
|
---|
27 | #include <VBox/vmm/pdmdrv.h>
|
---|
28 |
|
---|
29 | /** Maximum number of devices supported */
|
---|
30 | enum { MOUSE_MAX_DEVICES = 3 };
|
---|
31 | /** Mouse driver instance data. */
|
---|
32 | typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
|
---|
33 |
|
---|
34 | class ATL_NO_VTABLE Mouse :
|
---|
35 | public MouseWrap
|
---|
36 | {
|
---|
37 | public:
|
---|
38 |
|
---|
39 | DECLARE_EMPTY_CTOR_DTOR (Mouse)
|
---|
40 |
|
---|
41 | HRESULT FinalConstruct();
|
---|
42 | void FinalRelease();
|
---|
43 |
|
---|
44 | // public initializer/uninitializer for internal purposes only
|
---|
45 | HRESULT init(ConsoleMouseInterface *parent);
|
---|
46 | void uninit();
|
---|
47 |
|
---|
48 | static const PDMDRVREG DrvReg;
|
---|
49 |
|
---|
50 | ConsoleMouseInterface *i_getParent() const
|
---|
51 | {
|
---|
52 | return mParent;
|
---|
53 | }
|
---|
54 |
|
---|
55 | /** notify the front-end of guest capability changes */
|
---|
56 | void i_onVMMDevGuestCapsChange(uint32_t fCaps)
|
---|
57 | {
|
---|
58 | mfVMMDevGuestCaps = fCaps;
|
---|
59 | i_sendMouseCapsNotifications();
|
---|
60 | }
|
---|
61 |
|
---|
62 | void updateMousePointerShape(bool fVisible, bool fAlpha,
|
---|
63 | uint32_t hotX, uint32_t hotY,
|
---|
64 | uint32_t width, uint32_t height,
|
---|
65 | const uint8_t *pu8Shape, uint32_t cbShape);
|
---|
66 | private:
|
---|
67 |
|
---|
68 | // Wrapped IMouse properties
|
---|
69 | HRESULT getAbsoluteSupported(BOOL *aAbsoluteSupported);
|
---|
70 | HRESULT getRelativeSupported(BOOL *aRelativeSupported);
|
---|
71 | HRESULT getMultiTouchSupported(BOOL *aMultiTouchSupported);
|
---|
72 | HRESULT getNeedsHostCursor(BOOL *aNeedsHostCursor);
|
---|
73 | HRESULT getPointerShape(ComPtr<IMousePointerShape> &aPointerShape);
|
---|
74 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
75 |
|
---|
76 | // Wrapped IMouse methods
|
---|
77 | HRESULT putMouseEvent(LONG aDx,
|
---|
78 | LONG aDy,
|
---|
79 | LONG aDz,
|
---|
80 | LONG aDw,
|
---|
81 | LONG aButtonState);
|
---|
82 | HRESULT putMouseEventAbsolute(LONG aX,
|
---|
83 | LONG aY,
|
---|
84 | LONG aDz,
|
---|
85 | LONG aDw,
|
---|
86 | LONG aButtonState);
|
---|
87 | HRESULT putEventMultiTouch(LONG aCount,
|
---|
88 | const std::vector<LONG64> &aContacts,
|
---|
89 | ULONG aScanTime);
|
---|
90 | HRESULT putEventMultiTouchString(LONG aCount,
|
---|
91 | const com::Utf8Str &aContacts,
|
---|
92 | ULONG aScanTime);
|
---|
93 |
|
---|
94 |
|
---|
95 | static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
96 | static DECLCALLBACK(void) i_mouseReportModes(PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool fMT);
|
---|
97 | static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
98 | static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
|
---|
99 |
|
---|
100 | HRESULT i_updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
|
---|
101 | HRESULT i_reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
|
---|
102 | int32_t dw, uint32_t fButtons);
|
---|
103 | HRESULT i_reportAbsEventToMouseDev(int32_t x, int32_t y, int32_t dz,
|
---|
104 | int32_t dw, uint32_t fButtons);
|
---|
105 | HRESULT i_reportMTEventToMouseDev(int32_t x, int32_t z, uint32_t cContact,
|
---|
106 | uint32_t fContact);
|
---|
107 | HRESULT i_reportMultiTouchEventToDevice(uint8_t cContacts, const uint64_t *pau64Contacts, uint32_t u32ScanTime);
|
---|
108 | HRESULT i_reportAbsEventToVMMDev(int32_t x, int32_t y);
|
---|
109 | HRESULT i_reportAbsEventToInputDevices(int32_t x, int32_t y, int32_t dz, int32_t dw, uint32_t fButtons,
|
---|
110 | bool fUsesVMMDevEvent);
|
---|
111 | HRESULT i_reportAbsEventToDisplayDevice(int32_t x, int32_t y);
|
---|
112 | HRESULT i_convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj,
|
---|
113 | bool *pfValid);
|
---|
114 | HRESULT i_putEventMultiTouch(LONG aCount, const LONG64 *paContacts, ULONG aScanTime);
|
---|
115 |
|
---|
116 | void i_getDeviceCaps(bool *pfAbs, bool *pfRel, bool *fMT);
|
---|
117 | void i_sendMouseCapsNotifications(void);
|
---|
118 | bool i_guestNeedsHostCursor(void);
|
---|
119 | bool i_vmmdevCanAbs(void);
|
---|
120 | bool i_deviceCanAbs(void);
|
---|
121 | bool i_supportsAbs(void);
|
---|
122 | bool i_supportsRel(void);
|
---|
123 | bool i_supportsMT(void);
|
---|
124 |
|
---|
125 | ConsoleMouseInterface * const mParent;
|
---|
126 | /** Pointer to the associated mouse driver. */
|
---|
127 | struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
|
---|
128 |
|
---|
129 | uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
|
---|
130 | int32_t mcLastX;
|
---|
131 | int32_t mcLastY;
|
---|
132 | uint32_t mfLastButtons;
|
---|
133 |
|
---|
134 | ComPtr<IMousePointerShape> mPointerShape;
|
---|
135 | struct
|
---|
136 | {
|
---|
137 | bool fVisible;
|
---|
138 | bool fAlpha;
|
---|
139 | uint32_t hotX;
|
---|
140 | uint32_t hotY;
|
---|
141 | uint32_t width;
|
---|
142 | uint32_t height;
|
---|
143 | uint8_t *pu8Shape;
|
---|
144 | uint32_t cbShape;
|
---|
145 | } mPointerData;
|
---|
146 |
|
---|
147 | const ComObjPtr<EventSource> mEventSource;
|
---|
148 | VBoxEventDesc mMouseEvent;
|
---|
149 |
|
---|
150 | void i_fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw,
|
---|
151 | LONG fButtons);
|
---|
152 |
|
---|
153 | void i_fireMultiTouchEvent(uint8_t cContacts,
|
---|
154 | const LONG64 *paContacts,
|
---|
155 | uint32_t u32ScanTime);
|
---|
156 | };
|
---|
157 |
|
---|
158 | #endif // !____H_MOUSEIMPL
|
---|
159 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|