def __init__(self): self._vr_system = None self._devices = [] self._device_serial_lookup = {} self._device_index_lookup = {} self._last_pose_batch = None self._plot = None # Attempt to start OpenVR. if not openvr.isRuntimeInstalled(): raise OSError('OpenVR runtime not installed.') self._vr_system = openvr.init(openvr.VRApplication_Other)
def printSteamVRInfo(): print("OpenVR test program") if openvr.isHmdPresent(): print("VR head set found") if openvr.isRuntimeInstalled(): print("Runtime is installed") print(openvr.runtimePath()) #To initialize the API and get access to the vr::IVRSystem interface call the vr::VR_Init function # VRApplication_Background # VRApplication_Utility : IVRSettings and IVRApplications are guaranteed to work result = openvr.checkInitError(openvr.VRApplication_Background) print("test", result, " ", openvr.getVRInitErrorAsSymbol(result)) if result == 0: state = 10100 #------------------------------------------------------------- #Developing part vr_app = openvr.IVRApplications() #ctypes.c_char_p("410570") print("vr_app getApplicationState: ", vr_app.getApplicationState()) print( "vr_app getTransitionState: ", vr_app.getApplicationsTransitionStateNameFromEnum( vr_app.getTransitionState())) print("vr_app : ", vr_app.getApplicationProcessId('SteamVR.exe'.encode("utf-8"))) # vr_settings = openvr.VRSettings() if result == 0: vr_sys = openvr.VRSystem() state = vr_sys.getInt32TrackedDeviceProperty( openvr.k_unTrackedDeviceIndex_Hmd, 10100) print("CloudXR_Server_State ", ServerState(ctypes.c_ulong(state[0]).value).name) print("isDisplayOnDesktop ", vr_sys.isDisplayOnDesktop()) print( "isTrackedDeviceConnected ", vr_sys.isTrackedDeviceConnected(openvr.k_unTrackedDeviceIndex_Hmd)) # print("getPropErrorNameFromEnum ", vr_sys.getPropErrorNameFromEnum(result)) driver = vr_sys.getStringTrackedDeviceProperty( openvr.k_unTrackedDeviceIndex_Hmd, openvr.Prop_TrackingSystemName_String, ) display = vr_sys.getStringTrackedDeviceProperty( openvr.k_unTrackedDeviceIndex_Hmd, openvr.Prop_SerialNumber_String, ) print("driver: ", driver, "; diplay :", display)
def main(): # Should we look for VR input to detect AFK state or should # we just focus on getting the app title? # # Possibly useful endpoints: # IVRApplications.getApplicationPropertyString # IVRApplications.getApplicationPropertyString if openvr.isHmdPresent(): print("VR head set found") if openvr.isRuntimeInstalled(): print("Runtime is installed") vr_system = openvr.init(openvr.VRApplication_Utility) print(dir(vr_system)) print(openvr.runtimePath()) print(vr_system.getRecommendedRenderTargetSize()) print(vr_system.isDisplayOnDesktop()) def get_appkeys(ivrapps: openvr.IVRApplications): appkeys = [] appcount = ivrapps.getApplicationCount() for idx in range(appcount): # TODO: I'm not sure how to handle buffer in this C++ interop context pchAppKeyBuffer = '' pchAppKeyBufferLen = 90 error = ivrapps.getApplicationKeyByIndex(idx, pchAppKeyBuffer, pchAppKeyBufferLen) if error: print(error) appkeys.append(pchAppKeyBuffer) return appkeys def get_app(ivrapps: openvr.IVRApplications): for pchAppKey in get_appkeys(ivrapps): pchPropertyValueBuffer = '' unPropertyValueBufferLen = 90 appname = ivrapps.getApplicationPropertyString( pchAppKey, openvr.VRApplicationProperty_Name_String, pchPropertyValueBuffer, unPropertyValueBufferLen) print(appname)
#!/bin/env python import sys import time import openvr print ("OpenVR test program") if openvr.isHmdPresent(): print ("VR head set found") if openvr.isRuntimeInstalled(): print ("Runtime is installed") vr_system = openvr.init(openvr.VRApplication_Scene) print (openvr.runtimePath()) print (vr_system.getRecommendedRenderTargetSize()) print (vr_system.isDisplayOnDesktop()) for i in range(10): xform = vr_system.getEyeToHeadTransform(openvr.Eye_Left) print (xform) sys.stdout.flush() time.sleep(0.2) openvr.shutdown()
from gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from sdl_app import SdlApp import sys import time import openvr """ Minimal sdl programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ print("OpenVR test program") if openvr.isHmdPresent(): print("VR head set found") if openvr.isRuntimeInstalled(): print("Runtime is installed") vr_system = openvr.init(openvr.VRApplication_Scene) print(openvr.runtimePath()) print(vr_system.getRecommendedRenderTargetSize()) print(vr_system.isDisplayOnDesktop()) if __name__ == "__main__": renderer = OpenVrGlRenderer(multisample=2) renderer.append(ColorCubeActor()) with SdlApp(renderer, "sdl2 OpenVR color cube") as app: app.run_loop()
# Did the audiocontext change? if (sndNext != sndCur): if (sndCur): sndCur.stop() sndCur = sndNext if (sndCur): sndCur.play(-1) else: # VR either not running or initializing an OpenVR context failed -> Get new VR context and wait 10 seconds self.startContext() time.sleep(10) time.sleep(0.01) mixer.music.stop() vr.shutdown() # ########### cstor def __init__(self): self.startContext() # Start OpenVR context self.updateBounds() # Update chaperone bounds # ########### Main def main(): guard = VRGuard() guard.start() if __name__ == '__main__': if not vr.isRuntimeInstalled(): print("Runtime not installed") exit() main()
def check_system_ready(): establish_server_connection() return openvr.isRuntimeInstalled() and openvr.isHmdPresent()