From 96e79ed6c50fe915c806f2ddd0690fc7afb00a16 Mon Sep 17 00:00:00 2001 From: botoddly <250804054+botoddly@users.noreply.github.com> Date: Sat, 12 Sep 2026 09:15:59 +0200 Subject: [PATCH] Drive input automation from standard input --- docs/frame-order.md | 1 + docs/input-automation.md | 30 +++++ src/Pixely.Core/UpdateOrders.cs | 3 + .../InputAutomationCommandInterpreter.cs | 103 ++++++++++++++++++ src/Pixely/Input/InputAutomationConsole.cs | 55 ++++++++++ src/Pixely/Input/InputAutomationExtensions.cs | 1 + src/Pixely/PixelyFactory.cs | 6 + .../InputAutomationCommandInterpreterTests.cs | 95 ++++++++++++++++ .../InputAutomationConsoleTests.cs | 57 ++++++++++ 9 files changed, 351 insertions(+) create mode 100644 src/Pixely/Input/InputAutomationCommandInterpreter.cs create mode 100644 src/Pixely/Input/InputAutomationConsole.cs create mode 100644 tests/Pixely.Tests/InputAutomationCommandInterpreterTests.cs create mode 100644 tests/Pixely.Tests/InputAutomationConsoleTests.cs diff --git a/docs/frame-order.md b/docs/frame-order.md index 4db9dba1..7971bc1e 100644 --- a/docs/frame-order.md +++ b/docs/frame-order.md @@ -24,6 +24,7 @@ work relative to them instead of guessing. | Constant | Value | Runs there | | --- | --- | --- | | `UpdateOrders.Diagnostics` | -20 000 | `PerformanceTracker` | +| `UpdateOrders.Input` | -10 000 | `InputAutomationConsole` (with `AddInputAutomation()`) | | `UpdateOrders.Default` | 0 | `TimerSystem`, `UpdateSystem` | | `UpdateOrders.Ui` | 10 000 | `UiUpdateSystem` (Pixely.Ui) | | `UpdateOrders.Maintenance` | 20 000 | `FontSystem` | diff --git a/docs/input-automation.md b/docs/input-automation.md index ae716390..52fb41a2 100644 --- a/docs/input-automation.md +++ b/docs/input-automation.md @@ -35,3 +35,33 @@ input.MouseUp(MouseButton.Left, new Vector2(200, 100)); The default `ViewScope` targets the ordinary single-window application. Pass a scope explicitly for another registered window. Automated input affects Pixely's event-derived synthetic device state. It does not move the operating-system cursor, change window focus, or modify SDL's physical/global device state. + +## Driving the app from standard input + +`AddInputAutomation()` also reads command lines from the process's standard input and runs each one on the frame loop at `UpdateOrders.Input`, after the frame's real events and before the game's updatables. Every command gets one reply line on standard output: `ok` or `error: ` for a malformed line. Blank lines and lines starting with `#` are ignored and get no reply. Lines queued before a frame starts run in that frame; a chord written in one go usually lands in one frame but may split across two. An exception thrown by an input handler propagates out of the frame loop, the same as for real input. + +| Command | Calls | +| --- | --- | +| `mouse move ` | `MouseMoveTo` | +| `mouse moveby ` | `MouseMoveBy` | +| `mouse down