mirror of
https://github.com/CrispyPin/sinpin-vr.git
synced 2025-04-15 14:48:32 +02:00
Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
66227ae744 | |||
2c0386b141 | |||
22496fcc35 |
8 changed files with 42 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
sinpin_vr
|
sinpin_vr
|
||||||
.vscode/
|
.vscode/
|
||||||
*.zip
|
*.zip
|
||||||
|
*.tar.xz
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -1,18 +1,23 @@
|
||||||
VERSION=v0.2.2
|
VERSION=v0.2.3
|
||||||
CC := g++
|
|
||||||
# CC := clang++
|
CXX := g++
|
||||||
|
# CXX := clang++
|
||||||
|
CPPFLAGS := -g -Wall -std=c++17
|
||||||
LFLAGS := -lX11 -lXrandr -lXtst -lglfw -lGL
|
LFLAGS := -lX11 -lXrandr -lXtst -lglfw -lGL
|
||||||
LIBS := openvr/libopenvr_api.so
|
OVR := -Llib -lopenvr_api
|
||||||
SRC := src/*.cpp
|
TARGET := ./sinpin_vr
|
||||||
OUT := ./sinpin_vr
|
|
||||||
CPPFLAGS := -Wall -std=c++17 $(LFLAGS) $(LIBS) $(SRC) -o $(OUT)
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(CC) -g $(CPPFLAGS)
|
$(CXX) src/*.cpp $(CPPFLAGS) $(LFLAGS) -Wl,-rpath,'$$ORIGIN/lib' $(OVR) -o $(TARGET)
|
||||||
|
|
||||||
release: build
|
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
|
run: build
|
||||||
$(OUT)
|
$(TARGET)
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,11 @@
|
||||||
"requirement": "suggested",
|
"requirement": "suggested",
|
||||||
"type": "vector2"
|
"type": "vector2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "/actions/cursor/in/toggle_transparent",
|
||||||
|
"requirement": "suggested",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "/actions/cursor/out/scroll_haptic",
|
"name": "/actions/cursor/out/scroll_haptic",
|
||||||
"requirement": "suggested",
|
"requirement": "suggested",
|
||||||
|
@ -89,6 +94,7 @@
|
||||||
"/actions/cursor/in/mouse_right": "right mouse button",
|
"/actions/cursor/in/mouse_right": "right mouse button",
|
||||||
"/actions/cursor/in/mouse_middle": "middle mouse button",
|
"/actions/cursor/in/mouse_middle": "middle mouse button",
|
||||||
"/actions/cursor/in/scroll": "scroll",
|
"/actions/cursor/in/scroll": "scroll",
|
||||||
|
"/actions/cursor/in/toggle_transparent": "toggle transparency",
|
||||||
"/actions/cursor/out/scroll_haptic": "scrolling haptic feedback"
|
"/actions/cursor/out/scroll_haptic": "scrolling haptic feedback"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
17
src/app.cpp
17
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 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 int FRAME_INTERVAL = 4; // number of update loops until the frame buffer is updated
|
||||||
|
const float TRANSPARENCY = 0.6f;
|
||||||
|
|
||||||
App::App()
|
App::App()
|
||||||
{
|
{
|
||||||
|
@ -75,6 +76,8 @@ App::App()
|
||||||
assert(action_err == 0);
|
assert(action_err == 0);
|
||||||
action_err = vr_input->GetActionHandle("/actions/cursor/in/scroll", &_input_handles.cursor.scroll);
|
action_err = vr_input->GetActionHandle("/actions/cursor/in/scroll", &_input_handles.cursor.scroll);
|
||||||
assert(action_err == 0);
|
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);
|
action_err = vr_input->GetActionHandle("/actions/cursor/out/scroll_haptic", &_input_handles.cursor.scroll_haptic);
|
||||||
assert(action_err == 0);
|
assert(action_err == 0);
|
||||||
action_err = vr_input->GetActionSetHandle("/actions/main", &_input_handles.main_set);
|
action_err = vr_input->GetActionSetHandle("/actions/main", &_input_handles.main_set);
|
||||||
|
@ -193,6 +196,20 @@ void App::UpdateInput(float dtime)
|
||||||
}
|
}
|
||||||
UpdateUIVisibility();
|
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 (!_hidden)
|
||||||
{
|
{
|
||||||
if (IsInputJustPressed(_input_handles.main.reset))
|
if (IsInputJustPressed(_input_handles.main.reset))
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct InputHandles
|
||||||
vr::VRActionHandle_t mouse_middle;
|
vr::VRActionHandle_t mouse_middle;
|
||||||
vr::VRActionHandle_t scroll;
|
vr::VRActionHandle_t scroll;
|
||||||
vr::VRActionHandle_t scroll_haptic;
|
vr::VRActionHandle_t scroll_haptic;
|
||||||
|
vr::VRActionHandle_t toggle_transparent;
|
||||||
} cursor;
|
} cursor;
|
||||||
vr::VRActionSetHandle_t cursor_set;
|
vr::VRActionSetHandle_t cursor_set;
|
||||||
struct
|
struct
|
||||||
|
@ -87,6 +88,7 @@ class App
|
||||||
Overlay _root_overlay;
|
Overlay _root_overlay;
|
||||||
std::vector<Panel> _panels;
|
std::vector<Panel> _panels;
|
||||||
bool _hidden = false;
|
bool _hidden = false;
|
||||||
|
bool _transparent = false;
|
||||||
bool _edit_mode = false;
|
bool _edit_mode = false;
|
||||||
std::optional<Controller *> _active_cursor;
|
std::optional<Controller *> _active_cursor;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../openvr/openvr.h"
|
#include "../lib/openvr.h"
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
typedef vr::TrackedDeviceIndex_t TrackerID;
|
typedef vr::TrackedDeviceIndex_t TrackerID;
|
||||||
|
|
Loading…
Add table
Reference in a new issue