Merge pull request #25366 from Susko3/better-touch-settings

Add "disable taps during gameplay" to touch input settings and related UI
This commit is contained in:
Dean Herbert 2023-11-09 18:19:02 +09:00 committed by GitHub
commit 67dc3aa5b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 81 additions and 39 deletions

View File

@ -70,7 +70,7 @@ namespace osu.Android
},
new SettingsCheckbox
{
LabelText = MouseSettingsStrings.DisableMouseButtons,
LabelText = MouseSettingsStrings.DisableClicksDuringGameplay,
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons),
},
});

View File

@ -133,8 +133,11 @@ namespace osu.Game.Rulesets.Osu.Tests
}
[Test]
public void TestSimpleInput()
public void TestSimpleInput([Values] bool disableMouseButtons)
{
// OsuSetting.MouseDisableButtons should not affect touch taps
AddStep($"{(disableMouseButtons ? "disable" : "enable")} mouse buttons", () => config.SetValue(OsuSetting.MouseDisableButtons, disableMouseButtons));
beginTouch(TouchSource.Touch1);
assertKeyCounter(1, 0);
@ -468,7 +471,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[Test]
public void TestInputWhileMouseButtonsDisabled()
{
AddStep("Disable mouse buttons", () => config.SetValue(OsuSetting.MouseDisableButtons, true));
AddStep("Disable gameplay taps", () => config.SetValue(OsuSetting.TouchDisableGameplayTaps, true));
beginTouch(TouchSource.Touch1);
@ -620,6 +623,7 @@ namespace osu.Game.Rulesets.Osu.Tests
AddStep("Release all touches", () =>
{
config.SetValue(OsuSetting.MouseDisableButtons, false);
config.SetValue(OsuSetting.TouchDisableGameplayTaps, false);
foreach (TouchSource source in InputManager.CurrentState.Touch.ActiveSources)
InputManager.EndTouch(new Touch(source, osuInputManager.ScreenSpaceDrawQuad.Centre));
});

View File

@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.UI
private readonly OsuInputManager osuInputManager;
private Bindable<bool> mouseDisabled = null!;
private Bindable<bool> tapsDisabled = null!;
public OsuTouchInputMapper(OsuInputManager inputManager)
{
@ -43,9 +43,7 @@ namespace osu.Game.Rulesets.Osu.UI
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
// The mouse button disable setting affects touch. It's a bit weird.
// This is mostly just doing the same as what is done in RulesetInputManager to match behaviour.
mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
tapsDisabled = config.GetBindable<bool>(OsuSetting.TouchDisableGameplayTaps);
}
// Required to handle touches outside of the playfield when screen scaling is enabled.
@ -64,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.UI
: OsuAction.LeftButton;
// Ignore any taps which trigger an action which is already handled. But track them for potential positional input in the future.
bool shouldResultInAction = osuInputManager.AllowGameplayInputs && !mouseDisabled.Value && trackedTouches.All(t => t.Action != action);
bool shouldResultInAction = osuInputManager.AllowGameplayInputs && !tapsDisabled.Value && trackedTouches.All(t => t.Action != action);
// If we can actually accept as an action, check whether this tap was on a circle's receptor.
// This case gets special handling to allow for empty-space stream tapping.

View File

@ -108,6 +108,8 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.MouseDisableWheel, false);
SetDefault(OsuSetting.ConfineMouseMode, OsuConfineMouseMode.DuringGameplay);
SetDefault(OsuSetting.TouchDisableGameplayTaps, false);
// Graphics
SetDefault(OsuSetting.ShowFpsDisplay, false);
@ -330,6 +332,10 @@ namespace osu.Game.Configuration
ShowHealthDisplayWhenCantFail,
FadePlayfieldWhenHealthLow,
/// <summary>
/// Disables mouse buttons clicks during gameplay.
/// </summary>
MouseDisableButtons,
MouseDisableWheel,
ConfineMouseMode,
@ -408,6 +414,7 @@ namespace osu.Game.Configuration
EditorLimitedDistanceSnap,
ReplaySettingsOverlay,
AutomaticallyDownloadMissingBeatmaps,
EditorShowSpeedChanges
EditorShowSpeedChanges,
TouchDisableGameplayTaps,
}
}

View File

