aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/src/Godosa.Core/Runs/Scripts/Input.cs
blob: d549bb45bb939ca986dcf6ecf7f0fe73a0c6c504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Provenance: own design — shared run scripts (spec §5.5)
namespace Godosa.Core.Runs.Scripts;

public enum InputKind { Move, Down, Up, Wheel, KeyDown, KeyUp, Text }

public enum MouseButton { Left, Right }

/// <summary>One simulated user input event at virtual-screen coordinates.</summary>
public sealed record InputEvent(InputKind Kind, int X = 0, int Y = 0, MouseButton Button = MouseButton.Left, string Key = "",
    string Text = "", int Delta = 0);

/// <summary>An event due <see cref="Frame"/> frames after its step began.</summary>
public sealed record PlannedInput(int Frame, InputEvent Event);

public sealed record InputPlan(IReadOnlyList<PlannedInput> Events)
{
    public int LastFrame => Events.Count == 0 ? 0 : Events.Max(e => e.Frame);
}

/// <summary>The game's input entry: the real UI in a window, its layout + hit-testing headless.</summary>
public interface IInputRouter
{
    void Send(InputEvent e);
}