Invert Y on the wire, not in the router: the panel keeps tracking the stick

InputRouter.InvertJoystickY flipped the stored axis, so the X/Y dot and
readout moved opposite the physical stick. The toggle now lives on
VRioDevice and negates joystick Y only while building AnalogReply: local
state keeps the physical direction for every source (pad, keys, panel
drags) and only the host sees the flip. Negating a full -8192 deflection
lands one past the 14-bit Max, so the reply clamps it to 8191.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-06 19:21:57 -05:00
co-authored by Claude Fable 5
parent 41f6ef364d
commit ce5ed1117a
5 changed files with 32 additions and 31 deletions
+2 -2
View File
@@ -190,8 +190,8 @@ internal sealed class MainForm : Form
if (!_kbInput.Checked)
_router.ReleaseAllKeys();
};
_invertY.CheckedChanged += (_, _) => _router.InvertJoystickY = _invertY.Checked;
_router.InvertJoystickY = _invertY.Checked; // the field initializer raises no event
_invertY.CheckedChanged += (_, _) => _device.InvertJoystickY = _invertY.Checked;
_device.InvertJoystickY = _invertY.Checked; // the field initializer raises no event
_kbLights.CheckedChanged += (_, _) =>
{
_lampMirror.Enabled = _kbLights.Checked;
+9
View File
@@ -57,6 +57,13 @@ public sealed class VRioDevice
/// <summary>Firmware version reported by VersionReply (real boards run 4.2).</summary>
public byte VersionMinor { get; set; } = 2;
/// <summary>
/// Negate joystick Y in AnalogReply. Only the host sees the flip — local
/// state (<see cref="GetAxis"/>, the panel's dot and readout) keeps the
/// physical stick direction.
/// </summary>
public bool InvertJoystickY { get; set; }
/// <summary>
/// When true, retry exhaustion leaves the analog reply path wedged (the
/// v4.2 latch-leak bug) until a host ResetRequest clears it.
@@ -274,6 +281,8 @@ public sealed class VRioDevice
y = _axes[(int)RioAxis.JoystickY];
x = _axes[(int)RioAxis.JoystickX];
}
if (InvertJoystickY) // clamp: -Min (8192) is one past the 14-bit Max
y = (short)Math.Min(AnalogCodec.Max, -y);
Send(PacketBuilder.AnalogReply(t, l, r, y, x));
break;
-9
View File
@@ -57,13 +57,6 @@ public sealed class InputRouter
/// <summary>A routed address went down (true) or came back up (false) — for panel highlighting.</summary>
public event Action<int, bool>? AddressHeldChanged;
/// <summary>
/// Flip the sign of the composed joystick Y before it reaches the device.
/// Applies to all routed sources (keys and pad) alike; panel drags write
/// the device directly and are unaffected.
/// </summary>
public bool InvertJoystickY { get; set; }
/// <summary>
/// The active bindings. Assigning releases everything currently held
/// (keys, toggles, pad buttons) so a reload never strands a pressed input.
@@ -223,8 +216,6 @@ public sealed class InputRouter
if (b.Rate <= 0f)
total += Shape(_pad.Axis(b.Source), b);
}
if (InvertJoystickY && axis == RioAxis.JoystickY)
total = -total;
total = ClampNorm(axis, total);
short raw = (short)Math.Round(total * RioAxisRange.Full(axis));