mirror of
https://github.com/lbgos/rift-s-linux.git
synced 2026-10-28 17:01:46 +01:00
d/ohmd: Use unofficial OpenHMD Haptics API
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2329>
This commit is contained in:
1 parent
b1117a7854
commit
62900fade1
1 file changed
+23
-2
@@ -85,6 +85,12 @@ enum input_indices
|
||||
// one mapping for each of enum ohmd_control_hint
|
||||
#define CONTROL_MAPPING_SIZE 16
|
||||
|
||||
// Default haptic frequency for when the driver needs to decide frequency.
|
||||
#if defined(OHMD_HAVE_HAPTICS_API_v0)
|
||||
#define DEFAULT_HAPTIC_FREQ 160.0
|
||||
#endif
|
||||
|
||||
|
||||
// generic controllers are mapped to the khronos simple profile
|
||||
// touch controllers input mappings are special cased
|
||||
enum openhmd_device_type
|
||||
@@ -322,9 +328,24 @@ static void
|
||||
oh_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const union xrt_output_value *value)
|
||||
{
|
||||
struct oh_device *ohd = oh_device(xdev);
|
||||
(void)ohd;
|
||||
|
||||
//! @todo OpenHMD haptic API not finished
|
||||
#if defined(OHMD_HAVE_HAPTICS_API_v0)
|
||||
// Use the unofficial Haptics API from thaytan's fork of OpenHMD:
|
||||
// https://github.com/thaytan/OpenHMD/blob/rift-room-config/include/openhmd.h#L481
|
||||
|
||||
float frequency = value->vibration.frequency;
|
||||
|
||||
// A frequency of 0.0f from OpenXR means to let the driver decide.
|
||||
if (frequency == 0.0f) {
|
||||
frequency = DEFAULT_HAPTIC_FREQ;
|
||||
}
|
||||
|
||||
ohmd_device_set_haptics_on(ohd->dev, (float)value->vibration.duration_ns / 1e9f, frequency,
|
||||
value->vibration.amplitude);
|
||||
#else
|
||||
// There is no official OpenHMD Haptic API.
|
||||
(void)ohd;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
|
||||
Reference in new issue
Block a user