mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 17:33:02 +08:00
Expose bindable for identifying last input source
This commit is contained in:
parent
9b45a9cf76
commit
894127a948
@ -3,17 +3,43 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.StateChanges.Events;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Input
|
namespace osu.Game.Input
|
||||||
{
|
{
|
||||||
public class OsuUserInputManager : UserInputManager
|
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()
|
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)
|
protected override MouseButtonEventManager CreateButtonEventManagerFor(MouseButton button)
|
||||||
{
|
{
|
||||||
switch (button)
|
switch (button)
|
||||||
|
Loading…
Reference in New Issue
Block a user