Skip to content

Input: controller input keeps the display and the PC awake, as keyboard and mouse do (#893) - #921

Open
xiepeixuan wants to merge 1 commit into
trustno1-coder:mainfrom
xiepeixuan:codex/controller-display-idle
Open

xiepeixuan wants to merge 1 commit into
trustno1-coder:mainfrom
xiepeixuan:codex/controller-display-idle

Conversation

@xiepeixuan

@xiepeixuan xiepeixuan commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #893 (the display sleeping); the Game Bar part is not addressed.

What it changes

Windows can reach its display or system idle timeout while the player is using only a controller. Here GameInput polls XInput and reads PlayStation HID reports directly, then passes snapshots to the title; that path does not tell Windows to reset the idle timers as keyboard and mouse activity do. This fits the report that moving the mouse restores the screen while the title is still presenting.

In the Windows Host::pad refresh of the merged XInput/PlayStation snapshot, check all physical slots before adding VICTORY_KEYS buttons. A button, a trigger above the XInput threshold (30), or a stick outside its radial dead zone (7849 left, 8689 right) counts as activity. The thresholds are converted to the existing normalized PadState units; they are only used for the idle decision and never filter the values passed to the title.

Reuse the keyboard's foreground check and send a single SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) at most once per second across the four slots. Without ES_CONTINUOUS, Windows resets the idle timers rather than holding a request. The title's own deferrals already go through display.rs, which is unchanged. This does not add a switch, change the power plan, or keep the PC awake once nobody is using the controller.

Uses audit

Checked use Effect
Host::pad from Hub::poll One check when slot zero refreshes the shared snapshot, including when slot zero is empty but another slot is active. Other slots return the same cached readings. Hub::start still does its initial poll and starts the same poll thread.
Source::pad from single-pad set_rumble Its existing enumeration can also observe physical input at slot zero. It shares the same timer and focus gate; a rumble command itself is not activity. The connected-slot test, motor levels, routing and multi-pad path are unchanged. Fake and non-Windows sources are unchanged.
host(), Host::default, and HUB The single shared Windows host starts with no previous reset. The existing source mutex protects the same snapshot and the new timestamp for both callers.
Host::pads, hid_slots, Host::xinput, convert, and playstation::{mode, slots, pads} Device polling, XInput precedence, HID slot assignment, and rumble ownership do not change. The idle check reads the merged snapshot without mutating it. convert, the HID parser, pad merging, the keyboard stand-in, reading history, and the gamepad_state ABI keep the same PadState values.
focused, scripted, and FALLBACK_BUTTONS The keyboard path calls the same helpers and keeps the same behavior. Slot zero still gets the same scripted buttons only when it has a physical pad, but only after the activity check. The stand-in keyboard pad still uses the same mapping.
pad_active, PadActivity::first_pad, last_reset, and reset_idle_timers New private uses only: the activity helper supplies the one Windows call site, and tests inject the clock, focus, script and reset callbacks.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): No in-game run; Windows unit tests only.

  • Before: 26 passed, 0 failed on 63b902fe.

  • After: 30 passed, 0 failed on 16c09473.

  • cargo test passed for the crates it touches: Yes — cargo test -p victory-hle --lib gameinput.

  • Windows workspace check: cargo check --workspace --locked passed on 16c09473e1d588e71fd38f2360a57c5961a0289b. Fork Windows job

  • Windows GameInput tests: cargo test -p victory-hle --lib gameinput passed: 30 passed, 0 failed, versus 26 passed, 0 failed on upstream 63b902fe in the same workflow. The four new tests cover the shared one-second limit, inactive input and normalized threshold boundaries, foreground gating, and scripted buttons.

  • Full Windows CI: the fork run stops at the same two Clippy errors as upstream main (see CI: the rest of main's clippy findings, so that with #1517 and #1459 both builds are clean #665), with no new diagnostics. The later all-features Clippy and workspace-test steps are skipped as on main.

    • clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768:9
    • clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708:32

The fork workflow was triggered separately, but both topic jobs checked out and asserted the exact PR SHA above. No workflow changes or workspace-wide formatting are included in this PR.

Checked for overlap

AI-assisted (Codex). Not run in the game here.

MystifiedSky added a commit to MystifiedSky/VIctory-NVIDIA-Improved that referenced this pull request Nov 28, 2026
@xiepeixuan
xiepeixuan marked this pull request as ready for review November 28, 2026 09:10

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests: cargo test -p victory-hle --lib gameinput passed (30 passed; 0 failed; 1 ignored, including all 4 new idle-reset tests: scripted_buttons_are_delivered_without_resetting_idle, a_background_pad_does_not_reset_idle_or_delay_the_first_foreground_reset, pad_idle_reset_uses_normalized_xinput_thresholds, and all_physical_pad_slots_share_one_idle_reset_per_second) with 0 compiler warnings.

Well-scoped QoL fix keeping the display awake on active foreground controller input without triggering from background or scripted inputs. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@xiepeixuan xiepeixuan changed the title Input: controller input keeps the display and the PC awake, as keyboard and mouse do (#893) [pr-fix][input] Input: controller input keeps the display and the PC awake, as keyboard and mouse do (#893) Nov 28, 2026
@github-actions github-actions Bot added input Keyboard, mouse or controller pr-fix Pull request: fixes a bug labels Nov 28, 2026
@github-actions github-actions Bot changed the title [pr-fix][input] Input: controller input keeps the display and the PC awake, as keyboard and mouse do (#893) Input: controller input keeps the display and the PC awake, as keyboard and mouse do (#893) Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

input Keyboard, mouse or controller pr-fix Pull request: fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants