VirtualBox

忽略:
時間撮記:
2010-1-22 上午11:15:43 (15 年 以前)
作者:
vboxsync
訊息:

PDMIBASE refactoring; use UUID as interface IDs.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Input/DevPS2.cpp

    r25732 r25966  
    5353#include <VBox/pdmdev.h>
    5454#include <iprt/assert.h>
     55#include <iprt/uuid.h>
    5556
    5657#include "../Builtins.h"
     
    221222    /**
    222223     * Keyboard port - LUN#0.
     224     *
     225     * @implements  PDMIBASE
     226     * @implements  PDMIKEYBOARDPORT
    223227     */
    224228    struct
     
    237241    /**
    238242     * Mouse port - LUN#1.
     243     *
     244     * @implements  PDMIBASE
     245     * @implements  PDMIMOUSEPORT
    239246     */
    240247    struct
     
    13491356
    13501357/**
    1351  * Queries an interface to the driver.
    1352  *
    1353  * @returns Pointer to interface.
    1354  * @returns NULL if the interface was not supported by the device.
    1355  * @param   pInterface          Pointer to the keyboard port base interface (KBDState::Keyboard.Base).
    1356  * @param   enmInterface        The requested interface identification.
    1357  */
    1358 static DECLCALLBACK(void *)  kbdKeyboardQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
    1359 {
    1360     KBDState *pThis = (KBDState *)((uintptr_t)pInterface -  RT_OFFSETOF(KBDState, Keyboard.Base));
    1361     switch (enmInterface)
    1362     {
    1363         case PDMINTERFACE_BASE:
    1364             return &pThis->Keyboard.Base;
    1365         case PDMINTERFACE_KEYBOARD_PORT:
    1366             return &pThis->Keyboard.Port;
    1367         default:
    1368             return NULL;
    1369     }
     1358 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     1359 */
     1360static DECLCALLBACK(void *)  kbdKeyboardQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     1361{
     1362    KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Keyboard.Base);
     1363    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     1364        return &pThis->Keyboard.Base;
     1365    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_KEYBOARD_PORT) == 0)
     1366        return &pThis->Keyboard.Port;
     1367    return NULL;
    13701368}
    13711369
    13721370
    13731371/* -=-=-=-=-=- Keyboard: IKeyboardPort  -=-=-=-=-=- */
    1374 
    1375 /** Converts a keyboard port interface pointer to a keyboard state pointer. */
    1376 #define IKEYBOARDPORT_2_KBDSTATE(pInterface) ( (KBDState *)((uintptr_t)pInterface -  RT_OFFSETOF(KBDState, Keyboard.Port)) )
    13771372
    13781373/**
     
    13851380static DECLCALLBACK(int) kbdKeyboardPutEvent(PPDMIKEYBOARDPORT pInterface, uint8_t u8KeyCode)
    13861381{
    1387     KBDState *pThis = IKEYBOARDPORT_2_KBDSTATE(pInterface);
     1382    KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Keyboard.Port);
    13881383    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    13891384    AssertReleaseRC(rc);
     1385
    13901386    pc_kbd_put_keycode(pThis, u8KeyCode);
     1387
    13911388    PDMCritSectLeave(&pThis->CritSect);
    13921389    return VINF_SUCCESS;
     
    13971394
    13981395/**
    1399  * Queries an interface to the driver.
    1400  *
    1401  * @returns Pointer to interface.
    1402  * @returns NULL if the interface was not supported by the device.
    1403  * @param   pInterface          Pointer to the mouse port base interface (KBDState::Mouse.Base).
    1404  * @param   enmInterface        The requested interface identification.
    1405  */
    1406 static DECLCALLBACK(void *)  kbdMouseQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
    1407 {
    1408     KBDState *pThis = (KBDState *)((uintptr_t)pInterface -  RT_OFFSETOF(KBDState, Mouse.Base));
    1409     switch (enmInterface)
    1410     {
    1411         case PDMINTERFACE_BASE:
    1412             return &pThis->Mouse.Base;
    1413         case PDMINTERFACE_MOUSE_PORT:
    1414             return &pThis->Mouse.Port;
    1415         default:
    1416             return NULL;
    1417     }
     1396 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     1397 */
     1398static DECLCALLBACK(void *)  kbdMouseQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     1399{
     1400    KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Mouse.Base);
     1401    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     1402        return &pThis->Mouse.Base;
     1403    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_MOUSE_PORT) == 0)
     1404        return &pThis->Mouse.Port;
     1405    return NULL;
    14181406}
    14191407
    14201408
    14211409/* -=-=-=-=-=- Mouse: IMousePort  -=-=-=-=-=- */
    1422 
    1423 /** Converts a mouse port interface pointer to a keyboard state pointer. */
    1424 #define IMOUSEPORT_2_KBDSTATE(pInterface) ( (KBDState *)((uintptr_t)pInterface -  RT_OFFSETOF(KBDState, Mouse.Port)) )
    14251410
    14261411/**
     
    14361421static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates)
    14371422{
    1438     KBDState *pThis = IMOUSEPORT_2_KBDSTATE(pInterface);
     1423    KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Mouse.Port);
    14391424    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    14401425    AssertReleaseRC(rc);
     1426
    14411427    pc_kbd_mouse_event(pThis, i32DeltaX, i32DeltaY, i32DeltaZ, i32DeltaW, fButtonStates);
     1428
    14421429    PDMCritSectLeave(&pThis->CritSect);
    14431430    return VINF_SUCCESS;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette