VirtualBox

source: vbox/trunk/src/VBox/Main/include/KeyboardImpl.h@ 30690

Last change on this file since 30690 was 28909, checked in by vboxsync, 14 years ago

Route input to PS/2 keyboard unless USB keyboard was explicitly activated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: KeyboardImpl.h 28909 2010-04-29 16:34:17Z 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/** Limit of simultaneously attached devices (just USB and/or PS/2). */
27enum { KEYBOARD_MAX_DEVICES = 2 };
28
29/** Simple keyboard event class. */
30class KeyboardEvent
31{
32public:
33 KeyboardEvent() : scan(-1) {}
34 KeyboardEvent(int _scan) : scan(_scan) {}
35 bool isValid()
36 {
37 return (scan & ~0x80) && !(scan & ~0xFF);
38 }
39 int scan;
40};
41// template instantiation
42typedef ConsoleEventBuffer<KeyboardEvent> KeyboardEventBuffer;
43
44class Console;
45
46class ATL_NO_VTABLE Keyboard :
47 public VirtualBoxBase,
48 public VirtualBoxSupportErrorInfoImpl<Keyboard, IKeyboard>,
49 public VirtualBoxSupportTranslation<Keyboard>,
50 VBOX_SCRIPTABLE_IMPL(IKeyboard)
51{
52
53public:
54
55 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Keyboard)
56
57 DECLARE_NOT_AGGREGATABLE(Keyboard)
58
59 DECLARE_PROTECT_FINAL_CONSTRUCT()
60
61 BEGIN_COM_MAP(Keyboard)
62 COM_INTERFACE_ENTRY(ISupportErrorInfo)
63 COM_INTERFACE_ENTRY(IKeyboard)
64 COM_INTERFACE_ENTRY(IDispatch)
65 END_COM_MAP()
66
67 DECLARE_EMPTY_CTOR_DTOR (Keyboard)
68
69 HRESULT FinalConstruct();
70 void FinalRelease();
71
72 // public initializer/uninitializer for internal purposes only
73 HRESULT init (Console *aParent);
74 void uninit();
75
76 STDMETHOD(PutScancode)(LONG scancode);
77 STDMETHOD(PutScancodes)(ComSafeArrayIn (LONG, scancodes),
78 ULONG *codesStored);
79 STDMETHOD(PutCAD)();
80
81 // for VirtualBoxSupportErrorInfoImpl
82 static const wchar_t *getComponentName() { return L"Keyboard"; }
83
84 static const PDMDRVREG DrvReg;
85
86 Console *getParent() const
87 {
88 return mParent;
89 }
90
91private:
92
93 static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
94 static DECLCALLBACK(void) keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive);
95 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
96 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
97
98 Console * const mParent;
99 /** Pointer to the associated keyboard driver(s). */
100 struct DRVMAINKEYBOARD *mpDrv[KEYBOARD_MAX_DEVICES];
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: */
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