Skip to content

Commit

Permalink
Merge pull request #351 from LumpBloom7/touch-input-fix
Browse files Browse the repository at this point in the history
Fix dedicated lane button overriding lane receptor
  • Loading branch information
LumpBloom7 authored Jul 16, 2022
2 parents b26a321 + 4c36eca commit 9280e5c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
23 changes: 22 additions & 1 deletion osu.Game.Rulesets.Sentakki/SentakkiInputManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.ComponentModel;
using osu.Framework.Extensions.ListExtensions;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Framework.Lists;
using osu.Game.Rulesets.UI;

Expand Down Expand Up @@ -34,6 +36,25 @@ protected override bool Handle(UIEvent e)

return base.Handle(e);
}

// We want the press behavior of SimultaneousBindingMode.All, but we want the release behavior of SimultaneousBindingMode.Unique
// As long as there are more than one input source triggering the action, we manually remove the action from the list once, without propogating the release
// When the final source is released, we let the original handling take over, which would also propogate the release event
// This is so that multiple sources (virtual input/key) can trigger a press, but not release until the last key is released
protected override void PropagateReleased(IEnumerable<Drawable> drawables, InputState state, SentakkiAction released)
{
int actionCount = 0;
var pressed = (List<SentakkiAction>)PressedActions;

for (int i = 0; i < pressed.Count; ++i)
if (pressed[i] == released && ++actionCount > 1)
break;

if (actionCount > 1)
pressed.Remove(released);
else
base.PropagateReleased(drawables, state, released);
}
}

public SlimReadOnlyListWrapper<SentakkiAction> PressedActions => ((List<SentakkiAction>)KeyBindingContainer.PressedActions).AsSlimReadOnly();
Expand All @@ -43,7 +64,7 @@ protected override bool Handle(UIEvent e)
public void TriggerReleased(SentakkiAction action) => KeyBindingContainer.TriggerReleased(action);

public SentakkiInputManager(RulesetInfo ruleset)
: base(ruleset, 0, SimultaneousBindingMode.Unique)
: base(ruleset, 0, SimultaneousBindingMode.All)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Sentakki/UI/Lane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void updateInputState()

private void handleKeyPress(ValueChangedEvent<int> keys)
{
if (keys.NewValue > keys.OldValue || keys.NewValue == 0)
if (keys.NewValue < keys.OldValue)
SentakkiActionInputManager.TriggerReleased(SentakkiAction.Key1 + LaneNumber);

if (keys.NewValue > keys.OldValue)
Expand Down
15 changes: 0 additions & 15 deletions osu.Game.Rulesets.Sentakki/UI/SentakkiCursorContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.UI;

namespace osu.Game.Rulesets.Sentakki.UI
Expand All @@ -26,19 +25,5 @@ private void load(TextureStore textures)
if (cursorSprite != null)
cursorSprite.Texture = cursorTexture;
}

protected override bool Handle(UIEvent e)
{
switch (e)
{
case MouseEvent _:
Show();
break;
case TouchEvent _:
Hide();
break;
}
return base.Handle(e);
}
}
}

0 comments on commit 9280e5c

Please sign in to comment.