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