VirtualBox

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

Last change on this file since 47174 was 47174, checked in by vboxsync, 12 years ago

Devices/Input: most of the Main plumbing for guest multi-touch.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: MouseImpl.h 47174 2013-07-16 03:27:24Z 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.215389.xyz. 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 = 3 };
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(Console *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(COMGETTER(EventSource)) (IEventSource ** aEventSource);
69
70 static const PDMDRVREG DrvReg;
71
72 Console *getParent() const
73 {
74 return mParent;
75 }
76
77 /** notify the front-end of guest capability changes */
78 void onVMMDevGuestCapsChange(uint32_t fCaps)
79 {
80 mfVMMDevGuestCaps = fCaps;
81 sendMouseCapsNotifications();
82 }
83
84private:
85
86 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
87 static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool fMT);
88 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
89 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
90
91 HRESULT updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
92 HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
93 int32_t dw, uint32_t fButtons);
94 HRESULT reportAbsEventToMouseDev(int32_t mouseXAbs, int32_t mouseYAbs,
95 int32_t dz, int32_t dw, uint32_t fButtons);
96 HRESULT reportMTEventToMouseDev(int32_t mouseX, int32_t mouseY,
97 uint32_t cContact, bool fContact);
98 HRESULT reportAbsEventToVMMDev(int32_t mouseXAbs, int32_t mouseYAbs);
99 HRESULT reportAbsEvent(int32_t mouseXAbs, int32_t mouseYAbs,
100 int32_t dz, int32_t dw, uint32_t fButtons,
101 bool fUsesVMMDevEvent);
102 HRESULT convertDisplayRes(LONG x, LONG y, int32_t *pcX, int32_t *pcY,
103 bool *pfValid);
104
105 void getDeviceCaps(bool *pfAbs, bool *pfRel, bool *fMT);
106 void sendMouseCapsNotifications(void);
107 bool guestNeedsHostCursor(void);
108 bool vmmdevCanAbs(void);
109 bool deviceCanAbs(void);
110 bool supportsAbs(void);
111 bool supportsRel(void);
112 bool supportsMT(void);
113
114 Console * const mParent;
115 /** Pointer to the associated mouse driver. */
116 struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
117
118 uint32_t mfVMMDevGuestCaps; /** We cache this to avoid access races */
119 int32_t mcLastAbsX;
120 int32_t mcLastAbsY;
121 uint32_t mfLastButtons;
122
123 const ComObjPtr<EventSource> mEventSource;
124 VBoxEventDesc mMouseEvent;
125
126 void fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw, LONG Buttons);
127};
128
129#endif // !____H_MOUSEIMPL
130/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette