Skip to content
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

Tidy up various input handling anomalies #31603

Merged
merged 4 commits into from
Jan 22, 2025
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
9 changes: 0 additions & 9 deletions osu.Game/Graphics/UserInterfaceV2/OsuPopover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osuTK;
using osuTK.Input;

namespace osu.Game.Graphics.UserInterfaceV2
{
Expand Down Expand Up @@ -75,14 +74,6 @@ protected override void PopOut()
samplePopOut?.Play();
}

protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Key == Key.Escape)
return false; // disable the framework-level handling of escape key for conformity (we use GlobalAction.Back).

return base.OnKeyDown(e);
}

public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,26 @@ protected override void TransferBlueprintFor(HitObject hitObject, DrawableHitObj

protected override bool OnKeyDown(KeyDownEvent e)
{
// Until the keys below are global actions, this will prevent conflicts with "seek between sample points"
// which has a default of ctrl+shift+arrows.
if (e.ShiftPressed)
return false;

if (e.ControlPressed)
{
switch (e.Key)
{
case Key.Left:
nudgeSelection(new Vector2(-1, 0));
return true;
return nudgeSelection(new Vector2(-1, 0));

case Key.Right:
nudgeSelection(new Vector2(1, 0));
return true;
return nudgeSelection(new Vector2(1, 0));

case Key.Up:
nudgeSelection(new Vector2(0, -1));
return true;
return nudgeSelection(new Vector2(0, -1));

case Key.Down:
nudgeSelection(new Vector2(0, 1));
return true;
return nudgeSelection(new Vector2(0, 1));
}
}

Expand All @@ -151,7 +152,7 @@ protected override void OnKeyUp(KeyUpEvent e)
/// Move the current selection spatially by the specified delta, in gamefield coordinates (ie. the same coordinates as the blueprints).
/// </summary>
/// <param name="delta"></param>
private void nudgeSelection(Vector2 delta)
private bool nudgeSelection(Vector2 delta)
{
if (!nudgeMovementActive)
{
Expand All @@ -162,12 +163,13 @@ private void nudgeSelection(Vector2 delta)
var firstBlueprint = SelectionHandler.SelectedBlueprints.FirstOrDefault();

if (firstBlueprint == null)
return;
return false;

// convert to game space coordinates
delta = firstBlueprint.ToScreenSpace(delta) - firstBlueprint.ToScreenSpace(Vector2.Zero);

SelectionHandler.HandleMovement(new MoveSelectionEvent<HitObject>(firstBlueprint, delta));
return true;
}

private void updatePlacementNewCombo()
Expand Down
9 changes: 9 additions & 0 deletions osu.Game/Screens/Menu/ButtonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ protected override bool OnKeyDown(KeyDownEvent e)
if (e.Repeat || e.ControlPressed || e.ShiftPressed || e.AltPressed || e.SuperPressed)
return false;

if (e.Key >= Key.F1 && e.Key <= Key.F35)
return false;

switch (e.Key)
{
case Key.Escape:
return false;
}

if (triggerInitialOsuLogo())
return true;

Expand Down
5 changes: 0 additions & 5 deletions osu.Game/Screens/Play/GameplayMenuOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ protected override void PopIn()

protected override void PopOut() => this.FadeOut(TRANSITION_DURATION, Easing.In);

// Don't let mouse down events through the overlay or people can click circles while paused.
protected override bool OnMouseDown(MouseDownEvent e) => true;

protected override bool OnMouseMove(MouseMoveEvent e) => true;

protected void AddButton(LocalisableString text, Color4 colour, Action? action)
{
var button = new Button
Expand Down
Loading