VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/MouseImpl.cpp@ 82968

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.4 KB
Line 
1/* $Id: MouseImpl.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#define LOG_GROUP LOG_GROUP_MAIN_MOUSE
19#include "LoggingNew.h"
20
21#include <iprt/cpp/utils.h>
22
23#include "MouseImpl.h"
24#include "DisplayImpl.h"
25#include "VMMDev.h"
26#include "MousePointerShapeWrap.h"
27
28#include <VBox/vmm/pdmdrv.h>
29#include <VBox/VMMDev.h>
30#include <VBox/err.h>
31
32
33class ATL_NO_VTABLE MousePointerShape:
34 public MousePointerShapeWrap
35{
36public:
37
38 DECLARE_EMPTY_CTOR_DTOR(MousePointerShape)
39
40 HRESULT FinalConstruct();
41 void FinalRelease();
42
43 /* Public initializer/uninitializer for internal purposes only. */
44 HRESULT init(ComObjPtr<Mouse> pMouse,
45 bool fVisible, bool fAlpha,
46 uint32_t hotX, uint32_t hotY,
47 uint32_t width, uint32_t height,
48 const uint8_t *pu8Shape, uint32_t cbShape);
49 void uninit();
50
51private:
52 // wrapped IMousePointerShape properties
53 virtual HRESULT getVisible(BOOL *aVisible);
54 virtual HRESULT getAlpha(BOOL *aAlpha);
55 virtual HRESULT getHotX(ULONG *aHotX);
56 virtual HRESULT getHotY(ULONG *aHotY);
57 virtual HRESULT getWidth(ULONG *aWidth);
58 virtual HRESULT getHeight(ULONG *aHeight);
59 virtual HRESULT getShape(std::vector<BYTE> &aShape);
60
61 struct Data
62 {
63 ComObjPtr<Mouse> pMouse;
64 bool fVisible;
65 bool fAlpha;
66 uint32_t hotX;
67 uint32_t hotY;
68 uint32_t width;
69 uint32_t height;
70 std::vector<BYTE> shape;
71 };
72
73 Data m;
74};
75
76/*
77 * MousePointerShape implementation.
78 */
79DEFINE_EMPTY_CTOR_DTOR(MousePointerShape)
80
81HRESULT MousePointerShape::FinalConstruct()
82{
83 return BaseFinalConstruct();
84}
85
86void MousePointerShape::FinalRelease()
87{
88 uninit();
89
90 BaseFinalRelease();
91}
92
93HRESULT MousePointerShape::init(ComObjPtr<Mouse> pMouse,
94 bool fVisible, bool fAlpha,
95 uint32_t hotX, uint32_t hotY,
96 uint32_t width, uint32_t height,
97 const uint8_t *pu8Shape, uint32_t cbShape)
98{
99 LogFlowThisFunc(("v %d, a %d, h %d,%d, %dx%d, cb %d\n",
100 fVisible, fAlpha, hotX, hotY, width, height, cbShape));
101
102 /* Enclose the state transition NotReady->InInit->Ready */
103 AutoInitSpan autoInitSpan(this);
104 AssertReturn(autoInitSpan.isOk(), E_FAIL);
105
106 m.pMouse = pMouse;
107 m.fVisible = fVisible;
108 m.fAlpha = fAlpha;
109 m.hotX = hotX;
110 m.hotY = hotY;
111 m.width = width;
112 m.height = height;
113 m.shape.resize(cbShape);
114 if (cbShape)
115 {
116 memcpy(&m.shape.front(), pu8Shape, cbShape);
117 }
118
119 /* Confirm a successful initialization */
120 autoInitSpan.setSucceeded();
121
122 return S_OK;
123}
124
125void MousePointerShape::uninit()
126{
127 LogFlowThisFunc(("\n"));
128
129 /* Enclose the state transition Ready->InUninit->NotReady */
130 AutoUninitSpan autoUninitSpan(this);
131 if (autoUninitSpan.uninitDone())
132 return;
133
134 m.pMouse.setNull();
135}
136
137HRESULT MousePointerShape::getVisible(BOOL *aVisible)
138{
139 *aVisible = m.fVisible;
140 return S_OK;
141}
142
143HRESULT MousePointerShape::getAlpha(BOOL *aAlpha)
144{
145 *aAlpha = m.fAlpha;
146 return S_OK;
147}
148
149HRESULT MousePointerShape::getHotX(ULONG *aHotX)
150{
151 *aHotX = m.hotX;
152 return S_OK;
153}
154
155HRESULT MousePointerShape::getHotY(ULONG *aHotY)
156{
157 *aHotY = m.hotY;
158 return S_OK;
159}
160
161HRESULT MousePointerShape::getWidth(ULONG *aWidth)
162{
163 *aWidth = m.width;
164 return S_OK;
165}
166
167HRESULT MousePointerShape::getHeight(ULONG *aHeight)
168{
169 *aHeight = m.height;
170 return S_OK;
171}
172
173HRESULT MousePointerShape::getShape(std::vector<BYTE> &aShape)
174{
175 aShape.resize(m.shape.size());
176 if (m.shape.size())
177 memcpy(&aShape.front(), &m.shape.front(), aShape.size());
178 return S_OK;
179}
180
181
182/** @name Mouse device capabilities bitfield
183 * @{ */
184enum
185{
186 /** The mouse device can do relative reporting */
187 MOUSE_DEVCAP_RELATIVE = 1,
188 /** The mouse device can do absolute reporting */
189 MOUSE_DEVCAP_ABSOLUTE = 2,
190 /** The mouse device can do absolute reporting */
191 MOUSE_DEVCAP_MULTI_TOUCH = 4
192};
193/** @} */
194
195
196/**
197 * Mouse driver instance data.
198 */
199struct DRVMAINMOUSE
200{
201 /** Pointer to the mouse object. */
202 Mouse *pMouse;
203 /** Pointer to the driver instance structure. */
204 PPDMDRVINS pDrvIns;
205 /** Pointer to the mouse port interface of the driver/device above us. */
206 PPDMIMOUSEPORT pUpPort;
207 /** Our mouse connector interface. */
208 PDMIMOUSECONNECTOR IConnector;
209 /** The capabilities of this device. */
210 uint32_t u32DevCaps;
211};
212
213
214// constructor / destructor
215/////////////////////////////////////////////////////////////////////////////
216
217Mouse::Mouse()
218 : mParent(NULL)
219{
220}
221
222Mouse::~Mouse()
223{
224}
225
226
227HRESULT Mouse::FinalConstruct()
228{
229 RT_ZERO(mpDrv);
230 RT_ZERO(mPointerData);
231 mcLastX = 0x8000;
232 mcLastY = 0x8000;
233 mfLastButtons = 0;
234 mfVMMDevGuestCaps = 0;
235 return BaseFinalConstruct();
236}
237
238void Mouse::FinalRelease()
239{
240 uninit();
241 BaseFinalRelease();
242}
243
244// public methods only for internal purposes
245/////////////////////////////////////////////////////////////////////////////
246
247/**
248 * Initializes the mouse object.
249 *
250 * @returns COM result indicator
251 * @param parent handle of our parent object
252 */
253HRESULT Mouse::init (ConsoleMouseInterface *parent)
254{
255 LogFlowThisFunc(("\n"));
256
257 ComAssertRet(parent, E_INVALIDARG);
258
259 /* Enclose the state transition NotReady->InInit->Ready */
260 AutoInitSpan autoInitSpan(this);
261 AssertReturn(autoInitSpan.isOk(), E_FAIL);
262
263 unconst(mParent) = parent;
264
265 unconst(mEventSource).createObject();
266 HRESULT rc = mEventSource->init();
267 AssertComRCReturnRC(rc);
268 mMouseEvent.init(mEventSource, VBoxEventType_OnGuestMouse,
269 0, 0, 0, 0, 0, 0);
270
271 /* Confirm a successful initialization */
272 autoInitSpan.setSucceeded();
273
274 return S_OK;
275}
276
277/**
278 * Uninitializes the instance and sets the ready flag to FALSE.
279 * Called either from FinalRelease() or by the parent when it gets destroyed.
280 */
281void Mouse::uninit()
282{
283 LogFlowThisFunc(("\n"));
284
285 /* Enclose the state transition Ready->InUninit->NotReady */
286 AutoUninitSpan autoUninitSpan(this);
287 if (autoUninitSpan.uninitDone())
288 return;
289
290 for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
291 {
292 if (mpDrv[i])
293 mpDrv[i]->pMouse = NULL;
294 mpDrv[i] = NULL;
295 }
296
297 mPointerShape.setNull();
298
299 RTMemFree(mPointerData.pu8Shape);
300 mPointerData.pu8Shape = NULL;
301 mPointerData.cbShape = 0;
302
303 mMouseEvent.uninit();
304 unconst(mEventSource).setNull();
305 unconst(mParent) = NULL;
306}
307
308void Mouse::updateMousePointerShape(bool fVisible, bool fAlpha,
309 uint32_t hotX, uint32_t hotY,
310 uint32_t width, uint32_t height,
311 const uint8_t *pu8Shape, uint32_t cbShape)
312{
313 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
314
315 RTMemFree(mPointerData.pu8Shape);
316 mPointerData.pu8Shape = NULL;
317 mPointerData.cbShape = 0;
318
319 mPointerData.fVisible = fVisible;
320 mPointerData.fAlpha = fAlpha;
321 mPointerData.hotX = hotX;
322 mPointerData.hotY = hotY;
323 mPointerData.width = width;
324 mPointerData.height = height;
325 if (cbShape)
326 {
327 mPointerData.pu8Shape = (uint8_t *)RTMemDup(pu8Shape, cbShape);
328 if (mPointerData.pu8Shape)
329 {
330 mPointerData.cbShape = cbShape;
331 }
332 }
333
334 mPointerShape.setNull();
335}
336
337// IMouse properties
338/////////////////////////////////////////////////////////////////////////////
339
340/** Report the front-end's mouse handling capabilities to the VMM device and
341 * thus to the guest.
342 * @note all calls out of this object are made with no locks held! */
343HRESULT Mouse::i_updateVMMDevMouseCaps(uint32_t fCapsAdded,
344 uint32_t fCapsRemoved)
345{
346 VMMDevMouseInterface *pVMMDev = mParent->i_getVMMDevMouseInterface();
347 if (!pVMMDev)
348 return E_FAIL; /* No assertion, as the front-ends can send events
349 * at all sorts of inconvenient times. */
350 DisplayMouseInterface *pDisplay = mParent->i_getDisplayMouseInterface();
351 if (pDisplay == NULL)
352 return E_FAIL;
353 PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
354 if (!pVMMDevPort)
355 return E_FAIL; /* same here */
356
357 int rc = pVMMDevPort->pfnUpdateMouseCapabilities(pVMMDevPort, fCapsAdded,
358 fCapsRemoved);
359 if (RT_FAILURE(rc))
360 return E_FAIL;
361 return pDisplay->i_reportHostCursorCapabilities(fCapsAdded, fCapsRemoved);
362}
363
364/**
365 * Returns whether the currently active device portfolio can accept absolute
366 * mouse events.
367 *
368 * @returns COM status code
369 * @param aAbsoluteSupported address of result variable
370 */
371HRESULT Mouse::getAbsoluteSupported(BOOL *aAbsoluteSupported)
372{
373 *aAbsoluteSupported = i_supportsAbs();
374 return S_OK;
375}
376
377/**
378 * Returns whether the currently active device portfolio can accept relative
379 * mouse events.
380 *
381 * @returns COM status code
382 * @param aRelativeSupported address of result variable
383 */
384HRESULT Mouse::getRelativeSupported(BOOL *aRelativeSupported)
385{
386 *aRelativeSupported = i_supportsRel();
387 return S_OK;
388}
389
390/**
391 * Returns whether the currently active device portfolio can accept multi-touch
392 * mouse events.
393 *
394 * @returns COM status code
395 * @param aMultiTouchSupported address of result variable
396 */
397HRESULT Mouse::getMultiTouchSupported(BOOL *aMultiTouchSupported)
398{
399 *aMultiTouchSupported = i_supportsMT();
400 return S_OK;
401}
402
403/**
404 * Returns whether the guest can currently switch to drawing the mouse cursor
405 * itself if it is asked to by the front-end.
406 *
407 * @returns COM status code
408 * @param aNeedsHostCursor address of result variable
409 */
410HRESULT Mouse::getNeedsHostCursor(BOOL *aNeedsHostCursor)
411{
412 *aNeedsHostCursor = i_guestNeedsHostCursor();
413 return S_OK;
414}
415
416HRESULT Mouse::getPointerShape(ComPtr<IMousePointerShape> &aPointerShape)
417{
418 HRESULT hr = S_OK;
419
420 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
421
422 if (mPointerShape.isNull())
423 {
424 ComObjPtr<MousePointerShape> obj;
425 hr = obj.createObject();
426 if (SUCCEEDED(hr))
427 {
428 hr = obj->init(this, mPointerData.fVisible, mPointerData.fAlpha,
429 mPointerData.hotX, mPointerData.hotY,
430 mPointerData.width, mPointerData.height,
431 mPointerData.pu8Shape, mPointerData.cbShape);
432 }
433
434 if (SUCCEEDED(hr))
435 {
436 mPointerShape = obj;
437 }
438 }
439
440 if (SUCCEEDED(hr))
441 {
442 aPointerShape = mPointerShape;
443 }
444
445 return hr;
446}
447
448// IMouse methods
449/////////////////////////////////////////////////////////////////////////////
450
451/** Converts a bitfield containing information about mouse buttons currently
452 * held down from the format used by the front-end to the format used by PDM
453 * and the emulated pointing devices. */
454static uint32_t i_mouseButtonsToPDM(LONG buttonState)
455{
456 uint32_t fButtons = 0;
457 if (buttonState & MouseButtonState_LeftButton)
458 fButtons |= PDMIMOUSEPORT_BUTTON_LEFT;
459 if (buttonState & MouseButtonState_RightButton)
460 fButtons |= PDMIMOUSEPORT_BUTTON_RIGHT;
461 if (buttonState & MouseButtonState_MiddleButton)
462 fButtons |= PDMIMOUSEPORT_BUTTON_MIDDLE;
463 if (buttonState & MouseButtonState_XButton1)
464 fButtons |= PDMIMOUSEPORT_BUTTON_X1;
465 if (buttonState & MouseButtonState_XButton2)
466 fButtons |= PDMIMOUSEPORT_BUTTON_X2;
467 return fButtons;
468}
469
470HRESULT Mouse::getEventSource(ComPtr<IEventSource> &aEventSource)
471{
472 // no need to lock - lifetime constant
473 mEventSource.queryInterfaceTo(aEventSource.asOutParam());
474 return S_OK;
475}
476
477/**
478 * Send a relative pointer event to the relative device we deem most
479 * appropriate.
480 *
481 * @returns COM status code
482 */
483HRESULT Mouse::i_reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
484 int32_t dw, uint32_t fButtons)
485{
486 if (dx || dy || dz || dw || fButtons != mfLastButtons)
487 {
488 PPDMIMOUSEPORT pUpPort = NULL;
489 {
490 AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
491
492 for (unsigned i = 0; !pUpPort && i < MOUSE_MAX_DEVICES; ++i)
493 {
494 if (mpDrv[i] && (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_RELATIVE))
495 pUpPort = mpDrv[i]->pUpPort;
496 }
497 }
498 if (!pUpPort)
499 return S_OK;
500
501 int vrc = pUpPort->pfnPutEvent(pUpPort, dx, dy, dz, dw, fButtons);
502
503 if (RT_FAILURE(vrc))
504 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
505 tr("Could not send the mouse event to the virtual mouse (%Rrc)"),
506 vrc);
507 mfLastButtons = fButtons;
508 }
509 return S_OK;
510}
511
512
513/**
514 * Send an absolute pointer event to the emulated absolute device we deem most
515 * appropriate.
516 *
517 * @returns COM status code
518 */
519HRESULT Mouse::i_reportAbsEventToMouseDev(int32_t x, int32_t y,
520 int32_t dz, int32_t dw, uint32_t fButtons)
521{
522 if ( x < VMMDEV_MOUSE_RANGE_MIN
523 || x > VMMDEV_MOUSE_RANGE_MAX)
524 return S_OK;
525 if ( y < VMMDEV_MOUSE_RANGE_MIN
526 || y > VMMDEV_MOUSE_RANGE_MAX)
527 return S_OK;
528 if ( x != mcLastX || y != mcLastY
529 || dz || dw || fButtons != mfLastButtons)
530 {
531 PPDMIMOUSEPORT pUpPort = NULL;
532 {
533 AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
534
535 for (unsigned i = 0; !pUpPort && i < MOUSE_MAX_DEVICES; ++i)
536 {
537 if (mpDrv[i] && (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_ABSOLUTE))
538 pUpPort = mpDrv[i]->pUpPort;
539 }
540 }
541 if (!pUpPort)
542 return S_OK;
543
544 int vrc = pUpPort->pfnPutEventAbs(pUpPort, x, y, dz,
545 dw, fButtons);
546 if (RT_FAILURE(vrc))
547 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
548 tr("Could not send the mouse event to the virtual mouse (%Rrc)"),
549 vrc);
550 mfLastButtons = fButtons;
551
552 }
553 return S_OK;
554}
555
556HRESULT Mouse::i_reportMultiTouchEventToDevice(uint8_t cContacts,
557 const uint64_t *pau64Contacts,
558 uint32_t u32ScanTime)
559{
560 HRESULT hrc = S_OK;
561
562 PPDMIMOUSEPORT pUpPort = NULL;
563 {
564 AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
565
566 unsigned i;
567 for (i = 0; i < MOUSE_MAX_DEVICES; ++i)
568 {
569 if ( mpDrv[i]
570 && (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_MULTI_TOUCH))
571 {
572 pUpPort = mpDrv[i]->pUpPort;
573 break;
574 }
575 }
576 }
577
578 if (pUpPort)
579 {
580 int vrc = pUpPort->pfnPutEventMultiTouch(pUpPort, cContacts, pau64Contacts, u32ScanTime);
581 if (RT_FAILURE(vrc))
582 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
583 tr("Could not send the multi-touch event to the virtual device (%Rrc)"),
584 vrc);
585 }
586 else
587 {
588 hrc = E_UNEXPECTED;
589 }
590
591 return hrc;
592}
593
594
595/**
596 * Send an absolute position event to the VMM device.
597 * @note all calls out of this object are made with no locks held!
598 *
599 * @returns COM status code
600 */
601HRESULT Mouse::i_reportAbsEventToVMMDev(int32_t x, int32_t y)
602{
603 VMMDevMouseInterface *pVMMDev = mParent->i_getVMMDevMouseInterface();
604 ComAssertRet(pVMMDev, E_FAIL);
605 PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
606 ComAssertRet(pVMMDevPort, E_FAIL);
607
608 if (x != mcLastX || y != mcLastY)
609 {
610 int vrc = pVMMDevPort->pfnSetAbsoluteMouse(pVMMDevPort,
611 x, y);
612 if (RT_FAILURE(vrc))
613 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
614 tr("Could not send the mouse event to the virtual mouse (%Rrc)"),
615 vrc);
616 }
617 return S_OK;
618}
619
620
621/**
622 * Send an absolute pointer event to a pointing device (the VMM device if
623 * possible or whatever emulated absolute device seems best to us if not).
624 *
625 * @returns COM status code
626 */
627HRESULT Mouse::i_reportAbsEventToInputDevices(int32_t x, int32_t y, int32_t dz, int32_t dw, uint32_t fButtons,
628 bool fUsesVMMDevEvent)
629{
630 HRESULT rc;
631 /** If we are using the VMMDev to report absolute position but without
632 * VMMDev IRQ support then we need to send a small "jiggle" to the emulated
633 * relative mouse device to alert the guest to changes. */
634 LONG cJiggle = 0;
635
636 if (i_vmmdevCanAbs())
637 {
638 /*
639 * Send the absolute mouse position to the VMM device.
640 */
641 if (x != mcLastX || y != mcLastY)
642 {
643 rc = i_reportAbsEventToVMMDev(x, y);
644 cJiggle = !fUsesVMMDevEvent;
645 }
646 rc = i_reportRelEventToMouseDev(cJiggle, 0, dz, dw, fButtons);
647 }
648 else
649 rc = i_reportAbsEventToMouseDev(x, y, dz, dw, fButtons);
650
651 mcLastX = x;
652 mcLastY = y;
653 return rc;
654}
655
656
657/**
658 * Send an absolute position event to the display device.
659 * @note all calls out of this object are made with no locks held!
660 * @param x Cursor X position in pixels relative to the first screen, where
661 * (1, 1) is the upper left corner.
662 * @param y Cursor Y position in pixels relative to the first screen, where
663 * (1, 1) is the upper left corner.
664 */
665HRESULT Mouse::i_reportAbsEventToDisplayDevice(int32_t x, int32_t y)
666{
667 DisplayMouseInterface *pDisplay = mParent->i_getDisplayMouseInterface();
668 ComAssertRet(pDisplay, E_FAIL);
669
670 if (x != mcLastX || y != mcLastY)
671 {
672 pDisplay->i_reportHostCursorPosition(x - 1, y - 1, false);
673 }
674 return S_OK;
675}
676
677
678void Mouse::i_fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw,
679 LONG fButtons)
680{
681 /* If mouse button is pressed, we generate new event, to avoid reusable events coalescing and thus
682 dropping key press events */
683 GuestMouseEventMode_T mode;
684 if (fAbsolute)
685 mode = GuestMouseEventMode_Absolute;
686 else
687 mode = GuestMouseEventMode_Relative;
688
689 if (fButtons != 0)
690 {
691 VBoxEventDesc evDesc;
692 evDesc.init(mEventSource, VBoxEventType_OnGuestMouse, mode, x, y,
693 dz, dw, fButtons);
694 evDesc.fire(0);
695 }
696 else
697 {
698 mMouseEvent.reinit(VBoxEventType_OnGuestMouse, mode, x, y, dz, dw,
699 fButtons);
700 mMouseEvent.fire(0);
701 }
702}
703
704void Mouse::i_fireMultiTouchEvent(uint8_t cContacts,
705 const LONG64 *paContacts,
706 uint32_t u32ScanTime)
707{
708 com::SafeArray<SHORT> xPositions(cContacts);
709 com::SafeArray<SHORT> yPositions(cContacts);
710 com::SafeArray<USHORT> contactIds(cContacts);
711 com::SafeArray<USHORT> contactFlags(cContacts);
712
713 uint8_t i;
714 for (i = 0; i < cContacts; i++)
715 {
716 uint32_t u32Lo = RT_LO_U32(paContacts[i]);
717 uint32_t u32Hi = RT_HI_U32(paContacts[i]);
718 xPositions[i] = (int16_t)u32Lo;
719 yPositions[i] = (int16_t)(u32Lo >> 16);
720 contactIds[i] = RT_BYTE1(u32Hi);
721 contactFlags[i] = RT_BYTE2(u32Hi);
722 }
723
724 VBoxEventDesc evDesc;
725 evDesc.init(mEventSource, VBoxEventType_OnGuestMultiTouch,
726 cContacts, ComSafeArrayAsInParam(xPositions), ComSafeArrayAsInParam(yPositions),
727 ComSafeArrayAsInParam(contactIds), ComSafeArrayAsInParam(contactFlags), u32ScanTime);
728 evDesc.fire(0);
729}
730
731/**
732 * Send a relative mouse event to the guest.
733 * @note the VMMDev capability change is so that the guest knows we are sending
734 * real events over the PS/2 device and not dummy events to signal the
735 * arrival of new absolute pointer data
736 *
737 * @returns COM status code
738 * @param dx X movement.
739 * @param dy Y movement.
740 * @param dz Z movement.
741 * @param dw Mouse wheel movement.
742 * @param aButtonState The mouse button state.
743 */
744HRESULT Mouse::putMouseEvent(LONG dx, LONG dy, LONG dz, LONG dw,
745 LONG aButtonState)
746{
747 HRESULT rc;
748 uint32_t fButtonsAdj;
749
750 LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
751 dx, dy, dz, dw));
752
753 fButtonsAdj = i_mouseButtonsToPDM(aButtonState);
754 /* Make sure that the guest knows that we are sending real movement
755 * events to the PS/2 device and not just dummy wake-up ones. */
756 i_updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE);
757 rc = i_reportRelEventToMouseDev(dx, dy, dz, dw, fButtonsAdj);
758
759 i_fireMouseEvent(false, dx, dy, dz, dw, aButtonState);
760
761 return rc;
762}
763
764/**
765 * Convert an (X, Y) value pair in screen co-ordinates (starting from 1) to a
766 * value from VMMDEV_MOUSE_RANGE_MIN to VMMDEV_MOUSE_RANGE_MAX. Sets the
767 * optional validity value to false if the pair is not on an active screen and
768 * to true otherwise.
769 * @note since guests with recent versions of X.Org use a different method
770 * to everyone else to map the valuator value to a screen pixel (they
771 * multiply by the screen dimension, do a floating point divide by
772 * the valuator maximum and round the result, while everyone else
773 * does truncating integer operations) we adjust the value we send
774 * so that it maps to the right pixel both when the result is rounded
775 * and when it is truncated.
776 *
777 * @returns COM status value
778 */
779HRESULT Mouse::i_convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj,
780 bool *pfValid)
781{
782 AssertPtrReturn(pxAdj, E_POINTER);
783 AssertPtrReturn(pyAdj, E_POINTER);
784 AssertPtrNullReturn(pfValid, E_POINTER);
785 DisplayMouseInterface *pDisplay = mParent->i_getDisplayMouseInterface();
786 ComAssertRet(pDisplay, E_FAIL);
787 /** The amount to add to the result (multiplied by the screen width/height)
788 * to compensate for differences in guest methods for mapping back to
789 * pixels */
790 enum { ADJUST_RANGE = - 3 * VMMDEV_MOUSE_RANGE / 4 };
791
792 if (pfValid)
793 *pfValid = true;
794 if (!(mfVMMDevGuestCaps & VMMDEV_MOUSE_NEW_PROTOCOL) && !pDisplay->i_isInputMappingSet())
795 {
796 ULONG displayWidth, displayHeight;
797 ULONG ulDummy;
798 LONG lDummy;
799 /* Takes the display lock */
800 HRESULT rc = pDisplay->i_getScreenResolution(0, &displayWidth,
801 &displayHeight, &ulDummy, &lDummy, &lDummy);
802 if (FAILED(rc))
803 return rc;
804
805 *pxAdj = displayWidth ? (x * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
806 / (LONG) displayWidth: 0;
807 *pyAdj = displayHeight ? (y * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
808 / (LONG) displayHeight: 0;
809 }
810 else
811 {
812 int32_t x1, y1, x2, y2;
813 /* Takes the display lock */
814 pDisplay->i_getFramebufferDimensions(&x1, &y1, &x2, &y2);
815 *pxAdj = x1 < x2 ? ((x - x1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
816 / (x2 - x1) : 0;
817 *pyAdj = y1 < y2 ? ((y - y1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
818 / (y2 - y1) : 0;
819 if ( *pxAdj < VMMDEV_MOUSE_RANGE_MIN
820 || *pxAdj > VMMDEV_MOUSE_RANGE_MAX
821 || *pyAdj < VMMDEV_MOUSE_RANGE_MIN
822 || *pyAdj > VMMDEV_MOUSE_RANGE_MAX)
823 if (pfValid)
824 *pfValid = false;
825 }
826 return S_OK;
827}
828
829
830/**
831 * Send an absolute mouse event to the VM. This requires either VirtualBox-
832 * specific drivers installed in the guest or absolute pointing device
833 * emulation.
834 * @note the VMMDev capability change is so that the guest knows we are sending
835 * dummy events over the PS/2 device to signal the arrival of new
836 * absolute pointer data, and not pointer real movement data
837 * @note all calls out of this object are made with no locks held!
838 *
839 * @returns COM status code
840 * @param x X position (pixel), starting from 1
841 * @param y Y position (pixel), starting from 1
842 * @param dz Z movement
843 * @param dw mouse wheel movement
844 * @param aButtonState The mouse button state
845 */
846HRESULT Mouse::putMouseEventAbsolute(LONG x, LONG y, LONG dz, LONG dw,
847 LONG aButtonState)
848{
849 LogRel3(("%s: x=%d, y=%d, dz=%d, dw=%d, fButtons=0x%x\n",
850 __PRETTY_FUNCTION__, x, y, dz, dw, aButtonState));
851
852 DisplayMouseInterface *pDisplay = mParent->i_getDisplayMouseInterface();
853 ComAssertRet(pDisplay, E_FAIL);
854 int32_t xAdj, yAdj;
855 uint32_t fButtonsAdj;
856 bool fValid;
857
858 /* If we are doing old-style (IRQ-less) absolute reporting to the VMM
859 * device then make sure the guest is aware of it, so that it knows to
860 * ignore relative movement on the PS/2 device. */
861 i_updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE, 0);
862 /* Detect out-of-range. */
863 if (x == 0x7FFFFFFF && y == 0x7FFFFFFF)
864 {
865 pDisplay->i_reportHostCursorPosition(0, 0, true);
866 return S_OK;
867 }
868 /* Detect "report-only" (-1, -1). This is not ideal, as in theory the
869 * front-end could be sending negative values relative to the primary
870 * screen. */
871 if (x == -1 && y == -1)
872 return S_OK;
873 /** @todo the front end should do this conversion to avoid races */
874 /** @note Or maybe not... races are pretty inherent in everything done in
875 * this object and not really bad as far as I can see. */
876 HRESULT rc = i_convertDisplayRes(x, y, &xAdj, &yAdj, &fValid);
877 if (FAILED(rc)) return rc;
878
879 fButtonsAdj = i_mouseButtonsToPDM(aButtonState);
880 if (fValid)
881 {
882 rc = i_reportAbsEventToInputDevices(xAdj, yAdj, dz, dw, fButtonsAdj,
883 RT_BOOL(mfVMMDevGuestCaps & VMMDEV_MOUSE_NEW_PROTOCOL));
884 if (FAILED(rc)) return rc;
885
886 i_fireMouseEvent(true, x, y, dz, dw, aButtonState);
887 }
888 rc = i_reportAbsEventToDisplayDevice(x, y);
889
890 return rc;
891}
892
893/**
894 * Send a multi-touch event. This requires multi-touch pointing device emulation.
895 * @note all calls out of this object are made with no locks held!
896 *
897 * @returns COM status code.
898 * @param aCount Number of contacts.
899 * @param aContacts Information about each contact.
900 * @param aScanTime Timestamp.
901 */
902HRESULT Mouse::putEventMultiTouch(LONG aCount,
903 const std::vector<LONG64> &aContacts,
904 ULONG aScanTime)
905{
906 LogRel3(("%s: aCount %d(actual %d), aScanTime %u\n",
907 __FUNCTION__, aCount, aContacts.size(), aScanTime));
908
909 HRESULT rc = S_OK;
910
911 if ((LONG)aContacts.size() >= aCount)
912 {
913 const LONG64 *paContacts = aCount > 0? &aContacts.front(): NULL;
914
915 rc = i_putEventMultiTouch(aCount, paContacts, aScanTime);
916 }
917 else
918 {
919 rc = E_INVALIDARG;
920 }
921
922 return rc;
923}
924
925/**
926 * Send a multi-touch event. Version for scripting languages.
927 *
928 * @returns COM status code.
929 * @param aCount Number of contacts.
930 * @param aContacts Information about each contact.
931 * @param aScanTime Timestamp.
932 */
933HRESULT Mouse::putEventMultiTouchString(LONG aCount,
934 const com::Utf8Str &aContacts,
935 ULONG aScanTime)
936{
937 /** @todo implement: convert the string to LONG64 array and call putEventMultiTouch. */
938 NOREF(aCount);
939 NOREF(aContacts);
940 NOREF(aScanTime);
941 return E_NOTIMPL;
942}
943
944
945// private methods
946/////////////////////////////////////////////////////////////////////////////
947
948/* Used by PutEventMultiTouch and PutEventMultiTouchString. */
949HRESULT Mouse::i_putEventMultiTouch(LONG aCount,
950 const LONG64 *paContacts,
951 ULONG aScanTime)
952{
953 if (aCount >= 256)
954 {
955 return E_INVALIDARG;
956 }
957
958 DisplayMouseInterface *pDisplay = mParent->i_getDisplayMouseInterface();
959 ComAssertRet(pDisplay, E_FAIL);
960
961 /* Touch events are mapped to the primary monitor, because the emulated USB
962 * touchscreen device is associated with one (normally the primary) screen in the guest.
963 */
964 ULONG uScreenId = 0;
965
966 ULONG cWidth = 0;
967 ULONG cHeight = 0;
968 ULONG cBPP = 0;
969 LONG xOrigin = 0;
970 LONG yOrigin = 0;
971 HRESULT rc = pDisplay->i_getScreenResolution(uScreenId, &cWidth, &cHeight, &cBPP, &xOrigin, &yOrigin);
972 NOREF(cBPP);
973 ComAssertComRCRetRC(rc);
974
975 uint64_t* pau64Contacts = NULL;
976 uint8_t cContacts = 0;
977
978 /* Deliver 0 contacts too, touch device may use this to reset the state. */
979 if (aCount > 0)
980 {
981 /* Create a copy with converted coords. */
982 pau64Contacts = (uint64_t *)RTMemTmpAlloc(aCount * sizeof(uint64_t));
983 if (pau64Contacts)
984 {
985 int32_t x1 = xOrigin;
986 int32_t y1 = yOrigin;
987 int32_t x2 = x1 + cWidth;
988 int32_t y2 = y1 + cHeight;
989
990 LogRel3(("%s: screen [%d] %d,%d %d,%d\n",
991 __FUNCTION__, uScreenId, x1, y1, x2, y2));
992
993 LONG i;
994 for (i = 0; i < aCount; i++)
995 {
996 uint32_t u32Lo = RT_LO_U32(paContacts[i]);
997 uint32_t u32Hi = RT_HI_U32(paContacts[i]);
998 int32_t x = (int16_t)u32Lo;
999 int32_t y = (int16_t)(u32Lo >> 16);
1000 uint8_t contactId = RT_BYTE1(u32Hi);
1001 bool fInContact = (RT_BYTE2(u32Hi) & 0x1) != 0;
1002 bool fInRange = (RT_BYTE2(u32Hi) & 0x2) != 0;
1003
1004 LogRel3(("%s: [%d] %d,%d id %d, inContact %d, inRange %d\n",
1005 __FUNCTION__, i, x, y, contactId, fInContact, fInRange));
1006
1007 /* x1,y1 are inclusive and x2,y2 are exclusive,
1008 * while x,y start from 1 and are inclusive.
1009 */
1010 if (x <= x1 || x > x2 || y <= y1 || y > y2)
1011 {
1012 /* Out of range. Skip the contact. */
1013 continue;
1014 }
1015
1016 int32_t xAdj = x1 < x2? ((x - 1 - x1) * VMMDEV_MOUSE_RANGE) / (x2 - x1) : 0;
1017 int32_t yAdj = y1 < y2? ((y - 1 - y1) * VMMDEV_MOUSE_RANGE) / (y2 - y1) : 0;
1018
1019 bool fValid = ( xAdj >= VMMDEV_MOUSE_RANGE_MIN
1020 && xAdj <= VMMDEV_MOUSE_RANGE_MAX
1021 && yAdj >= VMMDEV_MOUSE_RANGE_MIN
1022 && yAdj <= VMMDEV_MOUSE_RANGE_MAX);
1023
1024 if (fValid)
1025 {
1026 uint8_t fu8 = (uint8_t)( (fInContact? 0x01: 0x00)
1027 | (fInRange? 0x02: 0x00));
1028 pau64Contacts[cContacts] = RT_MAKE_U64_FROM_U16((uint16_t)xAdj,
1029 (uint16_t)yAdj,
1030 RT_MAKE_U16(contactId, fu8),
1031 0);
1032 cContacts++;
1033 }
1034 }
1035 }
1036 else
1037 {
1038 rc = E_OUTOFMEMORY;
1039 }
1040 }
1041
1042 if (SUCCEEDED(rc))
1043 {
1044 rc = i_reportMultiTouchEventToDevice(cContacts, cContacts? pau64Contacts: NULL, (uint32_t)aScanTime);
1045
1046 /* Send the original contact information. */
1047 i_fireMultiTouchEvent(cContacts, cContacts? paContacts: NULL, (uint32_t)aScanTime);
1048 }
1049
1050 RTMemTmpFree(pau64Contacts);
1051
1052 return rc;
1053}
1054
1055
1056/** Does the guest currently rely on the host to draw the mouse cursor or
1057 * can it switch to doing it itself in software? */
1058bool Mouse::i_guestNeedsHostCursor(void)
1059{
1060 return RT_BOOL(mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
1061}
1062
1063
1064/** Check what sort of reporting can be done using the devices currently
1065 * enabled. Does not consider the VMM device.
1066 *
1067 * @param pfAbs supports absolute mouse coordinates.
1068 * @param pfRel supports relative mouse coordinates.
1069 * @param pfMT supports multitouch.
1070 */
1071void Mouse::i_getDeviceCaps(bool *pfAbs, bool *pfRel, bool *pfMT)
1072{
1073 bool fAbsDev = false;
1074 bool fRelDev = false;
1075 bool fMTDev = false;
1076
1077 AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
1078
1079 for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
1080 if (mpDrv[i])
1081 {
1082 if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_ABSOLUTE)
1083 fAbsDev = true;
1084 if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_RELATIVE)
1085 fRelDev = true;
1086 if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_MULTI_TOUCH)
1087 fMTDev = true;
1088 }
1089 if (pfAbs)
1090 *pfAbs = fAbsDev;
1091 if (pfRel)
1092 *pfRel = fRelDev;
1093 if (pfMT)
1094 *pfMT = fMTDev;
1095}
1096
1097
1098/** Does the VMM device currently support absolute reporting? */
1099bool Mouse::i_vmmdevCanAbs(void)
1100{
1101 bool fRelDev;
1102
1103 i_getDeviceCaps(NULL, &fRelDev, NULL);
1104 return (mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
1105 && fRelDev;
1106}
1107
1108
1109/** Does the VMM device currently support absolute reporting? */
1110bool Mouse::i_deviceCanAbs(void)
1111{
1112 bool fAbsDev;
1113
1114 i_getDeviceCaps(&fAbsDev, NULL, NULL);
1115 return fAbsDev;
1116}
1117
1118
1119/** Can we currently send relative events to the guest? */
1120bool Mouse::i_supportsRel(void)
1121{
1122 bool fRelDev;
1123
1124 i_getDeviceCaps(NULL, &fRelDev, NULL);
1125 return fRelDev;
1126}
1127
1128
1129/** Can we currently send absolute events to the guest? */
1130bool Mouse::i_supportsAbs(void)
1131{
1132 bool fAbsDev;
1133
1134 i_getDeviceCaps(&fAbsDev, NULL, NULL);
1135 return fAbsDev || i_vmmdevCanAbs();
1136}
1137
1138
1139/** Can we currently send absolute events to the guest? */
1140bool Mouse::i_supportsMT(void)
1141{
1142 bool fMTDev;
1143
1144 i_getDeviceCaps(NULL, NULL, &fMTDev);
1145 return fMTDev;
1146}
1147
1148
1149/** Check what sort of reporting can be done using the devices currently
1150 * enabled (including the VMM device) and notify the guest and the front-end.
1151 */
1152void Mouse::i_sendMouseCapsNotifications(void)
1153{
1154 bool fRelDev, fMTDev, fCanAbs, fNeedsHostCursor;
1155
1156 {
1157 AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
1158
1159 i_getDeviceCaps(NULL, &fRelDev, &fMTDev);
1160 fCanAbs = i_supportsAbs();
1161 fNeedsHostCursor = i_guestNeedsHostCursor();
1162 }
1163 mParent->i_onMouseCapabilityChange(fCanAbs, fRelDev, fMTDev, fNeedsHostCursor);
1164}
1165
1166
1167/**
1168 * @interface_method_impl{PDMIMOUSECONNECTOR,pfnReportModes}
1169 * A virtual device is notifying us about its current state and capabilities
1170 */
1171DECLCALLBACK(void) Mouse::i_mouseReportModes(PPDMIMOUSECONNECTOR pInterface, bool fRelative,
1172 bool fAbsolute, bool fMultiTouch)
1173{
1174 PDRVMAINMOUSE pDrv = RT_FROM_MEMBER(pInterface, DRVMAINMOUSE, IConnector);
1175 if (fRelative)
1176 pDrv->u32DevCaps |= MOUSE_DEVCAP_RELATIVE;
1177 else
1178 pDrv->u32DevCaps &= ~MOUSE_DEVCAP_RELATIVE;
1179 if (fAbsolute)
1180 pDrv->u32DevCaps |= MOUSE_DEVCAP_ABSOLUTE;
1181 else
1182 pDrv->u32DevCaps &= ~MOUSE_DEVCAP_ABSOLUTE;
1183 if (fMultiTouch)
1184 pDrv->u32DevCaps |= MOUSE_DEVCAP_MULTI_TOUCH;
1185 else
1186 pDrv->u32DevCaps &= ~MOUSE_DEVCAP_MULTI_TOUCH;
1187
1188 pDrv->pMouse->i_sendMouseCapsNotifications();
1189}
1190
1191
1192/**
1193 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
1194 */
1195DECLCALLBACK(void *) Mouse::i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
1196{
1197 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
1198 PDRVMAINMOUSE pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINMOUSE);
1199
1200 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
1201 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSECONNECTOR, &pDrv->IConnector);
1202 return NULL;
1203}
1204
1205
1206/**
1207 * Destruct a mouse driver instance.
1208 *
1209 * @returns VBox status code.
1210 * @param pDrvIns The driver instance data.
1211 */
1212DECLCALLBACK(void) Mouse::i_drvDestruct(PPDMDRVINS pDrvIns)
1213{
1214 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
1215 PDRVMAINMOUSE pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINMOUSE);
1216 LogFlow(("Mouse::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
1217
1218 if (pThis->pMouse)
1219 {
1220 AutoWriteLock mouseLock(pThis->pMouse COMMA_LOCKVAL_SRC_POS);
1221 for (unsigned cDev = 0; cDev < MOUSE_MAX_DEVICES; ++cDev)
1222 if (pThis->pMouse->mpDrv[cDev] == pThis)
1223 {
1224 pThis->pMouse->mpDrv[cDev] = NULL;
1225 break;
1226 }
1227 }
1228}
1229
1230
1231/**
1232 * Construct a mouse driver instance.
1233 *
1234 * @copydoc FNPDMDRVCONSTRUCT
1235 */
1236DECLCALLBACK(int) Mouse::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
1237{
1238 RT_NOREF(fFlags);
1239 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
1240 PDRVMAINMOUSE pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINMOUSE);
1241 LogFlow(("drvMainMouse_Construct: iInstance=%d\n", pDrvIns->iInstance));
1242
1243 /*
1244 * Validate configuration.
1245 */
1246 if (!CFGMR3AreValuesValid(pCfg, "Object\0"))
1247 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
1248 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
1249 ("Configuration error: Not possible to attach anything to this driver!\n"),
1250 VERR_PDM_DRVINS_NO_ATTACH);
1251
1252 /*
1253 * IBase.
1254 */
1255 pDrvIns->IBase.pfnQueryInterface = Mouse::i_drvQueryInterface;
1256
1257 pThis->IConnector.pfnReportModes = Mouse::i_mouseReportModes;
1258
1259 /*
1260 * Get the IMousePort interface of the above driver/device.
1261 */
1262 pThis->pUpPort = (PPDMIMOUSEPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMIMOUSEPORT_IID);
1263 if (!pThis->pUpPort)
1264 {
1265 AssertMsgFailed(("Configuration error: No mouse port interface above!\n"));
1266 return VERR_PDM_MISSING_INTERFACE_ABOVE;
1267 }
1268
1269 /*
1270 * Get the Mouse object pointer and update the mpDrv member.
1271 */
1272 void *pv;
1273 int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
1274 if (RT_FAILURE(rc))
1275 {
1276 AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
1277 return rc;
1278 }
1279 pThis->pMouse = (Mouse *)pv; /** @todo Check this cast! */
1280 unsigned cDev;
1281 {
1282 AutoWriteLock mouseLock(pThis->pMouse COMMA_LOCKVAL_SRC_POS);
1283
1284 for (cDev = 0; cDev < MOUSE_MAX_DEVICES; ++cDev)
1285 if (!pThis->pMouse->mpDrv[cDev])
1286 {
1287 pThis->pMouse->mpDrv[cDev] = pThis;
1288 break;
1289 }
1290 }
1291 if (cDev == MOUSE_MAX_DEVICES)
1292 return VERR_NO_MORE_HANDLES;
1293
1294 return VINF_SUCCESS;
1295}
1296
1297
1298/**
1299 * Main mouse driver registration record.
1300 */
1301const PDMDRVREG Mouse::DrvReg =
1302{
1303 /* u32Version */
1304 PDM_DRVREG_VERSION,
1305 /* szName */
1306 "MainMouse",
1307 /* szRCMod */
1308 "",
1309 /* szR0Mod */
1310 "",
1311 /* pszDescription */
1312 "Main mouse driver (Main as in the API).",
1313 /* fFlags */
1314 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
1315 /* fClass. */
1316 PDM_DRVREG_CLASS_MOUSE,
1317 /* cMaxInstances */
1318 ~0U,
1319 /* cbInstance */
1320 sizeof(DRVMAINMOUSE),
1321 /* pfnConstruct */
1322 Mouse::i_drvConstruct,
1323 /* pfnDestruct */
1324 Mouse::i_drvDestruct,
1325 /* pfnRelocate */
1326 NULL,
1327 /* pfnIOCtl */
1328 NULL,
1329 /* pfnPowerOn */
1330 NULL,
1331 /* pfnReset */
1332 NULL,
1333 /* pfnSuspend */
1334 NULL,
1335 /* pfnResume */
1336 NULL,
1337 /* pfnAttach */
1338 NULL,
1339 /* pfnDetach */
1340 NULL,
1341 /* pfnPowerOff */
1342 NULL,
1343 /* pfnSoftReset */
1344 NULL,
1345 /* u32EndVersion */
1346 PDM_DRVREG_VERSION
1347};
1348/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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