VirtualBox

Changeset 26638 in vbox


Ignore:
Timestamp:
Feb 18, 2010 9:18:04 PM (15 years ago)
Author:
vboxsync
Message:

Devices, Main, pdmifs.h: changed the Main-to-Device absolute event protocol to include button and wheel events; some cleanups and fixes

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdmifs.h

    r26624 r26638  
    280280
    281281/** PDMIMOUSEPORT interface ID. */
    282 #define PDMIMOUSEPORT_IID "dcf20e6b-6cd5-4517-8759-91064605b8a8"
     282#define PDMIMOUSEPORT_IID "f8d45ecc-bd6f-4a8d-b262-b85498e7f143"
    283283/** Pointer to a mouse port interface. */
    284284typedef struct PDMIMOUSEPORT *PPDMIMOUSEPORT;
     
    313313     * @param   i32cX               The X value, in the range 0 to 0xffff.
    314314     * @param   i32cY               The Y value, in the range 0 to 0xffff.
    315      * @thread  The emulation thread.
    316      */
    317     DECLR3CALLBACKMEMBER(int, pfnPutEventAbs,(PPDMIMOUSEPORT pInterface, int32_t i32cX, int32_t i32cY));
     315     * @param   i32DeltaZ           The Z delta.
     316     * @param   i32DeltaW           The W (horizontal scroll button) delta.
     317     * @param   fButtonStates       The button states, see the PDMIMOUSEPORT_BUTTON_* \#defines.
     318     * @thread  The emulation thread.
     319     */
     320    DECLR3CALLBACKMEMBER(int, pfnPutEventAbs,(PPDMIMOUSEPORT pInterface, uint32_t i32cX, uint32_t i32cY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates));
    318321} PDMIMOUSEPORT;
    319322
     
    347350
    348351/** PDMIMOUSECONNECTOR interface ID.  */
    349 #define PDMIMOUSECONNECTOR_IID                  "847f965f-0eb8-4363-88ac-b0ee58a05bde"
     352#define PDMIMOUSECONNECTOR_IID                  "39e48c1c-1514-4ac6-8a9c-88034d36ae98"
    350353
    351354
  • trunk/src/VBox/Devices/Input/DevPS2.cpp

    r26624 r26638  
    230230    int32_t mouse_dw;
    231231    int32_t mouse_flags;
    232     int32_t mouse_cx;
    233     int32_t mouse_cy;
     232    uint32_t mouse_cx;
     233    uint32_t mouse_cy;
    234234    uint8_t mouse_buttons;
    235235    uint8_t mouse_buttons_reported;
     
    847847{
    848848    int aux = fToCmdQueue ? 1 : 2;
    849     int cx1 = s->mouse_cx * 4096 / 0xffff;
    850     int cy1 = 4096 - (s->mouse_cy * 4096 / 0xffff);
     849    unsigned cx1 = s->mouse_cx * 4095 / 0xffff;
     850    unsigned cy1 = 4095 - (s->mouse_cy * 4095 / 0xffff);
    851851    unsigned fButtons = s->mouse_buttons & 0x03;
    852     unsigned int b;
     852    unsigned int b[6];
    853853
    854854    LogRel3(("%s: cx1=%d, cy1=%d, fButtons=0x%x\n", __PRETTY_FUNCTION__,
    855855             cx1, cy1, fButtons));
    856     b = 4 /* Screen is being touched */ | fButtons;
    857     kbd_queue(s, b, aux);
    858     b = ((cy1 << 2) & 0xc0) | (cx1 >> 6);
    859     kbd_queue(s, b, aux);
    860     b = ((cx1 << 2) & 0xc0) | (cx1 & 0x3f);
    861     kbd_queue(s, b, aux);
    862     kbd_queue(s, 0xc0, aux);  /* This byte is really wasted in the protocol */
    863     b = ((cx1 << 2) & 0xc0) | (cy1 >> 6);
    864     kbd_queue(s, b, aux);
    865     b = ((cy1 << 2) & 0xc0) | (cy1 & 0x3f);
    866     kbd_queue(s, b, aux);
     856    b[0] = 4 /* Screen is being touched */ | fButtons;
     857    Assert((b[0] & 0xf8) == 0);
     858    kbd_queue(s, b[0], aux);
     859    b[1] = ((cy1 << 2) & 0xc0) | (cx1 >> 6);
     860    kbd_queue(s, b[1], aux);
     861    b[2] = ((cx1 << 2) & 0xc0) | (cx1 & 0x3f);
     862    Assert(((b[2] & 0x30) << 2) == (b[2] & 0xc0));
     863    kbd_queue(s, b[2], aux);
     864    b[3] = 0xc0;
     865    kbd_queue(s, b[3], aux);  /* This byte is really wasted in the protocol */
     866    b[4] = ((cx1 << 2) & 0xc0) | (cy1 >> 6);
     867    Assert((b[4] & 0xc0) == (b[2] & 0xc0));
     868    kbd_queue(s, b[4], aux);
     869    b[5] = ((cy1 << 2) & 0xc0) | (cy1 & 0x3f);
     870    Assert(   (((b[5] & 0x30) << 2) == (b[1] & 0xc0))
     871           && ((b[5] & 0xc0) == (b[1] & 0xc0)));
     872    kbd_queue(s, b[5], aux);
    867873}
    868874
     
    13391345    if (version_id > 3)
    13401346    {
    1341         SSMR3GetS32(f, &s->mouse_cx);
    1342         SSMR3GetS32(f, &s->mouse_cy);
     1347        SSMR3GetU32(f, &s->mouse_cx);
     1348        SSMR3GetU32(f, &s->mouse_cy);
    13431349        SSMR3GetU8(f, &s->mouse_buttons_reported);
    13441350        SSMR3GetU8(f, &s->mouse_last_button);
     
    16811687 * @param   i32cY           The Y value.
    16821688 */
    1683 static DECLCALLBACK(int) kbdMousePutEventAbs(PPDMIMOUSEPORT pInterface, int32_t i32cX, int32_t i32cY)
     1689static DECLCALLBACK(int) kbdMousePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t u32cX, uint32_t u32cY, int32_t dz, int32_t dw, uint32_t fButtons)
    16841690{
    16851691    KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Mouse.IPort);
     
    16871693    AssertReleaseRC(rc);
    16881694
    1689     pc_kbd_mouse_event_abs(pThis, i32cX, i32cY);
     1695    if (u32cX != pThis->mouse_cx || u32cY != pThis->mouse_cy)
     1696        pc_kbd_mouse_event_abs(pThis, u32cX, u32cY);
     1697    if (dz || dw || fButtons != pThis->mouse_buttons)
     1698        pc_kbd_mouse_event(pThis, 0, 0, dz, dw, fButtons);
    16901699
    16911700    PDMCritSectLeave(&pThis->CritSect);
  • trunk/src/VBox/Devices/Input/DrvMouseQueue.cpp

    r26624 r26638  
    7575    int32_t             i32DeltaW;
    7676    uint32_t            fButtonStates;
    77     int32_t             i32cX;
    78     int32_t             i32cY;
     77    uint32_t            u32cX;
     78    uint32_t            u32cY;
    7979} DRVMOUSEQUEUEITEM, *PDRVMOUSEQUEUEITEM;
    8080
     
    112112 * @param   i32DeltaY       The Y delta.
    113113 * @param   i32DeltaZ       The Z delta.
     114 * @param   i32DeltaW       The W delta.
    114115 * @param   fButtonStates   The button states.
    115116 * @thread  Any thread.
     
    142143 * @returns VBox status code.
    143144 * @param   pInterface      Pointer to interface structure.
    144  * @param   i32cX           The X value.
    145  * @param   i32cY           The Y value.
     145 * @param   u32cX           The X value.
     146 * @param   u32cY           The Y value.
     147 * @param   i32DeltaZ       The Z delta.
     148 * @param   i32DeltaW       The W delta.
     149 * @param   fButtonStates   The button states.
    146150 * @thread  Any thread.
    147151 */
    148 static DECLCALLBACK(int) drvMouseQueuePutEventAbs(PPDMIMOUSEPORT pInterface, int32_t i32cX, int32_t i32cY)
     152static DECLCALLBACK(int) drvMouseQueuePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t u32cX, uint32_t u32cY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates)
    149153{
    150154    PDRVMOUSEQUEUE pDrv = IMOUSEPORT_2_DRVMOUSEQUEUE(pInterface);
     
    156160    {
    157161        pItem->fAbs = 1;
    158         pItem->i32cX = i32cX;
    159         pItem->i32cY = i32cY;
     162        pItem->u32cX = u32cX;
     163        pItem->u32cY = u32cY;
     164        pItem->i32DeltaZ = i32DeltaZ;
     165        pItem->i32DeltaW = i32DeltaW;
     166        pItem->fButtonStates = fButtonStates;
    160167        PDMQueueInsert(pDrv->pQueue, &pItem->Core);
    161168        return VINF_SUCCESS;
     
    203210        rc = pThis->pUpPort->pfnPutEvent(pThis->pUpPort, pItem->i32DeltaX, pItem->i32DeltaY, pItem->i32DeltaZ, pItem->i32DeltaW, pItem->fButtonStates);
    204211    else
    205         rc = pThis->pUpPort->pfnPutEventAbs(pThis->pUpPort, pItem->i32cX, pItem->i32cY);
     212        rc = pThis->pUpPort->pfnPutEventAbs(pThis->pUpPort, pItem->u32cX, pItem->u32cY, pItem->i32DeltaZ, pItem->i32DeltaW, pItem->fButtonStates);
    206213    return RT_SUCCESS(rc);
    207214}
  • trunk/src/VBox/Main/MouseImpl.cpp

    r26624 r26638  
    258258 * @returns   COM status code
    259259 */
    260 int Mouse::reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs)
     260int Mouse::reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
     261                                    int32_t dz, int32_t dw, uint32_t fButtons)
    261262{
    262263    CHECK_CONSOLE_DRV (mpDrv);
    263264
    264     if (mouseXAbs != mLastAbsX || mouseYAbs != mLastAbsY)
     265    if (   mouseXAbs != mLastAbsX
     266        || mouseYAbs != mLastAbsY
     267        || dz
     268        || dw
     269        || fButtons != mLastButtons)
    265270    {
    266271        int vrc = mpDrv->pUpPort->pfnPutEventAbs(mpDrv->pUpPort, mouseXAbs,
    267                                                  mouseYAbs);
     272                                                 mouseYAbs, dz, dw, fButtons);
    268273        if (RT_FAILURE(vrc))
    269274            setError(VBOX_E_IPRT_ERROR,
     
    405410    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    406411
    407     LogRel3(("%s: x=%d, y=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
    408              x, y, dz, dw));
     412    LogRel3(("%s: x=%d, y=%d, dz=%d, dw=%d, buttonState=0x%x\n",
     413             __PRETTY_FUNCTION__, x, y, dz, dw, buttonState));
    409414
    410415    uint32_t mouseXAbs;
    411416    rc = convertDisplayWidth(x, &mouseXAbs);
    412417    ComAssertComRCRet(rc, rc);
     418    if (mouseXAbs > 0xffff)
     419        mouseXAbs = mLastAbsX;
    413420    uint32_t mouseYAbs;
    414421    rc = convertDisplayHeight(y, &mouseYAbs);
    415422    ComAssertComRCRet(rc, rc);
     423    if (mouseYAbs > 0xffff)
     424        mouseYAbs = mLastAbsY;
    416425    uint32_t fButtons = mouseButtonsToPDM(buttonState);
    417426    /* Older guest additions rely on a small phony movement event on the
     
    420429
    421430    if (uDevCaps & MOUSE_DEVCAP_ABSOLUTE)
    422         rc = reportAbsEventToMouseDev(mouseXAbs, mouseYAbs);
     431        rc = reportAbsEventToMouseDev(mouseXAbs, mouseYAbs, dz, dw, fButtons);
    423432    else
    424433    {
     
    443452    mLastAbsX = mouseXAbs;
    444453    mLastAbsY = mouseYAbs;
    445     /* We may need to send a relative event for button information or to
    446      * wake the guest up to the changed absolute co-ordinates. */
    447     /* If the event is a pure wake up one, we make sure it contains some
    448      * (possibly phony) event data to make sure it isn't just discarded on
    449      * the way.  Note: we ignore dw as it is optional. */
    450     if (fNeedsJiggle || fButtons != mLastButtons || dz || dw)
    451         rc = reportRelEventToMouseDev(fNeedsJiggle ? 1 : 0, 0, dz, dw,
    452                                       fButtons);
    453     if (SUCCEEDED(rc))
    454         mLastButtons = fButtons;
     454    if (!(uDevCaps & MOUSE_DEVCAP_ABSOLUTE))
     455    {
     456        /* We may need to send a relative event for button information or to
     457         * wake the guest up to the changed absolute co-ordinates.
     458         * If the event is a pure wake up one, we make sure it contains some
     459         * (possibly phony) event data to make sure it isn't just discarded on
     460         * the way. */
     461        if (fNeedsJiggle || fButtons != mLastButtons || dz || dw)
     462            rc = reportRelEventToMouseDev(fNeedsJiggle ? 1 : 0, 0, dz, dw,
     463                                          fButtons);
     464        ComAssertComRCRet (rc, rc);
     465    }
     466    mLastButtons = fButtons;
    455467    return rc;
    456468}
  • trunk/src/VBox/Main/include/MouseImpl.h

    r26624 r26638  
    111111    int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
    112112                                 int32_t dw, uint32_t fButtons);
    113     int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
     113    int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
     114                                 int32_t dz, int32_t dw, uint32_t fButtons);
    114115    int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
    115116    int convertDisplayWidth(LONG x, uint32_t *pcX);
    116117    int convertDisplayHeight(LONG y, uint32_t *pcY);
    117     bool needsRelativeEvent(uint32_t cXAbs, uint32_t cYAbs, int32_t dz, int32_t dw, uint32_t fButtons, uint32_t fCaps);
    118118
    119119    const ComObjPtr<Console, ComWeakRef> mParent;
Note: See TracChangeset for help on using the changeset viewer.

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