VirtualBox

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

Last change on this file since 33061 was 33061, checked in by vboxsync, 14 years ago

Main, vboxshell: implemented support for user activity capturing

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: MouseImpl.h 33061 2010-10-12 12:42:20Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2008 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#ifndef VBOXBFE_WITHOUT_COM
25#include "EventImpl.h"
26#endif
27#include <VBox/pdmdrv.h>
28
29/** Maximum number of devices supported */
30enum { MOUSE_MAX_DEVICES = 3 };
31/** Mouse driver instance data. */
32typedef struct DRVMAINMOUSE DRVMAINMOUSE, *PDRVMAINMOUSE;
33
34class ATL_NO_VTABLE Mouse :
35 public VirtualBoxBase
36#ifndef VBOXBFE_WITHOUT_COM
37 , VBOX_SCRIPTABLE_IMPL(IMouse)
38#endif
39{
40public:
41
42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Mouse, IMouse)
43
44 DECLARE_NOT_AGGREGATABLE(Mouse)
45
46 DECLARE_PROTECT_FINAL_CONSTRUCT()
47
48 BEGIN_COM_MAP(Mouse)
49 COM_INTERFACE_ENTRY (ISupportErrorInfo)
50 COM_INTERFACE_ENTRY (IMouse)
51 COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
52 END_COM_MAP()
53
54 DECLARE_EMPTY_CTOR_DTOR (Mouse)
55
56 HRESULT FinalConstruct();
57 void FinalRelease();
58
59 // public initializer/uninitializer for internal purposes only
60 HRESULT init(Console *parent);
61 void uninit();
62
63 // IMouse properties
64 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
65 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
66 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
67
68 // IMouse methods
69 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
70 LONG buttonState);
71 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
72 LONG buttonState);
73#ifndef VBOXBFE_WITHOUT_COM
74 STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
75#endif
76
77 static const PDMDRVREG DrvReg;
78
79 Console *getParent() const
80 {
81 return mParent;
82 }
83
84 /** notify the front-end that the guest now supports absolute reporting */
85 void onVMMDevCanAbsChange(bool)
86 {
87 sendMouseCapsNotifications();
88 }
89
90 /** notify the front-end as to whether the guest can start drawing its own
91 * cursor on demand */
92 void onVMMDevNeedsHostChange(bool needsHost)
93 {
94 mfVMMDevNeedsHostCursor = needsHost;
95 sendMouseCapsNotifications();
96 }
97
98private:
99
100 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
101 static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs);
102 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
103 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
104
105 HRESULT getVMMDevMouseCaps(uint32_t *pfCaps);
106 HRESULT setVMMDevMouseCaps(uint32_t fCaps);
107 HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
108 int32_t dw, uint32_t fButtons);
109 HRESULT reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
110 int32_t dz, int32_t dw, uint32_t fButtons);
111 HRESULT reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
112 HRESULT reportAbsEvent(uint32_t mouseXAbs, uint32_t mouseYAbs,
113 int32_t dz, int32_t dw, uint32_t fButtons,
114 bool fUsesVMMDevEvent);
115 HRESULT convertDisplayRes(LONG x, LONG y, uint32_t *pcX, uint32_t *pcY);
116
117 void sendMouseCapsNotifications(void);
118
119#ifdef VBOXBFE_WITHOUT_COM
120 Console *mParent;
121#else
122 Console * const mParent;
123#endif
124 /** Pointer to the associated mouse driver. */
125 struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
126
127 LONG mfHostCaps;
128 bool mfVMMDevCanAbs;
129 bool mfVMMDevNeedsHostCursor;
130 uint32_t mLastAbsX;
131 uint32_t mLastAbsY;
132 uint32_t mLastButtons;
133
134#ifndef VBOXBFE_WITHOUT_COM
135 const ComObjPtr<EventSource> mEventSource;
136 VBoxEventDesc mMouseEvent;
137#endif
138};
139
140#ifdef VBOXBFE_WITHOUT_COM
141/** @todo make this a member of Console */
142extern Mouse *gMouse;
143
144/** @todo can we get these from the API somehow? */
145enum
146{
147 MouseButtonState_LeftButton = 1,
148 MouseButtonState_RightButton = 2,
149 MouseButtonState_MiddleButton = 4,
150 MouseButtonState_XButton1 = 8,
151 MouseButtonState_XButton2 = 16,
152};
153#endif
154
155#endif // !____H_MOUSEIMPL
156/* 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