~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Main/MouseImpl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include <VBox/pdmdrv.h>
31
31
#include <iprt/asm.h>
32
 
#include <VBox/VBoxDev.h>
 
32
#include <VBox/VMMDev.h>
33
33
 
34
34
/**
35
35
 * Mouse driver instance data.
79
79
 */
80
80
HRESULT Mouse::init (Console *parent)
81
81
{
82
 
    LogFlowThisFunc (("\n"));
 
82
    LogFlowThisFunc(("\n"));
83
83
 
84
84
    ComAssertRet (parent, E_INVALIDARG);
85
85
 
86
86
    /* Enclose the state transition NotReady->InInit->Ready */
87
 
    AutoInitSpan autoInitSpan (this);
88
 
    AssertReturn (autoInitSpan.isOk(), E_FAIL);
 
87
    AutoInitSpan autoInitSpan(this);
 
88
    AssertReturn(autoInitSpan.isOk(), E_FAIL);
89
89
 
90
90
    unconst(mParent) = parent;
91
91
 
92
92
#ifdef RT_OS_L4
93
93
    /* L4 console has no own mouse cursor */
94
 
    uHostCaps = VMMDEV_MOUSEHOSTCANNOTHWPOINTER;
 
94
    uHostCaps = VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER;
95
95
#else
96
96
    uHostCaps = 0;
97
97
#endif
108
108
 */
109
109
void Mouse::uninit()
110
110
{
111
 
    LogFlowThisFunc (("\n"));
 
111
    LogFlowThisFunc(("\n"));
112
112
 
113
113
    /* Enclose the state transition Ready->InUninit->NotReady */
114
 
    AutoUninitSpan autoUninitSpan (this);
 
114
    AutoUninitSpan autoUninitSpan(this);
115
115
    if (autoUninitSpan.uninitDone())
116
116
        return;
117
117
 
119
119
        mpDrv->pMouse = NULL;
120
120
    mpDrv = NULL;
121
121
 
122
 
    unconst (mParent).setNull();
 
122
    unconst(mParent).setNull();
123
123
}
124
124
 
125
125
// IMouse properties
137
137
    if (!absoluteSupported)
138
138
        return E_POINTER;
139
139
 
140
 
    AutoCaller autoCaller (this);
141
 
    CheckComRCReturnRC (autoCaller.rc());
 
140
    AutoCaller autoCaller(this);
 
141
    CheckComRCReturnRC(autoCaller.rc());
142
142
 
143
 
    AutoWriteLock alock (this);
 
143
    AutoWriteLock alock(this);
144
144
 
145
145
    CHECK_CONSOLE_DRV (mpDrv);
146
146
 
150
150
    *absoluteSupported = FALSE;
151
151
    uint32_t mouseCaps;
152
152
    mParent->getVMMDev()->getVMMDevPort()->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(), &mouseCaps);
153
 
    *absoluteSupported = mouseCaps & VMMDEV_MOUSEGUESTWANTSABS;
 
153
    *absoluteSupported = mouseCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE;
154
154
 
155
155
    return S_OK;
156
156
}
167
167
    if (!needsHostCursor)
168
168
        return E_POINTER;
169
169
 
170
 
    AutoCaller autoCaller (this);
171
 
    CheckComRCReturnRC (autoCaller.rc());
 
170
    AutoCaller autoCaller(this);
 
171
    CheckComRCReturnRC(autoCaller.rc());
172
172
 
173
 
    AutoWriteLock alock (this);
 
173
    AutoWriteLock alock(this);
174
174
 
175
175
    CHECK_CONSOLE_DRV (mpDrv);
176
176
 
180
180
    *needsHostCursor = FALSE;
181
181
    uint32_t mouseCaps;
182
182
    mParent->getVMMDev()->getVMMDevPort()->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(), &mouseCaps);
183
 
    *needsHostCursor = mouseCaps & VMMDEV_MOUSEGUESTNEEDSHOSTCUR;
 
183
    *needsHostCursor = mouseCaps & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR;
184
184
 
185
185
    return S_OK;
186
186
}
197
197
 * @param dz          Z movement
198
198
 * @param buttonState The mouse button state
199
199
 */
200
 
STDMETHODIMP Mouse::PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG buttonState)
 
