Expose bindable for identifying last input source

This commit is contained in:
Salman Ahmed 2022-10-11 16:21:50 +03:00
parent 9b45a9cf76
commit 894127a948

View File

@ -3,17 +3,43 @@
#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)