1 | /* $Id: MouseImpl.h 23223 2009-09-22 15:50:03Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef ____H_MOUSEIMPL
|
---|
25 | #define ____H_MOUSEIMPL
|
---|
26 |
|
---|
27 | #include "VirtualBoxBase.h"
|
---|
28 | #include "ConsoleEvents.h"
|
---|
29 | #include "ConsoleImpl.h"
|
---|
30 | #include <VBox/pdmdrv.h>
|
---|
31 |
|
---|
32 | /** Simple mouse event class. */
|
---|
33 | class MouseEvent
|
---|
34 | {
|
---|
35 | public:
|
---|
36 | MouseEvent() : dx(0), dy(0), dz(0), dw(0), state(-1) {}
|
---|
37 | MouseEvent(int32_t _dx, int32_t _dy, int32_t _dz, int32_t _dw, int32_t _state) :
|
---|
38 | dx(_dx), dy(_dy), dz(_dz), dw(_dw), state(_state) {}
|
---|
39 | bool isValid()
|
---|
40 | {
|
---|
41 | return state != -1;
|
---|
42 | }
|
---|
43 | /* Note: dw is the horizontal scroll wheel */
|
---|
44 | int32_t dx, dy, dz, dw;
|
---|
45 | int32_t state;
|
---|
46 | };
|
---|
47 | // template instantiation
|
---|
48 | typedef ConsoleEventBuffer<MouseEvent> MouseEventBuffer;
|
---|
49 |
|
---|
50 | class ATL_NO_VTABLE Mouse :
|
---|
51 | public VirtualBoxBase,
|
---|
52 | public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
|
---|
53 | public VirtualBoxSupportTranslation<Mouse>,
|
---|
54 | VBOX_SCRIPTABLE_IMPL(IMouse)
|
---|
55 | {
|
---|
56 | public:
|
---|
57 |
|
---|
58 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
|
---|
59 |
|
---|
60 | DECLARE_NOT_AGGREGATABLE(Mouse)
|
---|
61 |
|
---|
62 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
63 |
|
---|
64 | BEGIN_COM_MAP(Mouse)
|
---|
65 | COM_INTERFACE_ENTRY (ISupportErrorInfo)
|
---|
66 | COM_INTERFACE_ENTRY (IMouse)
|
---|
67 | COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
|
---|
68 | END_COM_MAP()
|
---|
69 |
|
---|
70 | DECLARE_EMPTY_CTOR_DTOR (Mouse)
|
---|
71 |
|
---|
72 | HRESULT FinalConstruct();
|
---|
73 | void FinalRelease();
|
---|
74 |
|
---|
75 | // public initializer/uninitializer for internal purposes only
|
---|
76 | HRESULT init(Console *parent);
|
---|
77 | void uninit();
|
---|
78 |
|
---|
79 | // IMouse properties
|
---|
80 | STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
|
---|
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 | // for VirtualBoxSupportErrorInfoImpl
|
---|
90 | static const wchar_t *getComponentName() { return L"Mouse"; }
|
---|
91 |
|
---|
92 | static const PDMDRVREG DrvReg;
|
---|
93 |
|
---|
94 | private:
|
---|
95 |
|
---|
96 | static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
|
---|
97 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags);
|
---|
98 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
99 |
|
---|
100 | const ComObjPtr<Console, ComWeakRef> mParent;
|
---|
101 | /** Pointer to the associated mouse driver. */
|
---|
102 | struct DRVMAINMOUSE *mpDrv;
|
---|
103 |
|
---|
104 | LONG uHostCaps;
|
---|
105 | uint32_t mLastAbsX;
|
---|
106 | uint32_t mLastAbsY;
|
---|
107 | };
|
---|
108 |
|
---|
109 | #endif // ____H_MOUSEIMPL
|
---|
110 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|