Skip to content

Fix touch device not always activating when it should #26575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public override void SetUpSteps()
public void TestUserAlreadyHasTouchDeviceActive()
{
loadPlayer();
// it is presumed that a previous screen (i.e. song select) will set this up
AddStep("set up touchscreen user", () =>
{
currentPlayer.Score.ScoreInfo.Mods = currentPlayer.Score.ScoreInfo.Mods.Append(new OsuModTouchDevice()).ToArray();
Expand All @@ -69,6 +68,14 @@ public void TestUserAlreadyHasTouchDeviceActive()
AddAssert("touch device mod activated", () => currentPlayer.Score.ScoreInfo.Mods, () => Has.One.InstanceOf<OsuModTouchDevice>());
}

[Test]
public void TestTouchActivePriorToPlayerLoad()
{
AddStep("set touch input active", () => statics.SetValue(Static.TouchInputActive, true));
loadPlayer();
AddUntilStep("touch device mod activated", () => currentPlayer.Score.ScoreInfo.Mods, () => Has.One.InstanceOf<OsuModTouchDevice>());
}

[Test]
public void TestTouchDuringBreak()
{
Expand Down
6 changes: 5 additions & 1 deletion osu.Game/Screens/Play/PlayerTouchInputDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ public partial class PlayerTouchInputDetector : Component
private GameplayState gameplayState { get; set; } = null!;

private IBindable<bool> touchActive = new BindableBool();
private IBindable<bool> isBreakTime = null!;

[BackgroundDependencyLoader]
private void load(SessionStatics statics)
{
touchActive = statics.GetBindable<bool>(Static.TouchInputActive);
touchActive.BindValueChanged(_ => updateState());

isBreakTime = player.IsBreakTime.GetBoundCopy();
isBreakTime.BindValueChanged(_ => updateState(), true);
}

private void updateState()
Expand All @@ -39,7 +43,7 @@ private void updateState()
if (gameplayState.Score.ScoreInfo.Mods.OfType<ModTouchDevice>().Any())
return;

if (player.IsBreakTime.Value)
if (isBreakTime.Value)
return;

var touchDeviceMod = gameplayState.Ruleset.GetTouchDeviceMod();
Expand Down