From bda8f68da45a8645a07abd6c5fc1d7e5a2478156 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 26 Apr 2021 15:03:43 +0900 Subject: [PATCH 1/4] Add failing test --- osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs index 2cc031405e..590d159300 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs @@ -34,6 +34,18 @@ namespace osu.Game.Rulesets.Osu.Tests private List judgementResults; + [Test] + public void TestPressBothKeysSimultaneouslyAndReleaseOne() + { + performTest(new List + { + new OsuReplayFrame { Position = Vector2.Zero, Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = Vector2.Zero, Actions = { OsuAction.RightButton }, Time = time_during_slide_1 }, + }); + + AddAssert("Tracking retained", assertMaxJudge); + } + /// /// Scenario: /// - Press a key before a slider starts From 6182181ea1d3f1a6809d8631341ef2addbfbd3d4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 26 Apr 2021 15:20:29 +0900 Subject: [PATCH 2/4] Fix simultaneous slider input not allowing both keys --- .../Skinning/Default/SliderBall.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs index 82b677e12c..b85610491c 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -134,6 +135,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default /// private double? timeToAcceptAnyKeyAfter; + /// + /// The actions that were pressed in the previous frame. + /// + private readonly List lastPressedActions = new List(); + protected override void Update() { base.Update(); @@ -152,8 +158,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { var otherKey = headCircleHitAction == OsuAction.RightButton ? OsuAction.LeftButton : OsuAction.RightButton; - // we can return to accepting all keys if the initial head circle key is the *only* key pressed, or all keys have been released. - if (actions?.Contains(otherKey) != true) + // we can return to accepting all other keys if they were released in the previous frame. + if (!lastPressedActions.Contains(otherKey)) timeToAcceptAnyKeyAfter = Time.Current; } @@ -164,6 +170,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default lastScreenSpaceMousePosition.HasValue && followCircle.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) && // valid action (actions?.Any(isValidTrackingAction) ?? false); + + lastPressedActions.Clear(); + lastPressedActions.AddRange(actions); } /// From f70e45b1998a97dd8421f0f046c7efcada54d40b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 26 Apr 2021 15:35:08 +0900 Subject: [PATCH 3/4] Prevent adding null enumerable --- osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs index b85610491c..c5c95557e6 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs @@ -172,7 +172,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default (actions?.Any(isValidTrackingAction) ?? false); lastPressedActions.Clear(); - lastPressedActions.AddRange(actions); + if (actions != null) + lastPressedActions.AddRange(actions); } /// From 0d0b4ea78a8a07be1ac472641f8123e26f1a4bdf Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 26 Apr 2021 15:47:37 +0900 Subject: [PATCH 4/4] Rewrite comment to hopefully be more readable --- osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs index c5c95557e6..8feeca56e8 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs @@ -158,7 +158,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { var otherKey = headCircleHitAction == OsuAction.RightButton ? OsuAction.LeftButton : OsuAction.RightButton; - // we can return to accepting all other keys if they were released in the previous frame. + // we can start accepting any key once all other keys have been released in the previous frame. if (!lastPressedActions.Contains(otherKey)) timeToAcceptAnyKeyAfter = Time.Current; }