Files
CydandClaude Fable 5 e60d551f39 Phase 7: live encoder gauges in the profile editor
RioRuntime raises AxesUpdated with the calibrated AxisOutputs after every
analog reply (independent of the joystick sink, so the gauges work while
editor input routing is suppressed). The editor strip now renders the
values live: Z and the L/R pedals (Rx/Ry) fill bottom-up, Rz deflects
from a center tick, and the X/Y box tracks the stick as a dot over a
crosshair. Fraction/deflection math is pure in Core.Editing.AxisGauges
(clamped, unit-tested); the canvas repaints only the strip and only on
change. Verified by offline form screenshots against injected values.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 09:37:29 -05:00

33 lines
1.1 KiB
C#

using RioJoy.Core.Calibration;
using RioJoy.Core.Editing;
using Xunit;
namespace RioJoy.Core.Tests.Editing;
public class AxisGaugesTests
{
[Theory]
[InlineData(0, 0.0)]
[InlineData(AxisOutputs.Max, 1.0)]
[InlineData(-500, 0.0)] // clamps below range
[InlineData(AxisOutputs.Max + 500, 1.0)] // clamps above range
public void Fraction_MapsAndClamps(int value, double expected) =>
Assert.Equal(expected, AxisGauges.Fraction(value), precision: 6);
[Fact]
public void Fraction_Center_IsHalf() =>
Assert.Equal(0.5, AxisGauges.Fraction(AxisOutputs.Center), precision: 3);
[Theory]
[InlineData(AxisOutputs.Center, 0.0)]
[InlineData(0, -1.0)]
[InlineData(-500, -1.0)] // clamps below range
[InlineData(AxisOutputs.Max + 500, 1.0)] // clamps above range
public void Deflection_MapsAndClamps(int value, double expected) =>
Assert.Equal(expected, AxisGauges.Deflection(value), precision: 6);
[Fact]
public void Deflection_Max_IsFullRight() =>
Assert.Equal(1.0, AxisGauges.Deflection(AxisOutputs.Max), precision: 3);
}