P4: Lua io.AxisInverted always fails
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
这个 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
- Current master (8afa31842), Debug build, Linux. MediaVPs 5.0.2, no other mods, SM1-01.
- By default the mouse X axis and joystick 0's X axis are bound to the heading axis.
- From a script, run:
io.AxisInverted(-1, 0, true)and thenio.AxisInverted(-1, 0)io.AxisInverted(0, 0, true)
- Read
io.HeadingAxisSecondaryInvertedandio.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
- 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)). - Same as 1, and loop up to
JOY_AXIS_ENDinstead ofJOY_REL_THROTTLE_AXIS, so every axis action is searched. - Remove
AxisInvertedin favor of the per-action properties, if no script relies on it.
- 主要语言
- C++
- 星标
- 488
- 派生
- 184
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 35
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
scp-fs2open/fs2open.github.com 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
scp-fs2open/fs2open.github.com#7953 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 66/100
scp-fs2open/fs2open.github.com#7932 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
scp-fs2open/fs2open.github.com#7924 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
scp-fs2open/fs2open.github.com#7918 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
scp-fs2open/fs2open.github.com#7917 ·
维护者通常 1 天内回复
查看 scp-fs2open/fs2open.github.com 的全部 Issue
相似的 Issue
-
bug priority: low
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
chipsalliance/verible#2644 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
grafana/pyroscope-dotnet#470 ·
维护者通常 1 天内回复
-
documentation P5 XS
难度 2/5 1-3 小时 新手友好度 72/100
open-astro/AlpacaBridge#1848 ·
维护者通常 1 天内回复
-
DiskANN AnnIterator returns unconverted IP distances after the graph walk runs out of candidates未关闭
难度 2/5 1-3 小时 新手友好度 75/100
zilliztech/knowhere#1933 ·
维护者通常 1 天内回复