DrvKeyboardQueue.cpp revision 84fdcc72b1724a0e3cb516f7732241fe6768578c
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * VBox input devices: Keyboard queue driver
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * Copyright (C) 2006-2010 Oracle Corporation
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * This file is part of VirtualBox Open Source Edition (OSE), as
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * available from http://www.virtualbox.org. This file is free software;
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * you can redistribute it and/or modify it under the terms of the GNU
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * General Public License (GPL) as published by the Free Software
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington * Foundation, in version 2 as it comes in the "COPYING" file of the
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal/*******************************************************************************
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott* Header Files *
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott*******************************************************************************/
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott/*******************************************************************************
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott* Structures and Typedefs *
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott*******************************************************************************/
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * Keyboard queue driver instance data.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @implements PDMIKEYBOARDCONNECTOR
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @implements PDMIKEYBOARDPORT
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** Pointer to the driver instance structure. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** Pointer to the keyboard port interface of the driver/device above us. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** Pointer to the keyboard port interface of the driver/device below us. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** Our keyboard connector interface. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** Our keyboard port interface. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** The queue handle. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** Discard input when this flag is set.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * We only accept input when the VM is running. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * Keyboard queue item.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** The core part owned by the queue manager. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /** The keycode. */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott/* -=-=-=-=- IBase -=-=-=-=- */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @interface_method_impl{PDMIBASE,pfnQueryInterface}
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottstatic DECLCALLBACK(void *) drvKbdQueueQueryInterface(PPDMIBASE pInterface, const char *pszIID)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott PDRVKBDQUEUE pThis = PDMINS_2_DATA(pDrvIns, PDRVKBDQUEUE);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott PDMIBASE_RETURN_INTERFACE(pszIID, PDMIKEYBOARDCONNECTOR, &pThis->IConnector);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott PDMIBASE_RETURN_INTERFACE(pszIID, PDMIKEYBOARDPORT, &pThis->IPort);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott/* -=-=-=-=- IKeyboardPort -=-=-=-=- */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott/** Converts a pointer to DRVKBDQUEUE::IPort to a DRVKBDQUEUE pointer. */
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshott#define IKEYBOARDPORT_2_DRVKBDQUEUE(pInterface) ( (PDRVKBDQUEUE)((char *)(pInterface) - RT_OFFSETOF(DRVKBDQUEUE, IPort)) )
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * Queues a keyboard event.
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * Because of the event queueing the EMT context requirement is lifted.
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * @returns VBox status code.
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * @param pInterface Pointer to this interface structure.
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * @param u8KeyCode The keycode to queue.
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshott * @thread Any thread.
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshottstatic DECLCALLBACK(int) drvKbdQueuePutEvent(PPDMIKEYBOARDPORT pInterface, uint8_t u8KeyCode)
return VINF_SUCCESS;
if (pItem)
return VINF_SUCCESS;
return VERR_PDM_NO_QUEUE_ITEMS;
#define PPDMIKEYBOARDCONNECTOR_2_DRVKBDQUEUE(pInterface) ( (PDRVKBDQUEUE)((char *)(pInterface) - RT_OFFSETOF(DRVKBDQUEUE, IConnector)) )
static DECLCALLBACK(void) drvKbdPassThruLedsChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
return VERR_PDM_MISSING_INTERFACE_ABOVE;
return rc;
return VERR_PDM_MISSING_INTERFACE_BELOW;
cMilliesInterval = 0;
return rc;
return rc;
rc = PDMDrvHlpQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, "Keyboard", &pDrv->pQueue);
AssertMsgFailed(("Failed to create driver: cItems=%d cMilliesInterval=%d rc=%Rrc\n", cItems, cMilliesInterval, rc));
return rc;
return VINF_SUCCESS;
"Keyboard queue driver to plug in between the key source and the device to do queueing and inter-thread transport.",
sizeof(DRVKBDQUEUE),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,