mirror of
https://github.com/ppy/osu
synced 2024-12-15 19:36:34 +00:00
Expose bindable for identifying last input source
This commit is contained in:
parent
9b45a9cf76
commit
894127a948
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user