👍️[Update] Model : steamVRが起動してる最中のみoverlayが動作するように修正

This commit is contained in:
misyaguziya
2024-04-27 05:45:45 +09:00
parent f508dd6114
commit dcdcf1aeea
3 changed files with 30 additions and 11 deletions

View File

@@ -156,17 +156,19 @@ class Overlay:
"Ui_scaling": ui_scaling,
}
self.settings = settings
self.system = None
def init(self):
try:
if checkSteamvrRunning() is True:
openvr.init(openvr.VRApplication_Overlay)
self.system = openvr.init(openvr.VRApplication_Background)
self.initialized = True
except Exception as e:
print("Could not initialise OpenVR")
print(e)
async def mainLoop(self):
while True:
while self.checkActive() is True:
startTime = time.monotonic()
self.uiManager.update()
@@ -175,12 +177,32 @@ class Overlay:
await asyncio.sleep(sleepTime)
async def initMain(self):
self.uiManager = UIManager("Overlay_Speaker2log", "SOverlay_Speaker2log_UI", self.settings)
await self.mainLoop()
if self.initialized is True:
self.uiManager = UIManager("Overlay_Speaker2log", "SOverlay_Speaker2log_UI", self.settings)
await self.mainLoop()
def startOverlay(self):
asyncio.run(self.initMain())
def shutdown(self):
self.system = None
self.initialized = False
openvr.shutdown()
def checkActive(self):
try:
if self.system is not None and self.initialized is True:
new_event = openvr.VREvent_t()
while self.system.pollNextEvent(new_event):
if new_event.eventType == openvr.VREvent_Quit:
self.shutdown()
return False
return True
except Exception as e:
print("Could not check SteamVR running")
print(e)
return False
if __name__ == '__main__':
from overlay_image import OverlayImage
from threading import Thread, Event