HLE: write at-rest gamepad state for non-pad readings #574

Open
Quat3rnion wants to merge 1 commit from upstream-pr/574 into main
Quat3rnion commented 2026-11-24 05:10:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T05:10:27Z.


What

IGameInputReading::GetGamepadState must write default at-rest values and
return false when the reading has no gamepad. The shim returned false
without touching the caller's buffer, so a title reusing one PadState
could keep a held button or displaced stick after switching to keyboard
input. The state is now written in both cases; pad readings still write
their real state and return true.

An AI tool wrote part of this change.

Tested

  • Linux: cargo test --workspace: 165 passed, 0 failed, 3 ignored. A regression seeds a PadState with pressed buttons and moved sticks, calls slot 0xb0 on a keyboard reading, and asserts both false and PadState::default().
  • Windows cross-build: cargo check --target x86_64-pc-windows-gnu --workspace --tests passes. No Windows host here.
  • cargo xtask policy passes (150 files ok). No game files or data from them were added.

Checklist

  • Workspace tests and Windows cross-check pass.
  • cargo xtask policy passes. No game files or data from them were added.
  • AI authorship is disclosed above.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5466500182 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/574). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-24T05:10:27Z. --- ## What `IGameInputReading::GetGamepadState` must write default at-rest values and return `false` when the reading has no gamepad. The shim returned `false` without touching the caller's buffer, so a title reusing one `PadState` could keep a held button or displaced stick after switching to keyboard input. The state is now written in both cases; pad readings still write their real state and return `true`. An AI tool wrote part of this change. ## Tested - Linux: `cargo test --workspace`: 165 passed, 0 failed, 3 ignored. A regression seeds a `PadState` with pressed buttons and moved sticks, calls slot `0xb0` on a keyboard reading, and asserts both `false` and `PadState::default()`. - Windows cross-build: `cargo check --target x86_64-pc-windows-gnu --workspace --tests` passes. No Windows host here. - `cargo xtask policy` passes (150 files ok). No game files or data from them were added. ## Checklist - [x] Workspace tests and Windows cross-check pass. - [x] `cargo xtask policy` passes. No game files or data from them were added. - [x] AI authorship is disclosed above.
mercuryVM commented 2026-11-24 08:30:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:30:36Z.

Review: APPROVED


Tested c70c478 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed), including a_keyboard_reading_resets_the_gamepad_state_it_is_given.

IGameInputReading::GetGamepadState fills the struct with at-rest values and returns false when the reading has no gamepad, so writing PadState::default() there matches it. A title that reuses its buffer can no longer keep a stale held button. A null out still returns false without writing.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035942114 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/574#pullrequestreview-6035942114). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T08:30:36Z. **Review:** APPROVED --- Tested c70c478 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed), including `a_keyboard_reading_resets_the_gamepad_state_it_is_given`. `IGameInputReading::GetGamepadState` fills the struct with at-rest values and returns `false` when the reading has no gamepad, so writing `PadState::default()` there matches it. A title that reuses its buffer can no longer keep a stale held button. A null `out` still returns `false` without writing. No issues found. AI-assisted (Claude Code).
geiyiliyabumo commented 2026-11-24 13:02:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T12:21:07Z.


Independent verification & code review on Windows 11 x64 MSVC (merged onto main ffe310e):

Checks Run

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-hle --locked -- gameinput: PASS (8/8 tests, including a_keyboard_reading_resets_the_gamepad_state_it_is_given)

Review

Looks clean and ready to merge — gamepad_state properly guards out.is_null(), writes PadState::default() on non-pad readings so reused caller buffers don't retain stale buttons/axes, and returns false (or writes real state and returns true for Value::Pad).

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7131317317 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/574#issuecomment-7131317317). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T12:21:07Z. --- Independent verification & code review on Windows 11 x64 MSVC (merged onto `main` `ffe310e`): ### Checks Run - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-hle --locked -- gameinput`: **PASS** (`8/8` tests, including `a_keyboard_reading_resets_the_gamepad_state_it_is_given`) ### Review Looks clean and ready to merge — `gamepad_state` properly guards `out.is_null()`, writes `PadState::default()` on non-pad readings so reused caller buffers don't retain stale buttons/axes, and returns `false` (or writes real state and returns `true` for `Value::Pad`). *AI-assisted; synthetic tests only, no game files.*
Marvisak commented 2026-11-25 02:05:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:16:42Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-hle/src/modules/gameinput.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149384355 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/574#issuecomment-7149384355). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:16:42Z. --- <!-- victory-triage v1 head=253b9db4a8f3fee57be96e3e224f337480b0b9a8 verdict=needs-rebase at=2026-11-25T01:16:41Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-hle/src/modules/gameinput.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/574:upstream-pr/574'
git switch 'upstream-pr/574'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/574'
git switch 'upstream-pr/574'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/574'
git switch 'upstream-pr/574'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/574'
git switch 'main'
git merge --squash 'upstream-pr/574'
git switch 'main'
git merge --ff-only 'upstream-pr/574'
git switch 'main'
git merge 'upstream-pr/574'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!574
No description provided.