VirtualBox

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

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

Main/Mouse: actually comment things

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