1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 23:32:55 +08:00
osu-lazer/osu.Game/Input/OsuUserInputManager.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.0 KiB
C#
Raw Normal View History

// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using osu.Framework.Bindables;
using osu.Framework.Input;
using osu.Framework.Input.StateChanges.Events;
using osuTK.Input;
namespace osu.Game.Input
{
public class OsuUserInputManager : UserInputManager
{
/// <summary>
/// Whether the last input applied to the game is sourced from mouse.
/// </summary>
public IBindable<bool> IsMouseInputSource => isMouseInputSource;
private readonly Bindable<bool> isMouseInputSource = new Bindable<bool>();
internal OsuUserInputManager()
{
}
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange)
{
switch (inputStateChange)
{
case ButtonStateChangeEvent<MouseButton>:
case MousePositionChangeEvent:
isMouseInputSource.Value = true;
break;
default:
isMouseInputSource.Value = false;
break;
}
base.HandleInputStateChange(inputStateChange);
}
protected override MouseButtonEventManager CreateButtonEventManagerFor(MouseButton button)
{
switch (button)
{
case MouseButton.Right:
return new RightMouseManager(button);
}
return base.CreateButtonEventManagerFor(button);
}
private class RightMouseManager : MouseButtonEventManager
{
public RightMouseManager(MouseButton button)
: base(button)
{
}
public override bool EnableDrag => true; // allow right-mouse dragging for absolute scroll in scroll containers.
public override bool EnableClick => false;
public override bool ChangeFocusOnClick => false;
}
}
}