KeyboardImpl.h revision ba07e624035c1a7b83315677c0750e70f5300bf9
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync/* $Id$ */
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync/** @file
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * VirtualBox COM class implementation
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync */
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync/*
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync * Copyright (C) 2006-2011 Oracle Corporation
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync *
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync * available from http://www.virtualbox.org. This file is free software;
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * you can redistribute it and/or modify it under the terms of the GNU
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * General Public License (GPL) as published by the Free Software
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync */
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync#ifndef ____H_KEYBOARDIMPL
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync#define ____H_KEYBOARDIMPL
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync#include "VirtualBoxBase.h"
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync#include "ConsoleEvents.h"
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync#include "EventImpl.h"
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync#include <VBox/vmm/pdmdrv.h>
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync/** Limit of simultaneously attached devices (just USB and/or PS/2). */
0c437bb10c61b229407a7517efde04dfe3b1e4a1vboxsyncenum { KEYBOARD_MAX_DEVICES = 2 };
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync/** Simple keyboard event class. */
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsyncclass KeyboardEvent
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync{
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsyncpublic:
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync KeyboardEvent() : scan(-1) {}
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync KeyboardEvent(int _scan) : scan(_scan) {}
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync bool isValid()
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync {
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync return (scan & ~0x80) && !(scan & ~0xFF);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync }
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync int scan;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync};
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync// template instantiation
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsynctypedef ConsoleEventBuffer<KeyboardEvent> KeyboardEventBuffer;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsyncclass Console;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsyncclass ATL_NO_VTABLE Keyboard :
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync public VirtualBoxBase,
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync VBOX_SCRIPTABLE_IMPL(IKeyboard)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync{
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsyncpublic:
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
0493c79a1867f7760af6bc330c8c42a09da852abvboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Keyboard, IKeyboard)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync DECLARE_NOT_AGGREGATABLE(Keyboard)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync BEGIN_COM_MAP(Keyboard)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync VBOX_DEFAULT_INTERFACE_ENTRIES(IKeyboard)
22ec733a5e041fcdfe02fce2eafc9faf8b0077ddvboxsync END_COM_MAP()
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync DECLARE_EMPTY_CTOR_DTOR(Keyboard)
54211a0f33e1613ca0f749141ee8ec6fc0ea5c68vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync HRESULT FinalConstruct();
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync void FinalRelease();
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync // public initializer/uninitializer for internal purposes only
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync HRESULT init(Console *aParent);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync void uninit();
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync STDMETHOD(PutScancode)(LONG scancode);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync STDMETHOD(PutScancodes)(ComSafeArrayIn(LONG, scancodes),
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync ULONG *codesStored);
a0ed9c35186427ae0abbd14b1cfdf43bf2dc8659vboxsync STDMETHOD(PutCAD)();
a0ed9c35186427ae0abbd14b1cfdf43bf2dc8659vboxsync STDMETHOD(ReleaseKeys)();
a0ed9c35186427ae0abbd14b1cfdf43bf2dc8659vboxsync
a0ed9c35186427ae0abbd14b1cfdf43bf2dc8659vboxsync STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync static const PDMDRVREG DrvReg;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync Console *getParent() const
230bd8589bba39933ac5ec21482d6186d675e604vboxsync {
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync return mParent;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync }
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsyncprivate:
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync static DECLCALLBACK(void) keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync static DECLCALLBACK(void) keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
021c939a9e3f688c0c3bbd759354be906bb2dcabvboxsync static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
021c939a9e3f688c0c3bbd759354be906bb2dcabvboxsync static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync Console * const mParent;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync /** Pointer to the associated keyboard driver(s). */
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync struct DRVMAINKEYBOARD *mpDrv[KEYBOARD_MAX_DEVICES];
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync /** Pointer to the device instance for the VMM Device. */
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync PPDMDEVINS mpVMMDev;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync /** Set after the first attempt to find the VMM Device. */
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync bool mfVMMDevInited;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync const ComObjPtr<EventSource> mEventSource;
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync};
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync
021c939a9e3f688c0c3bbd759354be906bb2dcabvboxsync#endif // !____H_KEYBOARDIMPL
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync