A released stick can stay deflected while the game is unfocused, when it settles just past a noisy rest value

Aperta
#3,815 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
game-dev

Direzione di ricerca

Start by reading the WinForms BackgroundInputFilter and SDL's SDL_PrivateJoystickShouldIgnoreEvent, then trace how each backend records an axis rest value and filters background input. Compare their handling of XInput readings near rest and the dead zone. Done means a released stick settles at rest while unfocused and both backends behave consistently.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area-Input bug
Stride version

master (after #3803)

Platforms

Windows (XInput through the WinForms backend, and the SDL backend)

Graphics API

(leave empty)

What happens

While the game window has no focus, controller input follows SDL's rules (BackgroundInputFilter on the WinForms backend since #3803; SDL_PrivateJoystickShouldIgnoreEvent in SDL): an axis can only move towards its rest value, and the rest value is the first value read from the device.

XInput applies no dead zone, so that first value is a raw reading with some noise, not exactly 0. SDL's XInput driver also passes the raw values through (SDL_xinputjoystick.c). When a stick is released while the game is in the background and settles just past its rest value, on the other side from where it was pushed, that reading moves away from rest and is ignored, and so is every later reading on that side. The stick keeps its last accepted value, which can be far from centre, until the game has focus again. An unfocused game updates at 15 Hz by default (TreatNotFocusedLikeMinimized), so the last accepted value can be well away from centre, and a character can keep moving.

Expected: a released stick reads as at rest while the game is unfocused, on both backends.

Steps to reproduce
  1. Run a game on Windows with an XInput pad.
  2. Push a stick fully to one side, alt-tab away, then let the stick go.
  3. Depending on where it settles, the stick reads near its pushed value until focus returns, instead of near 0.
Log and callstack

None.

Screenshots and other details

Raised in the review of #3803. Accepting any value within XInput's dead zone of rest lets small movements through while unfocused, which SDL does not do. Settling values within the dead zone at the rest value would avoid both problems. It should be done for the WinForms and SDL backends together, so they keep the same behaviour.

Lingua principale
C#
Stelle
8k
Fork
1.2k
Merge medio
2g 7h
PR unite (30g)
316

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stride3d/stride

Tutte le issue di stride3d/stride

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.