Skip to content

Commit 0d5d0c2

Browse files
authored
Merge pull request #163 from ChristophHaag/vive_and_index
hello_xr: Add Valve Index bindings
2 parents efd4721 + 8dd68a2 commit 0d5d0c2

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello_xr: Add Valve Index Controller bindings. Also use trigger value instead of squeeze click for grab action on Vive Wand controller.

src/tests/hello_xr/openxr_program.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,19 @@ struct OpenXrProgram : IOpenXrProgram {
409409

410410
std::array<XrPath, Side::COUNT> selectPath;
411411
std::array<XrPath, Side::COUNT> squeezeValuePath;
412+
std::array<XrPath, Side::COUNT> squeezeForcePath;
412413
std::array<XrPath, Side::COUNT> squeezeClickPath;
413414
std::array<XrPath, Side::COUNT> posePath;
414415
std::array<XrPath, Side::COUNT> hapticPath;
415416
std::array<XrPath, Side::COUNT> menuClickPath;
417+
std::array<XrPath, Side::COUNT> bClickPath;
418+
std::array<XrPath, Side::COUNT> triggerValuePath;
416419
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/select/click", &selectPath[Side::LEFT]));
417420
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/select/click", &selectPath[Side::RIGHT]));
418421
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/value", &squeezeValuePath[Side::LEFT]));
419422
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/squeeze/value", &squeezeValuePath[Side::RIGHT]));
423+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/force", &squeezeForcePath[Side::LEFT]));
424+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/squeeze/force", &squeezeForcePath[Side::RIGHT]));
420425
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/click", &squeezeClickPath[Side::LEFT]));
421426
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/squeeze/click", &squeezeClickPath[Side::RIGHT]));
422427
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/grip/pose", &posePath[Side::LEFT]));
@@ -425,6 +430,10 @@ struct OpenXrProgram : IOpenXrProgram {
425430
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/output/haptic", &hapticPath[Side::RIGHT]));
426431
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/menu/click", &menuClickPath[Side::LEFT]));
427432
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/menu/click", &menuClickPath[Side::RIGHT]));
433+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/b/click", &bClickPath[Side::LEFT]));
434+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/b/click", &bClickPath[Side::RIGHT]));
435+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/trigger/value", &triggerValuePath[Side::LEFT]));
436+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/trigger/value", &triggerValuePath[Side::RIGHT]));
428437
// Suggest bindings for KHR Simple.
429438
{
430439
XrPath khrSimpleInteractionProfilePath;
@@ -468,8 +477,8 @@ struct OpenXrProgram : IOpenXrProgram {
468477
XrPath viveControllerInteractionProfilePath;
469478
CHECK_XRCMD(
470479
xrStringToPath(m_instance, "/interaction_profiles/htc/vive_controller", &viveControllerInteractionProfilePath));
471-
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, squeezeClickPath[Side::LEFT]},
472-
{m_input.grabAction, squeezeClickPath[Side::RIGHT]},
480+
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, triggerValuePath[Side::LEFT]},
481+
{m_input.grabAction, triggerValuePath[Side::RIGHT]},
473482
{m_input.poseAction, posePath[Side::LEFT]},
474483
{m_input.poseAction, posePath[Side::RIGHT]},
475484
{m_input.quitAction, menuClickPath[Side::LEFT]},
@@ -483,6 +492,26 @@ struct OpenXrProgram : IOpenXrProgram {
483492
CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));
484493
}
485494

495+
// Suggest bindings for the Valve Index Controller.
496+
{
497+
XrPath indexControllerInteractionProfilePath;
498+
CHECK_XRCMD(
499+
xrStringToPath(m_instance, "/interaction_profiles/valve/index_controller", &indexControllerInteractionProfilePath));
500+
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, squeezeForcePath[Side::LEFT]},
501+
{m_input.grabAction, squeezeForcePath[Side::RIGHT]},
502+
{m_input.poseAction, posePath[Side::LEFT]},
503+
{m_input.poseAction, posePath[Side::RIGHT]},
504+
{m_input.quitAction, bClickPath[Side::LEFT]},
505+
{m_input.quitAction, bClickPath[Side::RIGHT]},
506+
{m_input.vibrateAction, hapticPath[Side::LEFT]},
507+
{m_input.vibrateAction, hapticPath[Side::RIGHT]}}};
508+
XrInteractionProfileSuggestedBinding suggestedBindings{XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING};
509+
suggestedBindings.interactionProfile = indexControllerInteractionProfilePath;
510+
suggestedBindings.suggestedBindings = bindings.data();
511+
suggestedBindings.countSuggestedBindings = (uint32_t)bindings.size();
512+
CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));
513+
}
514+
486515
// Suggest bindings for the Microsoft Mixed Reality Motion Controller.
487516
{
488517
XrPath microsoftMixedRealityInteractionProfilePath;

0 commit comments

Comments
 (0)