mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Merge pull request #6347 from frenzibyte/fix-ptim-not-always-releasing
Fix `PassThroughInputManager` not always releasing input
This commit is contained in:
@@ -132,6 +132,25 @@ namespace osu.Framework.Tests.Visual.Input
|
||||
AddStep("UseParentInput = true", () => testInputManager.UseParentInput = true);
|
||||
AddStep("release key", () => InputManager.ReleaseKey(Key.A));
|
||||
AddAssert("key released", () => !testInputManager.CurrentState.Keyboard.Keys.HasAnyButtonPressed);
|
||||
|
||||
AddStep("press key", () => InputManager.PressKey(Key.A));
|
||||
AddStep("UseParentInput = false", () => testInputManager.UseParentInput = false);
|
||||
|
||||
AddStep("add blocking layer", () => Add(new HandlingBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
OnHandle = _ => true,
|
||||
}));
|
||||
|
||||
// with a blocking layer existing, the next key press will not be seen by PassThroughInputManager...
|
||||
AddStep("release key", () => InputManager.ReleaseKey(Key.A));
|
||||
AddStep("press key again", () => InputManager.PressKey(Key.A));
|
||||
|
||||
AddStep("UseParentInput = true", () => testInputManager.UseParentInput = true);
|
||||
|
||||
// ...but ensure it'll still release the key regardless of not seeing the corresponding press event (it does that by syncing releases every frame).
|
||||
AddStep("release key", () => InputManager.ReleaseKey(Key.A));
|
||||
AddAssert("key released", () => !testInputManager.CurrentState.Keyboard.Keys.HasAnyButtonPressed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -173,6 +173,18 @@ namespace osu.Framework.Input
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// There are scenarios wherein we cannot receive the release events of pressed inputs. For simplicity, sync every frame.
|
||||
if (UseParentInput)
|
||||
{
|
||||
syncReleasedInputs();
|
||||
syncJoystickAxes();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates state of any buttons that have been released by parent while <see cref="UseParentInput"/> was disabled.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user