🐛[bugfix] Model : Overlayの起動でライブラリの初期化を行うタイミングでsmallとlargeの2つのハンドルを生成するように変更
This commit is contained in:
@@ -80,35 +80,11 @@ class Model:
|
|||||||
self.previous_receive_message = ""
|
self.previous_receive_message = ""
|
||||||
self.translator = Translator()
|
self.translator = Translator()
|
||||||
self.keyword_processor = KeywordProcessor()
|
self.keyword_processor = KeywordProcessor()
|
||||||
self.overlay_small_log = Overlay(
|
self.overlay = Overlay(
|
||||||
"VRCT_SMALL_LOG",
|
config.OVERLAY_SMALL_LOG_SETTINGS,
|
||||||
"VRCT_SMALL_LOG",
|
config.OVERLAY_LARGE_LOG_SETTINGS
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["opacity"],
|
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["ui_scaling"],
|
|
||||||
)
|
)
|
||||||
self.overlay_small_log_pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
|
self.overlay_small_log_pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
|
||||||
self.overlay_large_log = Overlay(
|
|
||||||
"VRCT_LARGE_LOG",
|
|
||||||
"VRCT_LARGE_LOG",
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["x_pos"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["y_pos"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["z_pos"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["x_rotation"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["y_rotation"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["z_rotation"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["display_duration"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["fadeout_duration"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["opacity"],
|
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["ui_scaling"],
|
|
||||||
)
|
|
||||||
self.overlay_large_log_pre_settings = config.OVERLAY_LARGE_LOG_SETTINGS
|
self.overlay_large_log_pre_settings = config.OVERLAY_LARGE_LOG_SETTINGS
|
||||||
self.overlay_image = OverlayImage()
|
self.overlay_image = OverlayImage()
|
||||||
self.mic_audio_queue = None
|
self.mic_audio_queue = None
|
||||||
@@ -719,20 +695,17 @@ class Model:
|
|||||||
return self.overlay_image.createOverlayImageSmall(message, language)
|
return self.overlay_image.createOverlayImageSmall(message, language)
|
||||||
|
|
||||||
def clearOverlayImageSmall(self):
|
def clearOverlayImageSmall(self):
|
||||||
self.overlay_small_log.clearImage()
|
self.overlay.clearImage("small")
|
||||||
|
|
||||||
def updateOverlaySmall(self, img):
|
def updateOverlaySmall(self, img):
|
||||||
self.overlay_small_log.updateImage(img)
|
self.overlay.updateImage(img, "small")
|
||||||
|
|
||||||
def startOverlaySmall(self):
|
|
||||||
self.overlay_small_log.startOverlay()
|
|
||||||
|
|
||||||
def updateOverlaySmallLogSettings(self):
|
def updateOverlaySmallLogSettings(self):
|
||||||
for key in self.overlay_small_log_pre_settings.keys():
|
for key in self.overlay_small_log_pre_settings.keys():
|
||||||
if self.overlay_small_log_pre_settings[key] != config.OVERLAY_SMALL_LOG_SETTINGS[key]:
|
if self.overlay_small_log_pre_settings[key] != config.OVERLAY_SMALL_LOG_SETTINGS[key]:
|
||||||
match (key):
|
match (key):
|
||||||
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation" | "tracker":
|
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation" | "tracker":
|
||||||
self.overlay_small_log.updatePosition(
|
self.overlay.updatePosition(
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
|
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
|
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
|
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
|
||||||
@@ -740,43 +713,38 @@ class Model:
|
|||||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
|
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"],
|
config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"],
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS["tracker"],
|
config.OVERLAY_SMALL_LOG_SETTINGS["tracker"],
|
||||||
|
"small",
|
||||||
)
|
)
|
||||||
case "display_duration":
|
case "display_duration":
|
||||||
self.overlay_small_log.updateDisplayDuration(config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"])
|
self.overlay.updateDisplayDuration(config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"], "small")
|
||||||
case "fadeout_duration":
|
case "fadeout_duration":
|
||||||
self.overlay_small_log.updateFadeoutDuration(config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"])
|
self.overlay.updateFadeoutDuration(config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"], "small")
|
||||||
case "opacity":
|
case "opacity":
|
||||||
self.overlay_small_log.updateOpacity(config.OVERLAY_SMALL_LOG_SETTINGS["opacity"], with_fade=True)
|
self.overlay.updateOpacity(config.OVERLAY_SMALL_LOG_SETTINGS["opacity"], True, "small")
|
||||||
case "ui_scaling":
|
case "ui_scaling":
|
||||||
self.overlay_small_log.updateUiScaling(config.OVERLAY_SMALL_LOG_SETTINGS["ui_scaling"])
|
self.overlay.updateUiScaling(config.OVERLAY_SMALL_LOG_SETTINGS["ui_scaling"], "small")
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
self.overlay_small_log_pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
|
self.overlay_small_log_pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
|
||||||
|
|
||||||
def shutdownOverlaySmall(self):
|
|
||||||
self.overlay_small_log.shutdownOverlay()
|
|
||||||
|
|
||||||
def createOverlayImageLarge(self, message_type:str, message:str, translation:str):
|
def createOverlayImageLarge(self, message_type:str, message:str, translation:str):
|
||||||
your_language = config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"]
|
your_language = config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"]
|
||||||
target_language = config.SELECTED_YOUR_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"]
|
target_language = config.SELECTED_YOUR_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"]
|
||||||
return self.overlay_image.createOverlayImageLarge(message_type, message, your_language, translation, target_language)
|
return self.overlay_image.createOverlayImageLarge(message_type, message, your_language, translation, target_language)
|
||||||
|
|
||||||
def clearOverlayImageLarge(self):
|
def clearOverlayImageLarge(self):
|
||||||
self.overlay_large_log.clearImage()
|
self.overlay.clearImage("large")
|
||||||
|
|
||||||
def updateOverlayLarge(self, img):
|
def updateOverlayLarge(self, img):
|
||||||
self.overlay_large_log.updateImage(img)
|
self.overlay.updateImage(img, "large")
|
||||||
|
|
||||||
def startOverlayLarge(self):
|
|
||||||
self.overlay_large_log.startOverlay()
|
|
||||||
|
|
||||||
def updateOverlayLargeLogSettings(self):
|
def updateOverlayLargeLogSettings(self):
|
||||||
for key in self.overlay_large_log_pre_settings.keys():
|
for key in self.overlay_large_log_pre_settings.keys():
|
||||||
if self.overlay_large_log_pre_settings[key] != config.OVERLAY_LARGE_LOG_SETTINGS[key]:
|
if self.overlay_large_log_pre_settings[key] != config.OVERLAY_LARGE_LOG_SETTINGS[key]:
|
||||||
match (key):
|
match (key):
|
||||||
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation" | "tracker":
|
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation" | "tracker":
|
||||||
self.overlay_large_log.updatePosition(
|
self.overlay.updatePosition(
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["x_pos"],
|
config.OVERLAY_LARGE_LOG_SETTINGS["x_pos"],
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["y_pos"],
|
config.OVERLAY_LARGE_LOG_SETTINGS["y_pos"],
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["z_pos"],
|
config.OVERLAY_LARGE_LOG_SETTINGS["z_pos"],
|
||||||
@@ -784,22 +752,26 @@ class Model:
|
|||||||
config.OVERLAY_LARGE_LOG_SETTINGS["y_rotation"],
|
config.OVERLAY_LARGE_LOG_SETTINGS["y_rotation"],
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["z_rotation"],
|
config.OVERLAY_LARGE_LOG_SETTINGS["z_rotation"],
|
||||||
config.OVERLAY_LARGE_LOG_SETTINGS["tracker"],
|
config.OVERLAY_LARGE_LOG_SETTINGS["tracker"],
|
||||||
|
"large",
|
||||||
)
|
)
|
||||||
case "display_duration":
|
case "display_duration":
|
||||||
self.overlay_large_log.updateDisplayDuration(config.OVERLAY_LARGE_LOG_SETTINGS["display_duration"])
|
self.overlay.updateDisplayDuration(config.OVERLAY_LARGE_LOG_SETTINGS["display_duration"], "large")
|
||||||
case "fadeout_duration":
|
case "fadeout_duration":
|
||||||
self.overlay_large_log.updateFadeoutDuration(config.OVERLAY_LARGE_LOG_SETTINGS["fadeout_duration"])
|
self.overlay.updateFadeoutDuration(config.OVERLAY_LARGE_LOG_SETTINGS["fadeout_duration"], "large")
|
||||||
case "opacity":
|
case "opacity":
|
||||||
self.overlay_large_log.updateOpacity(config.OVERLAY_LARGE_LOG_SETTINGS["opacity"], with_fade=True)
|
self.overlay.updateOpacity(config.OVERLAY_LARGE_LOG_SETTINGS["opacity"], True, "large")
|
||||||
case "ui_scaling":
|
case "ui_scaling":
|
||||||
self.overlay_large_log.updateUiScaling(config.OVERLAY_LARGE_LOG_SETTINGS["ui_scaling"])
|
self.overlay.updateUiScaling(config.OVERLAY_LARGE_LOG_SETTINGS["ui_scaling"], "large")
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
self.overlay_large_log_pre_settings = config.OVERLAY_LARGE_LOG_SETTINGS
|
self.overlay_large_log_pre_settings = config.OVERLAY_LARGE_LOG_SETTINGS
|
||||||
|
|
||||||
def shutdownOverlayLarge(self):
|
def startOverlay(self):
|
||||||
self.overlay_large_log.shutdownOverlay()
|
self.overlay.startOverlay()
|
||||||
|
|
||||||
|
def shutdownOverlay(self):
|
||||||
|
self.overlay.shutdownOverlay()
|
||||||
|
|
||||||
def startWatchdog(self):
|
def startWatchdog(self):
|
||||||
self.th_watchdog = threadFnc(self.watchdog.start)
|
self.th_watchdog = threadFnc(self.watchdog.start)
|
||||||
|
|||||||
@@ -63,117 +63,119 @@ def getRightHandBaseMatrix():
|
|||||||
return arr
|
return arr
|
||||||
|
|
||||||
class Overlay:
|
class Overlay:
|
||||||
def __init__(self, key, name, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, display_duration, fadeout_duration, opacity, ui_scaling):
|
def __init__(self, small_settings, large_settings):
|
||||||
self.initialized = False
|
|
||||||
self.key = key
|
|
||||||
self.name = name
|
|
||||||
settings = {
|
|
||||||
"color": [1, 1, 1],
|
|
||||||
"opacity": opacity,
|
|
||||||
"x_pos": x_pos,
|
|
||||||
"y_pos": y_pos,
|
|
||||||
"z_pos": z_pos,
|
|
||||||
"x_rotation": x_rotation,
|
|
||||||
"y_rotation": y_rotation,
|
|
||||||
"z_rotation": z_rotation,
|
|
||||||
"display_duration": display_duration,
|
|
||||||
"fadeout_duration": fadeout_duration,
|
|
||||||
"ui_scaling": ui_scaling,
|
|
||||||
}
|
|
||||||
self.settings = settings
|
|
||||||
self.system = None
|
self.system = None
|
||||||
self.overlay = None
|
self.overlay = None
|
||||||
self.handle = None
|
self.handle = None
|
||||||
self.lastUpdate = time.monotonic()
|
self.initialized = False
|
||||||
self.thread_overlay = None
|
|
||||||
self.fadeRatio = 1
|
|
||||||
self.loop = True
|
self.loop = True
|
||||||
|
self.thread_overlay = None
|
||||||
|
|
||||||
|
self.settings = {"small": small_settings, "large": large_settings}
|
||||||
|
self.lastUpdate = {"small": time.monotonic(), "large": time.monotonic()}
|
||||||
|
self.fadeRatio = {"small": 1, "large": 1}
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
try:
|
try:
|
||||||
self.system = openvr.init(openvr.VRApplication_Background)
|
self.system = openvr.init(openvr.VRApplication_Background)
|
||||||
self.overlay = openvr.IVROverlay()
|
self.overlay = openvr.IVROverlay()
|
||||||
self.overlay_system = openvr.IVRSystem()
|
self.overlay_system = openvr.IVRSystem()
|
||||||
self.handle = self.overlay.createOverlay(self.key, self.name)
|
self.handle_small = self.overlay.createOverlay("VRCT_SMALL_LOG", "VRCT_SMALL_LOG")
|
||||||
self.overlay.showOverlay(self.handle)
|
self.handle_large = self.overlay.createOverlay("VRCT_LARGE_LOG", "VRCT_LARGE_LOG")
|
||||||
|
self.overlay.showOverlay(self.handle_small)
|
||||||
|
self.overlay.showOverlay(self.handle_large)
|
||||||
self.initialized = True
|
self.initialized = True
|
||||||
|
|
||||||
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
|
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)), "small")
|
||||||
self.updateColor(self.settings["color"])
|
self.updateColor([1, 1, 1], "small")
|
||||||
self.updateOpacity(self.settings["opacity"])
|
self.updateOpacity(self.settings["small"]["opacity"], "small")
|
||||||
self.updateUiScaling(self.settings["ui_scaling"])
|
self.updateUiScaling(self.settings["small"]["ui_scaling"], "small")
|
||||||
self.updatePosition(
|
self.updatePosition(
|
||||||
self.settings["x_pos"],
|
self.settings["small"]["x_pos"],
|
||||||
self.settings["y_pos"],
|
self.settings["small"]["y_pos"],
|
||||||
self.settings["z_pos"],
|
self.settings["small"]["z_pos"],
|
||||||
self.settings["x_rotation"],
|
self.settings["small"]["x_rotation"],
|
||||||
self.settings["y_rotation"],
|
self.settings["small"]["y_rotation"],
|
||||||
self.settings["z_rotation"],
|
self.settings["small"]["z_rotation"],
|
||||||
self.settings["tracker"]
|
self.settings["small"]["tracker"]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)), "large")
|
||||||
|
self.updateColor([1, 1, 1], "large")
|
||||||
|
self.updateOpacity(self.settings["large"]["opacity"], "large")
|
||||||
|
self.updateUiScaling(self.settings["large"]["ui_scaling"], "large")
|
||||||
|
self.updatePosition(
|
||||||
|
self.settings["large"]["x_pos"],
|
||||||
|
self.settings["large"]["y_pos"],
|
||||||
|
self.settings["large"]["z_pos"],
|
||||||
|
self.settings["large"]["x_rotation"],
|
||||||
|
self.settings["large"]["y_rotation"],
|
||||||
|
self.settings["large"]["z_rotation"],
|
||||||
|
self.settings["large"]["tracker"]
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printLog("error:Could not initialise OpenVR", e)
|
printLog("error:Could not initialise OpenVR", e)
|
||||||
|
|
||||||
def updateImage(self, img):
|
def updateImage(self, img, size: str = "small"):
|
||||||
if self.initialized is True:
|
if self.initialized is True:
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
img = img.tobytes()
|
img = img.tobytes()
|
||||||
img = (ctypes.c_char * len(img)).from_buffer_copy(img)
|
img = (ctypes.c_char * len(img)).from_buffer_copy(img)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.overlay.setOverlayRaw(self.handle, img, width, height, 4)
|
self.overlay.setOverlayRaw(self.handle_small[size], img, width, height, 4)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printLog("error:Could not update image", e)
|
printLog("error:Could not update image", e)
|
||||||
self.initialized = False
|
self.initialized = False
|
||||||
self.reStartOverlay()
|
self.reStartOverlay()
|
||||||
while self.initialized is False:
|
while self.initialized is False:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
self.overlay.setOverlayRaw(self.handle, img, width, height, 4)
|
self.overlay.setOverlayRaw(self.handle_small[size], img, width, height, 4)
|
||||||
self.updateOpacity(self.settings["opacity"])
|
self.updateOpacity(self.settings[size]["opacity"], "small")
|
||||||
self.lastUpdate = time.monotonic()
|
self.lastUpdate[size] = time.monotonic()
|
||||||
|
|
||||||
def clearImage(self):
|
def clearImage(self, size: str = "small"):
|
||||||
if self.initialized is True:
|
if self.initialized is True:
|
||||||
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
|
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)), size)
|
||||||
|
|
||||||
def updateColor(self, col):
|
def updateColor(self, col, size: str = "small"):
|
||||||
"""
|
"""
|
||||||
col is a 3-tuple representing (r, g, b)
|
col is a 3-tuple representing (r, g, b)
|
||||||
"""
|
"""
|
||||||
self.settings["color"] = col
|
|
||||||
if self.initialized is True:
|
if self.initialized is True:
|
||||||
r, g, b = self.settings["color"]
|
r, g, b = col
|
||||||
self.overlay.setOverlayColor(self.handle, r, g, b)
|
self.overlay.setOverlayColor(self.handle[size], r, g, b)
|
||||||
|
|
||||||
def updateOpacity(self, opacity, with_fade=False):
|
def updateOpacity(self, opacity, with_fade=False, size: str = "small"):
|
||||||
self.settings["opacity"] = opacity
|
self.settings[size]["opacity"] = opacity
|
||||||
|
|
||||||
if self.initialized is True:
|
if self.initialized is True:
|
||||||
if with_fade is True:
|
if with_fade is True:
|
||||||
if self.fadeRatio > 0:
|
if self.fadeRatio[size] > 0:
|
||||||
self.overlay.setOverlayAlpha(self.handle, self.fadeRatio * self.settings["opacity"])
|
self.overlay.setOverlayAlpha(self.handle[size], self.fadeRatio[size] * self.settings[size]["opacity"])
|
||||||
else:
|
else:
|
||||||
self.overlay.setOverlayAlpha(self.handle, self.settings["opacity"])
|
self.overlay.setOverlayAlpha(self.handle[size], self.settings[size]["opacity"])
|
||||||
|
|
||||||
def updateUiScaling(self, ui_scaling):
|
def updateUiScaling(self, ui_scaling, size: str = "small"):
|
||||||
self.settings["ui_scaling"] = ui_scaling
|
self.settings[size]["ui_scaling"] = ui_scaling
|
||||||
if self.initialized is True:
|
if self.initialized is True:
|
||||||
self.overlay.setOverlayWidthInMeters(self.handle, self.settings["ui_scaling"])
|
self.overlay.setOverlayWidthInMeters(self.handle[size], self.settings[size]["ui_scaling"])
|
||||||
|
|
||||||
def updatePosition(self, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, tracker="HMD"):
|
def updatePosition(self, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, tracker: str="HMD", size: str = "small"):
|
||||||
"""
|
"""
|
||||||
x_pos, y_pos, z_pos are floats representing the position of overlay
|
x_pos, y_pos, z_pos are floats representing the position of overlay
|
||||||
x_rotation, y_rotation, z_rotation are floats representing the rotation of overlay
|
x_rotation, y_rotation, z_rotation are floats representing the rotation of overlay
|
||||||
tracker is a string representing the tracker to use ("HMD", "LeftHand", "RightHand")
|
tracker is a string representing the tracker to use ("HMD", "LeftHand", "RightHand")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.settings["x_pos"] = x_pos
|
self.settings[size]["x_pos"] = x_pos
|
||||||
self.settings["y_pos"] = y_pos
|
self.settings[size]["y_pos"] = y_pos
|
||||||
self.settings["z_pos"] = z_pos
|
self.settings[size]["z_pos"] = z_pos
|
||||||
self.settings["x_rotation"] = x_rotation
|
self.settings[size]["x_rotation"] = x_rotation
|
||||||
self.settings["y_rotation"] = y_rotation
|
self.settings[size]["y_rotation"] = y_rotation
|
||||||
self.settings["z_rotation"] = z_rotation
|
self.settings[size]["z_rotation"] = z_rotation
|
||||||
|
self.settings[size]["tracker"] = tracker
|
||||||
|
|
||||||
match tracker:
|
match tracker:
|
||||||
case "HMD":
|
case "HMD":
|
||||||
@@ -189,23 +191,23 @@ class Overlay:
|
|||||||
base_matrix = getHMDBaseMatrix()
|
base_matrix = getHMDBaseMatrix()
|
||||||
trackerIndex = openvr.k_unTrackedDeviceIndex_Hmd
|
trackerIndex = openvr.k_unTrackedDeviceIndex_Hmd
|
||||||
|
|
||||||
translation = (self.settings["x_pos"], self.settings["y_pos"], - self.settings["z_pos"])
|
translation = (self.settings[size]["x_pos"], self.settings[size]["y_pos"], - self.settings[size]["z_pos"])
|
||||||
rotation = (self.settings["x_rotation"], self.settings["y_rotation"], self.settings["z_rotation"])
|
rotation = (self.settings[size]["x_rotation"], self.settings[size]["y_rotation"], self.settings[size]["z_rotation"])
|
||||||
transform = utils.transform_matrix(base_matrix, translation, rotation)
|
transform = utils.transform_matrix(base_matrix, translation, rotation)
|
||||||
self.transform = mat34Id(transform)
|
transform = mat34Id(transform)
|
||||||
|
|
||||||
if self.initialized is True:
|
if self.initialized is True:
|
||||||
self.overlay.setOverlayTransformTrackedDeviceRelative(
|
self.overlay.setOverlayTransformTrackedDeviceRelative(
|
||||||
self.handle,
|
self.handle[size],
|
||||||
trackerIndex,
|
trackerIndex,
|
||||||
self.transform
|
transform
|
||||||
)
|
)
|
||||||
|
|
||||||
def updateDisplayDuration(self, display_duration):
|
def updateDisplayDuration(self, display_duration, size: str = "small"):
|
||||||
self.settings["display_duration"] = display_duration
|
self.settings[size]["display_duration"] = display_duration
|
||||||
|
|
||||||
def updateFadeoutDuration(self, fadeout_duration):
|
def updateFadeoutDuration(self, fadeout_duration, size: str = "small"):
|
||||||
self.settings["fadeout_duration"] = fadeout_duration
|
self.settings[size]["fadeout_duration"] = fadeout_duration
|
||||||
|
|
||||||
def checkActive(self):
|
def checkActive(self):
|
||||||
try:
|
try:
|
||||||
@@ -219,26 +221,27 @@ class Overlay:
|
|||||||
printLog("error:Could not check SteamVR running", e)
|
printLog("error:Could not check SteamVR running", e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def evaluateOpacityFade(self, lastUpdate, currentTime):
|
def evaluateOpacityFade(self, lastUpdate, currentTime, size: str = "small"):
|
||||||
if (currentTime - lastUpdate) > self.settings["display_duration"]:
|
if (currentTime - lastUpdate) > self.settings[size]["display_duration"]:
|
||||||
timeThroughInterval = currentTime - lastUpdate - self.settings["display_duration"]
|
timeThroughInterval = currentTime - lastUpdate - self.settings[size]["display_duration"]
|
||||||
self.fadeRatio = 1 - timeThroughInterval / self.settings["fadeout_duration"]
|
self.fadeRatio[size] = 1 - timeThroughInterval / self.settings[size]["fadeout_duration"]
|
||||||
if self.fadeRatio < 0:
|
if self.fadeRatio[size] < 0:
|
||||||
self.fadeRatio = 0
|
self.fadeRatio[size] = 0
|
||||||
self.overlay.setOverlayAlpha(self.handle, self.fadeRatio * self.settings["opacity"])
|
self.overlay.setOverlayAlpha(self.handle[size], self.fadeRatio[size] * self.settings[size]["opacity"])
|
||||||
|
|
||||||
def update(self):
|
def update(self, size: str = "small"):
|
||||||
currTime = time.monotonic()
|
currTime = time.monotonic()
|
||||||
if self.settings["fadeout_duration"] != 0:
|
if self.settings[size]["fadeout_duration"] != 0:
|
||||||
self.evaluateOpacityFade(self.lastUpdate, currTime)
|
self.evaluateOpacityFade(self.lastUpdate[size], currTime, size)
|
||||||
else:
|
else:
|
||||||
self.updateOpacity(self.settings["opacity"])
|
self.updateOpacity(self.settings[size]["opacity"], size)
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
self.loop = True
|
self.loop = True
|
||||||
while self.checkActive() is True and self.loop is True:
|
while self.checkActive() is True and self.loop is True:
|
||||||
startTime = time.monotonic()
|
startTime = time.monotonic()
|
||||||
self.update()
|
self.update("small")
|
||||||
|
self.update("large")
|
||||||
sleepTime = (1 / 16) - (time.monotonic() - startTime)
|
sleepTime = (1 / 16) - (time.monotonic() - startTime)
|
||||||
if sleepTime > 0:
|
if sleepTime > 0:
|
||||||
time.sleep(sleepTime)
|
time.sleep(sleepTime)
|
||||||
@@ -258,8 +261,9 @@ class Overlay:
|
|||||||
self.loop = False
|
self.loop = False
|
||||||
self.thread_overlay.join()
|
self.thread_overlay.join()
|
||||||
self.thread_overlay = None
|
self.thread_overlay = None
|
||||||
if isinstance(self.overlay, openvr.IVROverlay) and isinstance(self.handle, int):
|
if isinstance(self.overlay, openvr.IVROverlay) and isinstance(self.handle["small"], int) and isinstance(self.handle["large"], int):
|
||||||
self.overlay.destroyOverlay(self.handle)
|
self.overlay.destroyOverlay(self.handle["small"])
|
||||||
|
self.overlay.destroyOverlay(self.handle["large"])
|
||||||
self.overlay = None
|
self.overlay = None
|
||||||
if isinstance(self.system, openvr.IVRSystem):
|
if isinstance(self.system, openvr.IVRSystem):
|
||||||
openvr.shutdown()
|
openvr.shutdown()
|
||||||
|
|||||||
@@ -1175,8 +1175,8 @@ class Controller:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def setEnableOverlaySmallLog(*args, **kwargs) -> dict:
|
def setEnableOverlaySmallLog(*args, **kwargs) -> dict:
|
||||||
config.OVERLAY_SMALL_LOG = True
|
config.OVERLAY_SMALL_LOG = True
|
||||||
if model.overlay_small_log.initialized is False and model.overlay_small_log.checkSteamvrRunning() is True:
|
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
|
||||||
model.startOverlaySmall()
|
model.startOverlay()
|
||||||
return {"status":200, "result":config.OVERLAY_SMALL_LOG}
|
return {"status":200, "result":config.OVERLAY_SMALL_LOG}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1184,7 +1184,8 @@ class Controller:
|
|||||||
config.OVERLAY_SMALL_LOG = False
|
config.OVERLAY_SMALL_LOG = False
|
||||||
if config.OVERLAY_SMALL_LOG is False:
|
if config.OVERLAY_SMALL_LOG is False:
|
||||||
model.clearOverlayImageSmall()
|
model.clearOverlayImageSmall()
|
||||||
model.shutdownOverlaySmall()
|
if config.OVERLAY_LARGE_LOG is False:
|
||||||
|
model.shutdownOverlay()
|
||||||
return {"status":200, "result":config.OVERLAY_SMALL_LOG}
|
return {"status":200, "result":config.OVERLAY_SMALL_LOG}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1204,8 +1205,8 @@ class Controller:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def setEnableOverlayLargeLog(*args, **kwargs) -> dict:
|
def setEnableOverlayLargeLog(*args, **kwargs) -> dict:
|
||||||
config.OVERLAY_LARGE_LOG = True
|
config.OVERLAY_LARGE_LOG = True
|
||||||
if model.overlay_large_log.initialized is False and model.overlay_large_log.checkSteamvrRunning() is True:
|
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
|
||||||
model.startOverlayLarge()
|
model.startOverlay()
|
||||||
return {"status":200, "result":config.OVERLAY_LARGE_LOG}
|
return {"status":200, "result":config.OVERLAY_LARGE_LOG}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1213,7 +1214,8 @@ class Controller:
|
|||||||
config.OVERLAY_LARGE_LOG = False
|
config.OVERLAY_LARGE_LOG = False
|
||||||
if config.OVERLAY_LARGE_LOG is False:
|
if config.OVERLAY_LARGE_LOG is False:
|
||||||
model.clearOverlayImageLarge()
|
model.clearOverlayImageLarge()
|
||||||
model.shutdownOverlayLarge()
|
if config.OVERLAY_SMALL_LOG is False:
|
||||||
|
model.shutdownOverlay()
|
||||||
return {"status":200, "result":config.OVERLAY_LARGE_LOG}
|
return {"status":200, "result":config.OVERLAY_LARGE_LOG}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1363,9 +1365,9 @@ class Controller:
|
|||||||
self.startThreadingTranscriptionSendMessage()
|
self.startThreadingTranscriptionSendMessage()
|
||||||
config.ENABLE_TRANSCRIPTION_SEND = True
|
config.ENABLE_TRANSCRIPTION_SEND = True
|
||||||
if (config.OVERLAY_LARGE_LOG is True and
|
if (config.OVERLAY_LARGE_LOG is True and
|
||||||
model.overlay_large_log.initialized is False and
|
model.overlay.initialized is False and
|
||||||
model.overlay_large_log.checkSteamvrRunning() is True):
|
model.overlay.checkSteamvrRunning() is True):
|
||||||
model.startOverlayLarge()
|
model.startOverlay()
|
||||||
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
|
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
|
||||||
|
|
||||||
def setDisableTranscriptionSend(self, *args, **kwargs) -> dict:
|
def setDisableTranscriptionSend(self, *args, **kwargs) -> dict:
|
||||||
@@ -1376,13 +1378,13 @@ class Controller:
|
|||||||
def setEnableTranscriptionReceive(self, *args, **kwargs) -> dict:
|
def setEnableTranscriptionReceive(self, *args, **kwargs) -> dict:
|
||||||
self.startThreadingTranscriptionReceiveMessage()
|
self.startThreadingTranscriptionReceiveMessage()
|
||||||
if (config.OVERLAY_SMALL_LOG is True and
|
if (config.OVERLAY_SMALL_LOG is True and
|
||||||
model.overlay_small_log.initialized is False and
|
model.overlay.initialized is False and
|
||||||
model.overlay_small_log.checkSteamvrRunning() is True):
|
model.overlay.checkSteamvrRunning() is True):
|
||||||
model.startOverlaySmall()
|
model.startOverlay()
|
||||||
if (config.OVERLAY_LARGE_LOG is True and
|
if (config.OVERLAY_LARGE_LOG is True and
|
||||||
model.overlay_large_log.initialized is False and
|
model.overlay.initialized is False and
|
||||||
model.overlay_large_log.checkSteamvrRunning() is True):
|
model.overlay.checkSteamvrRunning() is True):
|
||||||
model.startOverlayLarge()
|
model.startOverlay()
|
||||||
config.ENABLE_TRANSCRIPTION_RECEIVE = True
|
config.ENABLE_TRANSCRIPTION_RECEIVE = True
|
||||||
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
|
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user