toggle for OSC recieve

This commit is contained in:
Prohurtz 2023-03-19 15:45:17 -05:00
parent b6683b3038
commit 0e0ea2df4a
3 changed files with 31 additions and 11 deletions

View File

@ -54,6 +54,8 @@ class EyeTrackSettingsConfig(BaseModel):
gui_skip_autoradius: bool = False
gui_thresh_add: int = 11
gui_update_check: bool = False
gui_ROSC: bool = False
class EyeTrackConfig(BaseModel):
version: int = 1

View File

@ -46,7 +46,7 @@ def main():
config.save()
cancellation_event = threading.Event()
ROSC = False
# Check to see if we can connect to our video source first. If not, bring up camera finding
# dialog.
if config.settings.gui_update_check:
@ -163,9 +163,11 @@ def main():
settings[0].start()
# the eye's needs to be running before it is passed to the OSC
osc_receiver = VRChatOSCReceiver(cancellation_event, config, eyes)
osc_receiver_thread = threading.Thread(target=osc_receiver.run)
osc_receiver_thread.start()
if config.settings.gui_ROSC:
osc_receiver = VRChatOSCReceiver(cancellation_event, config, eyes)
osc_receiver_thread = threading.Thread(target=osc_receiver.run)
osc_receiver_thread.start()
ROSC = True
# Create the window
window = sg.Window(f"EyeTrackVR {appversion}" , layout, icon='Images/logo.ico', background_color='#292929')
@ -186,8 +188,9 @@ def main():
# threading.Event() wont work because pythonosc spawns its own thread.
# only way i can see to get around this is an ugly while loop that only checks if a threading event is triggered
# and then call the pythonosc shutdown function
osc_receiver.shutdown()
osc_receiver_thread.join()
if ROSC:
osc_receiver.shutdown()
osc_receiver_thread.join()
print("\033[94m[INFO] Exiting EyeTrackApp\033[0m")
return

View File

@ -41,6 +41,7 @@ class SettingsWidget:
self.gui_HSFP = f"-HSFP{widget_id}-"
self.gui_BLOBP = f"-BLOBP{widget_id}-"
self.gui_thresh_add = f"-THRESHADD{widget_id}-"
self.gui_ROSC = f"-ROSC{widget_id}-"
self.gui_update_check = f"-UPDATECHECK{widget_id}-"
self.gui_threshold_slider = f"-BLOBTHRESHOLD{widget_id}-"
@ -299,7 +300,7 @@ class SettingsWidget:
sg.Text("OSC Settings:", background_color='#242224'),
],
[
sg.Text("OSC Address:", background_color='#424042'),
sg.Text("Address:", background_color='#424042'),
sg.InputText(
self.config.gui_osc_address,
key=self.gui_osc_address,
@ -308,7 +309,7 @@ class SettingsWidget:
],
[
sg.Text("OSC Port:", background_color='#424042'),
sg.Text("Port:", background_color='#424042'),
sg.InputText(
self.config.gui_osc_port,
key=self.gui_osc_port,
@ -316,7 +317,17 @@ class SettingsWidget:
),
],
[
sg.Text("OSC Receiver Port:", background_color='#424042'),
sg.Text("Receive functions", background_color='#424042'),
sg.Checkbox(
"",
default=self.config.gui_ROSC,
key=self.gui_ROSC,
background_color='#424042',
tooltip = "Toggle OSC receive functions.",
),
],
[
sg.Text("Receiver Port:", background_color='#424042'),
sg.InputText(
self.config.gui_osc_receiver_port,
key=self.gui_osc_receiver_port,
@ -324,7 +335,7 @@ class SettingsWidget:
),
],
[
sg.Text("OSC Recenter Address:", background_color='#424042'),
sg.Text("Recenter Address:", background_color='#424042'),
sg.InputText(
self.config.gui_osc_recenter_address,
key=self.gui_osc_recenter_address,
@ -332,7 +343,7 @@ class SettingsWidget:
),
],
[
sg.Text("OSC Recalibrate Address:", background_color='#424042'),
sg.Text("Recalibrate Address:", background_color='#424042'),
sg.InputText(
self.config.gui_osc_recalibrate_address,
key=self.gui_osc_recalibrate_address,
@ -515,6 +526,10 @@ class SettingsWidget:
self.config.gui_blob_maxsize = values[self.gui_blob_maxsize]
changed = True
if self.config.gui_ROSC != values[self.gui_ROSC]:
self.config.gui_ROSC = values[self.gui_ROSC]
changed = True
if changed:
self.main_config.save()