1 | /* $Id: MouseImpl.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_MouseImpl_h
|
---|
29 | #define MAIN_INCLUDED_MouseImpl_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "MouseWrap.h"
|
---|
35 | #include "ConsoleImpl.h"
|
---|
36 | #include "EventImpl.h"
|
---|
37 | #include <VBox/vmm/pdmdrv.h>
|
---|
38 |
|
---|
39 | /** Maximum number of devices supported */
|
---|
40 | enum { MOUSE_MAX_DEVICES = 4 };
|
---|
41 | /** Mouse driver instance data. */
|
---|
42 | typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
|
---|
43 |
|
---|
44 | class ATL_NO_VTABLE Mouse :
|
---|
45 | public MouseWrap
|
---|
46 | {
|
---|
47 | public:
|
---|
48 |
|
---|
49 | DECLARE_COMMON_CLASS_METHODS (Mouse)
|
---|
50 |
|
---|
51 | HRESULT FinalConstruct();
|
---|
52 | void FinalRelease();
|
---|
53 |
|
---|
54 | // public initializer/uninitializer for internal purposes only
|
---|
55 | HRESULT init(ConsoleMouseInterface *parent);
|
---|
56 | void uninit();
|
---|
57 |
|
---|
58 | static const PDMDRVREG DrvReg;
|
---|
59 |
|
---|
60 | ConsoleMouseInterface *i_getParent() const
|
---|
61 | {
|
---|
62 | return mParent;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /** notify the front-end of guest capability changes */
|
---|
66 | void i_onVMMDevGuestCapsChange(uint32_t fCaps)
|
---|
67 | {
|
---|
68 | mfVMMDevGuestCaps = fCaps;
|
---|
69 | i_sendMouseCapsNotifications();
|
---|
70 | }
|
---|
71 |
|
---|
72 | void updateMousePointerShape(bool fVisible, bool fAlpha,
|
---|
73 | uint32_t hotX, uint32_t hotY,
|
---|
74 | uint32_t width, uint32_t height,
|
---|
75 | const uint8_t *pu8Shape, uint32_t cbShape);
|
---|
76 | private:
|
---|
77 |
|
---|
78 | // Wrapped IMouse properties
|
---|
79 | HRESULT getAbsoluteSupported(BOOL *aAbsoluteSupported);
|
---|
80 | HRESULT getRelativeSupported(BOOL *aRelativeSupported);
|
---|
81 | HRESULT getTouchScreenSupported(BOOL *aTouchScreenSupported);
|
---|
82 | HRESULT getTouchPadSupported(BOOL *aTouchPadSupported);
|
---|
83 | HRESULT getNeedsHostCursor(BOOL *aNeedsHostCursor);
|
---|
84 | HRESULT getPointerShape(ComPtr<IMousePointerShape> &aPointerShape);
|
---|
85 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
86 |
|
---|
87 | // Wrapped IMouse methods
|
---|
88 | HRESULT putMouseEvent(LONG aDx,
|
---|
89 | LONG aDy,
|
---|
90 | LONG aDz,
|
---|
91 | LONG aDw,
|
---|
92 | LONG aButtonState);
|
---|
93 | HRESULT putMouseEventAbsolute(LONG aX,
|
---|
94 | LONG aY,
|
---|
95 | LONG aDz,
|
---|
96 | LONG aDw,
|
---|
97 | LONG aButtonState);
|
---|
98 | HRESULT putEventMultiTouch(LONG aCount,
|
---|
99 | const std::vector<LONG64> &aContacts,
|
---|
100 | BOOL isTouchScreen,
|
---|
101 | ULONG aScanTime);
|
---|
102 | HRESULT putEventMultiTouchString(LONG aCount,
|
---|
103 | const com::Utf8Str &aContacts,
|
---|
104 | BOOL isTouchScreen,
|
---|
105 | ULONG aScanTime);
|
---|
106 |
|
---|
107 |
|
---|
108 | static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
109 | static DECLCALLBACK(void) i_mouseReportModes(PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool fMTAbs, bool fMTRel);
|
---|
110 | static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
111 | static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
|
---|
112 |
|
---|
113 | HRESULT i_updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
|
---|
114 | HRESULT i_reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
|
---|
115 | int32_t dw, uint32_t fButtons);
|
---|
116 | HRESULT i_reportAbsEventToMouseDev(int32_t x, int32_t y, int32_t dz,
|
---|
117 | int32_t dw, uint32_t fButtons);
|
---|
118 | HRESULT i_reportMTEventToMouseDev(int32_t x, int32_t z, uint32_t cContact,
|
---|
119 | uint32_t fContact);
|
---|
120 | HRESULT i_reportMultiTouchEventToDevice(uint8_t cContacts, const uint64_t *pau64Contacts, bool fTouchScreen, uint32_t u32ScanTime);
|
---|
121 | HRESULT i_reportAbsEventToVMMDev(int32_t x, int32_t y);
|
---|
122 | HRESULT i_reportAbsEventToInputDevices(int32_t x, int32_t y, int32_t dz, int32_t dw, uint32_t fButtons,
|
---|
123 | bool fUsesVMMDevEvent);
|
---|
124 | HRESULT i_reportAbsEventToDisplayDevice(int32_t x, int32_t y);
|
---|
125 | HRESULT i_convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj,
|
---|
126 | bool *pfValid);
|
---|
127 | HRESULT i_putEventMultiTouch(LONG aCount, const LONG64 *paContacts, BOOL isTouchScreen, ULONG aScanTime);
|
---|
128 |
|
---|
129 | void i_getDeviceCaps(bool *pfAbs, bool *pfRel, bool *pfTS, bool *pfTP);
|
---|
130 | void i_sendMouseCapsNotifications(void);
|
---|
131 | bool i_guestNeedsHostCursor(void);
|
---|
132 | bool i_vmmdevCanAbs(void);
|
---|
133 | bool i_deviceCanAbs(void);
|
---|
134 | bool i_supportsAbs(void);
|
---|
135 | bool i_supportsRel(void);
|
---|
136 | bool i_supportsTS(void);
|
---|
137 | bool i_supportsTP(void);
|
---|
138 |
|
---|
139 | ConsoleMouseInterface * const mParent;
|
---|
140 | /** Pointer to the associated mouse driver. */
|
---|
141 | struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
|
---|
142 |
|
---|
143 | uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
|
---|
144 | int32_t mcLastX;
|
---|
145 | int32_t mcLastY;
|
---|
146 | uint32_t mfLastButtons;
|
---|
147 |
|
---|
148 | ComPtr<IMousePointerShape> mPointerShape;
|
---|
149 | struct
|
---|
150 | {
|
---|
151 | bool fVisible;
|
---|
152 | bool fAlpha;
|
---|
153 | uint32_t hotX;
|
---|
154 | uint32_t hotY;
|
---|
155 | uint32_t width;
|
---|
156 | uint32_t height;
|
---|
157 | uint8_t *pu8Shape;
|
---|
158 | uint32_t cbShape;
|
---|
159 | } mPointerData;
|
---|
160 |
|
---|
161 | const ComObjPtr<EventSource> mEventSource;
|
---|
162 | VBoxEventDesc mMouseEvent;
|
---|
163 |
|
---|
164 | void i_fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw,
|
---|
165 | LONG fButtons);
|
---|
166 |
|
---|
167 | void i_fireMultiTouchEvent(uint8_t cContacts,
|
---|
168 | const LONG64 *paContacts,
|
---|
169 | bool fTouchScreen,
|
---|
170 | uint32_t u32ScanTime);
|
---|
171 | };
|
---|
172 |
|
---|
173 | #endif /* !MAIN_INCLUDED_MouseImpl_h */
|
---|
174 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|