Files
riojoy/tests/RioJoy.Core.Tests/Editing/CockpitPanelTests.cs
T
CydandClaude Opus 4.8 094637b0a4 Editor: rework to the original Win32 RIO control-panel layout
Reworked the profile/mapping editor to mirror the original unfinished Win32
RIO driver's control-panel design (docs/Win32RIO, by FASA / Michel Lowrance)
instead of the flat config-sheet grid. The wallpaper region positions are a
VGA chroma-split display artifact, not the cockpit's logical shape.

- RioJoy.Core.Editing.CockpitPanel: the functional layout — five MFD clusters,
  four board columns (Throttle/Secondary/Screen/Joystick-Hat), an encoder-gauge
  strip, and the two later-added 4x4 keypads (Internal/External). Places every
  address 0x00-0x47 / 0x50-0x6F exactly once (unit-tested).
- Tray PanelView/PanelCanvas render the panel; ProfileEditorForm drives it.
  Buttons show label + assigned function (ButtonBinding.Describe -> CTL-N, JOY1,
  POV-U, Mse LB, RIO command names; unit-tested). Lamp shade is driven by the
  IsLit flag (not by whether a function is assigned); keypads are neutral blue
  with no Lit checkbox. Added an Unassign button next to Apply.
- Removed the superseded sheet-grid UI (SheetView/SheetCanvas); SheetLayout +
  config-sheet.csv stay as reference data.

docs/Win32RIO: the original driver (tasgame.sys, a 32-bit kernel HID minidriver
that opened the serial port, set baud/8N1/DTR, and spoke the *identical* RIO
protocol -- AnalogRequest/Reply, Button Pressed/Released, Check/Lamp/Reset/
Version -- validating our protocol port), oemsetup.inf, RemoteDriver.doc, and the
extracted control-panel / game-controllers mockups.

~236 xUnit tests green. PLAN.md updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 19:48:14 -05:00

69 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using RioJoy.Core.Editing;
using RioJoy.Core.Mapping;
using Xunit;
namespace RioJoy.Core.Tests.Editing;
public class CockpitPanelTests
{
[Fact]
public void Covers_EveryValidAddress_ExactlyOnce()
{
List<int> addrs = CockpitPanel.Buttons().Select(b => b.Address).ToList();
// 0x000x47 buttons + 0x500x6F keypads = 104 valid addresses; 0x480x4F don't exist.
var expected = Enumerable.Range(0x00, 0x48).Concat(Enumerable.Range(0x50, 0x20)).ToHashSet();
Assert.Equal(expected.Count, addrs.Count); // no duplicates / no extras
Assert.Equal(expected, addrs.ToHashSet()); // exactly the valid set
Assert.DoesNotContain(0x48, addrs); // gap excluded
}
[Theory]
[InlineData(0x2F, "Upper Left MFD")]
[InlineData(0x20, "Upper Middle MFD")]
[InlineData(0x37, "Upper Right MFD")]
[InlineData(0x00, "Lower Right MFD")]
[InlineData(0x0F, "Lower Left MFD")]
[InlineData(0x38, "Throttle")]
[InlineData(0x10, "Secondary")]
[InlineData(0x18, "Screen")]
[InlineData(0x40, "Joystick / Hat")]
[InlineData(0x50, "Internal Keypad")]
[InlineData(0x6F, "External Keypad")]
public void Address_LandsInExpectedGroup(int address, string group)
{
PanelButton b = CockpitPanel.Buttons().Single(x => x.Address == address);
Assert.Equal(group, b.Group.Title);
}
[Fact]
public void Keypads_AreNotLampCapable()
{
foreach (PanelButton b in CockpitPanel.Buttons().Where(x => x.Group.Kind == PanelGroupKind.Keypad))
Assert.False(b.LampCapable);
// ...and everything else is.
foreach (PanelButton b in CockpitPanel.Buttons().Where(x => x.Group.Kind != PanelGroupKind.Keypad))
Assert.True(b.LampCapable);
}
[Fact]
public void Keypad_PhysicalLayout_MapsDigitsToAddresses()
{
// Internal keypad: top-left "1" -> 0x51, bottom-middle "0" -> 0x50, "C" -> 0x5C.
IReadOnlyList<PanelButton> all = CockpitPanel.Buttons();
PanelGroup pad = CockpitPanel.Groups.Single(g => g.Title == "Internal Keypad");
Assert.Equal(0x51, pad.Addresses[0]); // row0 col0 = "1"
Assert.Equal(0x5C, pad.Addresses[3]); // row0 col3 = "C"
Assert.Equal(0x50, pad.Addresses[13]); // row3 col1 = "0"
Assert.Equal(0x5F, pad.Addresses[15]); // row3 col3 = "F"
}
[Fact]
public void AllAddresses_AreValidRioAddresses()
{
foreach (PanelButton b in CockpitPanel.Buttons())
Assert.InRange(b.Address, 0, RioAddress.MaxAddress);
}
}