Repository navigation
Input hub: typed events, no device reference, no direct-write MCP tools - #2599
Merged
Merged
Conversation
This was referenced Dec 2, 2026
|
Generated code: 0 scenarios changed, 1 new, 0 removed (+152 -0 lines). Base
|
kevinferrare
force-pushed
the
feature/reproducible-run-option
branch
from
December 2, 2026 13:35
f94a969 to
68e33f4
Compare
kevinferrare
force-pushed
the
feature/input-event-hub
branch
from
December 2, 2026 13:36
ad7b557 to
0e493ca
Compare
Contributor
Author
kevinferrare
force-pushed
the
feature/reproducible-run-option
branch
4 times, most recently
from
December 2, 2026 21:06
adb468b to
bbab6d6
Compare
kevinferrare
force-pushed
the
feature/input-event-hub
branch
from
December 2, 2026 21:14
0e493ca to
d025a8f
Compare
kevinferrare
force-pushed
the
feature/input-event-hub
branch
2 times, most recently
from
December 2, 2026 21:49
1cd5fff to
d588639
Compare
maximilien-noal
self-requested a review
December 2, 2026 22:45
maximilien-noal
approved these changes
Dec 2, 2026
Every host input action now passes through one inspectable pipeline, which input recording and replay build on. - InputEventHub queues IInputEvent items instead of Action delegates: the keyboard and mouse event args implement IInputEvent and are queued as-is, and ReleaseAllKeysInput and TimeMultiplierInput carry the two commands. - Remove PostToEmulatorThread and InputEventHub.KeyboardDevice. The hub raises IKeyboardInputEvents.AllKeysReleased, which PS2Keyboard subscribes to, and UI time multiplier changes go through the hub. - Remove the press_key and send_mouse_packet MCP tools, which bypassed the hub by writing BIOS and PS/2 controller state directly, along with the Intel8042Controller and BiosKeyboardBuffer properties on EmulatorMcpServices. Pause-time key release is wired in Spice86DependencyInjection. - Add the input_timer_keys catalogue scenario: a cycle breakpoint calls ReleaseAllKeys between two injected keys, and the program must record A's break code, in interpreted and generated mode. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Approval is blocked by an untested queued time-multiplier path and a remaining file-organization issue.
2 open issues
What changed in this PR
This PR refactors emulator input handling around typed, emulator-thread events and removes direct-write MCP input tools.
Changes:
- Adds typed keyboard, mouse, release, and time-multiplier events.
- Routes pause-time key release and UI time changes through
InputEventHub. - Removes
press_keyandsend_mouse_packet, and adds theinput_timer_keysfixture.
| File | Description |
|---|---|
| tests/Spice86.Tests/Resources/GeneratedCodeReadability/bounds.tsv | Adds readability bounds for the input fixture. |
| tests/Spice86.Tests/Resources/cpuTests/asmsrc/input_timer_keys.asm | Adds the timer and keyboard test program. |
| tests/Spice86.Tests/MouseStateTests.cs | Updates mouse state tests for the revised input hub. |
| tests/Spice86.Tests/MouseInputTests.cs | Updates mouse input tests for the revised input hub. |
| tests/Spice86.Tests/MouseDriverTests.cs | Updates mouse driver tests for the revised input hub. |
| tests/Spice86.Tests/McpServerToolStateTests.cs | Removes tests for deleted MCP input tools. |
| tests/Spice86.Tests/McpIntegrationContext.cs | Removes obsolete MCP service wiring. |
| tests/Spice86.Tests/CSharpOverrideHelperTest.cs | Updates coverage for queued keyboard input. |
| tests/Spice86.Tests/AsmFixtures/AsmScenarioCatalog.cs | Registers the input fixture scenario. |
| tests/Spice86.Tests/AsmFixtures/AsmFixtureCatalog.cs | Adds release-all-keys behavioral coverage. |
| src/Spice86/Spice86DependencyInjection.cs | Wires input events, pause-time key release, and timing updates. |
| src/Spice86.Shared/Interfaces/IInputEvent.cs | Adds the input-event marker interface. |
| src/Spice86.Shared/Emulator/Mouse/MouseMoveEventArgs.cs | Makes mouse movement events queueable. |
| src/Spice86.Shared/Emulator/Mouse/MouseButtonEventArgs.cs | Makes mouse button events queueable. |
| src/Spice86.Shared/Emulator/Keyboard/KeyboardEventArgs.cs | Makes keyboard events queueable. |
| src/Spice86.Core/Emulator/VM/InputEventHub.cs | Queues and dispatches typed input events. |
| src/Spice86.Core/Emulator/VM/Input/Events/InputEvents.cs | Defines queued input event records. |
| src/Spice86.Core/Emulator/VM/IKeyboardInputEvents.cs | Exposes keyboard reconciliation events. |
| src/Spice86.Core/Emulator/Mcp/EmulatorMcpTools.cs | Removes direct-write MCP input tools. |
| src/Spice86.Core/Emulator/Mcp/EmulatorMcpServices.cs | Removes obsolete direct device references. |
| src/Spice86.Core/Emulator/Devices/Input/Keyboard/PS2Keyboard.cs | Handles queued key-release requests. |
| src/Spice86.Core/Emulator/Devices/Input/Keyboard/Intel8042Controller.cs | Uses the new keyboard input-event interface. |
| doc/mcp.md | Removes documentation for deleted MCP input tools. |
Review effort: Lite
| /// Thread-safe request to change the emulated clock time multiplier on the emulation thread. | ||
| /// </summary> | ||
| internal PS2Keyboard? KeyboardDevice { get; set; } | ||
| public void SetTimeMultiplier(double value) => Enqueue(new TimeMultiplierInput(value)); |
Comment on lines
+6
to
+9
| public sealed record ReleaseAllKeysInput : IInputEvent; | ||
|
|
||
| /// <summary>A request to change the emulated clock time multiplier.</summary> | ||
| public sealed record TimeMultiplierInput(double Multiplier) : IInputEvent; |
kevinferrare
force-pushed
the
feature/input-event-hub
branch
from
December 2, 2026 22:49
2d8493a to
89c9201
Compare
maximilien-noal
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Replaces #2585, which was merged into
feature/reproducible-run-optionbefore review;feature/reproducible-run-optionwas restored tof94a969cb.InputEventQueue.cstoInputEventHub.csin its own commit to preserve history.InputEventHubqueuesIInputEventitems instead ofActiondelegates:KeyboardEventArgs,MouseMoveEventArgsandMouseButtonEventArgsimplement the newSpice86.Shared.Interfaces.IInputEventmarker and are queued as-is;ReleaseAllKeysInputandTimeMultiplierInputcarry the two commands.Applydispatches on the payload type.PostToEmulatorThreadandInputEventHub.KeyboardDevice, exposeIKeyboardInputEvents.AllKeysReleasedforPS2Keyboard, and route UIITimeMultiplierchanges throughInputEventHub.press_keyandsend_mouse_packet(andEmulatorMcpServices.Intel8042Controller/BiosKeyboardBuffer), moving pause-time key release directly intoSpice86DependencyInjection.input_timer_keyscatalogue scenario (AsmFixtureCatalog.InputTimerKeysReleaseAll): a CPU cycle breakpoint callsReleaseAllKeysbetween two injected keys, and the program must record1E 9E 2E(A make, A break, C make) in interpreted and generated mode. It is marked timing-dependent because the keyboard and timer interrupts leave different stale frame bytes on the stack in the two modes (0x18FF8, 0x18FFC); the scan-code oracle is checked in both. Two readability baseline rows were added tobounds.tsvthrough the tightening pass; no other rows changed.Stack
PR 3 of 4 in the input recording stack:
--ReproducibleRuncommand-line presetPR 4 will need to drop its copy of
InputEventHubTests.csand moveInputRecordingTests(which runsinput_timer_keysdirectly) into the catalogue when it is rebased.Test plan
dotnet build src/Spice86.sln: Build succeeded (0 Warning(s), 0 Error(s)).dotnet test --project tests/Spice86.Tests --no-build -- --filter-class '*AsmScenarioTest*' --filter-class '*AsmFixtureGoldenKeyTests*' --filter-class '*AsmScenarioPipelineTest*' --filter-class '*GeneratedCodeMachineTest*': Passed! total: 627, failed: 0.dotnet test --project tests/Spice86.Tests --no-build -- --filter-not-class '*SingleStepTest*': Passed! total: 8489, failed: 0, skipped: 0.Gaps
McpServerToolStateTestsalone (outside the full suite) triggers a pre-existingMachineLeakGuardassembly cleanup failure onVideoWritePixelAndReadPixel_ShouldRoundTripColorAsync(all test bodies pass; reproduced identically on the base branch, and passes cleanly in the full suite).Generated with Devin