Changeset 47208 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jul 17, 2013 11:01:51 AM (11 years ago)
- Location:
- trunk/src/VBox/Devices/Input
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r46932 r47208 1364 1364 * @interface_method_impl{PDMIMOUSEPORT, pfnPutEvent} 1365 1365 */ 1366 static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t iDeltaX, int32_t iDeltaY, 1367 int32_t iDeltaZ, int32_t iDeltaW, uint32_t fButtonStates) 1366 static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, 1367 int32_t dy, int32_t dz, int32_t dw, 1368 uint32_t fButtons) 1368 1369 { 1369 1370 KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Mouse.IPort); … … 1371 1372 AssertReleaseRC(rc); 1372 1373 1373 pc_kbd_mouse_event(pThis, iDeltaX, iDeltaY, iDeltaZ, iDeltaW, fButtonStates);1374 pc_kbd_mouse_event(pThis, dx, dy, dz, dw, fButtons); 1374 1375 1375 1376 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); … … 1380 1381 * @interface_method_impl{PDMIMOUSEPORT, pfnPutEventAbs} 1381 1382 */ 1382 static DECLCALLBACK(int) kbdMousePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t uX, uint32_t uY, int32_t iDeltaZ, int32_t iDeltaW, uint32_t fButtons) 1383 static DECLCALLBACK(int) kbdMousePutEventAbs(PPDMIMOUSEPORT pInterface, 1384 uint32_t x, uint32_t y, int32_t dz, 1385 int32_t dw, uint32_t fButtons) 1383 1386 { 1384 1387 AssertFailedReturn(VERR_NOT_SUPPORTED); 1385 NOREF(pInterface); NOREF(uX); NOREF(uY); NOREF(iDeltaZ); NOREF(iDeltaW); NOREF(fButtons); 1388 NOREF(pInterface); NOREF(x); NOREF(y); NOREF(dz); NOREF(dw); NOREF(fButtons); 1389 } 1390 1391 /** 1392 * @interface_method_impl{PDMIMOUSEPORT, pfnPutEventMT} 1393 */ 1394 static DECLCALLBACK(int) kbdMousePutEventMT(PPDMIMOUSEPORT pInterface, 1395 uint32_t x, uint32_t y, 1396 uint32_t cContact, 1397 bool fContact) 1398 { 1399 AssertFailedReturn(VERR_NOT_SUPPORTED); 1400 NOREF(pInterface); NOREF(x); NOREF(y); NOREF(cContact); NOREF(fContact); 1386 1401 } 1387 1402 … … 1552 1567 pThis->Mouse.IPort.pfnPutEvent = kbdMousePutEvent; 1553 1568 pThis->Mouse.IPort.pfnPutEventAbs = kbdMousePutEventAbs; 1569 pThis->Mouse.IPort.pfnPutEventMT = kbdMousePutEventMT; 1554 1570 1555 1571 /* -
trunk/src/VBox/Devices/Input/DrvMouseQueue.cpp
r46932 r47208 59 59 60 60 /** 61 * Event type for @a DRVMOUSEQUEUEITEM 62 */ 63 enum EVENTTYPE { RELATIVE, ABSOLUTE, MULTITOUCH }; 64 65 /** 61 66 * Mouse queue item. 62 67 */ … … 65 70 /** The core part owned by the queue manager. */ 66 71 PDMQUEUEITEMCORE Core; 67 uint32_t fAbs; 68 int32_t iDeltaX; 69 int32_t iDeltaY; 70 int32_t iDeltaZ; 71 int32_t iDeltaW; 72 uint32_t fButtonStates; 73 uint32_t uX; 74 uint32_t uY; 72 enum EVENTTYPE enmType; 73 union 74 { 75 uint32_t padding[5]; 76 struct 77 { 78 uint32_t fButtons; 79 int32_t dx; 80 int32_t dy; 81 int32_t dz; 82 int32_t dw; 83 } Relative; 84 struct 85 { 86 uint32_t fButtons; 87 uint32_t x; 88 uint32_t y; 89 int32_t dz; 90 int32_t dw; 91 } Absolute; 92 struct 93 { 94 bool fContact; 95 uint32_t x; 96 uint32_t y; 97 uint32_t cContact; 98 } MultiTouch; 99 } u; 75 100 } DRVMOUSEQUEUEITEM, *PDRVMOUSEQUEUEITEM; 76 101 … … 102 127 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent} 103 128 */ 104 static DECLCALLBACK(int) drvMouseQueuePutEvent(PPDMIMOUSEPORT pInterface, int32_t iDeltaX, int32_t iDeltaY, int32_t iDeltaZ, int32_t iDeltaW, uint32_t fButtonStates) 129 static DECLCALLBACK(int) drvMouseQueuePutEvent(PPDMIMOUSEPORT pInterface, 130 int32_t dx, int32_t dy, 131 int32_t dz, int32_t dw, 132 uint32_t fButtons) 105 133 { 106 134 PDRVMOUSEQUEUE pDrv = IMOUSEPORT_2_DRVMOUSEQUEUE(pInterface); … … 111 139 if (pItem) 112 140 { 113 pItem->fAbs = 0; 114 pItem->iDeltaX = iDeltaX; 115 pItem->iDeltaY = iDeltaY; 116 pItem->iDeltaZ = iDeltaZ; 117 pItem->iDeltaW = iDeltaW; 118 pItem->fButtonStates = fButtonStates; 119 pItem->uX = 0; 120 pItem->uY = 0; 141 RT_ZERO(pItem->u.padding); 142 pItem->enmType = RELATIVE; 143 pItem->u.Relative.dx = dx; 144 pItem->u.Relative.dy = dy; 145 pItem->u.Relative.dz = dz; 146 pItem->u.Relative.dw = dw; 147 pItem->u.Relative.fButtons = fButtons; 121 148 PDMQueueInsert(pDrv->pQueue, &pItem->Core); 122 149 return VINF_SUCCESS; … … 128 155 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs} 129 156 */ 130 static DECLCALLBACK(int) drvMouseQueuePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t uX, uint32_t uY, int32_t iDeltaZ, int32_t iDeltaW, uint32_t fButtonStates) 157 static DECLCALLBACK(int) drvMouseQueuePutEventAbs(PPDMIMOUSEPORT pInterface, 158 uint32_t x, uint32_t y, 159 int32_t dz, int32_t dw, 160 uint32_t fButtons) 131 161 { 132 162 PDRVMOUSEQUEUE pDrv = IMOUSEPORT_2_DRVMOUSEQUEUE(pInterface); … … 137 167 if (pItem) 138 168 { 139 pItem->fAbs = 1; 140 pItem->iDeltaX = 0; 141 pItem->iDeltaY = 0; 142 pItem->iDeltaZ = iDeltaZ; 143 pItem->iDeltaW = iDeltaW; 144 pItem->fButtonStates = fButtonStates; 145 pItem->uX = uX; 146 pItem->uY = uY; 169 RT_ZERO(pItem->u.padding); 170 pItem->enmType = ABSOLUTE; 171 pItem->u.Absolute.x = x; 172 pItem->u.Absolute.y = y; 173 pItem->u.Absolute.dz = dz; 174 pItem->u.Absolute.dw = dw; 175 pItem->u.Absolute.fButtons = fButtons; 176 PDMQueueInsert(pDrv->pQueue, &pItem->Core); 177 return VINF_SUCCESS; 178 } 179 return VERR_PDM_NO_QUEUE_ITEMS; 180 } 181 182 183 /** 184 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMT} 185 */ 186 static DECLCALLBACK(int) drvMouseQueuePutEventMT(PPDMIMOUSEPORT pInterface, 187 uint32_t x, uint32_t y, 188 uint32_t cContact, 189 bool fContact) 190 { 191 PDRVMOUSEQUEUE pDrv = IMOUSEPORT_2_DRVMOUSEQUEUE(pInterface); 192 if (pDrv->fInactive) 193 return VINF_SUCCESS; 194 195 PDRVMOUSEQUEUEITEM pItem = (PDRVMOUSEQUEUEITEM)PDMQueueAlloc(pDrv->pQueue); 196 if (pItem) 197 { 198 RT_ZERO(pItem->u.padding); 199 pItem->enmType = MULTITOUCH; 200 pItem->u.MultiTouch.x = x; 201 pItem->u.MultiTouch.y = y; 202 pItem->u.MultiTouch.cContact = cContact; 203 pItem->u.MultiTouch.fContact = fContact; 147 204 PDMQueueInsert(pDrv->pQueue, &pItem->Core); 148 205 return VINF_SUCCESS; … … 189 246 PDRVMOUSEQUEUEITEM pItem = (PDRVMOUSEQUEUEITEM)pItemCore; 190 247 int rc; 191 if (!pItem->fAbs) 192 rc = pThis->pUpPort->pfnPutEvent(pThis->pUpPort, pItem->iDeltaX, pItem->iDeltaY, pItem->iDeltaZ, pItem->iDeltaW, pItem->fButtonStates); 248 if (pItem->enmType == RELATIVE) 249 rc = pThis->pUpPort->pfnPutEvent(pThis->pUpPort, 250 pItem->u.Relative.dx, 251 pItem->u.Relative.dy, 252 pItem->u.Relative.dz, 253 pItem->u.Relative.dw, 254 pItem->u.Relative.fButtons); 255 else if (pItem->enmType == ABSOLUTE) 256 rc = pThis->pUpPort->pfnPutEventAbs(pThis->pUpPort, 257 pItem->u.Absolute.x, 258 pItem->u.Absolute.y, 259 pItem->u.Absolute.dz, 260 pItem->u.Absolute.dw, 261 pItem->u.Absolute.fButtons); 262 else if (pItem->enmType == MULTITOUCH) 263 rc = pThis->pUpPort->pfnPutEventMT(pThis->pUpPort, 264 pItem->u.MultiTouch.x, 265 pItem->u.MultiTouch.y, 266 pItem->u.MultiTouch.cContact, 267 pItem->u.MultiTouch.fContact); 193 268 else 194 r c = pThis->pUpPort->pfnPutEventAbs(pThis->pUpPort, pItem->uX, pItem->uY, pItem->iDeltaZ, pItem->iDeltaW, pItem->fButtonStates);269 return false; 195 270 return RT_SUCCESS(rc); 196 271 } … … 291 366 pDrv->IPort.pfnPutEvent = drvMouseQueuePutEvent; 292 367 pDrv->IPort.pfnPutEventAbs = drvMouseQueuePutEventAbs; 368 pDrv->IPort.pfnPutEventMT = drvMouseQueuePutEventMT; 293 369 294 370 /* -
trunk/src/VBox/Devices/Input/UsbMouse.cpp
r46932 r47208 122 122 typedef struct USBHIDM_ACCUM 123 123 { 124 uint32_t btn; 125 int32_t dX; 126 int32_t dY; 127 int32_t dZ; 124 union 125 { 126 struct 127 { 128 uint32_t fButtons; 129 int32_t dx; 130 int32_t dy; 131 int32_t dz; 132 } Relative; 133 struct 134 { 135 uint32_t fButtons; 136 uint32_t x; 137 uint32_t y; 138 int32_t dz; 139 } Absolute; 140 struct 141 { 142 bool fContact; 143 uint32_t x; 144 uint32_t y; 145 uint32_t cContact; 146 } MultiTouch; 147 } u; 128 148 } USBHIDM_ACCUM, *PUSBHIDM_ACCUM; 129 149 … … 199 219 typedef struct USBHIDM_REPORT 200 220 { 201 uint8_t btn;221 uint8_t fButtons; 202 222 int8_t dx; 203 223 int8_t dy; … … 212 232 { 213 233 uint8_t rid; 214 uint8_t btn;234 uint8_t fButtons; 215 235 int8_t dz; 216 236 int8_t dummy; 217 uint16_t cx;218 uint16_t cy;237 uint16_t x; 238 uint16_t y; 219 239 } USBHIDT_REPORT, *PUSBHIDT_REPORT; 220 240 … … 891 911 case USBHIDMODE_ABSOLUTE: 892 912 { 893 pReport->t.rid = REPORTID_MOUSE;894 pReport->t. btn = pAccumulated->btn;895 pReport->t. cx = pAccumulated->dX;896 pReport->t. cy = pAccumulated->dY;897 pReport->t.dz = clamp_i8(pAccumulated->dZ);913 pReport->t.rid = REPORTID_MOUSE; 914 pReport->t.fButtons = pAccumulated->u.Absolute.fButtons; 915 pReport->t.x = pAccumulated->u.Absolute.x; 916 pReport->t.y = pAccumulated->u.Absolute.y; 917 pReport->t.dz = clamp_i8(pAccumulated->u.Absolute.dz); 898 918 899 919 cbCopy = sizeof(pReport->t); 900 LogRel3(("Abs event, X=%d, Y=%d, dZ=%d, btn=%02x, report size %d\n",901 pReport->t. cx, pReport->t.cy, pReport->t.dz, pReport->t.btn,920 LogRel3(("Abs event, x=%d, y=%d, dz=%d, fButtons=%02x, report size %d\n", 921 pReport->t.x, pReport->t.y, pReport->t.dz, pReport->t.fButtons, 902 922 cbCopy)); 903 923 break; … … 905 925 case USBHIDMODE_RELATIVE: 906 926 { 907 pReport->m. btn = pAccumulated->btn;908 pReport->m.dx = clamp_i8(pAccumulated->dX);909 pReport->m.dy = clamp_i8(pAccumulated->dY);910 pReport->m.dz = clamp_i8(pAccumulated->dZ);927 pReport->m.fButtons = pAccumulated->u.Relative.fButtons; 928 pReport->m.dx = clamp_i8(pAccumulated->u.Relative.dx); 929 pReport->m.dy = clamp_i8(pAccumulated->u.Relative.dy); 930 pReport->m.dz = clamp_i8(pAccumulated->u.Relative.dz); 911 931 912 932 cbCopy = sizeof(pReport->m); 913 LogRel3(("Rel event, d X=%d, dY=%d, dZ=%d, btn=%02x, report size %d\n",914 pReport->m.dx, pReport->m.dy, pReport->m.dz, pReport->m.btn,915 cbCopy));933 LogRel3(("Rel event, dx=%d, dy=%d, dz=%d, fButtons=%02x, report size %d\n", 934 pReport->m.dx, pReport->m.dy, pReport->m.dz, 935 pReport->m.fButtons, cbCopy)); 916 936 break; 917 937 } … … 919 939 { 920 940 pReport->mt.idReport = REPORTID_MOUSE; 921 pReport->mt.idContact = 1; 922 pReport->mt.x = pAccumulated->dX; 923 pReport->mt.y = pAccumulated->dY; 924 pReport->mt.fButton = 0x1; /* We only send events when there 925 * is contact. */ 941 pReport->mt.idContact = pAccumulated->u.MultiTouch.cContact; 942 pReport->mt.x = pAccumulated->u.MultiTouch.x; 943 pReport->mt.y = pAccumulated->u.MultiTouch.y; 944 pReport->mt.fButton = pAccumulated->u.MultiTouch.fContact; 926 945 927 946 cbCopy = sizeof(pReport->t); 928 LogRel3(("Multi-touch event, X=%d, Y=%d, report size %d\n",929 p Accumulated->dX, pAccumulated->dY, cbCopy));947 LogRel3(("Multi-touch event, x=%u, y=%u, report size %d\n", 948 pReport->mt.x, pReport->mt.y, cbCopy)); 930 949 break; 931 950 } … … 974 993 975 994 /** 976 * Relative mouse event handler. 977 * 978 * @returns VBox status code. 979 * @param pInterface Pointer to the mouse port interface (KBDState::Mouse.iPort). 980 * @param i32DeltaX The X delta. 981 * @param i32DeltaY The Y delta. 982 * @param i32DeltaZ The Z delta. 983 * @param i32DeltaW The W delta. 984 * @param fButtonStates The button states. 985 */ 986 static DECLCALLBACK(int) usbHidMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates) 995 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent} 996 */ 997 static DECLCALLBACK(int) usbHidMousePutEvent(PPDMIMOUSEPORT pInterface, 998 int32_t dx, int32_t dy, int32_t dz, 999 int32_t dw, uint32_t fButtons) 987 1000 { 988 1001 PUSBHID pThis = RT_FROM_MEMBER(pInterface, USBHID, Lun0.IPort); … … 992 1005 * at a much higher rate than USB can handle. 993 1006 */ 994 pThis->PtrDelta. btn = fButtonStates;995 pThis->PtrDelta. dX += i32DeltaX;996 pThis->PtrDelta. dY += i32DeltaY;997 pThis->PtrDelta. dZ -= i32DeltaZ; /* Inverted! */1007 pThis->PtrDelta.u.Relative.fButtons = fButtons; 1008 pThis->PtrDelta.u.Relative.dx += dx; 1009 pThis->PtrDelta.u.Relative.dy += dy; 1010 pThis->PtrDelta.u.Relative.dz -= dz; /* Inverted! */ 998 1011 999 1012 /* Send a report if possible. */ … … 1005 1018 1006 1019 /** 1007 * Absolute mouse event handler. 1008 * 1009 * @returns VBox status code. 1010 * @param pInterface Pointer to the mouse port interface (KBDState::Mouse.iPort). 1011 * @param u32X The X coordinate. 1012 * @param u32Y The Y coordinate. 1013 * @param i32DeltaZ The Z delta. 1014 * @param i32DeltaW The W delta. 1015 * @param fButtonStates The button states. 1016 */ 1017 static DECLCALLBACK(int) usbHidMousePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t u32X, uint32_t u32Y, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates) 1020 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs} 1021 */ 1022 static DECLCALLBACK(int) usbHidMousePutEventAbs(PPDMIMOUSEPORT pInterface, 1023 uint32_t x, uint32_t y, 1024 int32_t dz, int32_t dw, 1025 uint32_t fButtons) 1018 1026 { 1019 1027 PUSBHID pThis = RT_FROM_MEMBER(pInterface, USBHID, Lun0.IPort); … … 1027 1035 * accumulated and only the last value is used). 1028 1036 */ 1029 pThis->PtrDelta.btn = fButtonStates; 1030 pThis->PtrDelta.dX = u32X >> pThis->u8CoordShift; 1031 pThis->PtrDelta.dY = u32Y >> pThis->u8CoordShift; 1032 pThis->PtrDelta.dZ -= i32DeltaZ; /* Inverted! */ 1037 pThis->PtrDelta.u.Absolute.fButtons = fButtons; 1038 pThis->PtrDelta.u.Absolute.x = x >> pThis->u8CoordShift; 1039 pThis->PtrDelta.u.Absolute.y = y >> pThis->u8CoordShift; 1040 pThis->PtrDelta.u.Absolute.dz -= dz; /* Inverted! */ 1041 1042 /* Send a report if possible. */ 1043 usbHidSendReport(pThis); 1044 1045 RTCritSectLeave(&pThis->CritSect); 1046 return VINF_SUCCESS; 1047 } 1048 1049 /** 1050 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMT} 1051 */ 1052 static DECLCALLBACK(int) usbHidMousePutEventMT(PPDMIMOUSEPORT pInterface, 1053 uint32_t x, uint32_t y, 1054 uint32_t cContact, 1055 bool fContact) 1056 { 1057 PUSBHID pThis = RT_FROM_MEMBER(pInterface, USBHID, Lun0.IPort); 1058 RTCritSectEnter(&pThis->CritSect); 1059 1060 Assert(pThis->enmMode == USBHIDMODE_MULTI_TOUCH); 1061 1062 /* Accumulate movement - the events from the front end may arrive 1063 * at a much higher rate than USB can handle. Probably not a real issue 1064 * when only the Z axis is relative (X/Y movement isn't technically 1065 * accumulated and only the last value is used). 1066 */ 1067 pThis->PtrDelta.u.MultiTouch.fContact = fContact; 1068 pThis->PtrDelta.u.MultiTouch.x = x; 1069 pThis->PtrDelta.u.MultiTouch.y = y; 1070 pThis->PtrDelta.u.MultiTouch.cContact = cContact; 1033 1071 1034 1072 /* Send a report if possible. */
Note:
See TracChangeset
for help on using the changeset viewer.