VirtualBox

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

Last change on this file since 100841 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1/* $Id: MouseImpl.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2023 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 */
40enum { MOUSE_MAX_DEVICES = 4 };
41/** Mouse driver instance data. */
42typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
43
44class ATL_NO_VTABLE Mouse :
45 public MouseWrap
46{
47public:
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);
76private:
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, int32_t dz, int32_t dw, uint32_t fButtons);
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 uint32_t i_getDeviceCaps(void);
130 void i_sendMouseCapsNotifications(void);
131 bool i_guestNeedsHostCursor(void);
132 bool i_vmmdevCanAbs(void);
133 bool i_deviceCanAbs(void);
134 bool i_supportsAbs(uint32_t fCaps) const;
135 bool i_supportsAbs(void);
136 bool i_supportsRel(void);
137 bool i_supportsTS(void);
138 bool i_supportsTP(void);
139
140 ConsoleMouseInterface * const mParent;
141 /** Pointer to the associated mouse driver. */
142 struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
143
144 uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
145 int32_t mcLastX;
146 int32_t mcLastY;
147 uint32_t mfLastButtons;
148
149 ComPtr<IMousePointerShape> mPointerShape;
150 struct
151 {
152 bool fVisible;
153 bool fAlpha;
154 uint32_t hotX;
155 uint32_t hotY;
156 uint32_t width;
157 uint32_t height;
158 uint8_t *pu8Shape;
159 uint32_t cbShape;
160 } mPointerData;
161
162 const ComObjPtr<EventSource> mEventSource;
163 VBoxEventDesc mMouseEvent;
164
165 void i_fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw,
166 LONG fButtons);
167
168 void i_fireMultiTouchEvent(uint8_t cContacts,
169 const LONG64 *paContacts,
170 bool fTouchScreen,
171 uint32_t u32ScanTime);
172};
173
174#endif /* !MAIN_INCLUDED_MouseImpl_h */
175/* 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