Skip to content

Commit

Permalink
Merge pull request #163 from ChristophHaag/vive_and_index
Browse files Browse the repository at this point in the history
hello_xr: Add Valve Index bindings
  • Loading branch information
rpavlik authored Jul 27, 2020
2 parents efd4721 + 8dd68a2 commit 0d5d0c2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/sdk/pr.163.gh.OpenXR-SDK-Source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello_xr: Add Valve Index Controller bindings. Also use trigger value instead of squeeze click for grab action on Vive Wand controller.
33 changes: 31 additions & 2 deletions src/tests/hello_xr/openxr_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,19 @@ struct OpenXrProgram : IOpenXrProgram {

std::array<XrPath, Side::COUNT> selectPath;
std::array<XrPath, Side::COUNT> squeezeValuePath;
std::array<XrPath, Side::COUNT> squeezeForcePath;
std::array<XrPath, Side::COUNT> squeezeClickPath;
std::array<XrPath, Side::COUNT> posePath;
std::array<XrPath, Side::COUNT> hapticPath;
std::array<XrPath, Side::COUNT> menuClickPath;
std::array<XrPath, Side::COUNT> bClickPath;
std::array<XrPath, Side::COUNT> triggerValuePath;
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/select/click", &selectPath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/select/click", &selectPath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/value", &squeezeValuePath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/squeeze/value", &squeezeValuePath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/force", &squeezeForcePath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/squeeze/force", &squeezeForcePath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/squeeze/click", &squeezeClickPath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/squeeze/click", &squeezeClickPath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/grip/pose", &posePath[Side::LEFT]));
Expand All @@ -425,6 +430,10 @@ struct OpenXrProgram : IOpenXrProgram {
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/output/haptic", &hapticPath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/menu/click", &menuClickPath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/menu/click", &menuClickPath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/b/click", &bClickPath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/b/click", &bClickPath[Side::RIGHT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/left/input/trigger/value", &triggerValuePath[Side::LEFT]));
CHECK_XRCMD(xrStringToPath(m_instance, "/user/hand/right/input/trigger/value", &triggerValuePath[Side::RIGHT]));
// Suggest bindings for KHR Simple.
{
XrPath khrSimpleInteractionProfilePath;
Expand Down Expand Up @@ -468,8 +477,8 @@ struct OpenXrProgram : IOpenXrProgram {
XrPath viveControllerInteractionProfilePath;
CHECK_XRCMD(
xrStringToPath(m_instance, "/interaction_profiles/htc/vive_controller", &viveControllerInteractionProfilePath));
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, squeezeClickPath[Side::LEFT]},
{m_input.grabAction, squeezeClickPath[Side::RIGHT]},
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, triggerValuePath[Side::LEFT]},
{m_input.grabAction, triggerValuePath[Side::RIGHT]},
{m_input.poseAction, posePath[Side::LEFT]},
{m_input.poseAction, posePath[Side::RIGHT]},
{m_input.quitAction, menuClickPath[Side::LEFT]},
Expand All @@ -483,6 +492,26 @@ struct OpenXrProgram : IOpenXrProgram {
CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));
}

// Suggest bindings for the Valve Index Controller.
{
XrPath indexControllerInteractionProfilePath;
CHECK_XRCMD(
xrStringToPath(m_instance, "/interaction_profiles/valve/index_controller", &indexControllerInteractionProfilePath));
std::vector<XrActionSuggestedBinding> bindings{{{m_input.grabAction, squeezeForcePath[Side::LEFT]},
{m_input.grabAction, squeezeForcePath[Side::RIGHT]},
{m_input.poseAction, posePath[Side::LEFT]},
{m_input.poseAction, posePath[Side::RIGHT]},
{m_input.quitAction, bClickPath[Side::LEFT]},
{m_input.quitAction, bClickPath[Side::RIGHT]},
{m_input.vibrateAction, hapticPath[Side::LEFT]},
{m_input.vibrateAction, hapticPath[Side::RIGHT]}}};
XrInteractionProfileSuggestedBinding suggestedBindings{XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING};
suggestedBindings.interactionProfile = indexControllerInteractionProfilePath;
suggestedBindings.suggestedBindings = bindings.data();
suggestedBindings.countSuggestedBindings = (uint32_t)bindings.size();
CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));
}

// Suggest bindings for the Microsoft Mixed Reality Motion Controller.
{
XrPath microsoftMixedRealityInteractionProfilePath;
Expand Down

0 comments on commit 0d5d0c2

Please sign in to comment.