diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index 99803e2956..04ecfa7e9a 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -86,6 +86,7 @@ namespace osu.Game.Graphics.UserInterface Placeholder.Colour = colourProvider?.Foreground1 ?? new Color4(180, 180, 180, 255); + // Note that `KeyBindingRow` uses similar logic for input feedback, so remember to update there if changing here. var textAddedSamples = new Sample?[4]; for (int i = 0; i < textAddedSamples.Length; i++) textAddedSamples[i] = audio.Samples.Get($@"Keyboard/key-press-{1 + i}"); diff --git a/osu.Game/Overlays/Settings/Sections/Input/KeyBindingRow.cs b/osu.Game/Overlays/Settings/Sections/Input/KeyBindingRow.cs index 7a5a269eb3..c85fe4727a 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/KeyBindingRow.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/KeyBindingRow.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; @@ -17,6 +19,7 @@ using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Localisation; +using osu.Framework.Utils; using osu.Game.Database; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -96,6 +99,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input private KeyButton? bindTarget; + private Sample?[]? keypressSamples; + private const float transition_time = 150; private const float height = 20; private const float padding = 5; @@ -118,7 +123,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input } [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) + private void load(OverlayColourProvider colourProvider, AudioManager audioManager) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -202,6 +207,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input Scheduler.AddOnce(updateButtons); updateIsDefaultValue(); }, true); + + keypressSamples = new Sample[4]; + for (int i = 0; i < keypressSamples.Length; i++) + keypressSamples[i] = audioManager.Samples.Get($@"Keyboard/key-press-{1 + i}"); } public void RestoreDefaults() @@ -301,6 +310,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input Debug.Assert(bindTarget != null); + keypressSamples?[RNG.Next(0, keypressSamples.Length)]?.Play(); + bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromKey(e.Key)); if (!isModifier(e.Key)) finalise();