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
+83 -4
View File
@@ -1,10 +1,11 @@
## The game's menus (A10), in the paper-and-ink motifs of docs/STYLE.md: the welcome
## that offers the tutorial on the first launch (A12), the main menu, practice against bots, joining a server (with the LAN and list-server browser),
## settings (controls, mouse, graphics, audio, display), the pause menu and the results.
## settings (controls, mouse, gamepad, graphics, audio, display, accessibility), the pause menu and the results.
##
## Menus only edit `settings` and say what the player asked for through signals; the
## program (Main) starts and leaves matches. Every screen can be driven from the
## keyboard: each grabs focus on its first control when shown, and Escape goes back.
## keyboard or a gamepad: each grabs focus on its first control when shown, the arrows
## or the D-pad move it, and Escape, or East or Start on the pad, goes back (A13).
## show_screen() and the buttons' `pressed` signals are what the UI test drives.
class_name Menus
extends Control
@@ -62,6 +63,12 @@ var _volumes: Dictionary = {}
var _window_mode: OptionButton
var _vsync: CheckButton
var _max_fps: OptionButton
var _pad_speed: HSlider
var _aim_assist: CheckButton
var _vision: OptionButton
var _ui_scale: OptionButton
var _captions: CheckButton
var _reduce_motion: CheckButton
## Results.
var _results_title: Label
var _results_body: Label
@@ -79,6 +86,7 @@ var over_match: bool = false:
func _init() -> void:
name = "Menus"
PadInput.install_menu_actions()
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
theme = MenuTheme.make()
backdrop = MenuBackdrop.new()
@@ -208,7 +216,11 @@ func _unhandled_input(event: InputEvent) -> void:
return
if not listening_for.is_empty():
var code: int = KeyBindings.code_of_event(event)
if code == KEY_ESCAPE:
var pad: InputEventJoypadButton = event as InputEventJoypadButton
if pad != null and pad.pressed and (pad.button_index == JOY_BUTTON_B or pad.button_index == JOY_BUTTON_START):
back()
get_viewport().set_input_as_handled()
elif code == KEY_ESCAPE:
back()
get_viewport().set_input_as_handled()
elif code != 0:
@@ -497,6 +509,7 @@ func _build_settings() -> void:
var controls_scroll: ScrollContainer = ScrollContainer.new()
controls_scroll.name = "Controls"
controls_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
controls_scroll.follow_focus = true
_tabs.add_child(controls_scroll)
var controls: VBoxContainer = VBoxContainer.new()
controls.size_flags_horizontal = Control.SIZE_EXPAND_FILL
@@ -527,6 +540,38 @@ func _build_settings() -> void:
_invert.toggled.connect(func(on: bool) -> void: settings.mouse.invert_y = on)
_row(mouse, "Invert up and down", _invert)
var pad_scroll: ScrollContainer = ScrollContainer.new()
pad_scroll.name = "Gamepad"
pad_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
pad_scroll.follow_focus = true
_tabs.add_child(pad_scroll)
var pad_tab: VBoxContainer = VBoxContainer.new()
pad_tab.size_flags_horizontal = Control.SIZE_EXPAND_FILL
pad_tab.add_theme_constant_override("separation", 10)
pad_scroll.add_child(pad_tab)
_pad_speed = _slider(InputSettings.MIN_PAD_SENSITIVITY, InputSettings.MAX_PAD_SENSITIVITY, 0.05)
_pad_speed.value_changed.connect(func(value: float) -> void: settings.mouse.pad_sensitivity = value)
_slider_row(pad_tab, "Stick look speed", _pad_speed)
_aim_assist = CheckButton.new()
_aim_assist.toggled.connect(func(on: bool) -> void: settings.mouse.aim_assist = on)
_row(pad_tab, "Aim assist", _aim_assist)
var assist_note: Label = _note(pad_tab)
assist_note.text = "Aim assist slows the stick across an opponent in plain sight and, while aiming, eases towards them. It never acts on the mouse. Speed while aiming and Invert (Mouse tab) apply to the stick too."
# The layout in two columns of what and which.
var layout: GridContainer = GridContainer.new()
layout.columns = 4
layout.add_theme_constant_override("h_separation", 14)
layout.add_theme_constant_override("v_separation", 2)
pad_tab.add_child(layout)
for pair: Array in PadInput.LAYOUT:
for index: int in 2:
var cell: Label = Label.new()
cell.text = String(pair[index])
cell.add_theme_font_size_override("font_size", FONT_SMALL)
if index == 1:
cell.add_theme_color_override("font_color", Palette.GILT_DEEP)
layout.add_child(cell)
var graphics: VBoxContainer = _tab("Graphics")
_quality = OptionButton.new()
for index: int in GameSettings.QUALITY_NAMES.size():
@@ -560,6 +605,34 @@ func _build_settings() -> void:
_max_fps.item_selected.connect(func(index: int) -> void: settings.max_fps = GameSettings.FRAME_CAPS[index])
_row(display, "Frame limit", _max_fps)
var access: VBoxContainer = _tab("Access")
_vision = OptionButton.new()
for index: int in Palette.VISION_NAMES.size():
_vision.add_item(Palette.VISION_NAMES[index], index)
_vision.item_selected.connect(func(index: int) -> void:
settings.vision = index
save_settings())
_row(access, "Colour vision", _vision)
_ui_scale = OptionButton.new()
for index: int in GameSettings.UI_SCALES.size():
_ui_scale.add_item("%d%%" % roundi(GameSettings.UI_SCALES[index] * 100.0), index)
_ui_scale.item_selected.connect(func(index: int) -> void:
settings.ui_scale = GameSettings.UI_SCALES[index]
save_settings())
_row(access, "Interface size", _ui_scale)
_captions = CheckButton.new()
_captions.toggled.connect(func(on: bool) -> void:
settings.captions = on
save_settings())
_row(access, "Captions for sounds", _captions)
_reduce_motion = CheckButton.new()
_reduce_motion.toggled.connect(func(on: bool) -> void:
settings.reduce_motion = on
save_settings())
_row(access, "Reduce motion", _reduce_motion)
var access_note: Label = _note(access)
access_note.text = "Colour vision changes the build preview, danger marks and your own marks to colours told apart with that kind of colour blindness. Captions name the sounds that matter (the tide, gunfire, footsteps, building) and which way they came from. Reduce motion makes the zoom when aiming smaller and slower and the flash when you're hurt gentler."
_binding_note = _note(column)
_binding_note.text = "Choose an action to change its key."
_tabs.tab_changed.connect(func(tab: int) -> void: _binding_note.visible = tab == 0)
@@ -626,7 +699,13 @@ func _refresh_controls() -> void:
_window_mode.selected = settings.window_mode
_vsync.set_pressed_no_signal(settings.vsync)
_max_fps.selected = maxi(GameSettings.FRAME_CAPS.find(settings.max_fps), 0)
for slider: HSlider in [_sensitivity, _aim_scale, _volumes["master"], _volumes["music"], _volumes["effects"]]:
_pad_speed.set_value_no_signal(settings.mouse.pad_sensitivity)
_aim_assist.set_pressed_no_signal(settings.mouse.aim_assist)
_vision.selected = settings.vision
_ui_scale.selected = maxi(GameSettings.UI_SCALES.find(settings.ui_scale), 0)
_captions.set_pressed_no_signal(settings.captions)
_reduce_motion.set_pressed_no_signal(settings.reduce_motion)
for slider: HSlider in [_sensitivity, _aim_scale, _pad_speed, _volumes["master"], _volumes["music"], _volumes["effects"]]:
(slider.get_meta("readout") as Callable).call(slider.value)
_refresh_bindings()