Keyboard turning ramps to full over KeyboardTurnRampTime (0.4 s) so a tap feathers the turn; analog turn passes straight through

Release or reversal starts the ramp again from zero (operator request, 2026-10-29: the Longinus lurches).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-29 08:07:30 +01:00
commit 5e2a9efc8a
2 changed files with 16 additions and 1 deletions

View file

@ -13,6 +13,17 @@ public class HelmInput
public void Toggle() => Latched = !Latched;
private float _turnAxis;
// The turn axis as the helm reads it. A digital input (keys) ramps from zero to full over rampTime so a tap feathers the
// turn; releasing it, or reversing, starts again from zero. An analog input passes straight through.
public float TurnAxis(float raw, bool digital, float dt, float rampTime)
{
if (!digital || rampTime <= 0 || raw == 0) return _turnAxis = raw;
if (sign(raw) != sign(_turnAxis)) _turnAxis = 0;
return _turnAxis = sign(raw) * min(abs(raw), abs(_turnAxis) + dt / rampTime);
}
// The turn the player commands: the aim heading, resolved against the hull at each sim step, or the turn axis.
public TurnCommand Demand(float2 aim, float turnAxis) =>
FaceAim ? TurnCommand.Toward(aim) : TurnCommand.OfRate(clamp(turnAxis, -1f, 1f));