@ -40,14 +40,14 @@ namespace osu.Game.Localisation
public static LocalisableString DisableMouseWheelVolumeAdjust => new TranslatableString(getKey(@"disable_mouse_wheel_volume_adjust"), @"Disable mouse wheel adjusting volume during gameplay");
/// <summary>
/// "Volume can still be adjusted using the mouse wheel by holding "Alt""
/// "Volume can still be adjusted using the mouse wheel by holding &quot;Alt&quot;"
/// </summary>
public static LocalisableString DisableMouseWheelVolumeAdjustTooltip => new TranslatableString(getKey(@"disable_mouse_wheel_volume_adjust_tooltip"), @"Volume can still be adjusted using the mouse wheel by holding ""Alt""");
/// <summary>
/// "Disable mouse buttons during gameplay"
/// "Disable clicks during gameplay"
/// </summary>
public static LocalisableString DisableMouseButtons => new TranslatableString(getKey(@"disable_mouse_buttons"), @"Disable mouse buttons during gameplay");
public static LocalisableString DisableClicksDuringGameplay => new TranslatableString(getKey(@"disable_clicks"), @"Disable clicks during gameplay");
/// <summary>
/// "Enable high precision mouse to adjust sensitivity"

View File

@ -0,0 +1,24 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class TouchSettingsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.TouchSettings";
/// <summary>
/// "Touch"
/// </summary>
public static LocalisableString Touch => new TranslatableString(getKey(@"touch"), @"Touch");
/// <summary>
/// "Disable taps during gameplay"
/// </summary>
public static LocalisableString DisableTapsDuringGameplay => new TranslatableString(getKey(@"disable_taps_during_gameplay"), @"Disable taps during gameplay");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
},
new SettingsCheckbox
{
LabelText = MouseSettingsStrings.DisableMouseButtons,
LabelText = MouseSettingsStrings.DisableClicksDuringGameplay,
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons)
},
};

View File

@ -4,37 +4,43 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Handlers.Touch;
using osu.Framework.Input.Handlers;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Input
{
/// <summary>
/// Touch input settings subsection common to all touch handlers (even on different platforms).
/// </summary>
public partial class TouchSettings : SettingsSubsection
{
private readonly TouchHandler handler;
private readonly InputHandler handler;
public TouchSettings(TouchHandler handler)
protected override LocalisableString Header => TouchSettingsStrings.Touch;
public TouchSettings(InputHandler handler)
{
this.handler = handler;
}
[BackgroundDependencyLoader]
private void load()
private void load(OsuConfigManager osuConfig)
{
Children = new Drawable[]
Add(new SettingsCheckbox
{
new SettingsCheckbox
{
LabelText = CommonStrings.Enabled,
Current = handler.Enabled
},
};
LabelText = CommonStrings.Enabled,
Current = handler.Enabled
});
Add(new SettingsCheckbox
{
LabelText = TouchSettingsStrings.DisableTapsDuringGameplay,
Current = osuConfig.GetBindable<bool>(OsuSetting.TouchDisableGameplayTaps)
});
}
public override IEnumerable<LocalisableString> FilterTerms => base.FilterTerms.Concat(new LocalisableString[] { @"touchscreen" });
protected override LocalisableString Header => handler.Description;
}
}

View File

@ -72,6 +72,7 @@ namespace osu.Game.Rulesets.UI
private void load(OsuConfigManager config)
{
mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
tapsDisabled = config.GetBindable<bool>(OsuSetting.TouchDisableGameplayTaps);
}
#region Action mapping (for replays)
@ -124,6 +125,7 @@ namespace osu.Game.Rulesets.UI
#region Setting application (disables etc.)
private Bindable<bool> mouseDisabled;
private Bindable<bool> tapsDisabled;
protected override bool Handle(UIEvent e)
{
@ -147,9 +149,9 @@ namespace osu.Game.Rulesets.UI
protected override bool HandleMouseTouchStateChange(TouchStateChangeEvent e)
{
if (mouseDisabled.Value)
if (tapsDisabled.Value)
{
// Only propagate positional data when mouse buttons are disabled.
// Only propagate positional data when taps are disabled.
e = new TouchStateChangeEvent(e.State, e.Input, e.Touch, false, e.LastPosition);
}

View File

@ -10,21 +10,22 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
public partial class InputSettings : PlayerSettingsGroup
{
private readonly PlayerCheckbox mouseButtonsCheckbox;
public InputSettings()
: base("Input Settings")
{
Children = new Drawable[]
{
mouseButtonsCheckbox = new PlayerCheckbox
{
LabelText = MouseSettingsStrings.DisableMouseButtons
}
};
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config) => mouseButtonsCheckbox.Current = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
private void load(OsuConfigManager config)
{
Children = new Drawable[]
{
new PlayerCheckbox
{
LabelText = MouseSettingsStrings.DisableClicksDuringGameplay,
Current = config.GetBindable<bool>(OsuSetting.MouseDisableButtons)
}
};
}
}
}