P4: Lua io.AxisInverted always fails
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 70/100
Hướng nghiên cứu
Lỗi nằm ở phần kiểm tra ID bộ điều khiển ở đầu io.AxisInverted trong scripting/api/libs/controls.cpp, khoảng dòng 279, và trong vòng lặp tìm binding rồi dừng tại JOY_REL_THROTTLE_AXIS. Hãy bắt đầu bằng việc đọc hàm đó và các setter thuộc tính theo từng trục mà nó phải khớp. Hoàn thành nghĩa là ba lời gọi trong bản tái hiện (đảo chuột, truy vấn chuột, đảo joystick 0) trả về các giá trị mong đợi và io.HeadingAxisPrimaryInverted cùng io.HeadingAxisSecondaryInverted đọc ra true sau đó. Issue để ngỏ việc có nên xóa hàm hay không, nên hãy xác nhận lựa chọn đó với maintainer trước.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 488
- Fork
- 184
- Merge trung bình
- 2 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của scp-fs2open/fs2open.github.com
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
scp-fs2open/fs2open.github.com#7953 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 66/100
scp-fs2open/fs2open.github.com#7932 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
scp-fs2open/fs2open.github.com#7924 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
scp-fs2open/fs2open.github.com#7918 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
scp-fs2open/fs2open.github.com#7917 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của scp-fs2open/fs2open.github.com
Issue tương tự
-
bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
chipsalliance/verible#2644 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
grafana/pyroscope-dotnet#470 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation P5 XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-astro/AlpacaBridge#1848 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DiskANN AnnIterator returns unconverted IP distances after the graph walk runs out of candidatesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
zilliztech/knowhere#1933 ·
Maintainer thường phản hồi trong vòng 1 ngày