int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle) { GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return (int) window->getCursorVisibility(); }
bool Application::processEvent(GHOST_IEvent* event) { GHOST_IWindow* window = event->getWindow(); bool handled = true; switch (event->getType()) { /* case GHOST_kEventUnknown: break; case GHOST_kEventCursorButton: std::cout << "GHOST_kEventCursorButton"; break; case GHOST_kEventCursorMove: std::cout << "GHOST_kEventCursorMove"; break; */ case GHOST_kEventWheel: { GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) event->getData(); if (wheelData->z > 0) { view_rotz += 5.f; } else { view_rotz -= 5.f; } } break; case GHOST_kEventKeyUp: break; case GHOST_kEventKeyDown: { GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*) event->getData(); switch (keyData->key) { case GHOST_kKeyC: { int cursor = m_cursor; cursor++; if (cursor >= GHOST_kStandardCursorNumCursors) { cursor = GHOST_kStandardCursorFirstCursor; } m_cursor = (GHOST_TStandardCursor)cursor; window->setCursorShape(m_cursor); } break; case GHOST_kKeyE: { int x = 200, y= 200; m_system->setCursorPosition(x,y); break; } case GHOST_kKeyF: if (!m_system->getFullScreen()) { // Begin fullscreen mode GHOST_DisplaySetting setting; setting.bpp = 16; setting.frequency = 50; setting.xPixels = 640; setting.yPixels = 480; m_system->beginFullScreen(setting, &m_fullScreenWindow, false /* stereo flag */); } else { m_system->endFullScreen(); m_fullScreenWindow = 0; } break; case GHOST_kKeyH: window->setCursorVisibility(!window->getCursorVisibility()); break; case GHOST_kKeyM: { bool down = false; m_system->getModifierKeyState(GHOST_kModifierKeyLeftShift,down); if (down) { std::cout << "left shift down\n"; } m_system->getModifierKeyState(GHOST_kModifierKeyRightShift,down); if (down) { std::cout << "right shift down\n"; } m_system->getModifierKeyState(GHOST_kModifierKeyLeftAlt,down); if (down) { std::cout << "left Alt down\n"; } m_system->getModifierKeyState(GHOST_kModifierKeyRightAlt,down); if (down) { std::cout << "right Alt down\n"; } m_system->getModifierKeyState(GHOST_kModifierKeyLeftControl,down); if (down) { std::cout << "left control down\n"; } m_system->getModifierKeyState(GHOST_kModifierKeyRightControl,down); if (down) { std::cout << "right control down\n"; } } break; case GHOST_kKeyQ: if (m_system->getFullScreen()) { m_system->endFullScreen(); m_fullScreenWindow = 0; } m_exitRequested = true; break; case GHOST_kKeyS: // toggle mono and stereo if(stereo) stereo = false; else stereo = true; break; case GHOST_kKeyT: if (!m_testTimer) { m_testTimer = m_system->installTimer(0, 1000, testTimerProc); } else { m_system->removeTimer(m_testTimer); m_testTimer = 0; } break; case GHOST_kKeyW: if (m_mainWindow) { STR_String title; m_mainWindow->getTitle(title); title += "-"; m_mainWindow->setTitle(title); } break; default: break; } } break; case GHOST_kEventWindowClose: { GHOST_IWindow* window2 = event->getWindow(); if (window2 == m_mainWindow) { m_exitRequested = true; } else { m_system->disposeWindow(window2); } } break; case GHOST_kEventWindowActivate: handled = false; break; case GHOST_kEventWindowDeactivate: handled = false; break; case GHOST_kEventWindowUpdate: { GHOST_IWindow* window2 = event->getWindow(); if(!m_system->validWindow(window2)) break; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(stereo) { View(window2, stereo, LEFT_EYE); glPushMatrix(); RenderCamera(); RenderScene(); glPopMatrix(); View(window2, stereo, RIGHT_EYE); glPushMatrix(); RenderCamera(); RenderScene(); glPopMatrix(); } else { View(window2, stereo); glPushMatrix(); RenderCamera(); RenderScene(); glPopMatrix(); } window2->swapBuffers(); } break; default: handled = false; break; } return handled; }