VirtualBox

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

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

Devices, Main, pdmifs.h: initial support for PS/2 touchscreen emulation, based on the Lifebook touchscreen device

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: MouseImpl.h 26624 2010-02-18 10:35:24Z 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_ABSOLUTE = 1
51};
52
53class ATL_NO_VTABLE Mouse :
54 public VirtualBoxBase,
55 public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
56 public VirtualBoxSupportTranslation<Mouse>,
57 VBOX_SCRIPTABLE_IMPL(IMouse)
58{
59public:
60
61 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
62
63 DECLARE_NOT_AGGREGATABLE(Mouse)
64
65 DECLARE_PROTECT_FINAL_CONSTRUCT()
66
67 BEGIN_COM_MAP(Mouse)
68 COM_INTERFACE_ENTRY (ISupportErrorInfo)
69 COM_INTERFACE_ENTRY (IMouse)
70 COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
71 END_COM_MAP()
72
73 DECLARE_EMPTY_CTOR_DTOR (Mouse)
74
75 HRESULT FinalConstruct();
76 void FinalRelease();
77
78 // public initializer/uninitializer for internal purposes only
79 HRESULT init(Console *parent);
80 void uninit();
81
82 // IMouse properties
83 STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
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
102private:
103
104 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
105 static DECLCALLBACK(void) mouseAbsModeChange (PPDMIMOUSECONNECTOR pInterface, bool fAbs);
106 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
107 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
108
109 int getVMMDevMouseCaps(uint32_t *pfCaps);
110 int setVMMDevMouseCaps(uint32_t fCaps);
111 int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
112 int32_t dw, uint32_t fButtons);
113 int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
114 int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
115 int convertDisplayWidth(LONG x, uint32_t *pcX);
116 int convertDisplayHeight(LONG y, uint32_t *pcY);
117 bool needsRelativeEvent(uint32_t cXAbs, uint32_t cYAbs, int32_t dz, int32_t dw, uint32_t fButtons, uint32_t fCaps);
118
119 const ComObjPtr<Console, ComWeakRef> mParent;
120 /** Pointer to the associated mouse driver. */
121 struct DRVMAINMOUSE *mpDrv;
122
123 LONG uHostCaps;
124 LONG uDevCaps;
125 uint32_t mLastAbsX;
126 uint32_t mLastAbsY;
127 uint32_t mLastButtons;
128};
129
130#endif // !____H_MOUSEIMPL
131/* 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