Skip to content

Commit

Permalink
Merge pull request #560 from LumpBloom7/fix-input-crash
Browse files Browse the repository at this point in the history
Fix receptor input causing a crash
  • Loading branch information
LumpBloom7 authored Feb 22, 2024
2 parents dc1d6c2 + 78b22d8 commit 8275bd1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
1 change: 1 addition & 0 deletions osu.Game.Rulesets.Sentakki/Mods/SentakkiModRelax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SentakkiModRelax : Mod, IApplicableAfterBeatmapConversion
public override string Name => "Relax";

public override string Acronym => "RX";
public override ModType Type => ModType.DifficultyReduction;

public override LocalisableString Description => "All notes are EX notes, you've got nothing to prove!";

Expand Down
6 changes: 4 additions & 2 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ public void OnReleased(KeyBindingReleaseEvent<SentakkiAction> e)
return;

// We only release the hold once ALL inputs are released
if (--pressedCount == 0)
endHold();
if (--pressedCount != 0)
return;

endHold();

if (!AllJudged)
NoteBody.FadeColour(Color4.Gray, 100);
Expand Down
25 changes: 0 additions & 25 deletions osu.Game.Rulesets.Sentakki/SentakkiInputManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System.Collections.Generic;
using osu.Framework.Extensions.ListExtensions;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Framework.Lists;
using osu.Framework.Localisation;
using osu.Game.Rulesets.Sentakki.Localisation;
Expand Down Expand Up @@ -38,27 +34,6 @@ protected override bool Handle(UIEvent e)

return base.Handle(e);
}

// We want the press behavior of SimultaneousBindingMode.All, but we want the release behavior of SimultaneousBindingMode.Unique
// As long as there are more than one input source triggering the action, we manually remove the action from the list once, without propogating the release
// When the final source is released, we let the original handling take over, which would also propogate the release event
// This is so that multiple sources (virtual input/key) can trigger a press, but not release until the last key is released
protected override void PropagateReleased(IEnumerable<Drawable> drawables, InputState state, SentakkiAction released)
{
int actionCount = 0;
var pressed = PressedActions;

for (int i = 0; i < pressed.Count; ++i)
{
if (pressed[i] == released && ++actionCount > 1)
break;
}

if (actionCount > 1)
pressed.Remove(released);
else
base.PropagateReleased(drawables, state, released);
}
}

public SlimReadOnlyListWrapper<SentakkiAction> PressedActions => KeyBindingContainer.PressedActions;
Expand Down
10 changes: 8 additions & 2 deletions osu.Game.Rulesets.Sentakki/UI/Lane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,16 @@ private void updateInputState()
private void handleKeyPress(ValueChangedEvent<int> keys)
{
if (keys.NewValue < keys.OldValue)
SentakkiActionInputManager.TriggerReleased(SentakkiAction.Key1 + LaneNumber);
for (int i = 0; i < keys.OldValue - keys.NewValue; ++i)
{
SentakkiActionInputManager.TriggerReleased(SentakkiAction.Key1 + LaneNumber);
}

if (keys.NewValue > keys.OldValue)
SentakkiActionInputManager.TriggerPressed(SentakkiAction.Key1 + LaneNumber);
for (int i = 0; i < keys.NewValue - keys.OldValue; ++i)
{
SentakkiActionInputManager.TriggerPressed(SentakkiAction.Key1 + LaneNumber);
}
}

public bool OnPressed(KeyBindingPressEvent<SentakkiAction> e)
Expand Down

0 comments on commit 8275bd1

Please sign in to comment.