200
STDMETHODIMP Mouse::PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG dw, LONG buttonState)
201
201
{
202
202
    HRESULT rc = S_OK;
203
203
 
204
 
    AutoCaller autoCaller (this);
205
 
    CheckComRCReturnRC (autoCaller.rc());
 
204
    AutoCaller autoCaller(this);
 
205
    CheckComRCReturnRC(autoCaller.rc());
206
206
 
207
 
    AutoWriteLock alock (this);
 
207
    AutoWriteLock alock(this);
208
208
 
209
209
    CHECK_CONSOLE_DRV (mpDrv);
210
210
 
212
212
    ComAssertRet (mParent->getVMMDev()->getVMMDevPort(), E_FAIL);
213
213
 
214
214
    uint32_t mouseCaps;
 
215
    LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
 
216
             dx, dy, dz, dw));
215
217
    mParent->getVMMDev()->getVMMDevPort()
216
218
        ->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(),
217
219
                                    &mouseCaps);
220
222
     * longer wants to use absolute coordinates. If the VMM
221
223
     * device isn't aware of that yet, tell it.
222
224
     */
223
 
    if (mouseCaps & VMMDEV_MOUSEHOSTWANTSABS)
 
225
    if (mouseCaps & VMMDEV_MOUSE_HOST_CAN_ABSOLUTE)
224
226
    {
225
227
        mParent->getVMMDev()->getVMMDevPort()->pfnSetMouseCapabilities(
226
228
            mParent->getVMMDev()->getVMMDevPort(), uHostCaps);
233
235
        fButtons |= PDMIMOUSEPORT_BUTTON_RIGHT;
234
236
    if (buttonState & MouseButtonState_MiddleButton)
235
237
        fButtons |= PDMIMOUSEPORT_BUTTON_MIDDLE;
 
238
    if (buttonState & MouseButtonState_XButton1)
 
239
        fButtons |= PDMIMOUSEPORT_BUTTON_X1;
 
240
    if (buttonState & MouseButtonState_XButton2)
 
241
        fButtons |= PDMIMOUSEPORT_BUTTON_X2;
236
242
 
237
 
    int vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, dx, dy, dz, fButtons);
238
 
    if (RT_FAILURE (vrc))
 
243
    int vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, dx, dy, dz, dw, fButtons);
 
244
    if (RT_FAILURE(vrc))
239
245
        rc = setError (VBOX_E_IPRT_ERROR,
240
246
            tr ("Could not send the mouse event to the virtual mouse (%Rrc)"),
241
247
                vrc);
253
259
 * @param dz         Z movement
254
260
 * @param buttonState The mouse button state
255
261
 */
256
 
STDMETHODIMP Mouse::PutMouseEventAbsolute(LONG x, LONG y, LONG dz,
 
262
STDMETHODIMP Mouse::PutMouseEventAbsolute(LONG x, LONG y, LONG dz, LONG dw,
257
263
                                          LONG buttonState)
258
264
{
259
265
    HRESULT rc = S_OK;
260
266
 
261
 
    AutoCaller autoCaller (this);
262
 
    CheckComRCReturnRC (autoCaller.rc());
 
267
    AutoCaller autoCaller(this);
 
268
    CheckComRCReturnRC(autoCaller.rc());
263
269
 
264
 
    AutoWriteLock alock (this);
 
270
    AutoWriteLock alock(this);
265
271
 
266
272
    CHECK_CONSOLE_DRV (mpDrv);
267
273
 
269
275
    ComAssertRet (mParent->getVMMDev()->getVMMDevPort(), E_FAIL);
270
276
 
271
277
    uint32_t mouseCaps;
 
278
    LogRel3(("%s: x=%d, y=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
 
279
             x, y, dz, dw));
272
280
    mParent->getVMMDev()->getVMMDevPort()
273
281
        ->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(),
274
282
                                    &mouseCaps);
277
285
     * to use absolute coordinates. If the VMM device isn't
278
286
     * aware of that yet, tell it.
279
287
     */
280
 
    if (!(mouseCaps & VMMDEV_MOUSEHOSTWANTSABS))
 
288
    if (!(mouseCaps & VMMDEV_MOUSE_HOST_CAN_ABSOLUTE))
281
289
    {
282
290
        mParent->getVMMDev()->getVMMDevPort()->pfnSetMouseCapabilities(
283
291
            mParent->getVMMDev()->getVMMDevPort(),
284
 
            uHostCaps | VMMDEV_MOUSEHOSTWANTSABS);
 
292
            uHostCaps | VMMDEV_MOUSE_HOST_CAN_ABSOLUTE);
285
293
    }
286
294
 
287
295
    Display *pDisplay = mParent->getDisplay();
306
314
    ComAssertRCRet (vrc, E_FAIL);
307
315
 
