Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

P4: Lua io.AxisInverted always fails

オープン 初心者向け
#7,946 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, lua
領域
game-dev

調査の方向性

バグは、scripting/api/libs/controls.cpp の io.AxisInverted 冒頭、279 行目付近にあるコントローラー ID のチェックと、バインディングを検索して JOY_REL_THROTTLE_AXIS で停止するループにあります。まず、その関数と、それが一致すべき軸ごとのプロパティ setter を読んでください。完了とは、再現手順の 3 つの呼び出し(マウスの反転、マウスの問い合わせ、ジョイスティック 0 の反転)が期待値を返し、その後 io.HeadingAxisPrimaryInverted と io.HeadingAxisSecondaryInverted が true を読むことです。この issue は関数を削除するかどうかを未決定のままにしているので、その選択を先に maintainer と確認してください。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
C++
スター
488
フォーク
184
平均マージ
1日 19時間
マージ済み PR(30日)
33

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

scp-fs2open/fs2open.github.com のほかの issue

scp-fs2open/fs2open.github.com の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。