VirtualBox

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

Last change on this file since 26916 was 26782, checked in by vboxsync, 15 years ago

Main, Frontends: added support for virtual pointing devices with no relative reporting and cleaned up the VMMDev/mouse device absolute reporting interaction

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: MouseImpl.h 26782 2010-02-25 11:17:30Z 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 public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
57 public VirtualBoxSupportTranslation<Mouse>,
58 VBOX_SCRIPTABLE_IMPL(IMouse)
59{
60public:
61
62 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
63
64 DECLARE_NOT_AGGREGATABLE(Mouse)
65
66 DECLARE_PROTECT_FINAL_CONSTRUCT()
67
68 BEGIN_COM_MAP(Mouse)
69 COM_INTERFACE_ENTRY (ISupportErrorInfo)
70 COM_INTERFACE_ENTRY (IMouse)
71 COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
72 END_COM_MAP()
73
74 DECLARE_EMPTY_CTOR_DTOR (Mouse)
75
76 HRESULT FinalConstruct();
77 void FinalRelease();
78
79 // public initializer/uninitializer for internal purposes only
80 HRESULT init(Console *parent);
81 void uninit();
82
83 // IMouse properties
84 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
85 STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
86 STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
87
88 // IMouse methods
89 STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
90 LONG buttonState);
91 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
92 LONG buttonState);
93
94 // for VirtualBoxSupportErrorInfoImpl
95 static const wchar_t *getComponentName() { return L"Mouse"; }
96
97 static const PDMDRVREG DrvReg;
98
99 Console *getParent() const
100 {
101 return mParent;
102 }
103
104 // for VMMDevInterface
105 void onVMMDevCanAbsChange(bool canAbs)
106 {
107 fVMMDevCanAbs = canAbs;
108 sendMouseCapsCallback();
109 }
110
111 void onVMMDevNeedsHostChange(bool needsHost)
112 {
113 fVMMDevNeedsHostCursor = needsHost;
114 sendMouseCapsCallback();
115 }
116
117private:
118
119 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
120 static DECLCALLBACK(void) mouseAbsModeChange (PPDMIMOUSECONNECTOR pInterface, bool fAbs);
121 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
122 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
123
124 int getVMMDevMouseCaps(uint32_t *pfCaps);
125 int setVMMDevMouseCaps(uint32_t fCaps);
126 int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
127 int32_t dw, uint32_t fButtons);
128 int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
129 int32_t dz, int32_t dw, uint32_t fButtons);
130 int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
131 int convertDisplayWidth(LONG x, uint32_t *pcX);
132 int convertDisplayHeight(LONG y, uint32_t *pcY);
133
134 void sendMouseCapsCallback(void);
135
136 const ComObjPtr<Console, ComWeakRef> mParent;
137 /** Pointer to the associated mouse driver. */
138 struct DRVMAINMOUSE *mpDrv;
139
140 LONG uHostCaps;
141 LONG uDevCaps;
142 bool fVMMDevCanAbs;
143 bool fVMMDevNeedsHostCursor;
144 uint32_t mLastAbsX;
145 uint32_t mLastAbsY;
146 uint32_t mLastButtons;
147};
148
149#endif // !____H_MOUSEIMPL
150/* 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