Skip to content

Commit a763a74

Browse files
committed
hello_xr: Add Valve Index bindings
1 parent 51cade1 commit a763a74

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/tests/hello_xr/openxr_program.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ struct OpenXrProgram : IOpenXrProgram {
413413
std::array<XrPath, Side::COUNT> posePath;
414414
std::array<XrPath, Side::COUNT> hapticPath;
415415
std::array<XrPath, Side::COUNT> menuClickPath;
416+
std::array<XrPath, Side::COUNT> bClickPath;
416417
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/select/click", &selectPath[Side::LEFT]));
417418
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/select/click", &selectPath[Side::RIGHT]));
418419
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/value", &squeezeValuePath[Side::LEFT]));
@@ -425,6 +426,8 @@ struct OpenXrProgram : IOpenXrProgram {
425426
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/output/haptic", &hapticPath[Side::RIGHT]));
426427
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/menu/click", &menuClickPath[Side::LEFT]));
427428
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/menu/click", &menuClickPath[Side::RIGHT]));
429+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/b/click", &bClickPath[Side::LEFT]));
430+
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/b/click", &bClickPath[Side::RIGHT]));
428431
// Suggest bindings for KHR Simple.
429432
{
430433
XrPath khrSimpleInteractionProfilePath;
@@ -483,6 +486,26 @@ struct OpenXrProgram : IOpenXrProgram {
483486
CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));
484487
}
485488

489+
// Suggest bindings for the Valve Index Controller.
490+
{
491+
XrPath indexControllerInteractionProfilePath;
492+
CHECK_XRCMD(
493+
xrStringToPath(m_instance, "/interaction_profiles/valve/index_controller", &indexControllerInteractionProfilePath));
494+
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, squeezeValuePath[Side::LEFT]},
495+
{m_input.grabAction, squeezeValuePath[Side::RIGHT]},
496+
{m_input.poseAction, posePath[Side::LEFT]},
497+
{m_input.poseAction, posePath[Side::RIGHT]},
498+
{m_input.quitAction, bClickPath[Side::LEFT]},
499+
{m_input.quitAction, bClickPath[Side::RIGHT]},
500+
{m_input.vibrateAction, hapticPath[Side::LEFT]},
501+
{m_input.vibrateAction, hapticPath[Side::RIGHT]}}};
502+
XrInteractionProfileSuggestedBinding suggestedBindings{XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING};
503+
suggestedBindings.interactionProfile = indexControllerInteractionProfilePath;
504+
suggestedBindings.suggestedBindings = bindings.data();
505+
suggestedBindings.countSuggestedBindings = (uint32_t)bindings.size();
506+
CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));
507+
}
508+
486509
// Suggest bindings for the Microsoft Mixed Reality Motion Controller.
487510
{
488511
XrPath microsoftMixedRealityInteractionProfilePath;

0 commit comments

Comments
 (0)