1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
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), state(-1) {}
|
---|
35 | MouseEvent(int _dx, int _dy, int _dz, int _state) :
|
---|
36 | dx(_dx), dy(_dy), dz(_dz), state(_state) {}
|
---|
37 | bool isValid()
|
---|
38 | {
|
---|
39 | return state != -1;
|
---|
40 | }
|
---|
41 | // not logical to be int but that's how it's defined in QEMU
|
---|
42 | /** @todo r=bird: and what is the logical declaration then? We'll be using int32_t btw. */
|
---|
43 | int dx, dy, dz;
|
---|
44 | int state;
|
---|
45 | };
|
---|
46 | // template instantiation
|
---|
47 | typedef ConsoleEventBuffer<MouseEvent> MouseEventBuffer;
|
---|
48 |
|
---|
49 | class ATL_NO_VTABLE Mouse :
|
---|
50 | public VirtualBoxSupportErrorInfoImpl <Mouse, IMouse>,
|
---|
51 | public VirtualBoxSupportTranslation <Mouse>,
|
---|
52 | public VirtualBoxBase,
|
---|
53 | public IMouse
|
---|
54 | {
|
---|
55 | public:
|
---|
56 |
|
---|
57 | DECLARE_NOT_AGGREGATABLE(Mouse)
|
---|
58 |
|
---|
59 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
60 |
|
---|
61 | BEGIN_COM_MAP(Mouse)
|
---|
62 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
63 | COM_INTERFACE_ENTRY(IMouse)
|
---|
64 | END_COM_MAP()
|
---|
65 |
|
---|
66 | NS_DECL_ISUPPORTS
|
---|
67 |
|
---|
68 | HRESULT FinalConstruct();
|
---|
69 | void FinalRelease();
|
---|
70 |
|
---|
71 | // public methods only for internal purposes
|
---|
72 | HRESULT init(Console *parent);
|
---|
73 | void uninit();
|
---|
74 |
|
---|
75 | // IMouse properties
|
---|
76 | STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
|
---|
77 | STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
|
---|
78 |
|
---|
79 | // IMouse methods
|
---|
80 | STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz,
|
---|
81 | LONG buttonState);
|
---|
82 | STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz,
|
---|
83 | LONG buttonState);
|
---|
84 |
|
---|
85 | // for VirtualBoxSupportErrorInfoImpl
|
---|
86 | static const wchar_t *getComponentName() { return L"Mouse"; }
|
---|
87 |
|
---|
88 | static const PDMDRVREG DrvReg;
|
---|
89 |
|
---|
90 | private:
|
---|
91 |
|
---|
92 | static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
|
---|
93 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
|
---|
94 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
95 |
|
---|
96 | ComObjPtr <Console, ComWeakRef> mParent;
|
---|
97 | /** Pointer to the associated mouse driver. */
|
---|
98 | struct DRVMAINMOUSE *mpDrv;
|
---|
99 |
|
---|
100 | LONG uHostCaps;
|
---|
101 | };
|
---|
102 |
|
---|
103 | #endif // ____H_MOUSEIMPL
|
---|