1 | /* $Id: MouseImpl.h 25966 2010-01-22 11:15:43Z 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. */
|
---|
31 | class MouseEvent
|
---|
32 | {
|
---|
33 | public:
|
---|
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
|
---|
46 | typedef ConsoleEventBuffer<MouseEvent> MouseEventBuffer;
|
---|
47 |
|
---|
48 | class ATL_NO_VTABLE Mouse :
|
---|
49 | public VirtualBoxBase,
|
---|
50 | public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
|
---|
51 | public VirtualBoxSupportTranslation<Mouse>,
|
---|
52 | VBOX_SCRIPTABLE_IMPL(IMouse)
|
---|
53 | {
|
---|
54 | public:
|
---|
55 |
|
---|
56 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
|
---|
57 |
|
---|
58 | DECLARE_NOT_AGGREGATABLE(Mouse)
|
---|
59 |
|
---|
60 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
61 |
|
---|
62 | BEGIN_COM_MAP(Mouse)
|
---|
63 | COM_INTERFACE_ENTRY (ISupportErrorInfo)
|
---|
64 | COM_INTERFACE_ENTRY (IMouse)
|
---|
65 | COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
|
---|
66 | END_COM_MAP()
|
---|
67 |
|
---|
68 | DECLARE_EMPTY_CTOR_DTOR (Mouse)
|
---|
69 |
|
---|
70 | HRESULT FinalConstruct();
|
---|
71 | void FinalRelease();
|
---|
72 |
|
---|
73 | // public initializer/uninitializer for internal purposes only
|
---|
74 | HRESULT init(Console *parent);
|
---|
75 | void uninit();
|
---|
76 |
|
---|
77 | // IMouse properties
|
---|
78 | STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
|
---|
79 | STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
|
---|
80 |
|
---|
81 | // IMouse methods
|
---|
82 | STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
|
---|
83 | LONG buttonState);
|
---|
84 | STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
|
---|
85 | LONG buttonState);
|
---|
86 |
|
---|
87 | // for VirtualBoxSupportErrorInfoImpl
|
---|
88 | static const wchar_t *getComponentName() { return L"Mouse"; }
|
---|
89 |
|
---|
90 | static const PDMDRVREG DrvReg;
|
---|
91 |
|
---|
92 | private:
|
---|
93 |
|
---|
94 | static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
95 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags);
|
---|
96 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
97 |
|
---|
98 | const ComObjPtr<Console, ComWeakRef> mParent;
|
---|
99 | /** Pointer to the associated mouse driver. */
|
---|
100 | struct DRVMAINMOUSE *mpDrv;
|
---|
101 |
|
---|
102 | LONG uHostCaps;
|
---|
103 | uint32_t mLastAbsX;
|
---|
104 | uint32_t mLastAbsY;
|
---|
105 | };
|
---|
106 |
|
---|
107 | #endif // !____H_MOUSEIMPL
|
---|
108 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|