summaryrefslogtreecommitdiffstats
path: root/Scripts/steamvr.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-08-31 17:11:11 -0700
committeryum <yum.food.vr@gmail.com>2023-08-31 17:17:01 -0700
commit3db4f81573d89f6ebefb5ec119c7d66affc1a4a0 (patch)
tree202672af81898cfdf559dcfa3a2d89341584f25c /Scripts/steamvr.py
parent4fcf3e1e3ac8dcf510be96a84b81a688b1092869 (diff)
Bugfixes and tweaks
* Temporarily restore normal process priority. Working on adding a UI option to set STT prio. * Give audio indicator phonemes a 1/3 chance to do nothing. Makes result sound a little better imo. * Quiet down steamVR thread when steamVR isn't running * Fix use of `button_id` and `hand_id` in steamvr.py * Increase amount of silence allowed before transcript from 1 to 5 seconds. You want enough buffer to allow for a few full transcripts, else you risk spuriously dropping audio. * Enable background loading in audio metadata (required by vrc sdk)
Diffstat (limited to 'Scripts/steamvr.py')
-rw-r--r--Scripts/steamvr.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Scripts/steamvr.py b/Scripts/steamvr.py
index e0b59e3..da07134 100644
--- a/Scripts/steamvr.py
+++ b/Scripts/steamvr.py
@@ -30,19 +30,22 @@ def pollButtonPress(
buttons["thumbstick"] = vr.k_EButton_Axis0
system = None
+ first = True
while not system:
try:
system = vr.init(vr.VRApplication_Background)
except Exception as e:
- print(f"Failed to start steamVR input thread: {repr(e)}", file=sys.stderr)
- time.sleep(5)
+ if first:
+ print(f"Failed to start steamVR input thread: {repr(e)}", file=sys.stderr)
+ first = False
+ time.sleep(1)
last_packet = 0
event_high = False
while True:
time.sleep(0.01)
- lh_idx = system.getTrackedDeviceIndexForControllerRole(hand_id)
+ lh_idx = system.getTrackedDeviceIndexForControllerRole(hands[hand])
#print("left hand device idx: {}".format(lh_idx))
got_state, state = system.getControllerState(lh_idx)
@@ -58,7 +61,7 @@ def pollButtonPress(
# click, not movement.
dead_zone_radius = 0.7
- button_mask = (1 << button_id)
+ button_mask = (1 << buttons[button])
ret = EVENT_NONE
if (state.ulButtonPressed & button_mask) != 0 and\
(state.rAxis[0].x**2 + state.rAxis[0].y**2 < dead_zone_radius**2):
@@ -77,7 +80,7 @@ if __name__ == "__main__":
while True:
time.sleep(0.1)
- event = pollButtonPress(session_state, hand_id = hands["left"], button_id = buttons["joystick"])
+ event = pollButtonPress(session_state)
if event == EVENT_RISING_EDGE:
print("rising edge")
elif event == EVENT_FALLING_EDGE: