VirtualBox

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

Last change on this file since 47470 was 47245, checked in by vboxsync, 11 years ago

Main/Mouse: updated multi-touch protocol for in-contact informatin.

  • 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 47245 2013-07-19 08:01:57Z 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 */
28enum { MOUSE_MAX_DEVICES = 10 };
29/** Mouse driver instance data. */
30typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
31
32class ATL_NO_VTABLE Mouse :
33 public VirtualBoxBase
34 , VBOX_SCRIPTABLE_IMPL(IMouse)
35{
36public:
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(ConsoleMouseInterface *parent);
55 void uninit();
56
57 // IMouse properties
58 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
59 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
60 STDMETHOD(COMGETTER(MultiTouchSupported)) (BOOL *multiTouchSupported);
61 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
62
63 // IMouse methods
64 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
65 LONG buttonState);
66 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
67 LONG buttonState);
68 STDMETHOD(PutMouseEventMultiTouch)(LONG x, LONG y, LONG contactID,
69 LONG contactState);
70 STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
71
72 static const PDMDRVREG DrvReg;
73
74 ConsoleMouseInterface *getParent() const
75 {
76 return mParent;
77 }
78
79 /** notify the front-end of guest capability changes */
80 void onVMMDevGuestCapsChange(uint32_t fCaps)
81 {
82 mfVMMDevGuestCaps = fCaps;
83 sendMouseCapsNotifications();
84 }
85
86private:
87
88 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
89 static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool fMT);
90 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
91 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
92
93 HRESULT updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
94 HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
95 int32_t dw, uint32_t fButtons);
96 HRESULT reportAbsEventToMouseDev(int32_t x, int32_t y, int32_t dz,
97 int32_t dw, uint32_t fButtons);
98 HRESULT reportMTEventToMouseDev(int32_t x, int32_t z, uint32_t cContact,
99 uint32_t fContact);
100 HRESULT reportAbsEventToVMMDev(int32_t x, int32_t y);
101 HRESULT reportAbsEvent(int32_t x, int32_t y, int32_t dz, int32_t dw,
102 uint32_t fButtons, bool fUsesVMMDevEvent);
103 HRESULT convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj,
104 bool *pfValid);
105
106 void getDeviceCaps(bool *pfAbs, bool *pfRel, bool *fMT);
107 void sendMouseCapsNotifications(void);
108 bool guestNeedsHostCursor(void);
109 bool vmmdevCanAbs(void);
110 bool deviceCanAbs(void);
111 bool supportsAbs(void);
112 bool supportsRel(void);
113 bool supportsMT(void);
114
115 ConsoleMouseInterface * const mParent;
116 /** Pointer to the associated mouse driver. */
117 struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
118
119 uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
120 int32_t mcLastX;
121 int32_t mcLastY;
122 uint32_t mfLastButtons;
123
124 const ComObjPtr<EventSource> mEventSource;
125 VBoxEventDesc mMouseEvent;
126
127 void fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw,
128 LONG cContact, LONG fButtons);
129};
130
131#endif // !____H_MOUSEIMPL
132/* 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