//----------------------------------------------------------------------------- void OculusWorldDemoApp::CycleDisplay() { int screenCount = pPlatform->GetDisplayCount(); // If Windowed, switch to the HMD screen first in Full-Screen Mode. // If already Full-Screen, cycle to next screen until we reach FirstScreenInCycle. if (pRender->IsFullscreen()) { // Right now, we always need to restore window before going to next screen. pPlatform->SetFullscreen(RenderParams, Display_Window); Screen++; if (Screen == screenCount) Screen = 0; RenderParams.Display = pPlatform->GetDisplay(Screen); if (Screen != FirstScreenInCycle) { pRender->SetParams(RenderParams); pPlatform->SetFullscreen(RenderParams, Display_Fullscreen); } } else { // Try to find HMD Screen, making it the first screen in full-screen Cycle. FirstScreenInCycle = 0; if (pHMD) { DisplayId HMD (SConfig.GetHMDInfo().DisplayDeviceName, SConfig.GetHMDInfo().DisplayId); for (int i = 0; i< screenCount; i++) { if (pPlatform->GetDisplay(i) == HMD) { FirstScreenInCycle = i; break; } } } // Switch full-screen on the HMD. Screen = FirstScreenInCycle; RenderParams.Display = pPlatform->GetDisplay(Screen); pRender->SetParams(RenderParams); pPlatform->SetFullscreen(RenderParams, Display_Fullscreen); } }
void OculusWorldDemoApp::OnKey(OVR::KeyCode key, int chr, bool down, int modifiers) { OVR_UNUSED(chr); switch(key) { case Key_Q: if (down && (modifiers & Mod_Control)) { pPlatform->Exit(0); } break; case Key_B: if (down) { if(SConfig.GetDistortionScale() == 1.0f) { if(SConfig.GetHMDInfo().HScreenSize > 0.140f) // 7" { SConfig.SetDistortionFitPointVP(-1.0f, 0.0f); } else { SConfig.SetDistortionFitPointVP(0.0f, 1.0f); } } else { // No fitting; scale == 1.0. SConfig.SetDistortionFitPointVP(0, 0); } } break; // Support toggling background color for distortion so that we can see // the effect on the periphery. case Key_V: if (down) { if(DistortionClearColor.B == 0) { DistortionClearColor = Color(0, 128, 255); } else { DistortionClearColor = Color(0, 0, 0); } pRender->SetDistortionClearColor(DistortionClearColor); } break; case Key_F1: SConfig.SetStereoMode(Stereo_None); PostProcess = PostProcess_None; SetAdjustMessage("StereoMode: None"); break; case Key_F2: SConfig.SetStereoMode(Stereo_LeftRight_Multipass); PostProcess = PostProcess_None; SetAdjustMessage("StereoMode: Stereo + No Distortion"); break; case Key_F3: SConfig.SetStereoMode(Stereo_LeftRight_Multipass); PostProcess = PostProcess_Distortion; SetAdjustMessage("StereoMode: Stereo + Distortion"); break; // Stereo adjustments. case Key_BracketLeft: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustFov : 0; AdjustDirection = 1; break; case Key_BracketRight: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustFov : 0; AdjustDirection = -1; break; case Key_Insert: case Key_Num0: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustIPD : 0; AdjustDirection = 1; break; case Key_Delete: case Key_Num9: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustIPD : 0; AdjustDirection = -1; break; case Key_Home: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustPS : 0; AdjustDirection = 1; break; case Key_End: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustPS : 0; AdjustDirection = -1; break; case Key_PageUp: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustAspect : 0; AdjustDirection = 1; break; case Key_PageDown: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustAspect : 0; AdjustDirection = -1; break; // Distortion correction adjustments case Key_H: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK0 : NULL; AdjustDirection = -1; break; case Key_Y: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK0 : NULL; AdjustDirection = 1; break; case Key_J: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK1 : NULL; AdjustDirection = -1; break; case Key_U: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK1 : NULL; AdjustDirection = 1; break; case Key_K: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK2 : NULL; AdjustDirection = -1; break; case Key_I: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK2 : NULL; AdjustDirection = 1; break; case Key_L: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK3 : NULL; AdjustDirection = -1; break; case Key_O: pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK3 : NULL; AdjustDirection = 1; break; case Key_C: if (down) { // Toggle chromatic aberration correction on/off. RenderDevice::PostProcessShader shader = pRender->GetPostProcessShader(); if (shader == RenderDevice::PostProcessShader_Distortion) { pRender->SetPostProcessShader(RenderDevice::PostProcessShader_DistortionAndChromAb); SetAdjustMessage("Chromatic Aberration Correction On"); } else if (shader == RenderDevice::PostProcessShader_DistortionAndChromAb) { pRender->SetPostProcessShader(RenderDevice::PostProcessShader_Distortion); SetAdjustMessage("Chromatic Aberration Correction Off"); } else OVR_ASSERT(false); } break; case Key_F9: #ifndef OVR_OS_LINUX // On Linux F9 does the same as F11. if (!down) { CycleDisplay(); } break; #endif #ifdef OVR_OS_MAC case Key_F10: // F11 is reserved on Mac #else case Key_F11: #endif if (!down) { RenderParams = pRender->GetParams(); RenderParams.Display = DisplayId(SConfig.GetHMDInfo().DisplayDeviceName,SConfig.GetHMDInfo().DisplayId); pRender->SetParams(RenderParams); pPlatform->SetMouseMode(Mouse_Normal); pPlatform->SetFullscreen(RenderParams, pRender->IsFullscreen() ? Display_Window : Display_FakeFullscreen); pPlatform->SetMouseMode(Mouse_Relative); // Avoid mode world rotation jump. // If using an HMD, enable post-process (for distortion) and stereo. if(RenderParams.IsDisplaySet() && pRender->IsFullscreen()) { SConfig.SetStereoMode(Stereo_LeftRight_Multipass); PostProcess = PostProcess_Distortion; } } break; default: break; } }