Wire the Core pieces into a runnable tray app with per-game profiles and the three-state serial-yield auto-switch: - Profiles/: RioProfile + AppConfig model; ConfigStore (System.Text.Json, round-tripped); RioIniImporter ports the legacy RIO.ini (button table, invert flags, plasma greeting); AutoSwitchResolver + AutoSwitchWatcher resolve the foreground executable into Yield (native game) / Activate (profile) / Idle, with native always winning and change-only notifications. IForegroundProcessProvider abstracts the OS. - RioRuntime assembles a profile's live pipeline: serial ButtonPressed/Released + KeyPressed/Released → InputRouter (via RioAddress); AnalogReply → AxisCalibrator → the six joystick axes; RIO commands → calibration resets + version/check requests + lamp re-init. SerialLampSink sends lamp feedback over the link; NullJoystickSink is a placeholder until the Phase 1 HID feeder exists. - RioJoy.Tray: NotifyIcon menu mirroring the legacy console menu (axis resets, version/status, raw-axes & poll-rate toggles, quit) + profile selection (auto vs. manual) + "start with Windows"; RioCoordinator owns the serial acquire/release tied to the watcher (native-game COM-port yield). OS adapters: ForegroundProcessProvider (Win32 foreground PID→exe) and AutoStartManager (HKCU Run key). - tests: 18 new xUnit tests (123 total) for config round-trip, ini import, the three-state resolver + watcher, and RioRuntime end-to-end over the fake transport (button→joystick, keypad-offset→keyboard, analog→six axes). The joystick output stays a no-op until the Phase 1 driver; on-cabinet verification of the acquire/release lifecycle remains. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using RioJoy.Core.Profiles;
|
|
using Xunit;
|
|
|
|
namespace RioJoy.Core.Tests.Profiles;
|
|
|
|
public class RioIniImporterTests
|
|
{
|
|
private const string Sample = """
|
|
[Plasma]
|
|
Greeting = RIOvJoy2 v.03
|
|
|
|
[Desktop]
|
|
File = C:\games\RIO\VWE2.bmp
|
|
|
|
[JoyStick]
|
|
invertX = false
|
|
invertY = true
|
|
enableZR = false
|
|
|
|
; comment line
|
|
[Buttons]
|
|
RIO00 = 0x8049
|
|
RIO01 = 0x805A
|
|
RIO16 = 0x0
|
|
RIO50 = 33353
|
|
""";
|
|
|
|
[Fact]
|
|
public void Imports_ButtonsAsAddresses()
|
|
{
|
|
RioProfile p = RioIniImporter.Import(Sample, "VWE2");
|
|
|
|
Assert.Equal("VWE2", p.Name);
|
|
Assert.Equal(0x8049, p.Buttons[0x00]);
|
|
Assert.Equal(0x805A, p.Buttons[0x01]);
|
|
Assert.Equal(33353, p.Buttons[0x50]); // keypad-0 address, decimal value
|
|
Assert.False(p.Buttons.ContainsKey(0x16)); // 0x0 entries are skipped
|
|
}
|
|
|
|
[Fact]
|
|
public void Imports_PlasmaAndCalibration()
|
|
{
|
|
RioProfile p = RioIniImporter.Import(Sample);
|
|
|
|
Assert.Equal("RIOvJoy2 v.03", p.PlasmaGreeting);
|
|
Assert.Equal(@"C:\games\RIO\VWE2.bmp", p.WallpaperPath);
|
|
Assert.False(p.Calibration.InvertX);
|
|
Assert.True(p.Calibration.InvertY);
|
|
Assert.False(p.Calibration.EnableZR);
|
|
}
|
|
|
|
[Fact]
|
|
public void EnableZR_DefaultsTrue_WhenAbsent()
|
|
{
|
|
RioProfile p = RioIniImporter.Import("[JoyStick]\ninvertX = true");
|
|
Assert.True(p.Calibration.EnableZR);
|
|
}
|
|
}
|