[13607] | 1 | /* $Id: KeyboardImpl.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
| 3 | * VirtualBox COM class implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[96407] | 7 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
[1] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[1] | 26 | */
|
---|
| 27 |
|
---|
[76562] | 28 | #ifndef MAIN_INCLUDED_KeyboardImpl_h
|
---|
| 29 | #define MAIN_INCLUDED_KeyboardImpl_h
|
---|
[76487] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[1] | 33 |
|
---|
[52400] | 34 | #include "KeyboardWrap.h"
|
---|
[33061] | 35 | #include "EventImpl.h"
|
---|
[13606] | 36 |
|
---|
[35346] | 37 | #include <VBox/vmm/pdmdrv.h>
|
---|
[1] | 38 |
|
---|
[28909] | 39 | /** Limit of simultaneously attached devices (just USB and/or PS/2). */
|
---|
| 40 | enum { KEYBOARD_MAX_DEVICES = 2 };
|
---|
| 41 |
|
---|
[30764] | 42 | /** Simple keyboard event class. */
|
---|
| 43 | class KeyboardEvent
|
---|
| 44 | {
|
---|
| 45 | public:
|
---|
| 46 | KeyboardEvent() : scan(-1) {}
|
---|
| 47 | KeyboardEvent(int _scan) : scan(_scan) {}
|
---|
[52400] | 48 | bool i_isValid()
|
---|
[30764] | 49 | {
|
---|
| 50 | return (scan & ~0x80) && !(scan & ~0xFF);
|
---|
| 51 | }
|
---|
| 52 | int scan;
|
---|
| 53 | };
|
---|
[1] | 54 | class Console;
|
---|
| 55 |
|
---|
| 56 | class ATL_NO_VTABLE Keyboard :
|
---|
[52400] | 57 | public KeyboardWrap
|
---|
[1] | 58 | {
|
---|
| 59 | public:
|
---|
| 60 |
|
---|
[90828] | 61 | DECLARE_COMMON_CLASS_METHODS(Keyboard)
|
---|
[13606] | 62 |
|
---|
[1] | 63 | HRESULT FinalConstruct();
|
---|
| 64 | void FinalRelease();
|
---|
| 65 |
|
---|
[13606] | 66 | // public initializer/uninitializer for internal purposes only
|
---|
[33849] | 67 | HRESULT init(Console *aParent);
|
---|
[1] | 68 | void uninit();
|
---|
| 69 |
|
---|
| 70 | static const PDMDRVREG DrvReg;
|
---|
| 71 |
|
---|
[52400] | 72 | Console *i_getParent() const
|
---|
[1] | 73 | {
|
---|
| 74 | return mParent;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | private:
|
---|
| 78 |
|
---|
[52400] | 79 | // Wrapped Keyboard properties
|
---|
| 80 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
[52924] | 81 | HRESULT getKeyboardLEDs(std::vector<KeyboardLED_T> &aKeyboardLEDs);
|
---|
| 82 |
|
---|
| 83 | // Wrapped Keyboard members
|
---|
[52400] | 84 | HRESULT putScancode(LONG aScancode);
|
---|
| 85 | HRESULT putScancodes(const std::vector<LONG> &aScancodes,
|
---|
| 86 | ULONG *aCodesStored);
|
---|
| 87 | HRESULT putCAD();
|
---|
| 88 | HRESULT releaseKeys();
|
---|
[79676] | 89 | HRESULT putUsageCode(LONG aUsageCode, LONG aUsagePage, BOOL fKeyRelease);
|
---|
[52400] | 90 |
|
---|
| 91 | static DECLCALLBACK(void) i_keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds);
|
---|
| 92 | static DECLCALLBACK(void) i_keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive);
|
---|
| 93 | static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
| 94 | static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
| 95 | static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
|
---|
| 96 |
|
---|
[52924] | 97 | void onKeyboardLedsChange(PDMKEYBLEDS enmLeds);
|
---|
| 98 |
|
---|
[27607] | 99 | Console * const mParent;
|
---|
[28909] | 100 | /** Pointer to the associated keyboard driver(s). */
|
---|
| 101 | struct DRVMAINKEYBOARD *mpDrv[KEYBOARD_MAX_DEVICES];
|
---|
[33061] | 102 |
|
---|
[52924] | 103 | /* The current guest keyboard LED status. */
|
---|
| 104 | PDMKEYBLEDS menmLeds;
|
---|
| 105 |
|
---|
[33061] | 106 | const ComObjPtr<EventSource> mEventSource;
|
---|
[1] | 107 | };
|
---|
| 108 |
|
---|
[76562] | 109 | #endif /* !MAIN_INCLUDED_KeyboardImpl_h */
|
---|
[14949] | 110 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|