VirtualBox

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

Last change on this file since 26992 was 26982, checked in by vboxsync, 15 years ago

FE/BFE: VBoxBFE now uses MouseImpl from Main

  • 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 26982 2010-03-03 10:28:21Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_MOUSEIMPL
23#define ____H_MOUSEIMPL
24
25#include "VirtualBoxBase.h"
26#include "ConsoleEvents.h"
27#include "ConsoleImpl.h"
28#include <VBox/pdmdrv.h>
29
30/** Simple mouse event class. */
31class MouseEvent
32{
33public:
34 MouseEvent() : dx(0), dy(0), dz(0), dw(0), state(-1) {}
35 MouseEvent(int32_t _dx, int32_t _dy, int32_t _dz, int32_t _dw, int32_t _state) :
36 dx(_dx), dy(_dy), dz(_dz), dw(_dw), state(_state) {}
37 bool isValid()
38 {
39 return state != -1;
40 }
41 /* Note: dw is the horizontal scroll wheel */
42 int32_t dx, dy, dz, dw;
43 int32_t state;
44};
45// template instantiation
46typedef ConsoleEventBuffer<MouseEvent> MouseEventBuffer;
47
48enum
49{
50 MOUSE_DEVCAP_RELATIVE = 1,
51 MOUSE_DEVCAP_ABSOLUTE = 2
52};
53
54class ATL_NO_VTABLE Mouse :
55 public VirtualBoxBase
56#ifndef VBOXBFE_WITHOUT_COM
57 ,
58 public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
59 public VirtualBoxSupportTranslation<Mouse>,
60 VBOX_SCRIPTABLE_IMPL(IMouse)
61#endif
62{
63public:
64
65 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
66
67 DECLARE_NOT_AGGREGATABLE(Mouse)
68
69 DECLARE_PROTECT_FINAL_CONSTRUCT()
70
71 BEGIN_COM_MAP(Mouse)
72 COM_INTERFACE_ENTRY (ISupportErrorInfo)
73 COM_INTERFACE_ENTRY (IMouse)
74 COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
75 END_COM_MAP()
76
77 DECLARE_EMPTY_CTOR_DTOR (Mouse)
78
79 HRESULT FinalConstruct();
80 void FinalRelease();
81
82 // public initializer/uninitializer for internal purposes only
83 HRESULT init(Console *parent);
84 void uninit();
85
86 // IMouse properties
87 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
88 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
89 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
90
91 // IMouse methods
92 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
93 LONG buttonState);
94 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
95 LONG buttonState);
96
97 // for VirtualBoxSupportErrorInfoImpl
98 static const wchar_t *getComponentName() { return L"Mouse"; }
99
100 static const PDMDRVREG DrvReg;
101
102 Console *getParent() const
103 {
104 return mParent;
105 }
106
107 // for VMMDevInterface
108 void onVMMDevCanAbsChange(bool canAbs)
109 {
110 fVMMDevCanAbs = canAbs;
111 sendMouseCapsCallback();
112 }
113
114 void onVMMDevNeedsHostChange(bool needsHost)
115 {
116 fVMMDevNeedsHostCursor = needsHost;
117 sendMouseCapsCallback();
118 }
119
120private:
121
122 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
123 static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs);
124 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
125 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
126
127 int getVMMDevMouseCaps(uint32_t *pfCaps);
128 int setVMMDevMouseCaps(uint32_t fCaps);
129 int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
130 int32_t dw, uint32_t fButtons);
131 int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
132 int32_t dz, int32_t dw, uint32_t fButtons);
133 int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
134 int convertDisplayWidth(LONG x, uint32_t *pcX);
135 int convertDisplayHeight(LONG y, uint32_t *pcY);
136
137 void sendMouseCapsCallback(void);
138
139#ifdef VBOXBFE_WITHOUT_COM
140 Console *mParent;
141#else
142 const ComObjPtr<Console, ComWeakRef> mParent;
143#endif
144 /** Pointer to the associated mouse driver. */
145 struct DRVMAINMOUSE *mpDrv;
146
147 LONG uHostCaps;
148 LONG uDevCaps;
149 bool fVMMDevCanAbs;
150 bool fVMMDevNeedsHostCursor;
151 uint32_t mLastAbsX;
152 uint32_t mLastAbsY;
153 uint32_t mLastButtons;
154};
155
156#ifdef VBOXBFE_WITHOUT_COM
157/** @todo make this a member of Console */
158extern Mouse *gMouse;
159
160/** @todo can we get these from the API somehow? */
161enum
162{
163 MouseButtonState_LeftButton = 1,
164 MouseButtonState_RightButton = 2,
165 MouseButtonState_MiddleButton = 4,
166 MouseButtonState_XButton1 = 8,
167 MouseButtonState_XButton2 = 16,
168};
169#endif
170
171#endif // !____H_MOUSEIMPL
172/* 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