Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Z4urce committed Nov 23, 2024
1 parent 44b15d0 commit 3a01b14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 9 additions & 9 deletions BridgeApp/app_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from app_config import AppConfig, PatternConfig
from app_pattern import VibrationPattern

WINDOW_NAME = "Haptic Pancake Bridge v0.7.0a"
WINDOW_NAME = "Haptic Pancake Bridge v0.8.0a"

LIST_SERVER_TYPE = ["OSC (VRChat)", "WebSocket (Resonite)"]

Expand Down Expand Up @@ -76,7 +76,7 @@ def build_layout(self):
[sg.Text('Haptic settings:', font='_ 14')],
[proximity_frame, velocity_frame],
[self.small_vertical_space()],
[sg.Text('Trackers found:', font='_ 14')],
[sg.Text('Devices:', font='_ 14')],
[self.tracker_frame],
]

Expand Down Expand Up @@ -105,11 +105,11 @@ def build_pattern_setting_layout(key: str, pattern_list: [str], pattern_config:
def small_vertical_space():
return sg.Text('', font=('AnyFont', 1), auto_size_text=True)

def device_row(self, tracker_serial, tracker_model, additional_layout, icon=None):
def device_row(self, tracker_serial, tracker_model, additional_layout, icon=None, color=None):
if icon is None:
icon = "⚫"

string = f"{icon} {tracker_serial} {tracker_model}"
string = f"{tracker_serial} {tracker_model}"

dev_config = self.config.get_tracker_config(tracker_serial)
address = dev_config.get_address_str()
Expand All @@ -120,7 +120,7 @@ def device_row(self, tracker_serial, tracker_model, additional_layout, icon=None

print(f"[GUI] Adding tracker: {string}")
layout = [
[sg.Text(string, pad=(0, 0))],
[sg.Checkbox('', default=True, pad=0), sg.Text(icon, text_color=color, pad=0), sg.Text(string, pad=(0, 0))],
[sg.Text(" "), sg.Text("Address:"),
sg.InputText(address, k=(KEY_OSC_ADDRESS, tracker_serial),
enable_events=True, size=35,
Expand All @@ -132,7 +132,7 @@ def device_row(self, tracker_serial, tracker_model, additional_layout, icon=None
row = [sg.pin(sg.Col(layout, key=('-ROW-', tracker_serial)))]
return row

def tracker_row(self, tracker_serial, tracker_model):
def tracker_row(self, tracker_serial, tracker_model, color=None):
dev_config = self.config.get_tracker_config(tracker_serial)
vib_multiplier = dev_config.multiplier_override
battery_threshold = dev_config.battery_threshold
Expand All @@ -149,10 +149,10 @@ def tracker_row(self, tracker_serial, tracker_model):
size=4, tooltip=multiplier_tooltip),
sg.Button("Calibrate", button_color='grey', disabled=True, key=(KEY_BTN_CALIBRATE, tracker_serial),
tooltip="Coming soon...")]
return self.device_row(tracker_serial, tracker_model, tr)
return self.device_row(tracker_serial, tracker_model, tr, color=color)

def add_tracker(self, tracker_serial, tracker_model):
row = [self.tracker_row(tracker_serial, tracker_model)]
def add_tracker(self, tracker_serial, tracker_model, is_online=False):
row = [self.tracker_row(tracker_serial, tracker_model, color="green" if is_online else "red")]
self.add_target(tracker_serial, tracker_model, row)

def add_external_device(self, device_serial, device_model):
Expand Down
5 changes: 4 additions & 1 deletion BridgeApp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def refresh_tracker_list():
return

for device in vr.query_devices():
gui.add_tracker(device.serial, device.model)
gui.add_tracker(device.serial, device.model, True)

for serial, tracker_config in config.tracker_config_dict.items():
gui.add_tracker(serial, "- OFFLINE", False)

# Debug tracker (Uncomment this for debug purposes)
# gui.add_tracker("T35T-53R1AL", "Test Model 1.0")
Expand Down

0 comments on commit 3a01b14

Please sign in to comment.