Repository navigation
Conversation
- 震动:接着有马达的手柄就震手柄(同 iOS 系统手柄)。API 31 两路马达(InputDevice VibratorManager, id 0 左 / 强、id 1 右 / 弱)分别接 HD Rumble 左右两侧;一路马达或 API 29/30(InputDevice.getVibrator)取大的一侧。 租约 / 节流同手机马达;四指菜单「手柄震动」,缺省开。 - 六轴:API 31 InputDevice.getSensorManager,游戏要六轴且在前台才开(200 Hz)。安卓不统一手柄传感器轴向, 按驱动的两套坐标换成 NS2 原始坐标:PlayStation(x 右、y 法线、z 朝玩家)、任天堂(x 上沿、y 左、z 法线), 对照 Linux hid-playstation / hid-nintendo 与 SDL hidapi;认不出的厂商不用,回落手机陀螺仪。 来源仍走共用 motion_pick(有样本的手柄优先),换源丢一帧,手柄供满 2 秒手机传感器歇着(同 iOS)。 反注册整个监听器,避开 InputDeviceSensorManager 逐个移除的并发修改异常(Dolphin 记过)。 - 按键布局:padFace auto / switch / xbox 同 iOS / Mac(pad.c)。安卓按键码对所有手柄都按位置报, 所以 auto = 任天堂手柄用 Switch 布局、其余用 Xbox 布局;旧值 position = switch、label = xbox, 旧偏好 gamepadMapping 照搬。四指菜单可切,缺省 auto(原缺省 position)。 - 测试:phone_feedback_test 按姿态手算坐标换算(另拿 SDL 的任天堂→PS 换序交叉核对)、左右马达档位、来源仲裁, 含反向对照;GamepadStateTest 覆盖三种布局 × 任天堂 / 其他手柄、旧值、型号判断;仪器测试改成新缺省。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Owner
This branch has not been deployed
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.
Requested by wwmogu · project thread
本 PR 关的卡:Part of #528(差距表第 10 项,第二片:外接手柄自己的马达 / 六轴 + 手柄按键布局;第一片是 #1561)
问题与要证明什么
#1561 之后,安卓接着实体手柄时:手柄马达不震(手机马达也按 iOS 规矩让开,所以整局没震动);手柄自带的陀螺仪不用,体感一直读手机;面键只有按位置一种(缺省)或 adb 参数切
label,没有 iOS / Mac 的padFace自动 / Switch / Xbox。要证明:接着有马达的手柄时 HD Rumble 左右两侧出到手柄左右马达;接着 DS4 / DualSense / Pro / Joy-Con 时六轴读手柄、坐标与 NS2 原始坐标一致,断了回落手机;按键布局三档与
runtime/src/pad.c同义。改动(只改了哪些文件)
android/app/.../PadFeedback.java(新):选玩家 1 的手柄(最近一次有输入的那只,否则第一只),拿马达(API 31InputDevice.getVibratorManager,id 0 左 / 强、id 1 右 / 弱;API 29/30InputDevice.getVibrator)和传感器(API 31InputDevice.getSensorManager,加速度计 + 陀螺仪 200 Hz,只在游戏要六轴且在前台时注册)。反注册整个监听器,避开InputDeviceSensorManager逐个移除时的 ConcurrentModificationException(DolphinDolphinSensorEventListener记过这个 AOSP 坑)。android/native/phone_feedback.c:0x5044…);否则同 安卓:手机陀螺仪当掌机六轴、手机马达接游戏震动(#528 第 10 项第一片) #1561。反馈线程按会话下发到手柄或手机,换路先停上一路;租约 / 节流沿用 安卓:手机陀螺仪当掌机六轴、手机马达接游戏震动(#528 第 10 项第一片) #1561 的s2a_android_rumble_step,左右两路合成一个节奏键。换手柄、改设置、退后台都换手柄会话号。NativeBridge.padSensor进来(到达时刻做样本时间,100 ms 没新样本当断了);来源仍走共用motion_pick.c(有样本的手柄优先),换源丢一帧,手柄供满 2 秒手机传感器歇着(同ios/controller.m)。android/native/phone_feedback_policy.h:纯函数s2a_android_side_level/s2a_android_pad_rumble_key、s2a_android_pad_frame/s2a_android_pad_axes、s2a_android_motion_step。SDL_hidapi_switch.c的「任天堂 → PS」换序一致。认不出的厂商(含 Xbox,系统不给六轴)不用,回落手机。GamepadState.java、MainActivity.java:padFaceauto / switch / xbox。安卓按键码对所有手柄都按位置报(AOSPVendor_057e_Product_2009.kl把任天堂下键「B」报成BUTTON_A),所以 auto = 任天堂手柄(厂商 057e 或名字含 Nintendo / Switch / Joy-Con,同s2a_pad_kind的片段)用 Switch 布局、其余用 Xbox 布局(PS × 确认)。旧值position= switch、label= xbox,旧偏好gamepadMapping照搬;四指菜单加「手柄按键布局」「手柄震动」。缺省从 position 改成 auto(同 iOS / Mac)。NativeBridge.java:configurePadFeedback、padSensor。中英文案各 7 条。README.md两节。android/tests/phone_feedback_test.c、GamepadStateTest.java、GamepadMappingInstrumentation.java(改成新缺省,旧值存成新偏好);CMakeLists.txt给单测加motion_pick.c。修前 → 修后读数
期望值按物理姿态和按键位置手算,不跑被测实现。
phone_feedback_test新增三组在 #1561 上phone_feedback_test在本 PR(gcc 13 / clang 18,-Wall -Wextra -Werror)phone_feedback_test: okGamepadStateTest:auto × 非任天堂 / 任天堂、switch、xbox、旧值、按着切型号不卡键、型号判断padFace auto/switch/xbox … passedSystemPowerRails用 API 35 类,换桩,与本 PR 无关)phone_feedback.c语法检查(gcc / clang,JDK jni.h + NDK 签名的 sensor / looper 头)AttachCurrentThread形参类型差那一条(同 #1561)strings_translation_test/touch_strings_test/debug_gate_test/debug_environment_test/touch_appearance_wiring_test负对照
drop恒 0):红 2 条。GamepadState缺省改回 switch:GamepadStateTest.java:70红;任天堂厂商号写错::124红。射程
宿主单测:两套坐标 × 3 个姿态 × 加速度 / 两轴角速度 + 交叉核对 + 两条反向对照;马达 6 例 + 节奏 3 步;来源 10 步;布局 3 档 × 2 种手柄 + 旧值 + 6 个非法值 + 7 个型号名。没有安卓真机、没有 NDK 链接与出包,以 CI「贡献者自检」为准。
一级自检
本地云端环境缺 NDK / .NET 10,
tools/contrib_check.sh跑不全;以 CI 为准。平台耦合只减不增
没改
compat/tree、services/。苹果路径不受影响的证明
没改共用源(
runtime/src/motion_pick.c只是单测多链一份)。限制 / 未测项 / 后续
adb logcat -s S2Arm | grep -E "Controller for|手柄|六轴|按键":应有Controller for rumble / six-axis: <名字> (054c:0ce6), motor true, sensors true与手柄:震动 接手柄马达,六轴 PlayStation 坐标。手柄震动:首次 左 N/255、右 M/255,手柄两侧马达有区别。拔掉手柄后改由手机马达震。手柄六轴:开(…,200 Hz)、六轴:来源 手机 → 手柄;平放 / 上沿朝上 / 右侧朝上各转一下,看视角方向是否跟手。拔掉手柄应出六轴:来源 手柄 → …再回到手机。@jhaizhou-ops 请评审。
Generated by Claude Code