Skip to content

Commit

Permalink
Add AlwaysOnTop toggle, allowing single display mode
Browse files Browse the repository at this point in the history
  • Loading branch information
oneup03 committed Jul 20, 2024
1 parent de5d443 commit 1def6fd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Windows-only solution currently, but there are other solutions on Linux like Mon

## Base Installation

- Get a multi-display configuration setup (see notes)
- A multi-display configuration setup (see notes) will be the most compatible, but single displays can be used. Some mods or games may not work with a single display
- Install SteamVR
- Download the [latest release](https://github.com/oneup03/VRto3D/releases/latest) and copy the `vrto3d` folder to your `Steam\steamapps\common\SteamVR\drivers` folder
- Edit the `Steam\steamapps\common\SteamVR\drivers\vrto3d\resources\settings\default.vrsettings` as needed
Expand All @@ -60,8 +60,16 @@ Windows-only solution currently, but there are other solutions on Linux like Mon
- Run SteamVR at least once to verify that you see a Headset window. This is usually not needed before running games.
- The Headset window must be on your primary 3D display
- Try launching a VR game
- Drag everything besides the headset view to your second display
- Make the game's window in focus on your second display for control input to work
- Multi-Display setups:
- Drag everything besides the headset view to your second display
- Make the headset window in focus on your primary display
- Make the game's window in focus on your second display for control input to work
- Single Display setup:
- Make the headset window in focus on your display
- Press `Ctrl+F8` to toggle locking the headset window to the foreground
- Use `Alt+Tab` to switch to the game window
- If the headset window went completely black, this game isn't compatible in single display mode
- To quit, `Alt+Tab` to the SteamVR Status window and close it with `Alt+F4`
- Adjust Depth with `Ctrl+F3` and `Ctrl+F4`
- Adjust Convergence with `Ctrl+F5` and `Ctrl+F6`
- Save all Depth & Convergence settings with `Ctrl+F7`
Expand Down Expand Up @@ -98,6 +106,7 @@ Windows-only solution currently, but there are other solutions on Linux like Mon
- Having 3DVision enabled will crash DX12 games
- Make sure your game runs on old drivers with 3D disabled before attempting to get it working with VRto3D
- If you get a black screen while trying to run SteamVR + 3DVision, you may have to hard reset
- Only Multi-Display setups will work due to 3DVision needing to always be fullscreen to activate
- Complete the Base Installation section
- If you want full resolution per eye, enable DSR 4x in Nvidia Control Panel -> Manage 3D Settings
- Modify the `window_width` and `window_height` in `Steam\steamapps\common\SteamVR\drivers\vrto3d\resources\settings\default.vrsettings` to match your fullscreen resolution
Expand Down
34 changes: 29 additions & 5 deletions vrto3d/src/hmd_device_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,25 @@ vr::DriverPose_t MockControllerDeviceDriver::GetPose()
void MockControllerDeviceDriver::PoseUpdateThread()
{
static int sleep_time = (int)(floor(1000.0 / stereo_display_component_->GetConfig().display_frequency));
static int sleep_counter = 0;
static int height_sleep = 0;
static int top_sleep = 0;
static bool always_on_top = false;
static HWND vr_window;
static HWND top_window;

while ( is_active_ )
{
// Keep VR display always on top for 3D rendering
if (always_on_top) {
top_window = GetTopWindow(GetDesktopWindow());
if (vr_window != NULL && vr_window != top_window) {
SetWindowPos(vr_window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
else {
vr_window = FindWindow(NULL, L"Headset Window");
}
}

// Inform the vrserver that our tracked device's pose has updated, giving it the pose returned by our GetPose().
vr::VRServerDriverHost()->TrackedDevicePoseUpdated( device_index_, GetPose(), sizeof( vr::DriverPose_t ) );

Expand All @@ -451,13 +467,21 @@ void MockControllerDeviceDriver::PoseUpdateThread()
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_F7) & 0x8000)) {
SaveDepthConv();
}
// Ctrl+F8 Toggle Always On Top
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_F8) & 0x8000) && top_sleep == 0) {
top_sleep = stereo_display_component_->GetConfig().sleep_count_max;
always_on_top = !always_on_top;
}
else if (top_sleep > 0) {
top_sleep--;
}
// Ctrl+F9 Toggle HMD height
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_F9) & 0x8000) && sleep_counter == 0) {
sleep_counter = stereo_display_component_->GetConfig().sleep_count_max;
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_F9) & 0x8000) && height_sleep == 0) {
height_sleep = stereo_display_component_->GetConfig().sleep_count_max;
stereo_display_component_->SetHeight();
}
else if (sleep_counter > 0) {
sleep_counter--;
else if (height_sleep > 0) {
height_sleep--;
}

// Check User binds
Expand Down

0 comments on commit 1def6fd

Please sign in to comment.