#290

Android: vibrate on valuable drops (#289)

Openyyan160wants to merge intofrom

Part of #289 (item 2). Item 1, Share Diagnostics, is already fixed by #269, which is in v2.3.3.

What was wrong

The Custom page row Vibrate on valuable drops is shown on Android, but it did nothing. dm_drophaptic.c picks a tier when a valuable item lands. dm_drop_haptic_take() was called only by the iOS front end (front_ios.m tickTouchControls). Android had no consumer, no vibrator call and no VIBRATE permission.

Change (Android only)

  • touch_android.c: the per-frame input hook (dm_android_touch_step, called from hle_hid.c every frame) takes the pending tier and hands it to front_android_drop_haptic. This happens before the touch lock is taken. The call only queues and sends no UI messages, so the touch-lock deadlock rule is kept. It also runs in controller mode.
  • text_input_jni.c: a new job kind on the existing dm-java-input worker calls DmActivity.dropHaptic(int). The method lookup is optional, like shareDiagnostics: if it is missing, the app starts and only the vibration is off. The game thread never waits on Java.
  • DmActivity.dropHaptic: tiers 1 / 2 / 3 map to the predefined EFFECT_HEAVY_CLICK / EFFECT_CLICK / EFFECT_TICK, matching iOS Heavy / Medium / Light. They play as media vibration (VibrationAttributes.USAGE_MEDIA on API 33+, AudioAttributes.USAGE_GAME on 31–32). The system's touch-feedback switch therefore does not silence them; the media vibration setting does.
  • Manifest: android.permission.VIBRATE. It is a normal permission, granted at install with no prompt. The manifest comment that said "only one permission" was updated.
  • dm_drophaptic.c: two comment lines naming the Android consumer. There is no code change in shared files, so iOS and HarmonyOS are not affected.

Tested

Redmi K50 Ultra (Adreno 730). APK from this branch with a pack from the same tree. DM_TEST_GIVE=<rune>@100 drops one rune at the character's feet through the game's own drop call, so the real landing → tier → JNI → vibrator path runs. One cold start each:

RuneHost logJavadumpsys vibrator_manager
Ber (r30)掉落震动:物品 id 16 第 1 档(Ber)drop haptic tier=1 (+66 ms)Prebaked=HEAVY_CLICK, 147 ms, usage MEDIA, finished
Ist (r24)第 2 档(Ist)drop haptic tier=2 (+24 ms)Prebaked=CLICK, 95 ms, usage MEDIA, finished
Pul (r21)第 3 档(Pul)drop haptic tier=3 (+23 ms)Prebaked=TICK, 88 ms, usage MEDIA, finished

There were no crash lines. Host checks run on Linux: mode_scan.py passes, t_hid_receipt 5/5, t_hid_script 37/37 and t_touch_mac 39/39 (no host code changed).

Not tested: feel on other phones (cheap motors may make TICK faint) and a phone with media vibration turned off.

🤖 Generated with Claude Code

Activity

0

No activity yet.