[Update] OSC: Refactor OSC query handling and add enable/disable methods
This commit is contained in:
@@ -1426,9 +1426,12 @@ class Controller:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setEnableVrcMicMuteSync(*args, **kwargs) -> dict:
|
def setEnableVrcMicMuteSync(*args, **kwargs) -> dict:
|
||||||
|
if model.getIsOscQueryEnabled() is False:
|
||||||
config.VRC_MIC_MUTE_SYNC = True
|
config.VRC_MIC_MUTE_SYNC = True
|
||||||
model.setMuteSelfStatus()
|
model.setMuteSelfStatus()
|
||||||
model.changeMicTranscriptStatus()
|
model.changeMicTranscriptStatus()
|
||||||
|
else:
|
||||||
|
config.VRC_MIC_MUTE_SYNC = False
|
||||||
return {"status":200, "result":config.VRC_MIC_MUTE_SYNC}
|
return {"status":200, "result":config.VRC_MIC_MUTE_SYNC}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1905,6 +1908,12 @@ class Controller:
|
|||||||
def initializationProgress(self, progress):
|
def initializationProgress(self, progress):
|
||||||
self.run(200, self.run_mapping["initialization_progress"], progress)
|
self.run(200, self.run_mapping["initialization_progress"], progress)
|
||||||
|
|
||||||
|
def enableOscQuery(self):
|
||||||
|
self.run(200, self.run_mapping["enable_osc_query"], True)
|
||||||
|
|
||||||
|
def disableOscQuery(self):
|
||||||
|
self.run(200, self.run_mapping["enable_osc_query"], False)
|
||||||
|
|
||||||
def init(self, *args, **kwargs) -> None:
|
def init(self, *args, **kwargs) -> None:
|
||||||
removeLog()
|
removeLog()
|
||||||
printLog("Start Initialization")
|
printLog("Start Initialization")
|
||||||
@@ -1982,6 +1991,12 @@ class Controller:
|
|||||||
# init OSC receive
|
# init OSC receive
|
||||||
printLog("Init OSC Receive")
|
printLog("Init OSC Receive")
|
||||||
model.startReceiveOSC()
|
model.startReceiveOSC()
|
||||||
|
osc_query_enabled = model.getIsOscQueryEnabled()
|
||||||
|
if osc_query_enabled is True:
|
||||||
|
self.enableOscQuery()
|
||||||
|
else:
|
||||||
|
self.disableOscQuery()
|
||||||
|
|
||||||
if config.VRC_MIC_MUTE_SYNC is True:
|
if config.VRC_MIC_MUTE_SYNC is True:
|
||||||
self.setEnableVrcMicMuteSync()
|
self.setEnableVrcMicMuteSync()
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ run_mapping = {
|
|||||||
|
|
||||||
"initialization_progress":"/run/initialization_progress",
|
"initialization_progress":"/run/initialization_progress",
|
||||||
"initialization_complete":"/run/initialization_complete",
|
"initialization_complete":"/run/initialization_complete",
|
||||||
|
|
||||||
|
"enable_osc_query":"/run/enable_osc_query",
|
||||||
}
|
}
|
||||||
|
|
||||||
def run(status:int, endpoint:str, result:Any) -> None:
|
def run(status:int, endpoint:str, result:Any) -> None:
|
||||||
|
|||||||
@@ -323,6 +323,9 @@ class Model:
|
|||||||
def stopReceiveOSC(self):
|
def stopReceiveOSC(self):
|
||||||
self.osc_handler.oscServerStop()
|
self.osc_handler.oscServerStop()
|
||||||
|
|
||||||
|
def getIsOscQueryEnabled(self):
|
||||||
|
return self.osc_handler.getIsOscQueryEnabled()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def checkSoftwareUpdated():
|
def checkSoftwareUpdated():
|
||||||
# check update
|
# check update
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ class OSCHandler:
|
|||||||
def __init__(self, ip_address="127.0.0.1", port=9000) -> None:
|
def __init__(self, ip_address="127.0.0.1", port=9000) -> None:
|
||||||
|
|
||||||
if ip_address in ["127.0.0.1", "localhost"]:
|
if ip_address in ["127.0.0.1", "localhost"]:
|
||||||
self.osc_query_enabled = True
|
self.is_osc_query_enabled = True
|
||||||
else:
|
else:
|
||||||
self.osc_query_enabled = False
|
self.is_osc_query_enabled = False
|
||||||
|
|
||||||
self.osc_ip_address = ip_address
|
self.osc_ip_address = ip_address
|
||||||
self.osc_port = port
|
self.osc_port = port
|
||||||
@@ -33,11 +33,14 @@ class OSCHandler:
|
|||||||
self.dict_filter_and_target = {}
|
self.dict_filter_and_target = {}
|
||||||
self.browser = None
|
self.browser = None
|
||||||
|
|
||||||
|
def getIsOscQueryEnabled(self) -> bool:
|
||||||
|
return self.is_osc_query_enabled
|
||||||
|
|
||||||
def setOscIpAddress(self, ip_address:str) -> None:
|
def setOscIpAddress(self, ip_address:str) -> None:
|
||||||
if ip_address in ["127.0.0.1", "localhost"]:
|
if ip_address in ["127.0.0.1", "localhost"]:
|
||||||
self.osc_query_enabled = True
|
self.is_osc_query_enabled = True
|
||||||
else:
|
else:
|
||||||
self.osc_query_enabled = False
|
self.is_osc_query_enabled = False
|
||||||
|
|
||||||
self.oscServerStop()
|
self.oscServerStop()
|
||||||
self.osc_ip_address = ip_address
|
self.osc_ip_address = ip_address
|
||||||
@@ -60,7 +63,7 @@ class OSCHandler:
|
|||||||
self.udp_client.send_message(self.osc_parameter_chatbox_input, [f"{message}", True, notification])
|
self.udp_client.send_message(self.osc_parameter_chatbox_input, [f"{message}", True, notification])
|
||||||
|
|
||||||
def getOSCParameterValue(self, address:str) -> Any:
|
def getOSCParameterValue(self, address:str) -> Any:
|
||||||
if not self.osc_query_enabled:
|
if not self.is_osc_query_enabled:
|
||||||
# OSCQueryが無効な場合はNoneを返す
|
# OSCQueryが無効な場合はNoneを返す
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ class OSCHandler:
|
|||||||
self.dict_filter_and_target = dict_filter_and_target
|
self.dict_filter_and_target = dict_filter_and_target
|
||||||
|
|
||||||
def receiveOscParameters(self) -> None:
|
def receiveOscParameters(self) -> None:
|
||||||
if self.osc_query_enabled is False:
|
if self.is_osc_query_enabled is False:
|
||||||
# OSCQueryが無効な場合は何もしない
|
# OSCQueryが無効な場合は何もしない
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user