diff --git a/osu.Android.props b/osu.Android.props index f7b7b6fb23..cbd1c92fbe 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -52,7 +52,7 @@ - + diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs index 883b8a1ae0..70a43fafb5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs @@ -83,6 +83,9 @@ namespace osu.Game.Tests.Visual.Gameplay public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + ReceivedAction = e.Action == TestAction.Down; return true; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs index c8040f42f0..159d583fc0 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs @@ -231,6 +231,9 @@ namespace osu.Game.Tests.Visual.Gameplay public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + box.Colour = Color4.White; return true; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs index 08578168d6..1d4245308d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs @@ -164,6 +164,9 @@ namespace osu.Game.Tests.Visual.Gameplay public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + box.Colour = Color4.White; return true; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs index b4de060578..ef870a32a9 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs @@ -283,6 +283,9 @@ namespace osu.Game.Tests.Visual.Gameplay public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + box.Colour = Color4.White; return true; } diff --git a/osu.Game/Extensions/DrawableExtensions.cs b/osu.Game/Extensions/DrawableExtensions.cs index 03cc345947..005804789e 100644 --- a/osu.Game/Extensions/DrawableExtensions.cs +++ b/osu.Game/Extensions/DrawableExtensions.cs @@ -1,11 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input.Bindings; -using osu.Framework.Threading; using osu.Game.Screens.Play.HUD; using osu.Game.Skinning; using osuTK; @@ -14,30 +11,6 @@ namespace osu.Game.Extensions { public static class DrawableExtensions { - public const double REPEAT_INTERVAL = 70; - public const double INITIAL_DELAY = 250; - - /// - /// Helper method that is used while doesn't support repetitions of . - /// Simulates repetitions by continually invoking a delegate according to the default key repeat rate. - /// - /// - /// The returned delegate can be cancelled to stop repeat events from firing (usually in ). - /// - /// The which is handling the repeat. - /// The to schedule repetitions on. - /// The to be invoked once immediately and with every repetition. - /// The delay imposed on the first repeat. Defaults to . - /// A which can be cancelled to stop the repeat events from firing. - public static ScheduledDelegate BeginKeyRepeat(this IKeyBindingHandler handler, Scheduler scheduler, Action action, double initialRepeatDelay = INITIAL_DELAY) - { - action(); - - ScheduledDelegate repeatDelegate = new ScheduledDelegate(action, handler.Time.Current + initialRepeatDelay, REPEAT_INTERVAL); - scheduler.Add(repeatDelegate); - return repeatDelegate; - } - /// /// Shakes this drawable. /// diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 16ec7ab838..68351acd7e 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -90,6 +90,9 @@ namespace osu.Game.Graphics.Containers public virtual bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Back: diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 1f7f93b3c3..a39d7bfb47 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -60,6 +60,9 @@ namespace osu.Game.Graphics public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.TakeScreenshot: diff --git a/osu.Game/Graphics/UserInterface/BackButton.cs b/osu.Game/Graphics/UserInterface/BackButton.cs index c965fbcf45..1b564ef1b4 100644 --- a/osu.Game/Graphics/UserInterface/BackButton.cs +++ b/osu.Game/Graphics/UserInterface/BackButton.cs @@ -64,6 +64,9 @@ namespace osu.Game.Graphics.UserInterface public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Back: diff --git a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs index 88608bf43c..578ff3c618 100644 --- a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs +++ b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs @@ -75,6 +75,9 @@ namespace osu.Game.Graphics.UserInterface public virtual bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (!HasFocus) return false; if (e.Action == GlobalAction.Back) diff --git a/osu.Game/Graphics/UserInterfaceV2/OsuPopover.cs b/osu.Game/Graphics/UserInterfaceV2/OsuPopover.cs index 226c39c030..d1857dd174 100644 --- a/osu.Game/Graphics/UserInterfaceV2/OsuPopover.cs +++ b/osu.Game/Graphics/UserInterfaceV2/OsuPopover.cs @@ -58,6 +58,9 @@ namespace osu.Game.Graphics.UserInterfaceV2 public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (State.Value == Visibility.Hidden) return false; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 095add399c..1274d8d867 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1007,6 +1007,9 @@ namespace osu.Game public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (introScreen == null) return false; switch (e.Action) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index ce12e9554d..fe611d0134 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -94,6 +94,9 @@ namespace osu.Game.Overlays public override bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Back: diff --git a/osu.Game/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index 9db0f34d1b..9dea1ca00a 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -102,6 +102,9 @@ namespace osu.Game.Overlays public override bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Select: diff --git a/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs b/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs index 18ec69e106..baee17fb00 100644 --- a/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs +++ b/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs @@ -32,6 +32,9 @@ namespace osu.Game.Overlays.Music public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (beatmap.Disabled) return false; diff --git a/osu.Game/Overlays/Volume/VolumeControlReceptor.cs b/osu.Game/Overlays/Volume/VolumeControlReceptor.cs index 4129b46ce3..c601ce4130 100644 --- a/osu.Game/Overlays/Volume/VolumeControlReceptor.cs +++ b/osu.Game/Overlays/Volume/VolumeControlReceptor.cs @@ -6,8 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Framework.Threading; -using osu.Game.Extensions; using osu.Game.Input.Bindings; namespace osu.Game.Overlays.Volume @@ -17,18 +15,12 @@ namespace osu.Game.Overlays.Volume public Func ActionRequested; public Func ScrollActionRequested; - private ScheduledDelegate keyRepeat; - public bool OnPressed(KeyBindingPressEvent e) { switch (e.Action) { case GlobalAction.DecreaseVolume: case GlobalAction.IncreaseVolume: - keyRepeat?.Cancel(); - keyRepeat = this.BeginKeyRepeat(Scheduler, () => ActionRequested?.Invoke(e.Action), 150); - return true; - case GlobalAction.ToggleMute: case GlobalAction.NextVolumeMeter: case GlobalAction.PreviousVolumeMeter: @@ -41,7 +33,6 @@ namespace osu.Game.Overlays.Volume public void OnReleased(KeyBindingReleaseEvent e) { - keyRepeat?.Cancel(); } protected override bool OnScroll(ScrollEvent e) diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index a3f311c7a6..6564ff9e23 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -168,6 +168,8 @@ namespace osu.Game.Rulesets.UI public class RulesetKeyBindingContainer : DatabasedKeyBindingContainer { + protected override bool HandleRepeats => false; + public RulesetKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) : base(ruleset, variant, unique) { diff --git a/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs b/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs index 2a9d3d1cf0..1f3a937311 100644 --- a/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs +++ b/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs @@ -14,7 +14,6 @@ using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Configuration; -using osu.Game.Extensions; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; @@ -204,11 +203,11 @@ namespace osu.Game.Rulesets.UI.Scrolling switch (e.Action) { case GlobalAction.IncreaseScrollSpeed: - scheduleScrollSpeedAdjustment(1); + AdjustScrollSpeed(1); return true; case GlobalAction.DecreaseScrollSpeed: - scheduleScrollSpeedAdjustment(-1); + AdjustScrollSpeed(-1); return true; } @@ -223,12 +222,6 @@ namespace osu.Game.Rulesets.UI.Scrolling scheduledScrollSpeedAdjustment = null; } - private void scheduleScrollSpeedAdjustment(int amount) - { - scheduledScrollSpeedAdjustment?.Cancel(); - scheduledScrollSpeedAdjustment = this.BeginKeyRepeat(Scheduler, () => AdjustScrollSpeed(amount)); - } - private class LocalScrollingInfo : IScrollingInfo { public IBindable Direction { get; } = new Bindable(); diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 29e3f12d03..130d7a015f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -239,6 +239,9 @@ namespace osu.Game.Screens.Edit.Compose.Components public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case PlatformAction.SelectAll: diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 2a7e2c9cef..94b6e58b67 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -393,6 +393,9 @@ namespace osu.Game.Screens.Edit return true; case PlatformAction.Save: + if (e.Repeat) + return false; + Save(); return true; } @@ -457,6 +460,9 @@ namespace osu.Game.Screens.Edit public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Back: diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 5f76176aab..feb6f6c92a 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -220,6 +220,9 @@ namespace osu.Game.Screens.Menu public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Back: diff --git a/osu.Game/Screens/Menu/ExitConfirmOverlay.cs b/osu.Game/Screens/Menu/ExitConfirmOverlay.cs index 364da2f887..a90b83c5fe 100644 --- a/osu.Game/Screens/Menu/ExitConfirmOverlay.cs +++ b/osu.Game/Screens/Menu/ExitConfirmOverlay.cs @@ -21,6 +21,9 @@ namespace osu.Game.Screens.Menu public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (e.Action == GlobalAction.Back) { BeginConfirm(); diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomsContainer.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomsContainer.cs index 32ae7cf859..54c762b8ce 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomsContainer.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomsContainer.cs @@ -12,7 +12,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Framework.Threading; using osu.Game.Extensions; using osu.Game.Graphics.Cursor; using osu.Game.Input.Bindings; @@ -146,11 +145,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components switch (e.Action) { case GlobalAction.SelectNext: - beginRepeatSelection(() => selectNext(1), e.Action); + selectNext(1); return true; case GlobalAction.SelectPrevious: - beginRepeatSelection(() => selectNext(-1), e.Action); + selectNext(-1); return true; } @@ -159,40 +158,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components public void OnReleased(KeyBindingReleaseEvent e) { - switch (e.Action) - { - case GlobalAction.SelectNext: - case GlobalAction.SelectPrevious: - endRepeatSelection(e.Action); - break; - } - } - - private ScheduledDelegate repeatDelegate; - private object lastRepeatSource; - - /// - /// Begin repeating the specified selection action. - /// - /// The action to perform. - /// The source of the action. Used in conjunction with to only cancel the correct action (most recently pressed key). - private void beginRepeatSelection(Action action, object source) - { - endRepeatSelection(); - - lastRepeatSource = source; - repeatDelegate = this.BeginKeyRepeat(Scheduler, action); - } - - private void endRepeatSelection(object source = null) - { - // only the most recent source should be able to cancel the current action. - if (source != null && !EqualityComparer.Default.Equals(lastRepeatSource, source)) - return; - - repeatDelegate?.Cancel(); - repeatDelegate = null; - lastRepeatSource = null; } private void selectNext(int direction) diff --git a/osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs b/osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs index 72574b729a..0d2b2249ef 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs @@ -134,6 +134,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (SelectedRoom.Value != Room) return false; diff --git a/osu.Game/Screens/OnlinePlay/Match/Components/CreateRoomButton.cs b/osu.Game/Screens/OnlinePlay/Match/Components/CreateRoomButton.cs index 53131ab90e..81e1cb2406 100644 --- a/osu.Game/Screens/OnlinePlay/Match/Components/CreateRoomButton.cs +++ b/osu.Game/Screens/OnlinePlay/Match/Components/CreateRoomButton.cs @@ -19,6 +19,9 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (!Enabled.Value) return false; diff --git a/osu.Game/Screens/OnlinePlay/Match/Components/RoomSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/Components/RoomSettingsOverlay.cs index 6d14b95aec..435c9aca02 100644 --- a/osu.Game/Screens/OnlinePlay/Match/Components/RoomSettingsOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/Components/RoomSettingsOverlay.cs @@ -65,6 +65,9 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Select: diff --git a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs index 850543136c..8e0a38aa1f 100644 --- a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs +++ b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs @@ -208,6 +208,9 @@ namespace osu.Game.Screens.Play.HUD public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Back: diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 54c74a7177..b5c4433719 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -283,6 +283,9 @@ namespace osu.Game.Screens.Play public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.HoldForHUD: diff --git a/osu.Game/Screens/Play/HotkeyExitOverlay.cs b/osu.Game/Screens/Play/HotkeyExitOverlay.cs index 13b72ffaf6..9fe7d17cc7 100644 --- a/osu.Game/Screens/Play/HotkeyExitOverlay.cs +++ b/osu.Game/Screens/Play/HotkeyExitOverlay.cs @@ -12,6 +12,9 @@ namespace osu.Game.Screens.Play { public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (e.Action != GlobalAction.QuickExit) return false; BeginConfirm(); diff --git a/osu.Game/Screens/Play/HotkeyRetryOverlay.cs b/osu.Game/Screens/Play/HotkeyRetryOverlay.cs index 308befe372..2812df8bbe 100644 --- a/osu.Game/Screens/Play/HotkeyRetryOverlay.cs +++ b/osu.Game/Screens/Play/HotkeyRetryOverlay.cs @@ -12,6 +12,9 @@ namespace osu.Game.Screens.Play { public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (e.Action != GlobalAction.QuickRetry) return false; BeginConfirm(); diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 93054b7bb5..617374b4fd 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -7,9 +7,7 @@ using System.Linq; using System.Threading.Tasks; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Framework.Threading; using osu.Game.Beatmaps; -using osu.Game.Extensions; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; @@ -48,8 +46,6 @@ namespace osu.Game.Screens.Play protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false); - private ScheduledDelegate keyboardSeekDelegate; - public bool OnPressed(KeyBindingPressEvent e) { const double keyboard_seek_amount = 5000; @@ -57,13 +53,11 @@ namespace osu.Game.Screens.Play switch (e.Action) { case GlobalAction.SeekReplayBackward: - keyboardSeekDelegate?.Cancel(); - keyboardSeekDelegate = this.BeginKeyRepeat(Scheduler, () => keyboardSeek(-1)); + keyboardSeek(-1); return true; case GlobalAction.SeekReplayForward: - keyboardSeekDelegate?.Cancel(); - keyboardSeekDelegate = this.BeginKeyRepeat(Scheduler, () => keyboardSeek(1)); + keyboardSeek(1); return true; case GlobalAction.TogglePauseReplay: @@ -86,13 +80,6 @@ namespace osu.Game.Screens.Play public void OnReleased(KeyBindingReleaseEvent e) { - switch (e.Action) - { - case GlobalAction.SeekReplayBackward: - case GlobalAction.SeekReplayForward: - keyboardSeekDelegate?.Cancel(); - break; - } } } } diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index c35548c6b4..84d5507dce 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -146,6 +146,9 @@ namespace osu.Game.Screens.Play public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.SkipCutscene: diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index dacc4f5f9e..e43f40e203 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -330,6 +330,9 @@ namespace osu.Game.Screens.Ranking public bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + switch (e.Action) { case GlobalAction.Select: diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 0c593ebea1..0fc7a99c96 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -18,7 +18,6 @@ using osu.Framework.Threading; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Configuration; -using osu.Game.Extensions; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Input.Bindings; @@ -479,42 +478,27 @@ namespace osu.Game.Screens.Select switch (e.Key) { case Key.Left: - if (!e.Repeat) - beginRepeatSelection(() => SelectNext(-1), e.Key); + SelectNext(-1); return true; case Key.Right: - if (!e.Repeat) - beginRepeatSelection(() => SelectNext(), e.Key); + SelectNext(); return true; } return false; } - protected override void OnKeyUp(KeyUpEvent e) - { - switch (e.Key) - { - case Key.Left: - case Key.Right: - endRepeatSelection(e.Key); - break; - } - - base.OnKeyUp(e); - } - public bool OnPressed(KeyBindingPressEvent e) { switch (e.Action) { case GlobalAction.SelectNext: - beginRepeatSelection(() => SelectNext(1, false), e.Action); + SelectNext(1, false); return true; case GlobalAction.SelectPrevious: - beginRepeatSelection(() => SelectNext(-1, false), e.Action); + SelectNext(-1, false); return true; } @@ -523,40 +507,6 @@ namespace osu.Game.Screens.Select public void OnReleased(KeyBindingReleaseEvent e) { - switch (e.Action) - { - case GlobalAction.SelectNext: - case GlobalAction.SelectPrevious: - endRepeatSelection(e.Action); - break; - } - } - - private ScheduledDelegate repeatDelegate; - private object lastRepeatSource; - - /// - /// Begin repeating the specified selection action. - /// - /// The action to perform. - /// The source of the action. Used in conjunction with to only cancel the correct action (most recently pressed key). - private void beginRepeatSelection(Action action, object source) - { - endRepeatSelection(); - - lastRepeatSource = source; - repeatDelegate = this.BeginKeyRepeat(Scheduler, action); - } - - private void endRepeatSelection(object source = null) - { - // only the most recent source should be able to cancel the current action. - if (source != null && !EqualityComparer.Default.Equals(lastRepeatSource, source)) - return; - - repeatDelegate?.Cancel(); - repeatDelegate = null; - lastRepeatSource = null; } #endregion diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index aef00a9b00..2c36bf5fc8 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -821,6 +821,9 @@ namespace osu.Game.Screens.Select public virtual bool OnPressed(KeyBindingPressEvent e) { + if (e.Repeat) + return false; + if (!this.IsCurrentScreen()) return false; switch (e.Action) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 93fb729f46..6b722f00ea 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/osu.iOS.props b/osu.iOS.props index 3a2a3fd65e..00cbe2c849 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -70,7 +70,7 @@ - + @@ -93,7 +93,7 @@ - +