void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window) { mainWindow = window; #ifdef SPNAV_FOUND if (spnav_x11_open(QX11Info::display(), window->winId()) == -1) Base::Console().Log("Couldn't connect to spacenav daemon\n"); else { Base::Console().Log("Connected to spacenav daemon\n"); spaceballPresent = true; } #endif #ifdef _USE_3DCONNEXION_SDK spaceballPresent = Is3dmouseAttached(); if (spaceballPresent) { fLast3dmouseInputTime = 0; if (InitializeRawInput(mainWindow->winId())) { gMouseInput = this; qApp->setEventFilter(Gui::GUIApplicationNativeEventAware::RawInputEventFilter); } } #endif // _USE_3DCONNEXION_SDK Spaceball::MotionEvent::MotionEventType = QEvent::registerEventType(); Spaceball::ButtonEvent::ButtonEventType = QEvent::registerEventType(); }
void ConnexionClient::init() { if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) { fLast3dmouseInputTime = 0; InitializeRawInput(GetActiveWindow()); QAbstractEventDispatcher::instance()->installNativeEventFilter(this); } }
/******************************************************************* * WinMain *******************************************************************/ int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { //set up the application window if ( !initWindow(hWnd, hInstance, 800 , 600)) return -1; //initialize raw input if ( !InitializeRawInput() ) return -1; //create renderer if (!renderer.Initialize(&hWnd) ) return -1; //initialize test scene if (!renderer.InitializeScene() ) return -1; renderer.SetShadowMapBias( smBias); //camera setup float eye[3] = {0, 10, -10}, fp[3] = {9,9,0}, u[3] = {0,1,0}; camera.PositionCamera(eye, fp, u); camera.SetPerspectiveProjectionLH( 0.785f, 4.0f/3, 1.0f, 1000.0f); camera.SetMovementSpeed( 10.0f ); camera.Update(); //show first frame and welcome message renderer.RenderFrame(); MessageBox( hWnd, L"T = Toggle Shadow Map Filtering\nY = Toggle Shadow Map Resolution\nU = Toggle Shadow Map Generation Method\n +/- = Adjust shadow map bias", L"DirectX10 Tutorial 10 - Shadow Mapping", MB_ICONINFORMATION ); //frame timer HRTimer fTimer; fTimer.Reset(); //main message loop MSG msg = {0}; while (WM_QUIT != msg.message) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE) { TranslateMessage(&msg); DispatchMessage(&msg); } else { //limit FPS to 60FPS - hack to reduce GPU squealing while ( fTimer.GetElapsedTimeMilliseconds() < 16 ); renderer.RenderFrame(); camera.Update(); fTimer.Reset(); } } //cleanup return 0; }
void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window) { mainWindow = window; #ifdef Q_WS_X11 #ifdef SPNAV_FOUND if (spnav_x11_open(QX11Info::display(), window->winId()) == -1) Base::Console().Log("Couldn't connect to spacenav daemon\n"); else { Base::Console().Log("Connected to spacenav daemon\n"); spaceballPresent = true; } #endif #endif #ifdef _USE_3DCONNEXION_SDK #ifdef Q_WS_WIN spaceballPresent = Is3dmouseAttached(); if (spaceballPresent) { fLast3dmouseInputTime = 0; if (InitializeRawInput(mainWindow->winId())){ gMouseInput = this; qApp->setEventFilter(Gui::GUIApplicationNativeEventAware::RawInputEventFilter); } } #endif //mac #ifdef Q_WS_MACX OSStatus err; /* make sure the framework is installed */ if (InstallConnexionHandlers == NULL) { Base::Console().Log("3Dconnexion framework not found!\n"); return; } /* install 3dx message handler in order to receive driver events */ err = InstallConnexionHandlers(tdx_drv_handler, 0L, 0L); assert(err == 0); if (err) { Base::Console().Log("Error installing 3Dconnexion handler\n"); return; } /* register our app with the driver */ //Pascal string Application name required to register driver for application UInt8 tdxAppName[] = {7,'F','r','e','e','C','A','D'}; //32bit appID to register driver for application UInt32 tdxAppID = 'FCAd'; //std::cerr << "tdxClientID: " << tdxClientID << std::endl; tdxClientID = RegisterConnexionClient(tdxAppID, tdxAppName, kConnexionClientModeTakeOver, kConnexionMaskAll); //std::cerr << "tdxClientID: " << tdxClientID << std::endl; if (tdxClientID == 0) { Base::Console().Log("Couldn't connect to 3Dconnexion driver\n"); return; } Base::Console().Log("3Dconnexion device initialized. Client ID: %d\n", tdxClientID); spaceballPresent = true; #endif #endif // _USE_3DCONNEXION_SDK Spaceball::MotionEvent::MotionEventType = QEvent::registerEventType(); Spaceball::ButtonEvent::ButtonEventType = QEvent::registerEventType(); }