/** * Loads stereo mode effect file. ***/ void StereoView::InitShaderEffects() { shaderEffect[ANAGLYPH_RED_CYAN] = "AnaglyphRedCyan.fx"; shaderEffect[ANAGLYPH_RED_CYAN_GRAY] = "AnaglyphRedCyanGray.fx"; shaderEffect[ANAGLYPH_YELLOW_BLUE] = "AnaglyphYellowBlue.fx"; shaderEffect[ANAGLYPH_YELLOW_BLUE_GRAY] = "AnaglyphYellowBlueGray.fx"; shaderEffect[ANAGLYPH_GREEN_MAGENTA] = "AnaglyphGreenMagenta.fx"; shaderEffect[ANAGLYPH_GREEN_MAGENTA_GRAY] = "AnaglyphGreenMagentaGray.fx"; shaderEffect[SIDE_BY_SIDE] = "SideBySide.fx"; shaderEffect[DIY_RIFT] = "SideBySideRift.fx"; shaderEffect[OVER_UNDER] = "OverUnder.fx"; shaderEffect[INTERLEAVE_HORZ] = "InterleaveHorz.fx"; shaderEffect[INTERLEAVE_VERT] = "InterleaveVert.fx"; shaderEffect[CHECKERBOARD] = "Checkerboard.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); if (FAILED(D3DXCreateEffectFromFile(m_pActualDevice, viewPath, NULL, NULL, D3DXFX_DONOTSAVESTATE, NULL, &viewEffect, NULL))) { OutputDebugString("Effect creation failed\n"); } }
void new_selection3() { int selection = (int)SendMessage(combobox_handle, CB_GETCURSEL, 0, 0); if ( selection != CB_ERR ) { // save the adapter to xml file ProxyHelper helper = ProxyHelper(); helper.SaveDisplayAdapter(selection); } }
void ParsePaths() { proxyDllW = (LPCWSTR)malloc(512*sizeof(wchar_t)); ProxyHelper helper = ProxyHelper(); dllDir = _strdup(helper.GetPath("bin\\").c_str()); proxyDll = _strdup(helper.GetPath("bin\\d3d9.dll").c_str()); mbstowcs_s(NULL, (wchar_t*)proxyDllW, 512, proxyDll, 512); }
void ParsePaths() { dllDir = (LPCSTR)malloc(512*sizeof(char)); proxyDll = (LPCSTR)malloc(512*sizeof(char)); proxyDllW = (LPCWSTR)malloc(512*sizeof(wchar_t)); ProxyHelper helper = ProxyHelper(); helper.GetPath((char*)dllDir, "bin\\"); helper.GetPath((char*)proxyDll, "bin\\d3d9.dll"); mbstowcs_s(NULL, (wchar_t*)proxyDllW, 512, proxyDll, 512); }
void OculusRiftView::InitShaderEffects() { shaderEffect[OCULUS_RIFT] = "OculusRift.fx"; shaderEffect[OCULUS_RIFT_CROPPED] = "OculusRiftCropped.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); D3DXCreateEffectFromFile(device, viewPath, NULL, NULL, 0, NULL, &viewEffect, NULL); }
/** * Create D3D device proxy. * First it creates the device, then it loads the game configuration * calling the ProxyHelper class. Last it creates and returns the * device proxy calling D3DProxyDeviceFactory::Get(). ***/ HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) { // Create real interface HRESULT hResult = m_pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); if(FAILED(hResult)) return hResult; OutputDebugString("[OK] Normal D3D device created\n"); char buf[64]; sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount); OutputDebugString(buf); // load configuration file ProxyHelper helper = ProxyHelper(); ProxyHelper::ProxyConfig cfg; ProxyHelper::OculusProfile oculusProfile; if(!helper.LoadConfig(cfg, oculusProfile)) { OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } // load HUD/GUI settings helper.LoadHUDConfig(cfg); helper.LoadGUIConfig(cfg); OutputDebugString("[OK] Config loading - OK\n"); if(cfg.stereo_mode == StereoView::DISABLED) { OutputDebugString("[WARN] stereo_mode == disabled. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } OutputDebugString("[OK] Stereo mode is enabled.\n"); char buf1[32]; LPCSTR psz = NULL; wsprintf(buf1,"Config type: %d", cfg.game_type); psz = buf1; OutputDebugString(psz); OutputDebugString("\n"); // Create and return proxy *ppReturnedDeviceInterface = D3DProxyDeviceFactory::Get(cfg, *ppReturnedDeviceInterface, this); OutputDebugString("[OK] Vireio D3D device created.\n"); return hResult; }
HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { // load configuration file ProxyHelper helper = ProxyHelper(); ProxyHelper::ProxyConfig cfg; bool stereoificatorCfgLoaded = helper.LoadConfig(cfg); if (cfg.forceAdapterNumber >= (int)GetAdapterCount()) { OutputDebugString("[ERR] forceAdapterNumber outside of range of valid adapters. Using original Adapter instead.\n"); } // Create real interface HRESULT hResult = m_pD3D->CreateDevice( (cfg.forceAdapterNumber >= (int)GetAdapterCount() || (cfg.forceAdapterNumber < 0)) ? Adapter : cfg.forceAdapterNumber, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); if(FAILED(hResult)) return hResult; OutputDebugString("[OK] Normal D3D device created\n"); char buf[64]; sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount); OutputDebugString(buf); if(!stereoificatorCfgLoaded) { OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Stereoificator will not be active.\n"); return hResult; } OutputDebugString("[OK] Config loading - OK\n"); char buf1[32]; LPCSTR psz = NULL; wsprintf(buf1,"Config type: %d", cfg.game_type); psz = buf1; OutputDebugString(psz); OutputDebugString("\n"); // Create and return proxy D3DProxyDevice* newDev = new D3DProxyDevice(*ppReturnedDeviceInterface, this, cfg); *ppReturnedDeviceInterface = newDev; OutputDebugString("[OK] Stereoificator D3D device created.\n"); return hResult; }
void combobox_control::new_selection2() { char string[120]; int selection = (int)SendMessage(combobox_handle, CB_GETCURSEL, 0, 0); if ( selection != CB_ERR ) { SendMessage(combobox_handle, CB_GETLBTEXT, selection, (LPARAM)string); int length = 0; char * s = string; while ( *s++ != '\t' ) length++; // save the tracker mode to xml file ProxyHelper helper = ProxyHelper(); int mode = atoi(s); helper.SaveConfig2(mode); } }
void StereoView::InitShaderEffects() { shaderEffect[SIDE_BY_SIDE] = "SideBySide.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); if (FAILED(D3DXCreateEffectFromFile(m_pActualDevice, viewPath, NULL, NULL, D3DXFX_DONOTSAVESTATE, NULL, &viewEffect, NULL))) { OutputDebugString("Effect creation failed\n"); } }
void combobox_control::new_selection() { char string[120]; int selection = (int)SendMessage(combobox_handle, CB_GETCURSEL, 0, 0); if ( selection != CB_ERR ) { SendMessage(combobox_handle, CB_GETLBTEXT, selection, (LPARAM)string); int length = 0; char * s = string; while ( *s++ != '\t' ) length++; //text->set_text(s); // save the stereo mode to xml file ProxyHelper helper = ProxyHelper(); int mode = atoi(s); float aspect = mode == 25 ? 0.5f : 1.0f; helper.SaveConfig(mode, aspect); } }
// CBT Hook-style injection. BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved ) { if (fdwReason == DLL_PROCESS_ATTACH) // When initializing.... { hDLL = hModule; // We don't need thread notifications for what we're doing. Thus, get // rid of them, thereby eliminating some of the overhead of this DLL DisableThreadLibraryCalls(hModule); // Only hook the APIs if this is the right process. GetModuleFileName(GetModuleHandle(NULL), targetExe, sizeof(targetExe)); PathStripPath(targetExe); GetModuleFileName(GetModuleHandle(NULL), targetPath, sizeof(targetPath)); targetPathString = std::string(targetPath); targetPathString = targetPathString.substr(0, targetPathString.find_last_of("\\/")); OutputDebugString("HIJACKDLL checking process: "); OutputDebugString(targetExe); OutputDebugString("\n"); ParsePaths(); ProxyHelper helper = ProxyHelper(); if (helper.HasProfile(targetExe)) { if (HookAPICalls(&D3DHook)) { OutputDebugString("HookAPICalls(D3D): TRUE\n"); } else if(HookAPICalls(&KernelHook)) { OutputDebugString("HookAPICalls(Kernel): TRUE\n"); } else { OutputDebugString("HookAPICalls(Both): FALSE\n"); } SetDllDirectory(dllDir); SaveExeName(targetExe); } } return TRUE; }
/** * Loads Oculus Rift shader effect files. ***/ void OculusRiftView::InitShaderEffects() { //Currently, RiftUp DK1 and DK2 share the same shader effects shaderEffect[RIFTUP] = "OculusRift.fx"; shaderEffect[OCULUS_RIFT_DK1] = "OculusRift.fx"; shaderEffect[OCULUS_RIFT_DK1_CROPPED] = "OculusRiftCropped.fx"; shaderEffect[OCULUS_RIFT_DK2] = "OculusRiftDK2.fx"; shaderEffect[OCULUS_RIFT_DK2_CROPPED] = "OculusRiftDK2Cropped.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); D3DXCreateEffectFromFile(m_pActualDevice, viewPath, NULL, NULL, 0, NULL, &viewEffect, NULL); }
frame_window(LPCSTR window_class_identity) : window_class_name(window_class_identity) { int screen_width = GetSystemMetrics(SM_CXFULLSCREEN); int screen_height = GetSystemMetrics(SM_CYFULLSCREEN); instance_handle = GetModuleHandle(NULL); WNDCLASS window_class = { CS_OWNDC, main_window_proc, 0, 0, instance_handle, NULL, NULL, NULL, NULL, window_class_name }; window_class.hIcon = LoadIcon(instance_handle, MAKEINTRESOURCE(IDI_ICON_BIG)); RegisterClass(&window_class); window_handle = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_TOPMOST, window_class_name, "Vireio Perception", WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), //WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, (screen_width-585)/2, (screen_height-240)/2, 585, 270, NULL, NULL, instance_handle, NULL); SetWindowLongPtr(window_handle, GWL_USERDATA, (LONG)this); GetClientRect(window_handle, &client_rectangle); int width = client_rectangle.right - client_rectangle.left; int height = client_rectangle.bottom - client_rectangle.top; text = new static_control(instance_handle, window_handle); combobox = new combobox_control(instance_handle, window_handle, text, 20, 81, 1001); combobox2 = new combobox_control(instance_handle, window_handle, text, 20, 115, 1002); combobox3 = new combobox_control(instance_handle, window_handle, text, 20, 149, 1003); ProxyHelper helper = ProxyHelper(); std::string viewPath = helper.GetPath("img\\logo.bmp"); logo_bitmap = (HBITMAP)LoadImage(NULL,viewPath.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); OutputDebugString("Load the bitmap\n"); ProxyConfig cfg; helper.LoadUserConfig(cfg, oculusProfile); SetCursor(LoadCursor(NULL, IDC_ARROW)); ShowWindow(window_handle, SW_SHOW); UpdateWindow(window_handle); //Refresh on timer for FPS readings SetTimer(window_handle, 1, 500, NULL); }
int WINAPI wWinMain(HINSTANCE instance_handle, HINSTANCE, LPWSTR, INT) { InitConfig(); InitModes(); InstallHook(); frame_window main_window("perception"); main_window.add_item("Disabled\t0"); main_window.add_item("DIY Rift\t25"); main_window.add_item("Oculus Rift\t26"); main_window.add_item("Oculus Rift Cropped\t27"); main_window.add_item("Side by Side\t20"); main_window.add_item("Over Under\t30"); main_window.add_item("Horizontal Interleave\t40"); main_window.add_item("Vertical Interleave\t50"); main_window.add_item("Checkerboard\t60"); main_window.add_item("Anaglyph (Red/Cyan)\t1"); main_window.add_item("Anaglyph (Red/Cyan) B+W\t2"); main_window.add_item("Anaglyph (Yellow/Blue)\t5"); main_window.add_item("Anaglyph (Yellow/Blue) B+W\t6"); main_window.add_item("Anaglyph (Green/Magenta)\t10"); main_window.add_item("Anaglyph (Green/Magenta) B+W\t11"); main_window.add_item2("No Tracking\t0"); main_window.add_item2("Hillcrest Labs\t10"); main_window.add_item2("FreeTrack\t20"); main_window.add_item2("Shared Memory Tracker\t30"); main_window.add_item2("OculusTrack\t40"); int mode; int mode2; ProxyHelper helper = ProxyHelper(); helper.GetConfig(mode, mode2); SendMessage(main_window.combobox->combobox_handle, CB_SETCURSEL, stereoModes[mode], 0); SendMessage(main_window.combobox2->combobox_handle, CB_SETCURSEL, trackerModes[mode2], 0); main_window.run(); RemoveHook(); return 0; }
void D3DProxyDevice::HandleControls() { float keySpeed = 0.00002f; float keySpeed2 = 0.0005f; float mouseSpeed = 0.25f; float rollSpeed = 0.01f; static int keyWaitCount = 0; keyWaitCount--; static int saveWaitCount = 0; saveWaitCount--; static bool doSaveNext = false; if(KEY_DOWN(VK_F1)) { if(stereoView->initialized) { stereoView->SaveScreen(); } } if(KEY_DOWN(VK_F2)) { if(KEY_DOWN(VK_SHIFT)) { offset -= keySpeed; } else { separation -= keySpeed; } saveWaitCount = 500; doSaveNext = true; } if(KEY_DOWN(VK_F3)) { if(KEY_DOWN(VK_SHIFT)) { offset += keySpeed; } else { separation += keySpeed; } saveWaitCount = 500; doSaveNext = true; } if(KEY_DOWN(VK_F4)) { convergence -= keySpeed2; saveWaitCount = 500; doSaveNext = true; } if(KEY_DOWN(VK_F5)) { convergence += keySpeed2; saveWaitCount = 500; doSaveNext = true; } if(KEY_DOWN(VK_F6)) { if(KEY_DOWN(VK_SHIFT)) { separation = 0.0f; convergence = 0.0f; offset = 0.0f; yaw_multiplier = 25.0f; pitch_multiplier = 25.0f; roll_multiplier = 1.0f; //matrixIndex = 0; saveWaitCount = 500; doSaveNext = true; } else if(keyWaitCount <= 0) { swap_eyes = !swap_eyes; stereoView->SwapEyes(swap_eyes); keyWaitCount = 200; } } if(KEY_DOWN(VK_F7) && keyWaitCount <= 0) { matrixIndex++; if(matrixIndex > 15) { matrixIndex = 0; } keyWaitCount = 200; } if(KEY_DOWN(VK_F8)) { if(KEY_DOWN(VK_SHIFT)) { pitch_multiplier -= mouseSpeed; } else if(KEY_DOWN(VK_CONTROL)) { roll_multiplier -= rollSpeed; } else { yaw_multiplier -= mouseSpeed; } if(trackerInitialized && tracker->isAvailable()) { tracker->setMultipliers(yaw_multiplier, pitch_multiplier, roll_multiplier); } saveWaitCount = 500; doSaveNext = true; } if(KEY_DOWN(VK_F9)) { if(KEY_DOWN(VK_SHIFT)) { pitch_multiplier += mouseSpeed; } else if(KEY_DOWN(VK_CONTROL)) { roll_multiplier += rollSpeed; } else { yaw_multiplier += mouseSpeed; } if(trackerInitialized && tracker->isAvailable()) { tracker->setMultipliers(yaw_multiplier, pitch_multiplier, roll_multiplier); } saveWaitCount = 500; doSaveNext = true; } if(saveDebugFile) { debugFile.close(); } saveDebugFile = false; if(KEY_DOWN(VK_F12) && keyWaitCount <= 0) { // uncomment to save text debug file //saveDebugFile = true; keyWaitCount = 200; } if(doSaveNext && saveWaitCount < 0) { doSaveNext = false; ProxyHelper* helper = new ProxyHelper(); helper->SaveProfile(separation, convergence, yaw_multiplier, pitch_multiplier, roll_multiplier); } }
/** * Keyboard input handling ***/ void D3DProxyDevice::HandleControls() { SHOW_CALL("HandleControls"); controls.UpdateInputs(); if(config.hudSwitchHotkey->IsPressed(controls)) { HUD_3D_Depth_Modes newMode=(HUD_3D_Depth_Modes)(hud3DDepthMode+1); if (newMode>=HUD_3D_Depth_Modes::HUD_ENUM_RANGE) newMode=HUD_3D_Depth_Modes::HUD_DEFAULT; oldHudMode = hud3DDepthMode; ChangeHUD3DDepthMode(newMode); } if(config.guiSwitchHotkey->IsPressed(controls)) { GUI_3D_Depth_Modes newMode=(GUI_3D_Depth_Modes)(gui3DDepthMode+1); if (newMode>=GUI_3D_Depth_Modes::GUI_ENUM_RANGE) newMode=GUI_3D_Depth_Modes::GUI_DEFAULT; oldGuiMode = gui3DDepthMode; ChangeGUI3DDepthMode(newMode); } // loop through hotkeys for (int i=0; i<4; i++) { if (config.hudHotkeys[i]->IsPressed(controls) && HotkeysActive()) { if (hud3DDepthMode==(HUD_3D_Depth_Modes)i) { if (RCtrl->IsHeld(controls)) { oldHudMode = hud3DDepthMode; ChangeHUD3DDepthMode((HUD_3D_Depth_Modes)i); } else { ChangeHUD3DDepthMode(oldHudMode); } } else { oldHudMode = hud3DDepthMode; ChangeHUD3DDepthMode((HUD_3D_Depth_Modes)i); } } if (config.guiHotkeys[i]->IsPressed(controls) && HotkeysActive()) { if (gui3DDepthMode==(GUI_3D_Depth_Modes)i) { if (RCtrl->IsHeld(controls)) { oldGuiMode = gui3DDepthMode; ChangeGUI3DDepthMode((GUI_3D_Depth_Modes)i); } else { ChangeGUI3DDepthMode(oldGuiMode); } } else { oldGuiMode = gui3DDepthMode; ChangeGUI3DDepthMode((GUI_3D_Depth_Modes)i); } } } // test VRBoost reset hotkey if (config.VRBoostResetHotkey->IsPressed(controls) && HotkeysActive()) { if (hmVRboost!=NULL) { m_pVRboost_ReleaseAllMemoryRules(); m_bVRBoostToggle = !m_bVRBoostToggle; if (tracker->getStatus() > MTS_OK) tracker->resetOrientationAndPosition(); // set the indicator to be drawn m_fVRBoostIndicator = 1.0f; } } //If we are in comfort mode and user has pushed left or right, then change yaw if (VRBoostValue[VRboostAxis::ComfortMode] != 0.0f && VRBoostStatus.VRBoost_Active && HotkeysActive()) { if (config.ComfortModeLeftKey->IsPressed(controls)) { m_comfortModeYaw +=config.ComfortModeYawIncrement; if (m_comfortModeYaw == 180.0f) m_comfortModeYaw = -180.0f; } if (config.ComfortModeRightKey->IsPressed(controls)) { m_comfortModeYaw -= config.ComfortModeYawIncrement; if (m_comfortModeYaw == -180.0f) m_comfortModeYaw = 180.0f; } } //Double clicking the Right-Ctrl will disable or re-enable all Vireio hot-keys static DWORD rctrlStartClick = 0; if ((RCtrl->IsHeld(controls) || rctrlStartClick != 0) && HotkeysActive()) { if (RCtrl->IsHeld(controls) && rctrlStartClick == 0) { rctrlStartClick = 1; } else if (!RCtrl->IsHeld(controls) && rctrlStartClick == 1) { rctrlStartClick = GetTickCount(); } else if (RCtrl->IsHeld(controls) && rctrlStartClick > 1) { //If we clicked a second time within 500 ms if ((GetTickCount() - rctrlStartClick) <= 500) { if (!m_disableAllHotkeys) { m_disableAllHotkeys = true; ShowAdjusterToast("VIREIO HOT-KEYS: DISABLED", 2000); } else { m_disableAllHotkeys = false; ShowAdjusterToast("VIREIO HOT-KEYS: ENABLED", 2000); } } rctrlStartClick = 0; } else if (rctrlStartClick > 1 && (GetTickCount() - rctrlStartClick) > 500) { //Reset, user clearly not double clicking rctrlStartClick = 0; } } //Disconnected Screen View Mode if (config.EdgePeekHotkey->IsPressed(controls) && HotkeysActive()) { static bool bForceMouseEmulation = false; if (this->stereoView->m_disconnectedScreenView) { this->stereoView->m_disconnectedScreenView = false; tracker->setMouseEmulation(bForceMouseEmulation); //TODO Change this back to initial this->stereoView->HeadYOffset = 0; this->stereoView->HeadZOffset = FLT_MAX; this->stereoView->XOffset = 0; this->stereoView->PostReset(); } else { //Suspend in-game movement whilst showing disconnected screen view this->stereoView->m_disconnectedScreenView = true; bForceMouseEmulation = tracker->setMouseEmulation(false); if (tracker->getStatus() >= MTS_OK) { m_fFloatingScreenPitch = tracker->primaryPitch; m_fFloatingScreenYaw = tracker->primaryYaw; m_fFloatingScreenZ = tracker->z; } } } float screenFloatMultiplierY = 0.75; float screenFloatMultiplierX = 0.5; float screenFloatMultiplierZ = 1.5; if(this->stereoView->m_disconnectedScreenView) { if (tracker->getStatus() >= MTS_OK) { this->stereoView->HeadYOffset = (m_fFloatingScreenPitch - tracker->primaryPitch) * screenFloatMultiplierY + (0.5f * tracker->y); this->stereoView->XOffset = (m_fFloatingScreenYaw - tracker->primaryYaw) * screenFloatMultiplierX + (0.5f * tracker->x); this->stereoView->HeadZOffset = (m_fFloatingScreenZ - tracker->z) * screenFloatMultiplierZ; this->stereoView->PostReset(); } } else { if (this->stereoView->m_screenViewGlideFactor < 1.0f) { float drift = (sinf(1 + (-cosf((1.0f - this->stereoView->m_screenViewGlideFactor) * 3.142f) / 2)) - 0.5f) * 2.0f; this->stereoView->HeadYOffset = ((m_fFloatingScreenPitch - tracker->primaryPitch) * screenFloatMultiplierY) * drift; this->stereoView->XOffset = ((m_fFloatingScreenYaw - tracker->primaryYaw) * screenFloatMultiplierX) * drift; this->stereoView->PostReset(); } } //Anything in the following block will be unavailable whilst disable hot-keys is active if (!m_disableAllHotkeys) { //Rset HMD Orientation+Position LSHIFT+R, or L+R Shoulder buttons on Xbox 360 controller if (config.HotkeyResetOrientation->IsPressed(controls) && HotkeysActive()) { if (calibrate_tracker) { calibrate_tracker = false; //Replace popup DismissPopup(VPT_CALIBRATE_TRACKER); ShowPopup(VPT_NOTIFICATION, VPS_INFO, 3000, "\n\nHMD Orientation and Position Calibrated\n" "Please repeat if required..."); } else { ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, "HMD Orientation and Position Reset"); } tracker->resetOrientationAndPosition(); } //Duck and cover - trigger crouch and prone keys if Y position of HMD moves appropriately if (m_DuckAndCover.dfcStatus > DAC_INACTIVE && m_DuckAndCover.dfcStatus < DAC_DISABLED && tracker && tracker->getStatus() >= MTS_OK) { if (hotkeyCrouch->IsPressed(controls) && HotkeysActive()) { if (m_DuckAndCover.dfcStatus == DAC_CAL_STANDING) { //Reset positional ready for the next stage tracker->resetPosition(); m_DuckAndCover.dfcStatus = DAC_CAL_CROUCHING; } else if (m_DuckAndCover.dfcStatus == DAC_CAL_CROUCHING) { m_DuckAndCover.yPos_Crouch = tracker->y; //Slightly randomly decided on this m_DuckAndCover.yPos_Jump = fabs(tracker->y) / 3.0f; m_DuckAndCover.dfcStatus = DAC_CAL_PRONE; } else if (m_DuckAndCover.dfcStatus == DAC_CAL_PRONE) { m_DuckAndCover.proneEnabled = true; m_DuckAndCover.yPos_Prone = tracker->y - m_DuckAndCover.yPos_Crouch; m_DuckAndCover.dfcStatus = DAC_CAL_COMPLETE; } else if (m_DuckAndCover.dfcStatus == DAC_CAL_COMPLETE) { //Ready to go.. m_DuckAndCover.dfcStatus = DAC_STANDING; tracker->resetPosition(); DismissPopup(VPT_NOTIFICATION); } } //B button only skips the prone position else if (hotkeySkipProne->IsPressed(controls) && HotkeysActive()) { if (m_DuckAndCover.dfcStatus == DAC_CAL_PRONE) { m_DuckAndCover.proneEnabled = false; m_DuckAndCover.dfcStatus = DAC_CAL_COMPLETE; } } } // Show active VRBoost axes and their addresses (SHIFT+V) if (config.HotkeyShowAxes->IsPressed(controls) && HotkeysActive()) { if (hmVRboost!=NULL) { if (VRBoostStatus.VRBoost_Active) { VireioPopup popup(VPT_NOTIFICATION, VPS_INFO, 10000); ActiveAxisInfo axes[30]; memset(axes, 0xFF, sizeof(ActiveAxisInfo) * 30); UINT count = m_pVRboost_GetActiveRuleAxes((ActiveAxisInfo**)&axes); sprintf_s(popup.line[0], "VRBoost Axis Addresses: %i", count); UINT i = 0; while (i < count) { if (axes[i].Axis == MAXDWORD || i == 6) break; std::string axisName = VRboostAxisString(axes[i].Axis); sprintf_s(popup.line[i+1], " %s: 0x%"PR_SIZET"x", axisName.c_str(), axes[i].Address); i++; } ShowPopup(popup); } } } // switch to 2d Depth Mode (Shift + O / Numpad 9) if (config.HotkeySwitch2DDepthMode->IsPressed(controls) && HotkeysActive()) { m_3DReconstructionMode++; if (m_3DReconstructionMode == 4) m_3DReconstructionMode = Reconstruction_Type::GEOMETRY; stereoView->m_3DReconstructionMode = m_3DReconstructionMode; if(m_3DReconstructionMode == Reconstruction_Type::GEOMETRY) ShowAdjusterToast(retprintf("Depth Perception Mode %s","Geometry"), 1000); else if(m_3DReconstructionMode == Reconstruction_Type::ZBUFFER) ShowAdjusterToast(retprintf("Depth Perception Mode %s","Z Buffer"), 1000); else ShowAdjusterToast(retprintf("Depth Perception Mode %s","Mono"), 1000); } // Swap Sides on Depth mode (Alt + O) if (config.HotkeySwapSides->IsPressed(controls) && HotkeysActive()) { stereoView->m_bLeftSideActive = !stereoView->m_bLeftSideActive; ShowAdjusterToast("Depth Perception Side Switched", 1000); } // cycle Render States if ((config.HotkeyNextRenderState->IsPressed(controls) || config.HotkeyPrevRenderState->IsPressed(controls))&& HotkeysActive()) { std::string _str = ""; if(config.HotkeyPrevRenderState->IsPressed(controls)) { _str = stereoView->CycleRenderState(false); } else if(config.HotkeyNextRenderState->IsPressed(controls)) { _str = stereoView->CycleRenderState(true); } ShowPopup(VPT_ADJUSTER, VPS_TOAST, 1000, retprintf("New Render State :: %s", _str.c_str())); } // Toggle Through Cube Renders -> ALt + 1 if (config.HotkeyToggleCubeRenders->IsPressed(controls) && HotkeysActive()) { const char *cubeDuplicationDescription = "?"; if(m_pGameHandler->intDuplicateCubeTexture < 3) { m_pGameHandler->intDuplicateCubeTexture++; if(m_pGameHandler->intDuplicateCubeTexture == 1) cubeDuplicationDescription = "Always False"; else if(m_pGameHandler->intDuplicateCubeTexture == 2) cubeDuplicationDescription = "Always True"; else if(m_pGameHandler->intDuplicateCubeTexture == 3) cubeDuplicationDescription = "IS_RENDER_TARGET(Usage)"; } else { m_pGameHandler->intDuplicateCubeTexture = 0; cubeDuplicationDescription = "Default (Game Type)"; } ShowPopup(VPT_ADJUSTER, VPS_TOAST, 1000, retprintf("Cube Duplication :: %s", cubeDuplicationDescription)); } // Toggle Through Texture Renders -> ALt + 2 if (config.HotkeyToggleTextureRenders->IsPressed(controls) && HotkeysActive()) { const char *textureDuplicationDescription = "?"; if(m_pGameHandler->intDuplicateTexture < 4) { m_pGameHandler->intDuplicateTexture++; if(m_pGameHandler->intDuplicateTexture == 1) textureDuplicationDescription = "Always False"; else if(m_pGameHandler->intDuplicateTexture == 2) textureDuplicationDescription = "Always True"; else if(m_pGameHandler->intDuplicateTexture == 3) textureDuplicationDescription = "IS_RENDER_TARGET"; else if(m_pGameHandler->intDuplicateTexture == 4) textureDuplicationDescription = "IS_RENDER_TARGET + Width and Height)"; } else { m_pGameHandler->intDuplicateTexture = 0; textureDuplicationDescription = "Default (Game Type)"; } ShowPopup(VPT_ADJUSTER, VPS_TOAST, 1000, retprintf("Texture Duplication :: %s", textureDuplicationDescription)); } //When to render vpmenu (Alt + Up) if (config.HotkeyWhenToRenderMenu->IsPressed(controls) && HotkeysActive()) { const char *vpmenuRenderDesc = "?"; if(m_deviceBehavior.whenToRenderVPMENU == DeviceBehavior::BEGIN_SCENE) { m_deviceBehavior.whenToRenderVPMENU = DeviceBehavior::END_SCENE; vpmenuRenderDesc = "END_SCENE"; } else if(m_deviceBehavior.whenToRenderVPMENU == DeviceBehavior::END_SCENE) { m_deviceBehavior.whenToRenderVPMENU = DeviceBehavior::BEFORE_COMPOSITING; vpmenuRenderDesc = "BEFORE_COMPOSITING"; } else { m_deviceBehavior.whenToRenderVPMENU = DeviceBehavior::BEGIN_SCENE; vpmenuRenderDesc = "BEGIN_SCENE"; } ShowPopup(VPT_ADJUSTER, VPS_TOAST, 1000, retprintf("VPMENU RENDER = %s", vpmenuRenderDesc)); } //When to poll headtracking (Alt + Down) if (config.HotkeyWhenToPollHeadtracking->IsPressed(controls) && HotkeysActive()) { VireioPopup popup(VPT_ADJUSTER, VPS_TOAST, 1000); if(m_deviceBehavior.whenToHandleHeadTracking == DeviceBehavior::BEGIN_SCENE) { m_deviceBehavior.whenToHandleHeadTracking = DeviceBehavior::END_SCENE; sprintf_s(popup.line[2], "HEADTRACKING = END_SCENE"); } else if(m_deviceBehavior.whenToHandleHeadTracking == DeviceBehavior::END_SCENE) { m_deviceBehavior.whenToHandleHeadTracking = DeviceBehavior::BEGIN_SCENE; sprintf_s(popup.line[2], "HEADTRACKING = BEGIN SCENE"); } /*else if(m_deviceBehavior.whenToHandleHeadTracking == DeviceBehavior::BEFORE_COMPOSITING) { m_deviceBehavior.whenToHandleHeadTracking = DeviceBehavior::BEGIN_SCENE; sprintf_s(popup.line[2], "HEADTRACKING = BEGIN SCENE"); }//TODO This Crashes for some reason - problem for another day*/ ShowPopup(popup); } // Initiate VRBoost Memory Scan (NUMPAD5 or <LCTRL> + </> ) if (config.HotkeyInitiateScan->IsPressed(controls) && HotkeysActive()) { if (hmVRboost!=NULL) { //Use local static, as it is a simple flag static bool showRescanWarning = false; static bool shownRescanWarning = false; if (showRescanWarning && !VRBoostStatus.VRBoost_Scanning) { //If roll isn't enabled then rolling is done through the game engine using VRBoost //In this case, if the user has already run a successful scan then running again would likely //fail as the roll address will almost definitely not be 0, which is what the scanner would be looking for //so before starting the scan, confirm with the user this is what they actually wish to do //This will also prevent an accidental re-run //Games that use matrix roll can usually be re-run without issue ShowPopup(VPT_NOTIFICATION, VPS_INFO, 5000, " *WARNING*: re-running a scan once stable\n" " addresses have been found could fail\n" " IF NO SCAN HAS YET SUCCEEDED; IGNORE THIS WARNING\n" " Press scan trigger again to initiate scan\n" " or wait for this message to disappear (No Scan)"); showRescanWarning = false; shownRescanWarning = true; } else { //Ensure the previous notification is dismissed if (shownRescanWarning) { DismissPopup(VPT_NOTIFICATION); shownRescanWarning = false; } ReturnValue vr = m_pVRboost_StartMemoryScan(); if (vr == VRBOOST_ERROR) { ShowPopup(VPT_VRBOOST_FAILURE, VPS_TOAST, 5000, "VRBoost: StartMemoryScan - Failed"); } //If initialising then we have successfully started a new scan else if (vr = VRBOOST_SCAN_INITIALISING) { VRBoostStatus.VRBoost_Scanning = true; //Definitely have no candidates at this point VRBoostStatus.VRBoost_Candidates = false; showRescanWarning = true; } } } } // Select next scan candidate if there is one // Increase = NUMPAD6 or <LCTRL> + <.> // Decrease = NUMPAD4 or <LCTRL> + <,> if (VRBoostStatus.VRBoost_Candidates && (hotkeyNextScanCandidate->IsPressed(controls) || hotkeyPrevScanCandidate->IsPressed(controls)) && HotkeysActive()) { if (hmVRboost!=NULL) { static int c = 0; UINT candidates = m_pVRboost_GetScanCandidates(); bool increase = hotkeyNextScanCandidate->IsPressed(controls); if (increase) c = (c + 1) % candidates; else { if (--c < 0) c = candidates - 1; } m_pVRboost_SetNextScanCandidate(increase); DismissPopup(VPT_NOTIFICATION); ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1000, retprintf("VRBoost: Select Next Scan Candidate: %i / %i", c+1, candidates)); } } // Cancel VRBoost Memory Scan Mode (NUMPAD8 or <LCTRL> + <;> ) if (hotkeyCancelScan->IsPressed(controls) && HotkeysActive()) { DismissPopup(VPT_VRBOOST_SCANNING); VRBoostStatus.VRBoost_Scanning = false; VRBoostStatus.VRBoost_Candidates = false; m_bForceMouseEmulation = true; tracker->setMouseEmulation(true); } //Enabled/Disable Free Pitch (default is disabled), LSHIFT + X if (VRBoostStatus.VRBoost_Active && config.HotkeyToggleFreePitch->IsPressed(controls) && HotkeysActive()) { if (VRBoostValue[VRboostAxis::FreePitch] != 0.0f) { //Disable Free Pitch VRBoostValue[VRboostAxis::FreePitch] = 0.0f; } else { //Enable Free Pitch VRBoostValue[VRboostAxis::FreePitch] = 1.0f; } ShowAdjusterToast(retprintf("Pitch Free-look Enabled", (VRBoostValue[VRboostAxis::FreePitch] != 0.0f) ? "Enabled" : "Disabled"), 1000); } //Enabled/Disable Comfort Mode - LSHIFT + M if (VRBoostStatus.VRBoost_Active && config.HotkeyComfortMode->IsPressed(controls) && HotkeysActive()) { if (VRBoostValue[VRboostAxis::ComfortMode] != 0.0f) { //Disable Comfort Mode VRBoostValue[VRboostAxis::ComfortMode] = 0.0f; } else { //Enable Comfort Mode VRBoostValue[VRboostAxis::ComfortMode] = 1.0f; } m_comfortModeYaw = 0.0f; ShowAdjusterToast(retprintf("Comfort Mode %s", (VRBoostValue[VRboostAxis::ComfortMode]!=0.0f) ? "Enabled" : "Disabled"), 1000); } //Enabled/Disable Black Smear Correction for DK2 (default is disabled), LSHIFT + B if ((tracker && tracker->SupportsPositionTracking()) && config.HotkeyBlackSmear->IsPressed(controls) && HotkeysActive()) { if (stereoView->m_blackSmearCorrection != 0.0f) stereoView->m_blackSmearCorrection = 0.0f; else stereoView->m_blackSmearCorrection = 0.02f; stereoView->PostReset(); ShowAdjusterToast(retprintf("DK2 Black Smear Correction %s", stereoView->m_blackSmearCorrection!=0.0f ? "Enabled" : "Disabled"), 1000); } //Show FPS Counter / Frame Time counter LSHIFT+F if (config.HotkeyShowFPS->IsPressed(controls) && HotkeysActive()) { show_fps = (FPS_TYPE)((show_fps+1) % 3); } //Show HMD Stats Counter LSHIFT+H if (config.HotkeyShowHMDStats->IsPressed(controls) && HotkeysActive()) { if (activePopup.popupType == VPT_STATS) { DismissPopup(VPT_STATS); } else { VireioPopup popup(VPT_STATS); ShowPopup(popup); } } //Toggle positional tracking if (config.HotkeyTogglePositionalTracking->IsPressed(controls) && HotkeysActive()) { m_bPosTrackingToggle = !m_bPosTrackingToggle; ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, retprintf("HMD Positional Tracking %s", m_bPosTrackingToggle?"Enabled":"Disabled")); if (!m_bPosTrackingToggle) m_spShaderViewAdjustment->UpdatePosition(0.0f, 0.0f, 0.0f); } //Toggle mirror mode if (config.HotkeyMirrorMode->IsPressed(controls) && HotkeysActive()) { config.mirror_mode = 1 - config.mirror_mode; ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, retprintf("Mirroring Mode %s", config.mirror_mode ? "Distorted Rift View" : "Undistorted")); ProxyHelper ph; ph.SaveUserConfigMirrorMode(config.mirror_mode); } //Toggle SDK Pose Prediction- LSHIFT + DELETE if (hmdInfo->GetHMDManufacturer() == HMD_OCULUS && config.HotkeyTogglePosePrediction->IsPressed(controls) && HotkeysActive() && tracker) { tracker->useSDKPosePrediction = !tracker->useSDKPosePrediction; ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, retprintf("SDK Pose Prediction %s", tracker->useSDKPosePrediction?"Enabled":"Disabled")); } //Toggle chromatic abberation correction - SHIFT+J if (config.HotkeyToggleChromaticAbberationCorrection->IsPressed(controls) && HotkeysActive()) { stereoView->chromaticAberrationCorrection = !stereoView->chromaticAberrationCorrection; ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, retprintf("Chromatic Aberration Correction %s", stereoView->chromaticAberrationCorrection?"Enabled":"Disabled")); } //Double clicking the NUMPAD0 key will invoke the VR mouse //Double clicking when VR mouse is enabled will either: // - Toggle between GUI and HUD scaling if double click occurs within 2 seconds // - Disable VR Mouse if double click occurs after 2 seconds static DWORD numPad0Click = 0; if ((config.HotkeyVRMouse->IsPressed(controls) || numPad0Click != 0) && HotkeysActive()) { if (config.HotkeyVRMouse->IsPressed(controls) && numPad0Click == 0) { numPad0Click = 1; } else if (!config.HotkeyVRMouse->IsPressed(controls) && numPad0Click == 1) { numPad0Click = GetTickCount(); } else if (config.HotkeyVRMouse->IsPressed(controls) && numPad0Click > 1) { //If we clicked a second time within 500 ms, then trigger VR Mouse if ((GetTickCount() - numPad0Click) <= 500) { static DWORD tc = 0; if (tc != 0 && (GetTickCount() - tc > 2000)) { tc = 0; m_showVRMouse = 0; stereoView->m_mousePos.x = 0; stereoView->m_mousePos.y = 0; } else { tc = GetTickCount(); if (m_showVRMouse == 2) m_showVRMouse = 1; else m_showVRMouse++; } stereoView->PostReset(); DismissPopup(VPT_NOTIFICATION); const char *vrMouseDescription; if (m_showVRMouse == 1) vrMouseDescription = "GUI Scaling"; else if (m_showVRMouse == 2) vrMouseDescription = "HUD Scaling"; else vrMouseDescription = "Disabled"; ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, retprintf("VR Mouse - %s", vrMouseDescription)); } numPad0Click = 0; } else if (numPad0Click > 1 && (GetTickCount() - numPad0Click) > 500) { //Reset, user clearly not double clicking numPad0Click = 0; } } // floaty menus if (config.HotkeyFloatyMenus->IsPressed(controls) && HotkeysActive()) { if (m_bfloatingMenu) m_bfloatingMenu = false; else { m_bfloatingMenu = true; if (tracker->getStatus() >= MTS_OK) { m_fFloatingPitch = tracker->primaryPitch; m_fFloatingYaw = tracker->primaryYaw; } } ShowPopup(VPT_NOTIFICATION, VPS_TOAST, 1200, retprintf("Floating Menus %s", m_bfloatingMenu?"Enabled":"Disabled")); } //Double clicking the start button will invoke the VP menu static DWORD startClick = 0; if ((hotkeyDoubleClickVPMenu->IsPressed(controls) || startClick != 0) && HotkeysActive()) { if (hotkeyDoubleClickVPMenu->IsPressed(controls) && startClick == 0) { startClick = 1; } else if (!hotkeyDoubleClickVPMenu->IsPressed(controls) && startClick == 1) { startClick = GetTickCount(); } else if (hotkeyDoubleClickVPMenu->IsPressed(controls) && startClick > 1) { //If we clicked a second time within 500 ms, then open vp menu if ((GetTickCount() - startClick) <= 500) { if (!VPMENU_IsOpen()) VPMENU_OpenMainMenu(); else VPMENU_Close(); } startClick = 0; } else if (startClick > 1 && (GetTickCount() - startClick) > 500) { //Reset, user clearly not double clicking startClick = 0; } } // open VP Menu - <CTRL>+<Q> if(hotkeyOpenVPMenu->IsPressed(controls) && HotkeysActive()) { if (!VPMENU_IsOpen()) VPMENU_OpenMainMenu(); else VPMENU_Close(); } //Mouse Wheel Scroll int _wheel = dinput.GetWheel(); if(_wheel != 0) { int wheelSign = (_wheel>0) ? 1 : -1; if(hotkeyWheelYOffset->IsHeld(controls)) { config.YOffset += 0.005f * wheelSign; clamp(&config.YOffset, -0.1f, 0.1f); this->stereoView->PostReset(); DeferedSaveConfig(); ShowAdjusterToast(retprintf("Y-Offset: %1.3f", config.YOffset), 500); } else if(hotkeyWheelZBuffer->IsHeld(controls)) { if(stereoView->m_bZBufferFilterMode) { this->stereoView->m_fZBufferFilter += 0.0005f * wheelSign; clamp(&this->stereoView->m_fZBufferFilter, 0.01f, 1.0f); this->stereoView->PostReset(); ShowAdjusterToast(retprintf("ZBuffer Depth Filter: %1.6f", this->stereoView->m_fZBufferFilter), 500); } else if(stereoView->m_bZBufferVisualisationMode) { config.zbufferDepthLow += 0.0005f * wheelSign; clamp(&config.zbufferDepthLow, 0.01f, 1.0f); DeferedSaveConfig(); ShowAdjusterToast(retprintf("ZBuffer Depth Bound Low: %1.6f", config.zbufferDepthLow), 500); } else { config.zbufferStrength += 1.0000f * wheelSign; DeferedSaveConfig(); ShowAdjusterToast(retprintf("ZBuffer Seperation Strength: %1.6f", config.zbufferStrength), 500); } } //CTRL + ALT + Mouse Wheel - adjust World Scale dynamically else if (hotkeyWheelWorldScale->IsHeld(controls)) { float separationChange = 0.05f * wheelSign; m_spShaderViewAdjustment->ChangeWorldScale(separationChange); m_spShaderViewAdjustment->UpdateProjectionMatrices((float)stereoView->viewport.Width/(float)stereoView->viewport.Height, config.fPFOV); ShowAdjusterToast(retprintf("Stereo Separation (World Scale): %1.3f", config.fWorldScaleFactor), 500); DeferedSaveConfig(); } //CTRL + SPACE + Mouse Wheel - adjust projection fov dynamically else if(hotkeyWheelPFOV->IsHeld(controls)) { config.fPFOV += 0.5f*wheelSign; m_spShaderViewAdjustment->UpdateProjectionMatrices((float)stereoView->viewport.Width/(float)stereoView->viewport.Height, config.fPFOV); ShowAdjusterToast(retprintf("Projection FOV: %1.3f", config.fPFOV), 500); DeferedSaveConfig(); } else if(hotkeyWheelZoomScale->IsHeld(controls)) { this->stereoView->ZoomOutScale += 0.05f * wheelSign; clamp(&this->stereoView->ZoomOutScale, 0.05f, 2.00f); this->stereoView->PostReset(); DeferedSaveConfig(); ShowAdjusterToast(retprintf("Zoom Scale: %1.3f", this->stereoView->ZoomOutScale), 500); } } //Change Distortion Scale CTRL + + / - if(config.HotkeyDistortionScalePlus->IsPressed(controls) && HotkeysActive()) { this->stereoView->ZoomOutScale = 1.00f; this->stereoView->PostReset(); DeferedSaveConfig(); ShowAdjusterToast(retprintf("Zoom Scale: %1.3f", this->stereoView->ZoomOutScale), 500); } else if(config.HotkeyDistortionScaleMinus->IsPressed(controls) && HotkeysActive()) { this->stereoView->ZoomOutScale = 0.50f; this->stereoView->PostReset(); DeferedSaveConfig(); ShowAdjusterToast(retprintf("Zoom Scale: %1.3f", this->stereoView->ZoomOutScale), 500); } // screenshot - <RCONTROL>+<*> if(config.HotkeyScreenshot->IsPressed(controls) && HotkeysActive()) { // render 3 frames to get screenshots screenshot = 3; } //Telescopic mode - use ALT + Mouse Wheel CLick if (config.HotkeyTelescopeMode->IsPressed(controls) && HotkeysActive()) { //First check whether VRBoost is controlling FOV, we can't use this functionality if it isn't bool canUseTelescope = false; if (VRBoostStatus.VRBoost_Active) { ActiveAxisInfo axes[30]; memset(axes, 0xFF, sizeof(ActiveAxisInfo) * 30); UINT count = m_pVRboost_GetActiveRuleAxes((ActiveAxisInfo**)&axes); UINT i = 0; while (i < count) { if (axes[i].Axis == MAXDWORD) break; if (axes[i].Axis == VRboostAxis::WorldFOV) { canUseTelescope = true; break; } i++; } } if (canUseTelescope) { if (!m_telescopicSightMode && m_telescopeTargetFOV == FLT_MAX) { //enabling - reduce FOV to 20 (will result in zooming in) m_telescopeTargetFOV = 20; m_telescopeCurrentFOV = config.WorldFOV; stereoView->m_vignetteStyle = StereoView::TELESCOPIC_SIGHT; m_telescopicSightMode = true; } else if (m_telescopicSightMode) { //disabling m_telescopicSightMode = false; m_telescopeTargetFOV = config.WorldFOV; stereoView->m_vignetteStyle = StereoView::NONE; } } } } }
/** * Create D3D device proxy. * First it creates the device, then it loads the game configuration * calling the ProxyHelper class. Last it creates and returns the * device proxy calling D3DProxyDeviceFactory::Get(). ***/ HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { // Create real interface HRESULT hResult = m_pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); if (FAILED(hResult)) return hResult; OutputDebugString("[OK] Normal D3D device created\n"); char buf[64]; sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount); OutputDebugString(buf); sprintf_s(buf, "Format of back buffers = %x\n", pPresentationParameters->BackBufferFormat); OutputDebugString(buf); // for debug reasons, output the d3dswapeffect parameter switch (pPresentationParameters->SwapEffect) { case D3DSWAPEFFECT::D3DSWAPEFFECT_COPY: OutputDebugString("D3DSWAPEFFECT_COPY"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_DISCARD: OutputDebugString("D3DSWAPEFFECT_DISCARD"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_FLIP: OutputDebugString("D3DSWAPEFFECT_FLIP"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_FLIPEX: OutputDebugString("D3DSWAPEFFECT_FLIPEX"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_OVERLAY: OutputDebugString("D3DSWAPEFFECT_OVERLAY"); break; default: char buf[256]; sprintf_s(buf, 256, "D3DPRESENT_PARAMETERS::SwapEffect %x", pPresentationParameters->SwapEffect); OutputDebugString(buf); break; } // if no back buffer present (=D3DFMT_UNKNOWN), return base device - TODO !!! // DOES NOT WORK since the shaders will not be wrapped by the base device // create a special device for that..... /*if ((pPresentationParameters->BackBufferCount == 0) && (pPresentationParameters->BackBufferFormat == D3DFORMAT::D3DFMT_UNKNOWN)) { *ppReturnedDeviceInterface = new BaseDirect3DDevice9(*ppReturnedDeviceInterface, this); return hResult; }*/ // load configuration file ProxyHelper helper = ProxyHelper(); ProxyHelper::ProxyConfig cfg; ProxyHelper::OculusProfile oculusProfile; if (!helper.LoadConfig(cfg, oculusProfile)) { OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } OutputDebugString("[OK] Config loading - OK\n"); if (cfg.stereo_mode == StereoView::DISABLED) { OutputDebugString("[WARN] stereo_mode == disabled. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } OutputDebugString("[OK] Stereo mode is enabled.\n"); char buf1[32]; LPCSTR psz = NULL; wsprintf(buf1, "Config type: %d", cfg.game_type); psz = buf1; OutputDebugString(psz); OutputDebugString("\n"); // Create and return proxy *ppReturnedDeviceInterface = D3DProxyDeviceFactory::Get(cfg, *ppReturnedDeviceInterface, this); OutputDebugString("[OK] Vireio D3D device created.\n"); return hResult; }
// CBT Hook-style injection. BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved ) { if (fdwReason == DLL_PROCESS_ATTACH) // When initializing.... { hDLL = hModule; // We don't need thread notifications for what we're doing. Thus, get // rid of them, thereby eliminating some of the overhead of this DLL DisableThreadLibraryCalls(hModule); // Only hook the APIs if this is the right process. GetModuleFileName(GetModuleHandle(NULL), targetExe, sizeof(targetExe)); PathStripPath(targetExe); /*if(std::string(targetExe) == "GitHub.exe") { OutputDebugString("Ignoring process: "); OutputDebugString(targetExe); OutputDebugString("\n"); return TRUE; }*/ GetModuleFileName(GetModuleHandle(NULL), targetPath, sizeof(targetPath)); targetPathString = std::string(targetPath); targetPathString = targetPathString.substr(0, targetPathString.find_last_of("\\/") + 1); OutputDebugString("HIJACKDLL checking process: "); OutputDebugString(targetExe); OutputDebugString("\n"); #ifndef x64 ParsePaths(); #endif ProxyHelper helper = ProxyHelper(); if (helper.HasProfile(targetExe, targetPathString.c_str())) { #ifndef x64 //Need to check that the d3d9.dll is actually in the game folder - If it is, then we don't need to hook API calls //using the methods below as d3d9 will just be loaded by the game's executable if (!fileExists(targetPathString + "D3D9.dll")) { if (HookAPICalls(&D3DHook)) { OutputDebugString("HookAPICalls(D3D): TRUE\n"); } else if(HookAPICalls(&KernelHook)) { OutputDebugString("HookAPICalls(Kernel): TRUE\n"); } else { OutputDebugString("HookAPICalls(Both): FALSE\n"); } SetDllDirectory(dllDir); } else { OutputDebugString(std::string("D3D9.dll found in game directory (" + targetPathString + ") - Bypassing API injection").c_str()); } #endif } else { OutputDebugString((std::string("Game profile not found for: ") + targetExe).c_str()); } } return TRUE; }
int WINAPI wWinMain(HINSTANCE instance_handle, HINSTANCE, LPWSTR, INT) { // avoid double driver window HWND window = FindWindow( "perception", "Vireio Perception"); if( window != 0 ) { OutputDebugString("Vireio Perception is already present !"); return 0; } InitConfig(); InitModes(); InstallHook(); frame_window main_window("perception"); main_window.add_item("Disabled\t0"); main_window.add_item("Side by Side\t20"); main_window.add_item("Over Under\t30"); main_window.add_item("Horizontal Interleave\t40"); main_window.add_item("Vertical Interleave\t50"); main_window.add_item("Checkerboard\t60"); main_window.add_item("Anaglyph (Red/Cyan)\t1"); main_window.add_item("Anaglyph (Red/Cyan) B+W\t2"); main_window.add_item("Anaglyph (Yellow/Blue)\t5"); main_window.add_item("Anaglyph (Yellow/Blue) B+W\t6"); main_window.add_item("Anaglyph (Green/Magenta)\t10"); main_window.add_item("Anaglyph (Green/Magenta) B+W\t11"); main_window.add_item("DIY Rift\t100"); main_window.add_item("Oculus Rift: Extended Mode\t110"); main_window.add_item("Oculus Rift: Direct-to-HMD\t111"); main_window.add_item2("No Tracking\t0"); main_window.add_item2("Hillcrest Labs\t10"); main_window.add_item2("FreeTrack\t20"); main_window.add_item2("Shared Memory Tracker\t30"); main_window.add_item2("OculusTrack\t40"); UINT32 num_of_paths = 0; UINT32 num_of_modes = 0; DISPLAYCONFIG_PATH_INFO* displayPaths = NULL; DISPLAYCONFIG_MODE_INFO* displayModes = NULL; GetDisplayConfigBufferSizes(QDC_ALL_PATHS, &num_of_paths, &num_of_modes); // Allocate paths and modes dynamically displayPaths = (DISPLAYCONFIG_PATH_INFO*)calloc((int)num_of_paths, sizeof(DISPLAYCONFIG_PATH_INFO)); displayModes = (DISPLAYCONFIG_MODE_INFO*)calloc((int)num_of_modes, sizeof(DISPLAYCONFIG_MODE_INFO)); // Query for the information QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &num_of_paths, displayPaths, &num_of_modes, displayModes, NULL); UINT32 index = 0; int adapterNum = 0; while (index < num_of_modes) { if (displayModes[index].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET) { DISPLAYCONFIG_TARGET_DEVICE_NAME deviceName; DISPLAYCONFIG_DEVICE_INFO_HEADER header; header.size = sizeof(DISPLAYCONFIG_TARGET_DEVICE_NAME); header.adapterId = displayModes[index].adapterId; header.id = displayModes[index].id; header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; deviceName.header = header; DisplayConfigGetDeviceInfo( (DISPLAYCONFIG_DEVICE_INFO_HEADER*) &deviceName ); char monitorFriendlyDeviceName[256]; ZeroMemory(monitorFriendlyDeviceName, 256); size_t countConverted = 0; wcstombs_s(&countConverted, monitorFriendlyDeviceName, 256, deviceName.monitorFriendlyDeviceName, 256); std::string adapterStr(monitorFriendlyDeviceName); if (adapterNum == 0) adapterStr = "Primary Monitor: " + adapterStr + "\t0"; if (adapterNum == 1) adapterStr = "Secondary Monitor: " + adapterStr + "\t1"; if (adapterNum == 2) adapterStr = "Tertiary Monitor: " + adapterStr + "\t2"; main_window.add_item3(adapterStr.c_str()); adapterNum++; } index++; } ProxyHelper helper = ProxyHelper(); ProxyHelper::UserConfig userConfig; helper.LoadUserConfig(userConfig); SendMessage(main_window.combobox->combobox_handle, CB_SETCURSEL, stereoModes[userConfig.mode], 0); if (main_window.combobox->get_selection() == 111) { ShowWindow(main_window.combobox2->combobox_handle, SW_HIDE); //Select oculus track main_window.combobox2->set_selection(4); } else SendMessage(main_window.combobox2->combobox_handle, CB_SETCURSEL, trackerModes[userConfig.mode2], 0); //If an HMD is unplugged we may not actually be able to select it if (userConfig.adapter >= adapterNum) { userConfig.adapter = 0; helper.SaveDisplayAdapter(0); } SendMessage(main_window.combobox3->combobox_handle, CB_SETCURSEL, userConfig.adapter, 0); main_window.run(); RemoveHook(); return 0; }