儲存庫 vbox 的更動 62888
- 時間撮記:
- 2016-8-2 下午10:34:23 (8 年 以前)
- 位置:
- trunk/src/VBox/Devices/Input
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Devices/Input/UsbMouse.cpp
r62885 r62888 1975 1975 switch (pThis->enmMode) 1976 1976 { 1977 case USBHIDMODE_ABSOLUTE:1978 cbDesc = sizeof(g_UsbHidTIfHidDesc);1979 pDesc = (const uint8_t *)&g_UsbHidTIfHidDesc;1980 break;1981 case USBHIDMODE_RELATIVE:1982 cbDesc = sizeof(g_UsbHidMIfHidDesc);1983 pDesc = (const uint8_t *)&g_UsbHidMIfHidDesc;1984 break;1985 case USBHIDMODE_MULTI_TOUCH:1986 cbDesc = sizeof(g_UsbHidMTIfHidDesc);1987 pDesc = (const uint8_t *)&g_UsbHidMTIfHidDesc;1988 break;1989 default:1990 cbDesc = 0;1991 pDesc = 0;1992 break;1977 case USBHIDMODE_ABSOLUTE: 1978 cbDesc = sizeof(g_UsbHidTIfHidDesc); 1979 pDesc = (const uint8_t *)&g_UsbHidTIfHidDesc; 1980 break; 1981 case USBHIDMODE_RELATIVE: 1982 cbDesc = sizeof(g_UsbHidMIfHidDesc); 1983 pDesc = (const uint8_t *)&g_UsbHidMIfHidDesc; 1984 break; 1985 case USBHIDMODE_MULTI_TOUCH: 1986 cbDesc = sizeof(g_UsbHidMTIfHidDesc); 1987 pDesc = (const uint8_t *)&g_UsbHidMTIfHidDesc; 1988 break; 1989 default: 1990 cbDesc = 0; 1991 pDesc = 0; 1992 break; 1993 1993 } 1994 1994 /* Returned data is written after the setup message. */ … … 2006 2006 switch (pThis->enmMode) 2007 2007 { 2008 case USBHIDMODE_ABSOLUTE:2009 cbDesc = sizeof(g_UsbHidTReportDesc);2010 pDesc = (const uint8_t *)&g_UsbHidTReportDesc;2011 break;2012 case USBHIDMODE_RELATIVE:2013 cbDesc = sizeof(g_UsbHidMReportDesc);2014 pDesc = (const uint8_t *)&g_UsbHidMReportDesc;2015 break;2016 case USBHIDMODE_MULTI_TOUCH:2017 cbDesc = sizeof(g_UsbHidMTReportDesc);2018 pDesc = (const uint8_t *)&g_UsbHidMTReportDesc;2019 break;2020 default:2021 cbDesc = 0;2022 pDesc = 0;2023 break;2008 case USBHIDMODE_ABSOLUTE: 2009 cbDesc = sizeof(g_UsbHidTReportDesc); 2010 pDesc = (const uint8_t *)&g_UsbHidTReportDesc; 2011 break; 2012 case USBHIDMODE_RELATIVE: 2013 cbDesc = sizeof(g_UsbHidMReportDesc); 2014 pDesc = (const uint8_t *)&g_UsbHidMReportDesc; 2015 break; 2016 case USBHIDMODE_MULTI_TOUCH: 2017 cbDesc = sizeof(g_UsbHidMTReportDesc); 2018 pDesc = (const uint8_t *)&g_UsbHidMTReportDesc; 2019 break; 2020 default: 2021 cbDesc = 0; 2022 pDesc = 0; 2023 break; 2024 2024 } 2025 2025 /* Returned data is written after the setup message. */ … … 2257 2257 switch (pThis->enmMode) 2258 2258 { 2259 case USBHIDMODE_ABSOLUTE:2260 return &g_UsbHidTDescCache;2261 case USBHIDMODE_RELATIVE:2262 return &g_UsbHidMDescCache;2263 case USBHIDMODE_MULTI_TOUCH:2264 return &g_UsbHidMTDescCache;2265 default:2266 return NULL;2259 case USBHIDMODE_ABSOLUTE: 2260 return &g_UsbHidTDescCache; 2261 case USBHIDMODE_RELATIVE: 2262 return &g_UsbHidMDescCache; 2263 case USBHIDMODE_MULTI_TOUCH: 2264 return &g_UsbHidMTDescCache; 2265 default: 2266 return NULL; 2267 2267 } 2268 2268 } … … 2318 2318 PDMUSB_CHECK_VERSIONS_RETURN(pUsbIns); 2319 2319 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 2320 char szMode[64];2321 2320 LogRelFlow(("usbHidConstruct/#%u:\n", iInstance)); 2322 2321 … … 2342 2341 if (RT_FAILURE(rc)) 2343 2342 return rc; 2343 char szMode[64]; 2344 2344 rc = CFGMR3QueryStringDef(pCfg, "Mode", szMode, sizeof(szMode), "relative"); 2345 2345 if (RT_FAILURE(rc)) -
trunk/src/VBox/Devices/Input/testcase/tstUsbMouse.cpp
r62513 r62888 46 46 /** Is multi-touch mode currently supported? */ 47 47 bool fMT; 48 } DRVTSTMOUSE, *PDRVTSTMOUSE; 49 50 48 } DRVTSTMOUSE; 49 typedef DRVTSTMOUSE *PDRVTSTMOUSE; 50 51 52 /********************************************************************************************************************************* 53 * Global Variables * 54 *********************************************************************************************************************************/ 55 static PDMUSBHLP g_tstUsbHlp; 51 56 /** Global mouse driver variable. 52 57 * @todo To be improved some time. */ 53 static DRVTSTMOUSE s_drvTstMouse;58 static DRVTSTMOUSE g_drvTstMouse; 54 59 55 60 … … 68 73 /** @todo We currently just take the driver interface from the global 69 74 * variable. This is sufficient for a unit test but still a bit sad. */ 70 static DECLCALLBACK(int) tstDriverAttach(PPDMUSBINS pUsbIns, RTUINT iLun, 71 PPDMIBASE pBaseInterface, 72 PPDMIBASE *ppBaseInterface, 73 const char *pszDesc) 74 { 75 NOREF(iLun); 76 NOREF(pszDesc); 77 s_drvTstMouse.pDrvBase = pBaseInterface; 78 s_drvTstMouse.pDrv = PDMIBASE_QUERY_INTERFACE(pBaseInterface, 79 PDMIMOUSEPORT); 80 *ppBaseInterface = &s_drvTstMouse.IBase; 75 static DECLCALLBACK(int) tstDriverAttach(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, 76 PPDMIBASE *ppBaseInterface, const char *pszDesc) 77 { 78 RT_NOREF3(pUsbIns, iLun, pszDesc); 79 g_drvTstMouse.pDrvBase = pBaseInterface; 80 g_drvTstMouse.pDrv = PDMIBASE_QUERY_INTERFACE(pBaseInterface, PDMIMOUSEPORT); 81 *ppBaseInterface = &g_drvTstMouse.IBase; 81 82 return VINF_SUCCESS; 82 83 } 83 84 85 static PDMUSBHLP s_tstUsbHlp;86 84 87 85 … … 92 90 const char *pszIID) 93 91 { 94 PDRVTSTMOUSE p This = RT_FROM_MEMBER(pInterface, DRVTSTMOUSE, IBase);95 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &p This->IBase);96 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSECONNECTOR, &p This->IConnector);92 PDRVTSTMOUSE pUsbIns = RT_FROM_MEMBER(pInterface, DRVTSTMOUSE, IBase); 93 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pUsbIns->IBase); 94 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSECONNECTOR, &pUsbIns->IConnector); 97 95 return NULL; 98 96 } … … 113 111 114 112 static int tstMouseConstruct(int iInstance, const char *pcszMode, 115 uint8_t u8CoordShift, PPDMUSBINS *ppThis) 113 uint8_t u8CoordShift, PPDMUSBINS *ppThis, 114 uint32_t uInstanceVersion = PDM_USBINS_VERSION) 116 115 { 117 116 int rc = VERR_NO_MEMORY; 118 PPDMUSBINS p This = (PPDMUSBINS)RTMemAllocZ( sizeof(*pThis)117 PPDMUSBINS pUsbIns = (PPDMUSBINS)RTMemAllocZ( sizeof(*pUsbIns) 119 118 + g_UsbHidMou.cbInstance); 120 119 PCFGMNODE pCfg = NULL; 121 if (p This)120 if (pUsbIns) 122 121 pCfg = CFGMR3CreateTree(NULL); 123 122 if (pCfg) … … 127 126 if (RT_SUCCESS(rc)) 128 127 { 129 s_drvTstMouse.pDrv = NULL; 130 s_drvTstMouse.pDrvBase = NULL; 131 pThis->iInstance = iInstance; 132 pThis->pHlpR3 = &s_tstUsbHlp; 133 rc = g_UsbHidMou.pfnConstruct(pThis, iInstance, pCfg, NULL); 128 g_drvTstMouse.pDrv = NULL; 129 g_drvTstMouse.pDrvBase = NULL; 130 pUsbIns->u32Version = uInstanceVersion; 131 pUsbIns->iInstance = iInstance; 132 pUsbIns->pHlpR3 = &g_tstUsbHlp; 133 rc = g_UsbHidMou.pfnConstruct(pUsbIns, iInstance, pCfg, NULL); 134 134 if (RT_SUCCESS(rc)) 135 135 { 136 *ppThis = p This;136 *ppThis = pUsbIns; 137 137 return rc; 138 138 } … … 141 141 if (pCfg) 142 142 CFGMR3DestroyTree(pCfg); 143 if (p This)144 RTMemFree(p This);143 if (pUsbIns) 144 RTMemFree(pUsbIns); 145 145 return rc; 146 146 } … … 149 149 static void testConstructAndDestruct(RTTEST hTest) 150 150 { 151 PPDMUSBINS pThis;152 151 RTTestSub(hTest, "simple construction and destruction"); 153 int rc = tstMouseConstruct(0, "relative", 1, &pThis); 154 RTTEST_CHECK_RC_OK(hTest, rc); 155 if (pThis) 156 g_UsbHidMou.pfnDestruct(pThis); 152 153 /* 154 * Normal check first. 155 */ 156 PPDMUSBINS pUsbIns = NULL; 157 RTTEST_CHECK_RC(hTest, tstMouseConstruct(0, "relative", 1, &pUsbIns), VINF_SUCCESS); 158 if (pUsbIns) 159 g_UsbHidMou.pfnDestruct(pUsbIns); 160 161 /* 162 * Modify the dev hlp version. 163 */ 164 static struct 165 { 166 int rc; 167 uint32_t uInsVersion; 168 uint32_t uHlpVersion; 169 } const s_aVersionTests[] = 170 { 171 { VERR_PDM_USBHLPR3_VERSION_MISMATCH, PDM_USBINS_VERSION, 0 }, 172 { VERR_PDM_USBHLPR3_VERSION_MISMATCH, PDM_USBINS_VERSION, PDM_USBHLP_VERSION - PDM_VERSION_MAKE(0, 1, 0) }, 173 { VERR_PDM_USBHLPR3_VERSION_MISMATCH, PDM_USBINS_VERSION, PDM_USBHLP_VERSION + PDM_VERSION_MAKE(0, 1, 0) }, 174 { VERR_PDM_USBHLPR3_VERSION_MISMATCH, PDM_USBINS_VERSION, PDM_USBHLP_VERSION + PDM_VERSION_MAKE(0, 1, 1) }, 175 { VERR_PDM_USBHLPR3_VERSION_MISMATCH, PDM_USBINS_VERSION, PDM_USBHLP_VERSION + PDM_VERSION_MAKE(1, 0, 0) }, 176 { VERR_PDM_USBHLPR3_VERSION_MISMATCH, PDM_USBINS_VERSION, PDM_USBHLP_VERSION - PDM_VERSION_MAKE(1, 0, 0) }, 177 { VINF_SUCCESS, PDM_USBINS_VERSION, PDM_USBHLP_VERSION + PDM_VERSION_MAKE(0, 0, 1) }, 178 { VERR_PDM_USBINS_VERSION_MISMATCH, PDM_USBINS_VERSION - PDM_VERSION_MAKE(0, 1, 0), PDM_USBHLP_VERSION }, 179 { VERR_PDM_USBINS_VERSION_MISMATCH, PDM_USBINS_VERSION + PDM_VERSION_MAKE(0, 1, 0), PDM_USBHLP_VERSION }, 180 { VERR_PDM_USBINS_VERSION_MISMATCH, PDM_USBINS_VERSION + PDM_VERSION_MAKE(0, 1, 1), PDM_USBHLP_VERSION }, 181 { VERR_PDM_USBINS_VERSION_MISMATCH, PDM_USBINS_VERSION + PDM_VERSION_MAKE(1, 0, 0), PDM_USBHLP_VERSION }, 182 { VERR_PDM_USBINS_VERSION_MISMATCH, PDM_USBINS_VERSION - PDM_VERSION_MAKE(1, 0, 0), PDM_USBHLP_VERSION }, 183 { VINF_SUCCESS, PDM_USBINS_VERSION + PDM_VERSION_MAKE(0, 0, 1), PDM_USBHLP_VERSION }, 184 { VINF_SUCCESS, 185 PDM_USBINS_VERSION + PDM_VERSION_MAKE(0, 0, 1), PDM_USBHLP_VERSION + PDM_VERSION_MAKE(0, 0, 1) }, 186 }; 187 bool const fSavedMayPanic = RTAssertSetMayPanic(false); 188 bool const fSavedQuiet = RTAssertSetQuiet(true); 189 for (unsigned i = 0; i < RT_ELEMENTS(s_aVersionTests); i++) 190 { 191 g_tstUsbHlp.u32Version = g_tstUsbHlp.u32TheEnd = s_aVersionTests[i].uHlpVersion; 192 pUsbIns = NULL; 193 RTTEST_CHECK_RC(hTest, tstMouseConstruct(0, "relative", 1, &pUsbIns, s_aVersionTests[i].uInsVersion), 194 s_aVersionTests[i].rc); 195 } 196 RTAssertSetMayPanic(fSavedMayPanic); 197 RTAssertSetQuiet(fSavedQuiet); 198 199 g_tstUsbHlp.u32Version = g_tstUsbHlp.u32TheEnd = PDM_USBHLP_VERSION; 157 200 } 158 201 … … 160 203 static void testSendPositionRel(RTTEST hTest) 161 204 { 162 PPDMUSBINS p This = NULL;205 PPDMUSBINS pUsbIns = NULL; 163 206 VUSBURB Urb; 164 207 RTTestSub(hTest, "sending a relative position event"); 165 int rc = tstMouseConstruct(0, "relative", 1, &p This);208 int rc = tstMouseConstruct(0, "relative", 1, &pUsbIns); 166 209 RT_ZERO(Urb); 167 210 if (RT_SUCCESS(rc)) 168 rc = g_UsbHidMou.pfnUsbReset(p This, false);169 if (RT_SUCCESS(rc) && ! s_drvTstMouse.pDrv)211 rc = g_UsbHidMou.pfnUsbReset(pUsbIns, false); 212 if (RT_SUCCESS(rc) && !g_drvTstMouse.pDrv) 170 213 rc = VERR_PDM_MISSING_INTERFACE; 171 214 RTTEST_CHECK_RC_OK(hTest, rc); 172 215 if (RT_SUCCESS(rc)) 173 216 { 174 s_drvTstMouse.pDrv->pfnPutEvent(s_drvTstMouse.pDrv, 123, -16, 1, -1, 3);217 g_drvTstMouse.pDrv->pfnPutEvent(g_drvTstMouse.pDrv, 123, -16, 1, -1, 3); 175 218 Urb.EndPt = 0x01; 176 rc = g_UsbHidMou.pfnUrbQueue(p This, &Urb);177 } 178 if (RT_SUCCESS(rc)) 179 { 180 PVUSBURB pUrb = g_UsbHidMou.pfnUrbReap(p This, 0);219 rc = g_UsbHidMou.pfnUrbQueue(pUsbIns, &Urb); 220 } 221 if (RT_SUCCESS(rc)) 222 { 223 PVUSBURB pUrb = g_UsbHidMou.pfnUrbReap(pUsbIns, 0); 181 224 if (pUrb) 182 225 { … … 196 239 } 197 240 RTTEST_CHECK_RC_OK(hTest, rc); 198 if (p This)199 g_UsbHidMou.pfnDestruct(p This);241 if (pUsbIns) 242 g_UsbHidMou.pfnDestruct(pUsbIns); 200 243 } 201 244 … … 203 246 static void testSendPositionAbs(RTTEST hTest) 204 247 { 205 PPDMUSBINS p This = NULL;248 PPDMUSBINS pUsbIns = NULL; 206 249 VUSBURB Urb; 207 250 RTTestSub(hTest, "sending an absolute position event"); 208 int rc = tstMouseConstruct(0, "absolute", 1, &p This);251 int rc = tstMouseConstruct(0, "absolute", 1, &pUsbIns); 209 252 RT_ZERO(Urb); 210 253 if (RT_SUCCESS(rc)) 211 254 { 212 rc = g_UsbHidMou.pfnUsbReset(p This, false);213 } 214 if (RT_SUCCESS(rc)) 215 { 216 if ( s_drvTstMouse.pDrv)217 s_drvTstMouse.pDrv->pfnPutEventAbs(s_drvTstMouse.pDrv, 300, 200, 1,255 rc = g_UsbHidMou.pfnUsbReset(pUsbIns, false); 256 } 257 if (RT_SUCCESS(rc)) 258 { 259 if (g_drvTstMouse.pDrv) 260 g_drvTstMouse.pDrv->pfnPutEventAbs(g_drvTstMouse.pDrv, 300, 200, 1, 218 261 3, 3); 219 262 else … … 223 266 { 224 267 Urb.EndPt = 0x01; 225 rc = g_UsbHidMou.pfnUrbQueue(p This, &Urb);226 } 227 if (RT_SUCCESS(rc)) 228 { 229 PVUSBURB pUrb = g_UsbHidMou.pfnUrbReap(p This, 0);268 rc = g_UsbHidMou.pfnUrbQueue(pUsbIns, &Urb); 269 } 270 if (RT_SUCCESS(rc)) 271 { 272 PVUSBURB pUrb = g_UsbHidMou.pfnUrbReap(pUsbIns, 0); 230 273 if (pUrb) 231 274 { … … 246 289 } 247 290 RTTEST_CHECK_RC_OK(hTest, rc); 248 if (p This)249 g_UsbHidMou.pfnDestruct(p This);291 if (pUsbIns) 292 g_UsbHidMou.pfnDestruct(pUsbIns); 250 293 } 251 294 … … 254 297 static void testSendPositionMT(RTTEST hTest) 255 298 { 256 PPDMUSBINS p This = NULL;299 PPDMUSBINS pUsbIns = NULL; 257 300 VUSBURB Urb; 258 301 RTTestSub(hTest, "sending a multi-touch position event"); 259 int rc = tstMouseConstruct(0, "multitouch", 1, &p This);302 int rc = tstMouseConstruct(0, "multitouch", 1, &pUsbIns); 260 303 RT_ZERO(Urb); 261 304 if (RT_SUCCESS(rc)) 262 305 { 263 rc = g_UsbHidMou.pfnUsbReset(p This, false);264 } 265 if (RT_SUCCESS(rc)) 266 { 267 if ( s_drvTstMouse.pDrv)268 s_drvTstMouse.pDrv->pfnPutEventMT(s_drvTstMouse.pDrv, 300, 200, 2,306 rc = g_UsbHidMou.pfnUsbReset(pUsbIns, false); 307 } 308 if (RT_SUCCESS(rc)) 309 { 310 if (g_drvTstMouse.pDrv) 311 g_drvTstMouse.pDrv->pfnPutEventMT(g_drvTstMouse.pDrv, 300, 200, 2, 269 312 3); 270 313 else … … 274 317 { 275 318 Urb.EndPt = 0x01; 276 rc = g_UsbHidMou.pfnUrbQueue(p This, &Urb);277 } 278 if (RT_SUCCESS(rc)) 279 { 280 PVUSBURB pUrb = g_UsbHidMou.pfnUrbReap(p This, 0);319 rc = g_UsbHidMou.pfnUrbQueue(pUsbIns, &Urb); 320 } 321 if (RT_SUCCESS(rc)) 322 { 323 PVUSBURB pUrb = g_UsbHidMou.pfnUrbReap(pUsbIns, 0); 281 324 if (pUrb) 282 325 { … … 297 340 } 298 341 RTTEST_CHECK_RC_OK(hTest, rc); 299 if (p This)300 g_UsbHidMou.pfnDestruct(p This);342 if (pUsbIns) 343 g_UsbHidMou.pfnDestruct(pUsbIns); 301 344 } 302 345 #endif … … 313 356 RTTestBanner(hTest); 314 357 /* Set up our faked PDMUSBHLP interface. */ 315 s_tstUsbHlp.pfnVMSetErrorV = tstVMSetErrorV; 316 s_tstUsbHlp.pfnDriverAttach = tstDriverAttach; 358 g_tstUsbHlp.u32Version = PDM_USBHLP_VERSION; 359 g_tstUsbHlp.pfnVMSetErrorV = tstVMSetErrorV; 360 g_tstUsbHlp.pfnDriverAttach = tstDriverAttach; 361 g_tstUsbHlp.u32TheEnd = PDM_USBHLP_VERSION; 317 362 /* Set up our global mouse driver */ 318 s_drvTstMouse.IBase.pfnQueryInterface = tstMouseQueryInterface;319 s_drvTstMouse.IConnector.pfnReportModes = tstMouseReportModes;363 g_drvTstMouse.IBase.pfnQueryInterface = tstMouseQueryInterface; 364 g_drvTstMouse.IConnector.pfnReportModes = tstMouseReportModes; 320 365 321 366 /*
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器