The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/ohmd: Use unofficial OpenHMD Haptics API

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2329>

+23 -2
+23 -2
src/xrt/drivers/ohmd/oh_device.c
··· 85 85 // one mapping for each of enum ohmd_control_hint 86 86 #define CONTROL_MAPPING_SIZE 16 87 87 88 + // Default haptic frequency for when the driver needs to decide frequency. 89 + #if defined(OHMD_HAVE_HAPTICS_API_v0) 90 + #define DEFAULT_HAPTIC_FREQ 160.0 91 + #endif 92 + 93 + 88 94 // generic controllers are mapped to the khronos simple profile 89 95 // touch controllers input mappings are special cased 90 96 enum openhmd_device_type ··· 322 328 oh_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const union xrt_output_value *value) 323 329 { 324 330 struct oh_device *ohd = oh_device(xdev); 331 + 332 + #if defined(OHMD_HAVE_HAPTICS_API_v0) 333 + // Use the unofficial Haptics API from thaytan's fork of OpenHMD: 334 + // https://github.com/thaytan/OpenHMD/blob/rift-room-config/include/openhmd.h#L481 335 + 336 + float frequency = value->vibration.frequency; 337 + 338 + // A frequency of 0.0f from OpenXR means to let the driver decide. 339 + if (frequency == 0.0f) { 340 + frequency = DEFAULT_HAPTIC_FREQ; 341 + } 342 + 343 + ohmd_device_set_haptics_on(ohd->dev, (float)value->vibration.duration_ns / 1e9f, frequency, 344 + value->vibration.amplitude); 345 + #else 346 + // There is no official OpenHMD Haptic API. 325 347 (void)ohd; 326 - 327 - //! @todo OpenHMD haptic API not finished 348 + #endif 328 349 } 329 350 330 351 static bool