KeyboardImpl.cpp revision ba07e624035c1a7b83315677c0750e70f5300bf9
/* $Id$ */
/** @file
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "KeyboardImpl.h"
#include "ConsoleImpl.h"
#include "AutoCaller.h"
#include "Logging.h"
// defines
////////////////////////////////////////////////////////////////////////////////
// globals
////////////////////////////////////////////////////////////////////////////////
/** @name Keyboard device capabilities bitfield
* @{ */
enum
{
/** The keyboard device does not wish to receive keystrokes. */
/** The keyboard device does wishes to receive keystrokes. */
};
/**
* Keyboard driver instance data.
*/
typedef struct DRVMAINKEYBOARD
{
/** Pointer to the keyboard object. */
/** Pointer to the driver instance structure. */
/** Our keyboard connector interface. */
/** The capabilities of this device. */
/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
#define PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD(pInterface) ( (PDRVMAINKEYBOARD) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINKEYBOARD, IConnector)) )
// constructor / destructor
////////////////////////////////////////////////////////////////////////////////
{
}
{
}
{
mfVMMDevInited = false;
return BaseFinalConstruct();
}
void Keyboard::FinalRelease()
{
uninit();
}
// public methods
////////////////////////////////////////////////////////////////////////////////
/**
* Initializes the keyboard object.
*
* @returns COM result indicator
* @param parent handle of our parent object
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
for (unsigned i = 0; i < KEYBOARD_MAX_DEVICES; ++i)
{
if (mpDrv[i])
}
mfVMMDevInited = true;
}
/**
* Sends a scancode to the keyboard.
*
* @returns COM status code
* @param scancode The scancode to send
*/
{
}
/**
* Sends a list of scancodes to the keyboard.
*
* @returns COM status code
* @param scancodes Pointer to the first scancode
* @param count Number of scancodes
* @param codesStored Address of variable to store the number
* of scancodes that were sent to the keyboard.
This value can be NULL.
*/
{
return E_INVALIDARG;
AutoCaller autoCaller(this);
CHECK_CONSOLE_DRV(mpDrv[0]);
/* Send input to the last enabled device. Relies on the fact that
* the USB keyboard is always initialized after the PS/2 keyboard.
*/
for (int i = KEYBOARD_MAX_DEVICES - 1; i >= 0 ; --i)
{
{
break;
}
}
/* No enabled keyboard - throw the input away. */
if (!pUpPort)
{
if (codesStored)
return S_OK;
}
int vrc = VINF_SUCCESS;
if (codesStored)
*codesStored = sent;
/* Only signal the keys in the event which have been actually sent. */
if (RT_FAILURE(vrc))
return setError(VBOX_E_IPRT_ERROR,
tr("Could not send all scan codes to the virtual keyboard (%Rrc)"),
vrc);
return S_OK;
}
/**
* Sends Control-Alt-Delete to the keyboard. This could be done otherwise
* but it's so common that we'll be nice and supply a convenience API.
*
* @returns COM status code
*
*/
{
}
/**
* Releases all currently held keys in the virtual keyboard.
*
* @returns COM status code
*
*/
{
}
{
AutoCaller autoCaller(this);
// no need to lock - lifetime constant
return S_OK;
}
//
// private methods
//
DECLCALLBACK(void) Keyboard::keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
{
}
/**
* @interface_method_impl{PDMIKEYBOARDCONNECTOR,pfnSetActive}
*/
{
if (fActive)
else
}
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/**
* Destruct a keyboard driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
*/
{
{
{
break;
}
}
}
/**
* Construct a keyboard driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
/*
* Validate configuration.
*/
("Configuration error: Not possible to attach anything to this driver!\n"),
/*
* IBase.
*/
/*
*/
{
AssertMsgFailed(("Configuration error: No keyboard port interface above!\n"));
return VERR_PDM_MISSING_INTERFACE_ABOVE;
}
/*
* Get the Keyboard object pointer and update the mpDrv member.
*/
void *pv;
if (RT_FAILURE(rc))
{
return rc;
}
unsigned cDev;
{
break;
}
if (cDev == KEYBOARD_MAX_DEVICES)
return VERR_NO_MORE_HANDLES;
return VINF_SUCCESS;
}
/**
* Keyboard driver registration record.
*/
{
/* u32Version */
/* szName */
"MainKeyboard",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Main keyboard driver (Main as in the API).",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(DRVMAINKEYBOARD),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};
/* vi: set tabstop=4 shiftwidth=4 expandtab: */