From 22496fcc35642073886bbd85677d8478c5e401ff Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Wed, 3 May 2023 22:09:59 +0200 Subject: [PATCH 1/3] link executable properly so it can be started from other directories --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index dcb1dd9..256e98a 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,18 @@ VERSION=v0.2.2 -CC := g++ -# CC := clang++ + +CXX := g++ +# CXX := clang++ +CPPFLAGS := -g -Wall -std=c++17 LFLAGS := -lX11 -lXrandr -lXtst -lglfw -lGL -LIBS := openvr/libopenvr_api.so -SRC := src/*.cpp -OUT := ./sinpin_vr -CPPFLAGS := -Wall -std=c++17 $(LFLAGS) $(LIBS) $(SRC) -o $(OUT) +OVR := -Lopenvr -lopenvr_api +TARGET := ./sinpin_vr build: - $(CC) -g $(CPPFLAGS) + $(CXX) src/*.cpp $(CPPFLAGS) $(LFLAGS) -Wl,-rpath,'$$ORIGIN/openvr' $(OVR) -o $(TARGET) release: build zip -r sinpin_vr-$(VERSION).zip sinpin_vr bindings openvr/libopenvr_api.so run: build - $(OUT) + $(TARGET) From 2c0386b1418a5c5b3889b1721b554ecc6ce1e417 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 4 May 2023 22:27:47 +0200 Subject: [PATCH 2/3] refactor packaging --- .gitignore | 1 + Makefile | 13 +++++++++---- {openvr => lib}/libopenvr_api.so | Bin {openvr => lib}/openvr.h | 0 src/util.h | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) rename {openvr => lib}/libopenvr_api.so (100%) rename {openvr => lib}/openvr.h (100%) diff --git a/.gitignore b/.gitignore index 0aeec18..60b3c90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ sinpin_vr .vscode/ *.zip +*.tar.xz diff --git a/Makefile b/Makefile index 256e98a..ce81dcc 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,22 @@ -VERSION=v0.2.2 +VERSION=v0.2.3 CXX := g++ # CXX := clang++ CPPFLAGS := -g -Wall -std=c++17 LFLAGS := -lX11 -lXrandr -lXtst -lglfw -lGL -OVR := -Lopenvr -lopenvr_api +OVR := -Llib -lopenvr_api TARGET := ./sinpin_vr build: - $(CXX) src/*.cpp $(CPPFLAGS) $(LFLAGS) -Wl,-rpath,'$$ORIGIN/openvr' $(OVR) -o $(TARGET) + $(CXX) src/*.cpp $(CPPFLAGS) $(LFLAGS) -Wl,-rpath,'$$ORIGIN/lib' $(OVR) -o $(TARGET) release: build - zip -r sinpin_vr-$(VERSION).zip sinpin_vr bindings openvr/libopenvr_api.so + mkdir -p sinpin-vr/lib + cp lib/libopenvr_api.so sinpin-vr/lib + cp -r bindings sinpin-vr + cp sinpin_vr sinpin-vr + tar -caf sinpin-vr-$(VERSION).tar.xz sinpin-vr + rm -rf sinpin-vr run: build $(TARGET) diff --git a/openvr/libopenvr_api.so b/lib/libopenvr_api.so similarity index 100% rename from openvr/libopenvr_api.so rename to lib/libopenvr_api.so diff --git a/openvr/openvr.h b/lib/openvr.h similarity index 100% rename from openvr/openvr.h rename to lib/openvr.h diff --git a/src/util.h b/src/util.h index ecb7484..cfd8922 100644 --- a/src/util.h +++ b/src/util.h @@ -1,6 +1,6 @@ #pragma once -#include "../openvr/openvr.h" +#include "../lib/openvr.h" #include typedef vr::TrackedDeviceIndex_t TrackerID; From 66227ae7448cb6b9a2b11ffab0c9de00e0f372ff Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Tue, 6 Jun 2023 14:05:43 +0200 Subject: [PATCH 3/3] add transparency toggle --- bindings/action_manifest.json | 6 ++++++ src/app.cpp | 17 +++++++++++++++++ src/app.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/bindings/action_manifest.json b/bindings/action_manifest.json index 0c9128e..e9f2b6d 100644 --- a/bindings/action_manifest.json +++ b/bindings/action_manifest.json @@ -56,6 +56,11 @@ "requirement": "suggested", "type": "vector2" }, + { + "name": "/actions/cursor/in/toggle_transparent", + "requirement": "suggested", + "type": "boolean" + }, { "name": "/actions/cursor/out/scroll_haptic", "requirement": "suggested", @@ -89,6 +94,7 @@ "/actions/cursor/in/mouse_right": "right mouse button", "/actions/cursor/in/mouse_middle": "middle mouse button", "/actions/cursor/in/scroll": "scroll", + "/actions/cursor/in/toggle_transparent": "toggle transparency", "/actions/cursor/out/scroll_haptic": "scrolling haptic feedback" } ] diff --git a/src/app.cpp b/src/app.cpp index 72ff00a..7bbc85d 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -10,6 +10,7 @@ const VRMat root_start_pose = {{{1, 0, 0, 0}, {0, 1, 0, 0.8f}, {0, 0, 1, 0}}}; // 0.8m above origin const int FRAME_INTERVAL = 4; // number of update loops until the frame buffer is updated +const float TRANSPARENCY = 0.6f; App::App() { @@ -75,6 +76,8 @@ App::App() assert(action_err == 0); action_err = vr_input->GetActionHandle("/actions/cursor/in/scroll", &_input_handles.cursor.scroll); assert(action_err == 0); + action_err = vr_input->GetActionHandle("/actions/cursor/in/toggle_transparent", &_input_handles.cursor.toggle_transparent); + assert(action_err == 0); action_err = vr_input->GetActionHandle("/actions/cursor/out/scroll_haptic", &_input_handles.cursor.scroll_haptic); assert(action_err == 0); action_err = vr_input->GetActionSetHandle("/actions/main", &_input_handles.main_set); @@ -193,6 +196,20 @@ void App::UpdateInput(float dtime) } UpdateUIVisibility(); } + if (IsInputJustPressed(_input_handles.cursor.toggle_transparent)) + { + _transparent = !_transparent; + if (_transparent) + { + for (auto &panel : _panels) + panel.GetOverlay()->SetAlpha(TRANSPARENCY); + } + else + { + for (auto &panel : _panels) + panel.GetOverlay()->SetAlpha(1); + } + } if (!_hidden) { if (IsInputJustPressed(_input_handles.main.reset)) diff --git a/src/app.h b/src/app.h index fa721ce..ecbbd79 100644 --- a/src/app.h +++ b/src/app.h @@ -33,6 +33,7 @@ struct InputHandles vr::VRActionHandle_t mouse_middle; vr::VRActionHandle_t scroll; vr::VRActionHandle_t scroll_haptic; + vr::VRActionHandle_t toggle_transparent; } cursor; vr::VRActionSetHandle_t cursor_set; struct @@ -87,6 +88,7 @@ class App Overlay _root_overlay; std::vector _panels; bool _hidden = false; + bool _transparent = false; bool _edit_mode = false; std::optional _active_cursor;