VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: MouseImpl.h 28800 2010-04-27 08:22:32Z 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 ,
53 public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
54 public VirtualBoxSupportTranslation<Mouse>,
55 VBOX_SCRIPTABLE_IMPL(IMouse)
56#endif
57{
58public:
59
60 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
61
62 DECLARE_NOT_AGGREGATABLE(Mouse)
63
64 DECLARE_PROTECT_FINAL_CONSTRUCT()
65
66 BEGIN_COM_MAP(Mouse)
67 COM_INTERFACE_ENTRY (ISupportErrorInfo)
68 COM_INTERFACE_ENTRY (IMouse)
69 COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
70 END_COM_MAP()
71
72 DECLARE_EMPTY_CTOR_DTOR (Mouse)
73
74 HRESULT FinalConstruct();
75 void FinalRelease();
76
77 // public initializer/uninitializer for internal purposes only
78 HRESULT init(Console *parent);
79 void uninit();
80
81 // IMouse properties
82 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
83 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
84 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
85
86 // IMouse methods
87 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
88 LONG buttonState);
89 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
90 LONG buttonState);
91
92 // for VirtualBoxSupportErrorInfoImpl
93 static const wchar_t *getComponentName() { return L"Mouse"; }
94
95 static const PDMDRVREG DrvReg;
96
97 Console *getParent() const
98 {
99 return mParent;
100 }
101
102 // for VMMDevInterface
103 void onVMMDevCanAbsChange(bool)
104 {
105 sendMouseCapsNotifications();
106 }
107
108 void onVMMDevNeedsHostChange(bool needsHost)
109 {
110 fVMMDevNeedsHostCursor = needsHost;
111 sendMouseCapsNotifications();
112 }
113
114private:
115
116 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
117 static DECLCALLBACK(void) mouseReportModes (PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs);
118 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
119 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
120
121 HRESULT getVMMDevMouseCaps(uint32_t *pfCaps);
122 HRESULT setVMMDevMouseCaps(uint32_t fCaps);
123 HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
124 int32_t dw, uint32_t fButtons);
125 HRESULT reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
126 int32_t dz, int32_t dw, uint32_t fButtons);
127 HRESULT reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
128 HRESULT convertDisplayWidth(LONG x, uint32_t *pcX);
129 HRESULT convertDisplayHeight(LONG y, uint32_t *pcY);
130
131 void sendMouseCapsNotifications(void);
132
133#ifdef VBOXBFE_WITHOUT_COM
134 Console *mParent;
135#else
136 Console * const mParent;
137#endif
138 /** Pointer to the associated mouse driver. */
139 struct DRVMAINMOUSE *mpDrv[MOUSE_MAX_DEVICES];
140
141 LONG uHostCaps;
142 bool fVMMDevCanAbs;
143 bool fVMMDevNeedsHostCursor;
144 uint32_t mLastAbsX;
145 uint32_t mLastAbsY;
146 uint32_t mLastButtons;
147};
148
149#ifdef VBOXBFE_WITHOUT_COM
150/** @todo make this a member of Console */
151extern Mouse *gMouse;
152
153/** @todo can we get these from the API somehow? */
154enum
155{
156 MouseButtonState_LeftButton = 1,
157 MouseButtonState_RightButton = 2,
158 MouseButtonState_MiddleButton = 4,
159 MouseButtonState_XButton1 = 8,
160 MouseButtonState_XButton2 = 16,
161};
162#endif
163
164#endif // !____H_MOUSEIMPL
165/* 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