Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

P4: Lua io.AxisInverted always fails

Aperta Adatta ai principianti
#7,946 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp, lua
Ambito
game-dev

Direzione di ricerca

Il bug è nel controllo dell’ID del controller all’inizio di io.AxisInverted in scripting/api/libs/controls.cpp, intorno alla riga 279, e nel ciclo che cerca il binding e si ferma a JOY_REL_THROTTLE_AXIS. Inizia leggendo quella funzione e i setter delle proprietà per asse con cui dovrebbe corrispondere. Fatto significa che le tre chiamate nella riproduzione (invertire il mouse, interrogare il mouse, invertire il joystick 0) restituiscono i valori attesi e che io.HeadingAxisPrimaryInverted e io.HeadingAxisSecondaryInverted leggono true successivamente. L’issue lascia aperto se rimuovere la funzione, quindi conferma prima questa scelta con un maintainer.

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

Descrizione

bug controls LLM-suggested

This is minor: it only affects scripts, and the per-axis setters such as io.HeadingAxisPrimaryInverted work as a workaround.

Problem

The Lua function io.AxisInverted(cid, axis, inverted) never does anything. It always returns false, and setting an axis inverted through it doesn't change the binding.

The check on the controller ID at the top of the function (scripting/api/libs/controls.cpp:279) can never pass: the mouse (cid -1) fails joy < CID_JOY0, and every joystick (0 to 3) fails joy != CID_MOUSE. So the function returns its error value before it looks at any binding.

Steps to reproduce

  1. Current master (8afa31842), Debug build, Linux. MediaVPs 5.0.2, no other mods, SM1-01.
  2. By default the mouse X axis and joystick 0's X axis are bound to the heading axis.
  3. From a script, run:
    • io.AxisInverted(-1, 0, true) and then io.AxisInverted(-1, 0)
    • io.AxisInverted(0, 0, true)
  4. Read io.HeadingAxisSecondaryInverted and io.HeadingAxisPrimaryInverted.

Expected vs. actual behavior

Expected: the first call inverts the mouse binding and the second returns true; the third inverts the joystick binding. The heading axis properties then read true.

Actual: all three calls return false, and both heading properties stay false. Setting io.HeadingAxisPrimaryInverted = true directly does work, so the binding itself can be inverted.

Separately, even with the check fixed, the loop that searches for the binding stops at the relative throttle axis, so any axis action added after it would never be found.

Proposed fixes

  1. Change the check to reject only IDs that are neither the mouse nor a joystick: (joy != CID_MOUSE) && ((joy < CID_JOY0) || (joy >= CID_JOY_MAX)).
  2. Same as 1, and loop up to JOY_AXIS_END instead of JOY_REL_THROTTLE_AXIS, so every axis action is searched.
  3. Remove AxisInverted in favor of the per-action properties, if no script relies on it.
Lingua principale
C++
Stelle
488
Fork
184
Merge medio
1g 19h
PR unite (30g)
33

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 scp-fs2open/fs2open.github.com

Tutte le issue di scp-fs2open/fs2open.github.com

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.