From 8b823b87fb97a45c7ad9e1925dd608465f7cac09 Mon Sep 17 00:00:00 2001 From: digitalfox Date: Sun, 24 Mar 2024 21:37:33 -0400 Subject: [PATCH] [WIP] [Update] Support for Tundra Tracker quirks WORK IN PROGRESS - DO NOT MERGE - INCOMPLETE This does NOT fix the "Identify" button! Tentative intensity multiplier value: 9.0 "Linear" is strong, "Throb" is a bit weak, but that may change when the means of triggering haptic pulses is better tuned to support Tundra Trackers. This might break Vive Tracker support, or at the very least needlessly use more CPU cycles with the tighter FeedbackThread loop. This might need replaced with support for the IVRInput system in place of the deprecated triggerHapticPulse() function. This is just the bare minimum to get Tundra Trackers working with the bridge app during normal use (not the Identify button). Haptic Tundrakes, anyone? ...no? --- BridgeApp/app_runner.py | 27 ++++++++++++++++++++++++++- BridgeApp/target_ovr.py | 17 +++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/BridgeApp/app_runner.py b/BridgeApp/app_runner.py index ff3925e..79c5497 100644 --- a/BridgeApp/app_runner.py +++ b/BridgeApp/app_runner.py @@ -22,7 +22,32 @@ def __init__(self, config: AppConfig, tracker: VRTracker, pulse_function, batter self.strength_delta: float = 0.0 self.last_str_set_time = time.time() - self.interval_ms = 50 # millis + #self.interval_ms = 50 # millis + # HACK: test spacing out pulses + self.interval_ms = 5.1 # millis + # FIXME: Find the slowest interval that allows for a full-duration + # pulse on e.g. Tundra Trackers. + # + # TODO: + # Try switching from "triggerHapticPulse()" to IVRInput + # triggerHapticPulse() is deprecated as per + # See https://github.com/ValveSoftware/openvr/blob/v2.2.3/headers/openvr.h#L2431-L2433 + # And https://github.com/ValveSoftware/openvr/blob/v2.2.3/headers/openvr.h#L5216-L5218 + # + # This might be specific to Tundra Trackers vs. Vive Trackers, as + # Tundra ships their IO Expansion board with a LRA/haptic actuator + # + # Failing that, this thread could detect Tundra Trackers by model and + # adjust the interval, and adapt the force_pulse() function to + # automatically queue up anything that exceeds the max duration to be + # applied as a series of max duration pulses (until queue is empty). + # + # Example: + # force_pulse() -> self.force_pulse_queue = 500 (ms) + # run() + # inside while True, also check if force_pulse_queue > 0 + # triggerHapticPulse(max_duration) + # force_pulse_queue -= max_duration self.interval_s = self.interval_ms / 1000 # seconds self.vp = VibrationPattern(self.config) diff --git a/BridgeApp/target_ovr.py b/BridgeApp/target_ovr.py index 22b7692..e1aab1a 100644 --- a/BridgeApp/target_ovr.py +++ b/BridgeApp/target_ovr.py @@ -3,6 +3,8 @@ from app_config import VRTracker, AppConfig from typing import List, Dict +## HACK: test spacing out pulses +#import time class OpenVRTracker: def __init__(self, config: AppConfig): @@ -79,3 +81,18 @@ def is_alive(self): def __pulse(self, index, pulse_length: int = 200): if self.is_alive(): self.vr.triggerHapticPulse(index, 0, pulse_length) + # HACK: test spacing out pulses + #pulse_max_amount = 3999 + pulse_max_amount = 5000 + #sleep_min_delay = pulse_max_amount / 1000000 + #sleep_min_delay = 5000 / 1000000 + if pulse_length > pulse_max_amount: + print("PULSE LENGTH > " + str(pulse_max_amount) + ": " + str(pulse_length)) + #print("PULSE LENGTH: " + str(pulse_length)) + #while pulse_length > 3999: + # self.vr.triggerHapticPulse(index, 0, pulse_max_amount) + # pulse_length -= pulse_max_amount + # time.sleep(sleep_min_delay) + #if pulse_length > 0: + # self.vr.triggerHapticPulse(index, 0, pulse_length) + # time.sleep(sleep_min_delay)