openvr haptics

This commit is contained in:
galister
2024-02-04 03:16:30 +01:00
parent b5d970e5fd
commit d7c8b49efa
7 changed files with 76 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
use std::{array, io::Write, path::Path};
use std::{array, io::Write, path::Path, time::Duration};
use ovr_overlay::{
input::{ActionHandle, ActionSetHandle, ActiveActionSet, InputManager, InputValueHandle},
@@ -11,7 +11,7 @@ use ovr_overlay::{
};
use crate::{
backend::input::{TrackedDevice, TrackedDeviceRole},
backend::input::{Haptics, TrackedDevice, TrackedDeviceRole},
state::AppState,
};
@@ -119,6 +119,18 @@ impl OpenVrInputSource {
})
}
pub fn haptics(&mut self, input: &mut InputManager, hand: usize, haptics: &Haptics) {
let hnd = self.hands[hand].haptics_hnd;
let _ = input.trigger_haptic_vibration_action(
hnd,
0.0,
Duration::from_secs_f32(haptics.duration),
haptics.frequency,
haptics.intensity,
INPUT_ANY,
);
}
pub fn update(
&mut self,
input: &mut InputManager,