1 | /* $Id: KeyboardImpl.h 26173 2010-02-02 21:11:09Z 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_KEYBOARDIMPL
|
---|
23 | #define ____H_KEYBOARDIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 | #include "ConsoleEvents.h"
|
---|
27 |
|
---|
28 | #include <VBox/pdmdrv.h>
|
---|
29 |
|
---|
30 | /** Simple keyboard event class. */
|
---|
31 | class KeyboardEvent
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | KeyboardEvent() : scan(-1) {}
|
---|
35 | KeyboardEvent(int _scan) : scan(_scan) {}
|
---|
36 | bool isValid()
|
---|
37 | {
|
---|
38 | return (scan & ~0x80) && !(scan & ~0xFF);
|
---|
39 | }
|
---|
40 | int scan;
|
---|
41 | };
|
---|
42 | // template instantiation
|
---|
43 | typedef ConsoleEventBuffer<KeyboardEvent> KeyboardEventBuffer;
|
---|
44 |
|
---|
45 | class Console;
|
---|
46 |
|
---|
47 | class ATL_NO_VTABLE Keyboard :
|
---|
48 | public VirtualBoxBase,
|
---|
49 | public VirtualBoxSupportErrorInfoImpl<Keyboard, IKeyboard>,
|
---|
50 | public VirtualBoxSupportTranslation<Keyboard>,
|
---|
51 | VBOX_SCRIPTABLE_IMPL(IKeyboard)
|
---|
52 | {
|
---|
53 |
|
---|
54 | public:
|
---|
55 |
|
---|
56 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Keyboard)
|
---|
57 |
|
---|
58 | DECLARE_NOT_AGGREGATABLE(Keyboard)
|
---|
59 |
|
---|
60 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
61 |
|
---|
62 | BEGIN_COM_MAP(Keyboard)
|
---|
63 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
64 | COM_INTERFACE_ENTRY(IKeyboard)
|
---|
65 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
66 | END_COM_MAP()
|
---|
67 |
|
---|
68 | DECLARE_EMPTY_CTOR_DTOR (Keyboard)
|
---|
69 |
|
---|
70 | HRESULT FinalConstruct();
|
---|
71 | void FinalRelease();
|
---|
72 |
|
---|
73 | // public initializer/uninitializer for internal purposes only
|
---|
74 | HRESULT init (Console *aParent);
|
---|
75 | void uninit();
|
---|
76 |
|
---|
77 | STDMETHOD(PutScancode)(LONG scancode);
|
---|
78 | STDMETHOD(PutScancodes)(ComSafeArrayIn (LONG, scancodes),
|
---|
79 | ULONG *codesStored);
|
---|
80 | STDMETHOD(PutCAD)();
|
---|
81 |
|
---|
82 | // for VirtualBoxSupportErrorInfoImpl
|
---|
83 | static const wchar_t *getComponentName() { return L"Keyboard"; }
|
---|
84 |
|
---|
85 | static const PDMDRVREG DrvReg;
|
---|
86 |
|
---|
87 | Console *getParent() const
|
---|
88 | {
|
---|
89 | return mParent;
|
---|
90 | }
|
---|
91 |
|
---|
92 | private:
|
---|
93 |
|
---|
94 | static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
95 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
96 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
97 |
|
---|
98 | const ComObjPtr<Console, ComWeakRef> mParent;
|
---|
99 | /** Pointer to the associated keyboard driver. */
|
---|
100 | struct DRVMAINKEYBOARD *mpDrv;
|
---|
101 | /** Pointer to the device instance for the VMM Device. */
|
---|
102 | PPDMDEVINS mpVMMDev;
|
---|
103 | /** Set after the first attempt to find the VMM Device. */
|
---|
104 | bool mfVMMDevInited;
|
---|
105 | };
|
---|
106 |
|
---|
107 | #endif // !____H_KEYBOARDIMPL
|
---|
108 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|