308
316
    // Check if the guest actually wants absolute mouse positions.
309
 
    if (mouseCaps & VMMDEV_MOUSEGUESTWANTSABS)
 
317
    if (mouseCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
310
318
    {
311
319
        uint32_t fButtons = 0;
312
320
        if (buttonState & MouseButtonState_LeftButton)
315
323
            fButtons |= PDMIMOUSEPORT_BUTTON_RIGHT;
316
324
        if (buttonState & MouseButtonState_MiddleButton)
317
325
            fButtons |= PDMIMOUSEPORT_BUTTON_MIDDLE;
 
326
        if (buttonState & MouseButtonState_XButton1)
 
327
            fButtons |= PDMIMOUSEPORT_BUTTON_X1;
 
328
        if (buttonState & MouseButtonState_XButton2)
 
329
            fButtons |= PDMIMOUSEPORT_BUTTON_X2;
318
330
 
319
331
        /* This is a workaround.  In order to alert the Guest Additions to the
320
332
         * fact that the absolute pointer position has changed, we send a
323
335
         * see if the position has really changed since the last mouse event.
324
336
         */
325
337
        if (   ((mLastAbsX == mouseXAbs) && (mLastAbsY == mouseYAbs))
326
 
            || (mouseCaps & VBOXGUEST_MOUSE_GUEST_USES_VMMDEV))
327
 
            vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, 0, 0, dz,
 
338
            || (mouseCaps & VMMDEV_MOUSE_GUEST_USES_VMMDEV))
 
339
            vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, 0, 0, dz, dw,
328
340
                                              fButtons);
329
341
        else
330
 
            vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, 1, 1, dz,
 
342
            vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, 1, 1, dz, dw,
331
343
                                              fButtons);
332
344
        mLastAbsX = mouseXAbs;
333
345
        mLastAbsY = mouseYAbs;
334
 
        if (RT_FAILURE (vrc))
 
346
        if (RT_FAILURE(vrc))
335
347
            rc = setError (VBOX_E_IPRT_ERROR,
336
348
                tr ("Could not send the mouse event to the virtual mouse (%Rrc)"),
337
349
                    vrc);
388
400
/**
389
401
 * Construct a mouse driver instance.
390
402
 *
391
 
 * @returns VBox status.
392
 
 * @param   pDrvIns     The driver instance data.
393
 
 *                      If the registration structure is needed, pDrvIns->pDrvReg points to it.
394
 
 * @param   pCfgHandle  Configuration node handle for the driver. Use this to obtain the configuration
395
 
 *                      of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
396
 
 *                      iInstance it's expected to be used a bit in this function.
 
403
 * @copydoc FNPDMDRVCONSTRUCT
397
404
 */
398
 
DECLCALLBACK(int) Mouse::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
 
405
DECLCALLBACK(int) Mouse::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
399
406
{
400
407
    PDRVMAINMOUSE pData = PDMINS_2_DATA(pDrvIns, PDRVMAINMOUSE);
401
408
    LogFlow(("drvMainMouse_Construct: iInstance=%d\n", pDrvIns->iInstance));
405
412
     */
406
413
    if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
407
414
        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
408
 
    PPDMIBASE pBaseIgnore;
409
 
    int rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBaseIgnore);
410
 
    if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
411
 
    {
412
 
        AssertMsgFailed(("Configuration error: Not possible to attach anything to this driver!\n"));
413
 
        return VERR_PDM_DRVINS_NO_ATTACH;
414
 
    }
 
415
    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER, 
 
416
                    ("Configuration error: Not possible to attach anything to this driver!\n"),
 
417
                    VERR_PDM_DRVINS_NO_ATTACH);
415
418
 
416
419
    /*
417
420
     * IBase.
432
435
     * Get the Mouse object pointer and update the mpDrv member.
433
436
     */
434
437
    void *pv;
435
 
    rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
 
438
    int rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
436
439
    if (RT_FAILURE(rc))
437
440
    {
438
441
        AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
478
481
    NULL,
479
482
    /* pfnResume */
480
483
    NULL,
 
484
    /* pfnAttach */
 
485
    NULL,
481
486
    /* pfnDetach */
482
 
    NULL
 
487
    NULL, 
 
488
    /* pfnPowerOff */
 
489
    NULL, 
 
490
    /* pfnSoftReset */
 
491
    NULL,
 
492
    /* u32EndVersion */
 
493
    PDM_DRVREG_VERSION
483
494
};
484
495
/* vi: set tabstop=4 shiftwidth=4 expandtab: */