A13: Gamepad and accessibility

Gamepad: PadInput reads pad events in one fixed layout (sticks move and
look, triggers aim and fire, bumpers step slots and build pieces, Start
pauses), fed through ClientInput alongside the keys and mouse. Menus take
South to choose and East or Start to go back. The tutorial names pad
buttons once the pad is used.

Aim assist (option, on by default, pad only): friction across an
opponent in plain sight near the look, and a pull of at most 9 deg/s
while aiming. Client look only; never through cover.

Accessibility (new Access tab): colour-vision sets for the signal colours
(red-green, blue-yellow), checked by simulated colour vision in
test_palette; interface size 90-130%, with the HUD hotbar refitting at the
larger sizes; captions for key sounds with direction; reduce motion
(calmer aim zoom and hurt flash).

Tests for the pad, aim assist, captions, palettes, settings, the menus
driven from a pad, and a pad playing through a real offline session.
make access-captures renders the new screens and options.

Closes #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 08:53:30 -05:00
co-authored by Claude Opus 5.5
parent dbe1ef923a
commit 8142e39ab3
48 changed files with 1627 additions and 49 deletions
+35 -1
View File
@@ -10,6 +10,8 @@ const MIN_SENSITIVITY: float = 0.05
const MAX_SENSITIVITY: float = 10.0
## Looking straight up or down flips the camera basis, so stop just short.
const PITCH_LIMIT: float = deg_to_rad(85.0)
const MIN_PAD_SENSITIVITY: float = 0.2
const MAX_PAD_SENSITIVITY: float = 3.0
var mouse_sensitivity: float = 1.0:
set(value):
@@ -19,6 +21,12 @@ var aim_sensitivity_scale: float = 0.6:
set(value):
aim_sensitivity_scale = clampf(value, 0.1, 2.0)
var invert_y: bool = false
## The gamepad's right stick, against PadInput.LOOK_RADIANS_PER_SECOND (A13).
var pad_sensitivity: float = 1.0:
set(value):
pad_sensitivity = clampf(value, MIN_PAD_SENSITIVITY, MAX_PAD_SENSITIVITY)
## Aim assist for the gamepad (AimAssist). Never applies to the mouse.
var aim_assist: bool = true
## Applies a mouse motion to a look direction. Returns Vector2(yaw, pitch) in radians.
@@ -33,13 +41,33 @@ func apply_mouse(relative: Vector2, yaw: float, pitch: float, aiming: bool) -> V
return Vector2(new_yaw, new_pitch)
## Applies `delta` seconds of the right stick (PadInput.look(): x right, y down) to a
## look direction, slowed by `friction` (AimAssist). Returns Vector2(yaw, pitch).
## Pushing right turns right and pushing up looks up, unless invert_y is set.
func apply_stick(stick: Vector2, yaw: float, pitch: float, aiming: bool, delta: float, friction: float = 1.0) -> Vector2:
var scale: float = PadInput.LOOK_RADIANS_PER_SECOND * pad_sensitivity * delta * friction
if aiming:
scale *= aim_sensitivity_scale
var vertical: float = stick.y if invert_y else -stick.y
var new_yaw: float = fposmod(yaw - stick.x * scale, TAU)
var new_pitch: float = clampf(pitch + vertical * scale, -PITCH_LIMIT, PITCH_LIMIT)
return Vector2(new_yaw, new_pitch)
func save(path: String = DEFAULT_PATH) -> Error:
var config: ConfigFile = ConfigFile.new()
config.load(path) # Keep other sections; a missing file is fine.
write(config)
return config.save(path)
## Writes these settings into `config`'s input section.
func write(config: ConfigFile) -> void:
config.set_value(SECTION, "mouse_sensitivity", mouse_sensitivity)
config.set_value(SECTION, "aim_sensitivity_scale", aim_sensitivity_scale)
config.set_value(SECTION, "invert_y", invert_y)
return config.save(path)
config.set_value(SECTION, "pad_sensitivity", pad_sensitivity)
config.set_value(SECTION, "aim_assist", aim_assist)
## Loads saved settings. Missing or malformed values keep their defaults.
@@ -57,4 +85,10 @@ static func load_from(path: String = DEFAULT_PATH) -> InputSettings:
var invert: Variant = config.get_value(SECTION, "invert_y", false)
if invert is bool:
settings.invert_y = invert
var pad: Variant = config.get_value(SECTION, "pad_sensitivity", 1.0)
if (pad is float and is_finite(pad)) or pad is int:
settings.pad_sensitivity = float(pad)
var assist: Variant = config.get_value(SECTION, "aim_assist", true)
if assist is bool:
settings.aim_assist = assist
return settings