mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
st/oxr: Add force feedback extension implementation
This commit is contained in:
parent
b710127fad
commit
0bed585018
|
@ -544,6 +544,11 @@ oxr_xrLocateHandJointsEXT(XrHandTrackerEXT handTracker,
|
|||
const XrHandJointsLocateInfoEXT *locateInfo,
|
||||
XrHandJointLocationsEXT *locations);
|
||||
|
||||
//! OpenXR API function @ep{xrApplyForceFeedbackCurlMNDX}
|
||||
XRAPI_ATTR XrResult XRAPI_CALL
|
||||
oxr_xrApplyForceFeedbackCurlMNDX(XrHandTrackerEXT handTracker, const XrApplyForceFeedbackCurlLocationsMNDX *locations);
|
||||
|
||||
|
||||
//! OpenXR API function @ep{xrEnumerateDisplayRefreshRatesFB}
|
||||
XRAPI_ATTR XrResult XRAPI_CALL
|
||||
oxr_xrEnumerateDisplayRefreshRatesFB(XrSession session,
|
||||
|
|
|
@ -232,6 +232,10 @@ handle_non_null(struct oxr_instance *inst, struct oxr_logger *log, const char *n
|
|||
ENTRY_IF_EXT(xrLocateHandJointsEXT, EXT_hand_tracking);
|
||||
#endif
|
||||
|
||||
#ifdef OXR_HAVE_MNDX_force_feedback_curl
|
||||
ENTRY_IF_EXT(xrApplyForceFeedbackCurlMNDX, MNDX_force_feedback_curl);
|
||||
#endif
|
||||
|
||||
#ifdef OXR_HAVE_FB_display_refresh_rate
|
||||
ENTRY_IF_EXT(xrEnumerateDisplayRefreshRatesFB, FB_display_refresh_rate);
|
||||
ENTRY_IF_EXT(xrGetDisplayRefreshRateFB, FB_display_refresh_rate);
|
||||
|
|
|
@ -471,6 +471,29 @@ oxr_xrLocateHandJointsEXT(XrHandTrackerEXT handTracker,
|
|||
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* XR_MNDX_force_feedback_curl
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef XR_MNDX_force_feedback_curl
|
||||
|
||||
XrResult
|
||||
oxr_xrApplyForceFeedbackCurlMNDX(XrHandTrackerEXT handTracker, const XrApplyForceFeedbackCurlLocationsMNDX *locations)
|
||||
{
|
||||
OXR_TRACE_MARKER();
|
||||
|
||||
struct oxr_hand_tracker *hand_tracker;
|
||||
struct oxr_logger log;
|
||||
OXR_VERIFY_HAND_TRACKER_AND_INIT_LOG(&log, handTracker, hand_tracker, "xrApplyForceFeedbackCurlMNDX");
|
||||
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, locations, XR_TYPE_FORCE_FEEDBACK_CURL_APPLY_LOCATIONS_MNDX);
|
||||
|
||||
return oxr_session_apply_force_feedback(&log, hand_tracker, locations);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* XR_FB_display_refresh_rate
|
||||
|
|
|
@ -65,6 +65,8 @@ extern "C" {
|
|||
OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action_set, ACTIONSET, name, new_thing->inst)
|
||||
#define OXR_VERIFY_HAND_TRACKER_AND_INIT_LOG(log, thing, new_thing, name) \
|
||||
OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_hand_tracker, HTRACKER, name, new_thing->sess->sys->inst)
|
||||
#define OXR_VERIFY_FORCE_FEEDBACK_AND_INIT_LOG(log, thing, new_thing, name) \
|
||||
OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_force_feedback, FFB, name, new_thing->sess->sys->inst)
|
||||
// clang-format on
|
||||
|
||||
#define OXR_VERIFY_INSTANCE_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_instance, INSTANCE);
|
||||
|
|
|
@ -793,6 +793,11 @@ oxr_session_hand_joints(struct oxr_logger *log,
|
|||
const XrHandJointsLocateInfoEXT *locateInfo,
|
||||
XrHandJointLocationsEXT *locations);
|
||||
|
||||
XrResult
|
||||
oxr_session_apply_force_feedback(struct oxr_logger *log,
|
||||
struct oxr_hand_tracker *hand_tracker,
|
||||
const XrApplyForceFeedbackCurlLocationsMNDX *locations);
|
||||
|
||||
/*
|
||||
*
|
||||
* oxr_space.c
|
||||
|
@ -999,6 +1004,9 @@ oxr_system_enumerate_view_conf_views(struct oxr_logger *log,
|
|||
bool
|
||||
oxr_system_get_hand_tracking_support(struct oxr_logger *log, struct oxr_instance *inst);
|
||||
|
||||
bool
|
||||
oxr_system_get_force_feedback_support(struct oxr_logger *log, struct oxr_instance *inst);
|
||||
|
||||
/*
|
||||
*
|
||||
* oxr_event.cpp
|
||||
|
|
|
@ -1008,3 +1008,26 @@ oxr_session_hand_joints(struct oxr_logger *log,
|
|||
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
XrResult
|
||||
oxr_session_apply_force_feedback(struct oxr_logger *log,
|
||||
struct oxr_hand_tracker *hand_tracker,
|
||||
const XrApplyForceFeedbackCurlLocationsMNDX *locations)
|
||||
{
|
||||
struct xrt_device *xdev = hand_tracker->xdev;
|
||||
|
||||
union xrt_output_value result;
|
||||
result.force_feedback.force_feedback_location_count = locations->locationCount;
|
||||
for (uint32_t i = 0; i < locations->locationCount; i++) {
|
||||
result.force_feedback.force_feedback[i].location =
|
||||
(enum xrt_force_feedback_location)locations->locations[i].location;
|
||||
result.force_feedback.force_feedback[i].value = locations->locations[i].value;
|
||||
}
|
||||
|
||||
xrt_device_set_output(xdev,
|
||||
hand_tracker->hand == XRT_HAND_LEFT ? XRT_OUTPUT_NAME_FORCE_FEEDBACK_LEFT
|
||||
: XRT_OUTPUT_NAME_FORCE_FEEDBACK_RIGHT,
|
||||
&result);
|
||||
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -183,6 +183,19 @@ oxr_system_get_hand_tracking_support(struct oxr_logger *log, struct oxr_instance
|
|||
return left_supported || right_supported;
|
||||
}
|
||||
|
||||
bool
|
||||
oxr_system_get_force_feedback_support(struct oxr_logger *log, struct oxr_instance *inst)
|
||||
{
|
||||
struct oxr_system *sys = &inst->system;
|
||||
struct xrt_device *ffb_left = GET_XDEV_BY_ROLE(sys, hand_tracking.left);
|
||||
struct xrt_device *ffb_right = GET_XDEV_BY_ROLE(sys, hand_tracking.right);
|
||||
|
||||
bool left_supported = ffb_left && ffb_left->force_feedback_supported;
|
||||
bool right_supported = ffb_right && ffb_right->force_feedback_supported;
|
||||
|
||||
return left_supported || right_supported;
|
||||
}
|
||||
|
||||
XrResult
|
||||
oxr_system_get_properties(struct oxr_logger *log, struct oxr_system *sys, XrSystemProperties *properties)
|
||||
{
|
||||
|
@ -219,6 +232,17 @@ oxr_system_get_properties(struct oxr_logger *log, struct oxr_system *sys, XrSyst
|
|||
hand_tracking_props->supportsHandTracking = oxr_system_get_hand_tracking_support(log, sys->inst);
|
||||
}
|
||||
|
||||
XrSystemForceFeedbackCurlPropertiesMNDX *force_feedback_props = NULL;
|
||||
if (sys->inst->extensions.MNDX_force_feedback_curl) {
|
||||
force_feedback_props =
|
||||
OXR_GET_OUTPUT_FROM_CHAIN(properties, XR_TYPE_SYSTEM_FORCE_FEEDBACK_CURL_PROPERTIES_MNDX,
|
||||
XrSystemForceFeedbackCurlPropertiesMNDX);
|
||||
}
|
||||
|
||||
if (force_feedback_props) {
|
||||
force_feedback_props->supportsForceFeedbackCurl = oxr_system_get_force_feedback_support(log, sys->inst);
|
||||
}
|
||||
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue