----------------------------------------------------------------------------- Purpose: -----------------------------------------------------------------------------
| 270 | // Purpose: |
| 271 | //----------------------------------------------------------------------------- |
| 272 | void COpenVROverlayController::OnTimeoutPumpEvents() |
| 273 | { |
| 274 | if( !vr::VRSystem() ) |
| 275 | return; |
| 276 | |
| 277 | vr::VREvent_t vrEvent; |
| 278 | while( vr::VROverlay()->PollNextOverlayEvent( m_ulOverlayHandle, &vrEvent, sizeof( vrEvent ) ) ) |
| 279 | { |
| 280 | switch( vrEvent.eventType ) |
| 281 | { |
| 282 | case vr::VREvent_MouseMove: |
| 283 | { |
| 284 | QPointF ptNewMouse( vrEvent.data.mouse.x, vrEvent.data.mouse.y ); |
| 285 | QPoint ptGlobal = ptNewMouse.toPoint(); |
| 286 | QMouseEvent mouseEvent( QEvent::MouseMove, |
| 287 | ptNewMouse, |
| 288 | ptNewMouse, |
| 289 | ptGlobal, |
| 290 | Qt::NoButton, |
| 291 | m_lastMouseButtons, |
| 292 | 0, |
| 293 | Qt::MouseEventSynthesizedByApplication ); |
| 294 | |
| 295 | m_ptLastMouse = ptNewMouse; |
| 296 | |
| 297 | QCoreApplication::sendEvent( m_pWindow, &mouseEvent ); |
| 298 | OnRequestUpdate(); |
| 299 | } |
| 300 | break; |
| 301 | |
| 302 | case vr::VREvent_MouseButtonDown: |
| 303 | { |
| 304 | Qt::MouseButton button = vrEvent.data.mouse.button == vr::VRMouseButton_Right ? Qt::RightButton : Qt::LeftButton; |
| 305 | |
| 306 | m_lastMouseButtons |= button; |
| 307 | |
| 308 | QPoint ptGlobal = m_ptLastMouse.toPoint(); |
| 309 | QMouseEvent mouseEvent( QEvent::MouseButtonPress, |
| 310 | m_ptLastMouse, |
| 311 | m_ptLastMouse, |
| 312 | ptGlobal, |
| 313 | button, |
| 314 | m_lastMouseButtons, |
| 315 | 0, |
| 316 | Qt::MouseEventSynthesizedByApplication ); |
| 317 | |
| 318 | QCoreApplication::sendEvent( m_pWindow, &mouseEvent ); |
| 319 | } |
| 320 | break; |
| 321 | |
| 322 | case vr::VREvent_MouseButtonUp: |
| 323 | { |
| 324 | Qt::MouseButton button = vrEvent.data.mouse.button == vr::VRMouseButton_Right ? Qt::RightButton : Qt::LeftButton; |
| 325 | m_lastMouseButtons &= ~button; |
| 326 | |
| 327 | QPoint ptGlobal = m_ptLastMouse.toPoint(); |
| 328 | QMouseEvent mouseEvent( QEvent::MouseButtonRelease, |
| 329 | m_ptLastMouse, |