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:
@@ -191,26 +191,6 @@ public class InputRouterTests
|
||||
Assert.Equal(0, _device.GetAxis(RioAxis.JoystickY));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvertJoystickY_flips_the_composed_value_for_all_sources()
|
||||
{
|
||||
UseProfile("key Up axis JoystickY deflect 1\npadaxis LeftStickY axis JoystickY");
|
||||
_router.InvertJoystickY = true;
|
||||
|
||||
_router.KeyDown("Up");
|
||||
_router.Tick(0.016);
|
||||
Assert.Equal(-RioAxisRange.JoystickExtent, _device.GetAxis(RioAxis.JoystickY));
|
||||
_router.KeyUp("Up");
|
||||
|
||||
_router.SetPadState(new PadState(PadButtons.None, 0, 0.5f, 0, 0, 0, 0));
|
||||
_router.Tick(0.016);
|
||||
Assert.Equal(-RioAxisRange.JoystickExtent / 2, _device.GetAxis(RioAxis.JoystickY));
|
||||
|
||||
_router.InvertJoystickY = false; // toggling back re-sends the upright value
|
||||
_router.Tick(0.016);
|
||||
Assert.Equal(RioAxisRange.JoystickExtent / 2, _device.GetAxis(RioAxis.JoystickY));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rate_key_walks_the_throttle_and_position_sticks()
|
||||
{
|
||||
|
||||
@@ -66,6 +66,27 @@ public class VRioDeviceTests
|
||||
Assert.Equal(1, device.AnalogRequests);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvertJoystickY_flips_the_wire_but_not_local_state()
|
||||
{
|
||||
var device = new VRioDevice { InvertJoystickY = true };
|
||||
var wire = new Wire(device);
|
||||
device.SetAxis(RioAxis.JoystickY, 3000);
|
||||
|
||||
Send(device, PacketBuilder.Build(RioCommand.AnalogRequest));
|
||||
|
||||
byte[] p = Assert.Single(wire.Packets).Payload;
|
||||
Assert.Equal(-3000, AnalogCodec.Combine(p[6], p[7]));
|
||||
Assert.Equal(3000, device.GetAxis(RioAxis.JoystickY)); // the panel's view is unflipped
|
||||
|
||||
// Full negative deflection: -Min is one past Max, so it clamps rather than throws.
|
||||
device.SetAxis(RioAxis.JoystickY, AnalogCodec.Min);
|
||||
wire.Clear();
|
||||
Send(device, PacketBuilder.Build(RioCommand.AnalogRequest));
|
||||
p = Assert.Single(wire.Packets).Payload;
|
||||
Assert.Equal(AnalogCodec.Max, AnalogCodec.Combine(p[6], p[7]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VersionRequest_reports_configured_firmware()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user