Add touch input router for mobile (step 3)
Route each finger to UI, the attack button, a floating lower-left joystick or the camera (drag rotate, pinch zoom, tap = world click). Touch mode is default on Android/iOS and available on desktop via --touch / AVA2_TOUCH=1; it disables SDL touch-to-mouse and drives app.ENABLE_MOBILE_HUD. The joystick feeds the original camera-relative movement path and the attack button sets the same attack-key state as player.SetAttackKeyState. New `touch` Python module; the mobile HUD joystick and combat wheel become display-only. Tests: ava2.touch_router, ava2.touch_game (GameWindow + mobile HUD). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1dfdcba739
commit
5597842d90
@@ -8,7 +8,9 @@
|
||||
- `android/push_assets.py` 把资源(`assets/loose` + python-root + `python27.zip`)推送到应用外部存储目录,客户端启动时切换到该目录。
|
||||
- 游戏资源为 2.8 GB、约 5 万个散文件(`assets/loose`),17 个源文件中 120 多处通过 `std::filesystem` / `ifstream` 直接读文件,无法读取 APK 内置资源。
|
||||
- 没有处理前后台切换(`SDL_EVENT_WILL_ENTER_BACKGROUND` / `DID_ENTER_FOREGROUND`)和低内存事件。
|
||||
- 没有触摸事件处理;SDL 默认把单指触摸模拟成鼠标,只能点按钮。
|
||||
- 触摸分流已实现(`src/app/input/touch_router.*`,见下文 `input/`):移动端或 `--touch` / `AVA2_TOUCH=1` 时关闭 SDL 触摸转鼠标,每个手指分到界面、攻击键、左下浮动摇杆或镜头(单指拖动转向、双指缩放、轻点=点地移动)。Python 模块 `touch` 供 HUD 设置攻击键位置并读取摇杆状态;`ui_mobile_joystick` / `ui_mobile_combat` 改为只做显示(`not_pick`)。多指同时操作尚未在真机验证。
|
||||
- 实际出招尚未接通:触摸攻击键和键盘一样只设置 `player` 的攻击键状态,真服路径里 `player_ComboAttack` 仍是空实现。
|
||||
- 原型 HUD 用到的 `taskbar/attack_button_0x.sub`、`quickslot_0x.sub` 不在资源包里:攻击键暂用色块,技能圈槽位不可见。
|
||||
- 软键盘已改为仅在输入框获得焦点(`ime.EnableCaptureInput`)或聊天打开时弹出。
|
||||
- `src/app/main.cpp` 共 2418 行,启动、主循环、登录和调试参数都在其中。
|
||||
- Android 默认渲染缩放 0.75。
|
||||
|
||||
@@ -1144,3 +1144,37 @@ Verified: debug APK builds; the desktop client reaches the login screen inside
|
||||
`build/android-data/root` (the phone layout) with no missing-effect errors.
|
||||
Not verified: any run on a device (no phone attached), Vulkan rendering, touch,
|
||||
lifecycle, frame rate.
|
||||
|
||||
### 2026-10-12 Mobile step 3: touch input router
|
||||
|
||||
- `src/app/input/touch_router.{h,cpp}` (`ava2_input`): per-finger routing in
|
||||
this order: UI under the finger (or any finger outside the game phase) -> one
|
||||
UI pointer; attack circle; lower-left joystick area (floating base, dead zone
|
||||
0.18); otherwise camera (one-finger drag rotates after a slop, two-finger
|
||||
pinch zooms, a short tap is a world click). `CancelAll` on
|
||||
`SDL_EVENT_FINGER_CANCELED` / focus loss.
|
||||
- Touch mode is on by default on Android/iOS, or with `--touch` /
|
||||
`AVA2_TOUCH=1` on desktop; it sets `SDL_HINT_TOUCH_MOUSE_EVENTS=0` and makes
|
||||
`app.ENABLE_MOBILE_HUD` follow it. `main.cpp` hosts the sink: UI = a
|
||||
picked window that is not the player GameWindow; world tap = mouse move +
|
||||
left down for one frame (GameWindow keeps the move target after release);
|
||||
joystick -> `SetPlayerJoystick` (replaces the WASD axes while active, so
|
||||
movement uses the original camera-relative yaw path); attack ->
|
||||
`SetPlayerAttackKey` (same state and fishing check as
|
||||
`player.SetAttackKeyState`).
|
||||
- Python module `touch`: `IsEnabled`, `GetJoystick`, `IsAttackPressed`,
|
||||
`SetAttackButton`, `SetJoystickArea`, `GetLayout`. The mobile HUD prototype's
|
||||
joystick and combat wheel are now display-only (`not_pick`); the old joystick
|
||||
sent raw move packets and the attack button was a one-pointer `ui.Button`.
|
||||
|
||||
Verified: `ava2.touch_router` (routing unit test) and `ava2.touch_game` (the
|
||||
original GameWindow with the mobile HUD in touch mode: open world, joystick
|
||||
zone and attack button are not UI, the taskbar is; joystick right gives
|
||||
movement yaw 90 at camera yaw 0; attack held while walking; taskbar tap reaches
|
||||
the window manager, open-world tap becomes a world click); 51/51 desktop tests;
|
||||
`ava2_client --touch` reaches the login screen.
|
||||
Outstanding: no device run (real multi-touch, finger/pixel scale); the attack
|
||||
key state is still not consumed on the real-server path (`player_ComboAttack`
|
||||
stub), so touch attack does not swing yet; the prototype's attack/quickslot
|
||||
`.sub` art is missing from the packs (attack drawn as a coloured block, skill
|
||||
slots invisible).
|
||||
|
||||
Reference in New Issue
Block a user