From 8511933929a06c99a0ad358653a4db8f177a4527 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 10 Jul 2020 08:11:58 +0200 Subject: Change the behavior of cursor in stereoscopic mode to match the cursor position in the game (--cursor-wrap|--no-cursor-wrap) --- README.md | 10 +++++++++- src/main.cpp | 28 +++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9190793..fc23ec8 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,17 @@ killall -USR1 vr-video-player` You can launch vr-video-player without any arguments to show a list of all arguments: ``` -usage: vr-video-player [--flat] [--left-right|--right-left|--plane] [--stretch|--no-stretch] [--zoom zoom-level] [--cursor-scale scale] +usage: vr-video-player [--flat] [--left-right|--right-left|--plane] [--stretch|--no-stretch] [--zoom zoom-level] [--cursor-scale scale] [--cursor-wrap|--no-cursor-wrap] ``` +Note: If the cursor position is weird and does not match what you are seeing in stereoscopic vr mode, then try running the vr video player with the --cursor-wrap option: + +--cursor-wrap and --no-cursor-wrap changes the behavior of the cursor in steroscopic mode. Usually in games the game view is mirrored but the cursor is not and the center of the +game which is normally at the center moves to 1/4 and 3/4 of the window. With --cursor-wrap, the cursor position in VR will match the real position of the +cursor relative to the window and with --no-cursor-wrap the cursor will match the position of the cursor as the game sees it. + +Note: --cursor-scale is set to 0 by default in 180 degrees stereoscopic mode and --no-cursor-wrap is set by default in --flat mode. + # Games This vr video player can also be used to play games in VR to to get a 3D effect, and even for games that don't support VR.\ For games such as Trine that have built-in side-by-side view, you can launch it with proton and there is a launch option for side-by-side view. Select this and when the game launches, get the X11 window id of the game diff --git a/src/main.cpp b/src/main.cpp index 4370a24..aa91167 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -314,6 +314,7 @@ private: // X compositor float cursor_scale = 1.0f; ViewMode view_mode = ViewMode::LEFT_RIGHT; bool stretch = true; + bool cursor_wrap = true; GLuint arrow_image_texture_id = 0; stbi_uc *arrow_image_data = nullptr; @@ -410,7 +411,7 @@ void dprintf( const char *fmt, ... ) } static void usage() { - fprintf(stderr, "usage: vr-video-player [--flat] [--left-right|--right-left|--plane] [--stretch|--no-stretch] [--zoom zoom-level] [--cursor-scale scale] \n"); + fprintf(stderr, "usage: vr-video-player [--flat] [--left-right|--right-left|--plane] [--stretch|--no-stretch] [--zoom zoom-level] [--cursor-scale scale] [--cursor-wrap|--no-cursor-wrap] \n"); exit(1); } @@ -453,6 +454,7 @@ CMainApplication::CMainApplication( int argc, char *argv[] ) const char *view_mode_arg = nullptr; bool zoom_set = false; bool cursor_scale_set = false; + bool cursor_wrap_set = false; for(int i = 1; i < argc; ++i) { if(strcmp(argv[i], "--flat") == 0) { @@ -501,12 +503,17 @@ CMainApplication::CMainApplication( int argc, char *argv[] ) stretch = true; } else if(strcmp(argv[i], "--no-stretch") == 0) { stretch = false; + } else if(strcmp(argv[i], "--cursor-wrap") == 0) { + cursor_wrap = true; + cursor_wrap_set = true; + } else if(strcmp(argv[i], "--no-cursor-wrap") == 0) { + cursor_wrap = false; + cursor_wrap_set = true; } else if(argv[i][0] == '-') { fprintf(stderr, "Invalid flag: %s\n", argv[i]); usage(); } else { if (strncmp(argv[i], "window:", 7) == 0) { - printf("window"); argv[i] += 7; // "window:".length } src_window_id = strtol(argv[i], nullptr, 0); @@ -526,6 +533,10 @@ CMainApplication::CMainApplication( int argc, char *argv[] ) cursor_scale = 0.01f; } + if(!cursor_wrap_set && projection_mode == ProjectionMode::FLAT) { + cursor_wrap = false; + } + printf("src window id: %ld, zoom: %f\n", src_window_id, zoom); // other initialization tasks are done in BInit @@ -2027,13 +2038,12 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye ) m[0] = mouse_x / (float)window_width; m[1] = mouse_y / (float)window_height; - if(view_mode != ViewMode::PLANE && m[0] >= 0.5f) - m[0] -= 0.5f; - /* - // TODO: Set this as an option? - if(view_mode != ViewMode::PLANE) - m[0] *= 0.5f; - */ + if(view_mode != ViewMode::PLANE) { + if(cursor_wrap && m[0] >= 0.5f) + m[0] -= 0.5f; + else if(!cursor_wrap) + m[0] *= 0.5f; + } if( nEye == vr::Eye_Left ) { -- cgit v1.2.3