Skip to content

Commit

Permalink
Add option to disable legacy OSC support in PulsoidModule
Browse files Browse the repository at this point in the history
Added a new `disableLegacySupport` property to the `PulsoidModule` class
to toggle legacy OSC support. Updated `SendHRToOSC` method to conditionally
send additional OSC parameters based on this property. Introduced a new
checkbox in `MainWindow.xaml` to allow users to enable or disable legacy
OSC support through the UI.
  • Loading branch information
BoiHanny committed Dec 8, 2024
1 parent 55d3a81 commit 1ee8b85
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
22 changes: 17 additions & 5 deletions vrcosc-magicchatbox/Classes/Modules/PulsoidModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public partial class PulsoidModuleSettings : ObservableObject
[ObservableProperty]
private bool enableHeartRateOfflineCheck = true;

[ObservableProperty]
private bool disableLegacySupport = false;

[ObservableProperty]
private int unchangedHeartRateTimeoutInSec = 30;

Expand Down Expand Up @@ -911,14 +914,12 @@ private void HandleHeartRateMessage(string message)
SendHRToOSC(true);
}
}

// Send OSC parameters method
private void SendHRToOSC(bool isHRBeat)
{
if (!ViewModel.Instance.IntgrHeartRate_OSC) return; // Only send if enabled
if (!ViewModel.Instance.IntgrHeartRate_OSC) return;

bool isHRConnected = ViewModel.Instance.PulsoidAuthConnected; // Authenticated and token valid
bool isHRActive = PulsoidDeviceOnline; // Device considered online
bool isHRConnected = ViewModel.Instance.PulsoidAuthConnected;
bool isHRActive = PulsoidDeviceOnline;

int hrValueForOSC = GetOSCHeartRate();
if (hrValueForOSC <= 0) return;
Expand All @@ -935,6 +936,17 @@ private void SendHRToOSC(bool isHRBeat)
OSCSender.SendOscParam("/avatar/parameters/HRPercent", hrPercent);
OSCSender.SendOscParam("/avatar/parameters/FullHRPercent", fullHRPercent);
OSCSender.SendOscParam("/avatar/parameters/HR", hrValueForOSC);

if (!Settings.DisableLegacySupport)
{
int ones = hrValueForOSC % 10;
int tens = (hrValueForOSC / 10) % 10;
int hundreds = hrValueForOSC / 100;

OSCSender.SendOscParam("/avatar/parameters/onesHR", ones);
OSCSender.SendOscParam("/avatar/parameters/tensHR", tens);
OSCSender.SendOscParam("/avatar/parameters/hundredsHR", hundreds);
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions vrcosc-magicchatbox/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,27 @@
</CheckBox>
</StackPanel>
</Border>
<Border
Margin="0,0,0,5"
Background="#FF3B3054"
CornerRadius="5,0,0,5">
<StackPanel Margin="5">
<CheckBox
x:Name="DisableLegacyOSCSupport_checkbox"
Height="20"
Margin="4,2"
BorderBrush="#FF2D1265"
Checked="Update_Click"
FontFamily="Comfortaa Light"
FontSize="18"
Foreground="#FFB9B5C1"
IsChecked="{Binding HeartRateConnector.Settings.DisableLegacySupport, Mode=TwoWay}"
Style="{DynamicResource SettingsCheckbox}"
Unchecked="Update_Click">
disable legacy OSC support (improved performance)
</CheckBox>
</StackPanel>
</Border>
<Border
Margin="0,0,0,5"
Background="#FF3B3054"
Expand Down

0 comments on commit 1ee8b85

Please sign in to comment.