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:
shenlei
2026-10-12 19:46:24 +09:00
co-authored by Claude Opus 5.5
parent 1dfdcba739
commit 5597842d90
18 changed files with 978 additions and 103 deletions
+34
View File
@@ -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).