Skip to content

Commit fe7fca3

Browse files
NekoTikiLucHeartCopilot
authored
feat: Add option for random behavior on pull trigger (#45)
* feat: Add option for random behavior on pull trigger Signed-off-by: NekoTiki <17910933+nekotiki@users.noreply.github.com> * fix: pull trigger random behavior was skipping the check for the Preconditions being met Signed-off-by: NekoTiki <17910933+NekoTiki@users.noreply.github.com> * Update ShockOsc/Services/ShockOsc.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update ShockOsc/Services/ShockOsc.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update ShockOsc/Services/ShockOsc.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update ShockOsc/Ui/Pages/Dash/Tabs/ConfigTab.razor Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: NekoTiki <17910933+nekotiki@users.noreply.github.com> Signed-off-by: NekoTiki <17910933+NekoTiki@users.noreply.github.com> Co-authored-by: Luc ♥ <luc@luc.cat> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 2675396 commit fe7fca3

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

ShockOsc/Config/SharedBehaviourConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public class SharedBehaviourConfig
1616
public BoneAction WhenBoneReleased { get; set; } = BoneAction.Shock;
1717

1818
public uint? BoneHeldDurationLimit { get; set; } = null;
19+
public bool OnPullTriggerRandomBehavior { get; set; }
1920
}

ShockOsc/Services/ShockOsc.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using OpenShock.ShockOSC.Utils;
1515
using OscQueryLibrary;
1616
using OscQueryLibrary.Utils;
17+
using Serilog;
1718

1819
#pragma warning disable CS4014
1920

@@ -411,6 +412,17 @@ private async Task PhysboneHandling(ProgramGroup programGroup, bool isGrabbed)
411412
// Check all preconditions, maybe send stop command here aswell?
412413
if (!await HandlePrecondition(CheckAndSetAllPreconditions(programGroup), programGroup)) return;
413414

415+
var pullTriggerBehavior = _moduleConfig.Config.GetGroupOrGlobal(programGroup,
416+
behaviourConfig => behaviourConfig.OnPullTriggerRandomBehavior,
417+
group => group.OnPullTriggerRandomBehavior);
418+
419+
if (pullTriggerBehavior)
420+
{
421+
SendCommand(programGroup, GetDuration(programGroup), GetIntensity(programGroup), ControlType.Shock, false);
422+
423+
return;
424+
}
425+
414426
var releaseAction = _moduleConfig.Config.GetGroupOrGlobal(programGroup,
415427
behaviourConfig => behaviourConfig.WhenBoneReleased,
416428
group => group.OverrideBoneReleasedAction);
@@ -421,6 +433,9 @@ private async Task PhysboneHandling(ProgramGroup programGroup, bool isGrabbed)
421433
return;
422434
}
423435

436+
_logger.LogDebug("Physbone released, sending {Action} to group {Group}", releaseAction, programGroup.Name);
437+
_logger.LogDebug("Physbone stretch value: {StretchValue}", programGroup.LastStretchValue);
438+
424439
var physBoneIntensity = GetPhysbonePullIntensity(programGroup, programGroup.LastStretchValue);
425440
programGroup.LastStretchValue = 0;
426441

ShockOsc/Ui/Pages/Dash/Tabs/ConfigTab.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
OnSaveAction="_ => OnSettingsValueChange()">
6969
Max Intensity: @ModuleConfig.Config.Behaviour.IntensityRange.Max%
7070
</DebouncedSlider>
71+
72+
<br />
73+
74+
<div style="display: flex; align-items: center;">
75+
<MudCheckBox Class="option-width option-checkbox-height" @bind-Value="ModuleConfig.Config.Behaviour.OnPullTriggerRandomBehavior" Label="Pull Trigger Random" @bind-Value:after="OnSettingsValueChangeAsync"/>
76+
77+
<MudTooltip Text="When enabled, the shock will randomly choose between the two intensity values set above, instead of using the intensity based on distance.">
78+
<MudIcon Icon="@Icons.Material.Filled.Info" Size="Size.Small" Title="Information" />
79+
</MudTooltip>
80+
</div>
7181
}
7282

7383

ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@
228228
OnSaveAction="_ => ModuleConfig.SaveDeferred()">
229229
Max Intensity: @CurrentGroup.IntensityRange.Max%
230230
</DebouncedSlider>
231+
232+
<br />
233+
234+
<div style="display: flex; align-items: center;">
235+
<MudCheckBox Class="option-width option-checkbox-height" @bind-Value="@CurrentGroup.OnPullTriggerRandomBehavior" Label="Pull Trigger Random" @bind-Value:after="OnGroupSettingsValueChange"/>
236+
237+
<MudTooltip Text="When enabled, the shock will randomly choose between the two intensity values set above, instead of using the intensity based on distance.">
238+
<MudIcon Icon="@Icons.Material.Filled.Info" Size="Size.Small" Title="Information" />
239+
</MudTooltip>
240+
</div>
231241
}
232242

233243
</MudCollapse>

0 commit comments

Comments
 (0)