VirtualBox

忽略:
時間撮記:
2009-9-7 下午01:41:45 (15 年 以前)
作者:
vboxsync
訊息:

FE/Qt, Devices/Input, Main, FE/*: upgrade mouse device to an MS IntelliMouse Explorer (five buttons and tilt wheel)

檔案:
修改 1 筆資料

圖例:

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

    r22793 r22810  
    5757#include "../Builtins.h"
    5858
    59 #define PCKBD_SAVED_STATE_VERSION 2
     59#define PCKBD_SAVED_STATE_VERSION 3
    6060
    6161
     
    171171#define KBD_QUEUE_SIZE 256
    172172
     173#ifdef VBOX
     174# define MOUSE_REPORT_HORIZONTAL  0x01
     175# define MOUSE_OUTSTANDING_CLICK  0x02
     176#endif
     177
    173178typedef struct {
    174179#ifndef VBOX
     
    221226    int32_t mouse_dy;
    222227    int32_t mouse_dz;
     228#ifdef VBOX
     229    int32_t mouse_dw;
     230    int32_t mouse_flags;
     231#endif
    223232    uint8_t mouse_buttons;
    224233
     
    331340
    332341#if defined(DEBUG_MOUSE) || defined(DEBUG_KBD)
    333     if (aux)
    334         Log(("mouse event: 0x%02x\n", b));
     342    if (aux == 1)
     343        LogRel3(("%s: mouse command response: 0x%02x\n", __PRETTY_FUNCTION__, b));
     344    else if (aux == 2)
     345        LogRel3(("%s: mouse event data: 0x%02x\n", __PRETTY_FUNCTION__, b));
    335346#ifdef DEBUG_KBD
    336347    else
    337         Log(("kbd event: 0x%02x\n", b));
     348        LogRel3(("%s: kbd event: 0x%02x\n", __PRETTY_FUNCTION__, b));
    338349#endif
    339350#endif
     
    709720#endif /* VBOX */
    710721    unsigned int b;
    711     int dx1, dy1, dz1;
     722    int dx1, dy1, dz1, dw1;
    712723
    713724    dx1 = s->mouse_dx;
    714725    dy1 = s->mouse_dy;
    715726    dz1 = s->mouse_dz;
     727    dw1 = s->mouse_dw;
     728    LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
     729             dx1, dy1, dz1, dw1));
    716730    /* XXX: increase range to 8 bits ? */
    717731    if (dx1 > 127)
     
    749763        break;
    750764    case 4:
     765#ifndef VBOX
    751766        if (dz1 > 7)
    752767            dz1 = 7;
    753768        else if (dz1 < -7)
    754769            dz1 = -7;
    755         b = (dz1 & 0x0f) | ((s->mouse_buttons & 0x18) << 1);
    756 #ifdef VBOX
     770#else
     771        if (dz1 > 1)
     772            dz1 = 1;
     773        else if (dz1 < -1)
     774            dz1 = -1;
     775        else if (dw1 > 1)
     776            dw1 = 1;
     777        else if (dw1 < -1)
     778            dw1 = -1;
     779        if (dz1)
     780            dw1 = 0;
     781#endif
     782#ifdef VBOX
     783        if ((s->mouse_flags & MOUSE_REPORT_HORIZONTAL) && dw1)
     784            b = 0x40 | (dw1 & 0x3f);
     785        else
     786        {
     787            b =   (dz1 & 0x0f) | ((dw1 << 1) & 0x0f)
     788                | ((s->mouse_buttons & 0x18) << 1);
     789            s->mouse_flags &= ~MOUSE_OUTSTANDING_CLICK;
     790        }
    757791        kbd_queue(s, b, aux);
    758792#else /* !VBOX */
     793        b = (dz1 & 0x0f) | ((s->mouse_buttons & 0x18) << 1);
    759794        kbd_queue(s, b, 1);
    760795#endif /* !VBOX */
     
    766801    s->mouse_dy -= dy1;
    767802    s->mouse_dz -= dz1;
     803#ifdef VBOX
     804    s->mouse_dw -= dw1;
     805#endif
    768806}
    769807
    770808#ifdef IN_RING3
     809#ifndef VBOX
    771810static void pc_kbd_mouse_event(void *opaque,
    772811                               int dx, int dy, int dz, int buttons_state)
     812#else
     813static void pc_kbd_mouse_event(void *opaque,
     814                               int dx, int dy, int dz, int dw, int buttons_state)
     815#endif
    773816{
    774817    KBDState *s = (KBDState*)opaque;
     
    781824    s->mouse_dy -= dy;
    782825    s->mouse_dz += dz;
     826#ifdef VBOX
     827    s->mouse_dw += dw;
     828#endif
    783829#ifndef VBOX
    784830    /* XXX: SDL sometimes generates nul events: we delete them */
     
    787833        return;
    788834#else
    789     /* This issue does not affect VBox, and under some circumstances (which?)
    790      * we may wish to send null events to make mouse integration work. */
     835    /* The issue described above does not affect VBox, and under some
     836     * circumstances (which?) we may even wish to send null events to make
     837     * mouse integration work. */
     838    /* In horizontal reporting mode, we may need to send an additional packet
     839     * for the forth and fifth buttons, as they can't share a packet with a
     840     * horizontal scroll delta. */
     841    if ((s->mouse_buttons & 0x18) != (buttons_state & 0x18))
     842        s->mouse_flags |= MOUSE_OUTSTANDING_CLICK;
    791843#endif
    792844    s->mouse_buttons = buttons_state;
     
    799851               too big deltas */
    800852            kbd_mouse_send_packet(s, false);
    801             if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0)
     853            if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0 && s->mouse_dw == 0 && !(s->mouse_flags & MOUSE_OUTSTANDING_CLICK))
    802854                break;
    803855        }
     
    821873{
    822874#ifdef DEBUG_MOUSE
    823     Log(("kbd: write mouse 0x%02x\n", val));
     875    LogRelFlowFunc(("kbd: write mouse 0x%02x\n", val));
    824876#endif
    825877#ifdef VBOX
     
    9491001        s->mouse_sample_rate = val;
    9501002        /* detect IMPS/2 or IMEX */
     1003#ifdef VBOX
     1004        /* And enable horizontal scrolling reporting when requested */
     1005#endif
    9511006        switch(s->mouse_detect_state) {
    9521007        default:
     
    9601015            else if (val == 200)
    9611016                s->mouse_detect_state = 3;
     1017#ifdef VBOX
     1018            else if ((val == 80) && s->mouse_type == 4 /* IMEX */)
     1019                /* enable horizontal scrolling, byte two */
     1020                s->mouse_detect_state = 4;
     1021#endif
    9621022            else
    9631023                s->mouse_detect_state = 0;
    9641024            break;
    9651025        case 2:
     1026#ifdef VBOX
     1027            if (val == 80)
     1028            {
     1029                LogRelFlowFunc(("switching mouse device to IMPS/2 mode\n"));
     1030                s->mouse_type = 3; /* IMPS/2 */
     1031            }
     1032#else
    9661033            if (val == 80)
    9671034                s->mouse_type = 3; /* IMPS/2 */
     1035#endif
    9681036            s->mouse_detect_state = 0;
    9691037            break;
    9701038        case 3:
     1039#ifdef VBOX
     1040            if (val == 80)
     1041            {
     1042                LogRelFlowFunc(("switching mouse device to IMEX mode\n"));
     1043                s->mouse_type = 4; /* IMEX */
     1044            }
     1045#else
    9711046            if (val == 80)
    9721047                s->mouse_type = 4; /* IMEX */
     1048#endif
    9731049            s->mouse_detect_state = 0;
    9741050            break;
     1051#ifdef VBOX
     1052        case 4:
     1053            if (val == 40)
     1054            {
     1055                LogFlowFunc(("enabling IMEX horizontal scrolling reporting\n"));
     1056                s->mouse_flags |= MOUSE_REPORT_HORIZONTAL;
     1057            }
     1058            s->mouse_detect_state = 0;
     1059            break;
     1060#endif
    9751061        }
    9761062        kbd_queue(s, AUX_ACK, 1);
     
    10781164    s->mouse_dy = 0;
    10791165    s->mouse_dz = 0;
     1166    s->mouse_dw = 0;
     1167    s->mouse_flags = 0;
    10801168    s->mouse_buttons = 0;
    10811169#endif
     
    11191207    qemu_put_be32s(f, &s->mouse_dy);
    11201208    qemu_put_be32s(f, &s->mouse_dz);
     1209#ifdef VBOX
     1210    qemu_put_be32s(f, &s->mouse_dw);
     1211    qemu_put_be32s(f, &s->mouse_flags);
     1212#endif
    11211213    qemu_put_8s(f, &s->mouse_buttons);
    11221214
     
    11561248    KBDState *s = (KBDState*)opaque;
    11571249
    1158     if (version_id != PCKBD_SAVED_STATE_VERSION)
     1250    if (version_id < 2 || version_id > PCKBD_SAVED_STATE_VERSION)
    11591251#ifndef VBOX
    11601252        return -EINVAL;
     
    11771269    qemu_get_be32s(f, (uint32_t *)&s->mouse_dy);
    11781270    qemu_get_be32s(f, (uint32_t *)&s->mouse_dz);
     1271#ifdef VBOX
     1272    if (version_id > 2)
     1273    {
     1274        qemu_get_be32s(f, (uint32_t *)&s->mouse_dw);
     1275        qemu_get_be32s(f, (uint32_t *)&s->mouse_flags);
     1276    }
     1277#endif
    11791278    qemu_get_8s(f, &s->mouse_buttons);
    11801279#ifdef VBOX
     
    15371636 * @param   fButtonStates   The button states.
    15381637 */
    1539 static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, uint32_t fButtonStates)
     1638static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates)
    15401639{
    15411640    KBDState *pThis = IMOUSEPORT_2_KBDSTATE(pInterface);
    15421641    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    15431642    AssertReleaseRC(rc);
    1544     pc_kbd_mouse_event(pThis, i32DeltaX, i32DeltaY, i32DeltaZ, fButtonStates);
     1643    pc_kbd_mouse_event(pThis, i32DeltaX, i32DeltaY, i32DeltaZ, i32DeltaW, fButtonStates);
    15451644    PDMCritSectLeave(&pThis->CritSect);
    15461645    return VINF_SUCCESS;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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