Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

P4: Lua io.AxisInverted always fails

未关闭 适合新手
#7,946 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
70/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, lua
领域
game-dev

调研方向

这个 bug 位于 scripting/api/libs/controls.cpp 中 io.AxisInverted 顶部的 controller-ID 检查(大约在第 279 行),以及搜索 binding 并在 JOY_REL_THROTTLE_AXIS 处停止的循环中。先阅读该函数以及它应匹配的按轴属性 setter。完成意味着复现中的三个调用(鼠标反转、鼠标查询、joystick 0 反转)返回预期值,并且之后 io.HeadingAxisPrimaryInverted 和 io.HeadingAxisSecondaryInverted 读出 true。该 issue 未决定是否删除该函数,所以先与 maintainer 确认这一选择。

由索引模型根据 Issue 内容生成。

描述

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
平均合并
2 天 2 小时
30 天内合并 PR
35

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

scp-fs2open/fs2open.github.com 的其他 Issue

查看 scp-fs2open/fs2open.github.com 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。