improve vr controllers handling

This commit is contained in:
2019-05-22 14:14:34 +02:00
parent ed170e555d
commit 37491d9fe1
3 changed files with 46 additions and 41 deletions

View File

@@ -482,15 +482,14 @@ bool win32_vr_start()
bool trigger_down = false;
cbuffer<glm::vec3> controller_points(10);
glm::vec3 controller_last_point;
vive->on_analog_button = [&](const ViveController& c, ViveController::kButton b, ViveController::kAction a) {
vive->on_analog_button = [&](const ViveController& c, ViveController::kButton b, ViveController::kAction a, glm::vec2 force) {
if (b == ViveController::kButton::Trigger)
{
if (a == ViveController::kAction::Press)
{
glm::vec3 pos = glm::normalize(xyz(vive->m_controllers[0].m_mat[3])) * 800.f;
float force = vive->m_controllers[0].axis(b).x;
async_lock();
Canvas::I->stroke_start(pos, force);
Canvas::I->stroke_start(pos, force.x);
async_unlock();
controller_last_point = pos;
controller_points.clear();
@@ -504,9 +503,12 @@ bool win32_vr_start()
async_unlock();
}
}
};
vive->on_button = [&](const ViveController& c, ViveController::kButton b, ViveController::kAction a, glm::vec2 axis) {
if (b == ViveController::kButton::Pad && a == ViveController::kAction::Press)
{
App::I.toggle_ui();
if (glm::length(axis) < 0.5f)
App::I.toggle_ui();
}
};