Repository navigation
fix(libretro): 支持模拟摇杆方向输入,修复 RetroArch 中无法移动的问题 - #129
Merged
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



问题与影响
RetroArch 加载《赤刃》
EPOP/EBBLADE.smf后,模拟摇杆无法控制角色移动;独立版模拟器的实体摇杆正常。核心原先只接收十字键方向和 A/B 按键。当 RetroArch 没有开启 Analog to Digital Type(模拟摇杆转十字键) 时,手柄摇杆轴输入没有进入游戏,角色位置不变。这个缺失影响核心的方向输入,并非《赤刃》专属逻辑。
原因与历史定位
query_joypad_buttons()只调用input_state(port, RETRO_DEVICE_JOYPAD, 0, id),从未读取RETRO_DEVICE_ANALOG的 X/Y 轴。9feda2de74bad206377f9f680516f05d57e7af6c(2026-06-06)就只有十字键和 A/B 映射。be5ea41(2026-09-13)通过 gilrs 添加了实体手柄支持;libretro 前端没有同步实现对应的轴映射。修改方案
±0x4000才触发方向,中心及阈值以内不触发。set_buttons()路径,保持 A/B 映射、交换选项及自动重复处理。效果与验证
修复后,核心自身支持左右摇杆控制移动,无需依赖 RetroArch 的模拟摇杆转十字键设置。用户已在 RetroArch 中验证修复有效。
自动化回归
EPOP/EBBLADE.smf启动,隔离存档并通过真实场景切换进入BBPLAY10.SSL,从同一初始状态分别测试双摇杆的四方向,断言角色坐标朝正确方向变化,并与十字键的移动结果比较。(53, 188);启用修复后通过。#[ignore],在本地显式运行;资源和生成的 DLL 不提交到仓库。本地真实游戏回归中,每个方向保持 30 帧,左右摇杆均得到以下结果:
(53, 188)(14, 188)(53, 188)(125, 188)(53, 188)(53, 152)(53, 188)(53, 213)此外,通过 ctypes 加载发布版 DLL,调用实际导出的
retro_load_game、retro_run和存档接口,注入 libretro 输入回调,验证了双摇杆四方向均能移动。该验证属于回调模拟输入;实体手柄的 RetroArch 验证由用户完成。已完成检查
cargo test --workspacecargo test -p native32emu-libretro -- --include-ignored(包括《赤刃》回归,4 项通过)cargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcargo build -p native32emu-libretro --release