KeyboardImpl.cpp revision e7468e7cf9b3b703ab3cc383681376dfae00f367
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "KeyboardImpl.h"
#include "ConsoleImpl.h"
#include "Logging.h"
// defines
////////////////////////////////////////////////////////////////////////////////
// globals
////////////////////////////////////////////////////////////////////////////////
/**
* Keyboard driver instance data.
*/
typedef struct DRVMAINKEYBOARD
{
/** Pointer to the keyboard object. */
/** Pointer to the driver instance structure. */
/** Our mouse connector interface. */
/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
#define PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD(pInterface) ( (PDRVMAINKEYBOARD) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINKEYBOARD, Connector)) )
// constructor / destructor
////////////////////////////////////////////////////////////////////////////////
{
mfVMMDevInited = false;
return S_OK;
}
void Keyboard::FinalRelease()
{
if (isReady())
uninit();
}
// public methods
////////////////////////////////////////////////////////////////////////////////
/**
* Initializes the keyboard object.
*
* @returns COM result indicator
* @param parent handle of our parent object
*/
{
AutoWriteLock alock (this);
setReady (true);
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.
*/
{
AutoWriteLock alock (this);
AssertReturn (isReady(), (void) 0);
if (mpDrv)
mfVMMDevInited = true;
setReady (false);
}
/**
* Sends a scancode to the keyboard.
*
* @returns COM status code
* @param scancode The scancode to send
*/
{
AutoWriteLock alock (this);
CHECK_READY();
if (VBOX_FAILURE (rcVBox))
tr ("Could not send scan code 0x%08X to the virtual keyboard (%Vrc)"),
return S_OK;
}
/**
* 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;
AutoWriteLock alock (this);
CHECK_READY();
int rcVBox = VINF_SUCCESS;
{
}
if (VBOX_FAILURE (rcVBox))
/// @todo is it actually possible that not all scancodes can be transmitted?
if (codesStored)
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
*
*/
{
}
//
// private methods
//
/**
* Queries an interface to the driver.
*
* @returns Pointer to interface.
* @returns NULL if the interface was not supported by the driver.
* @param pInterface Pointer to this interface structure.
* @param enmInterface The requested interface identification.
*/
{
switch (enmInterface)
{
case PDMINTERFACE_BASE:
default:
return NULL;
}
}
/**
* Destruct a keyboard driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
*/
{
{
}
}
{
!!(enmLeds & PDMKEYBLEDS_CAPSLOCK),
!!(enmLeds & PDMKEYBLEDS_SCROLLLOCK));
}
/**
* Construct a keyboard driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
* If the registration structure is needed, pDrvIns->pDrvReg points to it.
* @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
* of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
* iInstance it's expected to be used a bit in this function.
*/
{
/*
* Validate configuration.
*/
if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
{
AssertMsgFailed(("Configuration error: Not possible to attach anything to this driver!\n"));
return VERR_PDM_DRVINS_NO_ATTACH;
}
/*
* IBase.
*/
/*
*/
pData->pUpPort = (PPDMIKEYBOARDPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_KEYBOARD_PORT);
{
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 (VBOX_FAILURE(rc))
{
return rc;
}
return VINF_SUCCESS;
}
/**
* Keyboard driver registration record.
*/
{
/* u32Version */
/* szDriverName */
"MainKeyboard",
/* pszDescription */
"Main keyboard driver (Main as in the API).",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVMAINKEYBOARD),
/* pfnConstruct */
/* pfnDestruct */
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnDetach */
};