Skip to content

Commit

Permalink
Merge branch 'alvr-org:master' into hand-gestures
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabwhy authored Aug 22, 2023
2 parents 329a260 + a111749 commit e2d4d51
Show file tree
Hide file tree
Showing 10 changed files with 4,732 additions and 29 deletions.
127 changes: 127 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions alvr/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ hyper = { version = "0.14", features = [
"runtime",
"tcp",
] }
reqwest = "0.11" # not used but webserver does not work without it. todo: investigate
rosc = "0.10"
tokio = { version = "1", features = [
"rt-multi-thread",
Expand Down
61 changes: 32 additions & 29 deletions alvr/server/cpp/alvr_server/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,36 +482,7 @@ void Controller::SetButton(uint64_t id, FfiButtonValue value) {
0.0);
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_TRIGGER_VALUE], m_triggerValue, 0.0);
{
float indexCurl = 0.0;
if (m_triggerValue > 0.0) {
indexCurl = 0.5 + m_triggerValue * 0.5;
} else if (m_lastIndexTouch == 0) {
indexCurl = m_indexTouchAnimationProgress * 0.5;
} else {
indexCurl = 0.5 - m_indexTouchAnimationProgress * 0.5;
}
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_INDEX], indexCurl, 0.0);

vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_MIDDLE], m_gripValue, 0.0);

// Ring and pinky fingers are not tracked. Infer a more natural pose.
if ((m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_X_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_Y_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_A_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_B_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_JOYSTICK_TOUCH)) != 0) {
vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_RING], 1, 0.0);
vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_PINKY], 1, 0.0);
} else {
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_RING], m_gripValue, 0.0);
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_PINKY], m_gripValue, 0.0);
}
}
break;
case 5: // Vive wand
case 9: // Vive Tracker
Expand Down Expand Up @@ -781,6 +752,38 @@ bool Controller::onPoseUpdate(float predictionS,
m_indexTouchAnimationProgress = 0;
}

// Valve Index
if (Settings::Instance().m_controllerMode == 3) {
float indexCurl = 0.0;
if (m_triggerValue > 0.0) {
indexCurl = 0.5 + m_triggerValue * 0.5;
} else if (m_lastIndexTouch == 0) {
indexCurl = m_indexTouchAnimationProgress * 0.5;
} else {
indexCurl = 0.5 - m_indexTouchAnimationProgress * 0.5;
}
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_INDEX], indexCurl, 0.0);

vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_MIDDLE], m_gripValue, 0.0);

// Ring and pinky fingers are not tracked. Infer a more natural pose.
if ((m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_X_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_Y_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_A_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_B_TOUCH)) != 0 ||
(m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_JOYSTICK_TOUCH)) != 0) {
vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_RING], 1, 0.0);
vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_PINKY], 1, 0.0);
} else {
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_RING], m_gripValue, 0.0);
vr_driver_input->UpdateScalarComponent(
m_handles[ALVR_INPUT_FINGER_PINKY], m_gripValue, 0.0);
}
}

uint64_t lastPoseTouch = m_lastThumbTouch + m_lastIndexTouch;

vr::VRBoneTransform_t boneTransforms[SKELETON_BONE_COUNT];
Expand Down
2 changes: 2 additions & 0 deletions alvr/server/cpp/alvr_server/alvr_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ void (*SetOpenvrProps)(unsigned long long deviceID);
void (*WaitForVSync)();

void *CppEntryPoint(const char *interface_name, int *return_code) {
HookCrashHandler();

// Initialize path constants
init_paths();

Expand Down
3 changes: 3 additions & 0 deletions alvr/server/cpp/alvr_server/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ extern "C" void CaptureFrame();
// NalParsing.cpp
void ParseFrameNals(
int codec, unsigned char *buf, int len, unsigned long long targetTimestampNs, bool isIdr);

// CrashHandler.cpp
void HookCrashHandler();
3 changes: 3 additions & 0 deletions alvr/server/cpp/platform/linux/CrashHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "../../alvr_server/bindings.h"

void HookCrashHandler() {}
3 changes: 3 additions & 0 deletions alvr/server/cpp/platform/macos/CrashHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "../../alvr_server/bindings.h"

void HookCrashHandler() {}
23 changes: 23 additions & 0 deletions alvr/server/cpp/platform/win32/CrashHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "../../alvr_server/bindings.h"

#include "../../alvr_server/Logger.h"
#include "../../shared/backward.hpp"
#include <Windows.h>
#include <ostream>

static LONG WINAPI handler(PEXCEPTION_POINTERS ptrs) {
backward::StackTrace stacktrace;
backward::Printer printer;
std::ostringstream stream;

stacktrace.load_from(ptrs->ExceptionRecord->ExceptionAddress);
printer.print(stacktrace, stream);
std::string str = stream.str();
Error("Unhandled exception: %X\n%s", ptrs->ExceptionRecord->ExceptionCode, str.c_str());

Sleep(2000);

return EXCEPTION_EXECUTE_HANDLER;
}

void HookCrashHandler() { SetUnhandledExceptionFilter(handler); }
42 changes: 42 additions & 0 deletions alvr/server/cpp/shared/backward.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Pick your poison.
//
// On GNU/Linux, you have few choices to get the most out of your stack trace.
//
// By default you get:
// - object filename
// - function name
//
// In order to add:
// - source filename
// - line and column numbers
// - source code snippet (assuming the file is accessible)

// Install one of the following libraries then uncomment one of the macro (or
// better, add the detection of the lib and the macro definition in your build
// system)

// - apt-get install libdw-dev ...
// - g++/clang++ -ldw ...
// #define BACKWARD_HAS_DW 1

// - apt-get install binutils-dev ...
// - g++/clang++ -lbfd ...
// #define BACKWARD_HAS_BFD 1

// - apt-get install libdwarf-dev ...
// - g++/clang++ -ldwarf ...
// #define BACKWARD_HAS_DWARF 1

// Regardless of the library you choose to read the debug information,
// for potentially more detailed stack traces you can use libunwind
// - apt-get install libunwind-dev
// - g++/clang++ -lunwind
// #define BACKWARD_HAS_LIBUNWIND 1

#include "backward.hpp"

namespace backward {

backward::SignalHandling sh;

} // namespace backward
Loading

0 comments on commit e2d4d51

Please sign in to comment.