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
+15 -1
View File
@@ -28,6 +28,13 @@ if(BUILD_TESTING)
target_link_libraries(skill_poly_test PRIVATE ava2_poly)
add_test(NAME ava2.skill_poly COMMAND skill_poly_test)
endif()
add_library(ava2_input src/app/input/touch_router.cpp)
target_include_directories(ava2_input PUBLIC src)
if(BUILD_TESTING)
add_executable(touch_router_test tests/touch_router_test.cpp)
target_link_libraries(touch_router_test PRIVATE ava2_input)
add_test(NAME ava2.touch_router COMMAND touch_router_test)
endif()
add_library(ava2_protocol src/network/protocol.cpp src/network/legacy_cipher.cpp src/network/login_session.cpp)
target_include_directories(ava2_protocol PUBLIC src src/network src/game)
find_package(Threads REQUIRED)
@@ -63,6 +70,7 @@ if(AVA2_EMBED_PYTHON)
src/scripting/python_runtime.cpp
src/scripting/python_net.cpp
src/scripting/python_dbg.cpp
src/scripting/python_touch.cpp
src/scripting/python_system.cpp
src/scripting/python_minimap.cpp
src/scripting/python_chr.cpp
@@ -87,7 +95,7 @@ if(AVA2_EMBED_PYTHON)
src/eter_net/PythonExchange.cpp
src/eter_net/PythonSafeBox.cpp)
target_include_directories(ava2_python PUBLIC src src/network src/game src/scripting ${CMAKE_CURRENT_SOURCE_DIR} third_party/extern_include)
target_link_libraries(ava2_python PUBLIC SDL3::SDL3 mtpython ava2_render PRIVATE mt_codepage ava2_transport ava2_lzo ava2_poly)
target_link_libraries(ava2_python PUBLIC SDL3::SDL3 mtpython ava2_render ava2_input PRIVATE mt_codepage ava2_transport ava2_lzo ava2_poly)
target_sources(ava2_python PRIVATE src/eter_ui/Font.cpp)
find_package(Freetype QUIET)
if(Freetype_FOUND)
@@ -212,6 +220,12 @@ if(BUILD_TESTING AND NOT ANDROID)
add_test(NAME ava2.game_entry COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/check_completion.py"
"Original GameWindow, inventory, taskbar and minimap created successfully" "$<TARGET_FILE:game_entry_test>" "${MT_PYTHON_STDLIB_ZIP}" "${CMAKE_SOURCE_DIR}/upstream/python-root")
set_tests_properties(ava2.game_entry PROPERTIES ENVIRONMENT "AVA2_TEST_RUNDIR=${AVA2_TEST_RUNDIR}" SKIP_RETURN_CODE 77)
add_executable(touch_game_test tests/touch_game_test.cpp)
target_link_libraries(touch_game_test PRIVATE ava2_python mtpython)
add_dependencies(touch_game_test mtpython_stdlib)
add_test(NAME ava2.touch_game COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/check_completion.py"
"Touch router drives joystick, attack and world taps around the mobile HUD" "$<TARGET_FILE:touch_game_test>" "${MT_PYTHON_STDLIB_ZIP}" "${CMAKE_SOURCE_DIR}/upstream/python-root")
set_tests_properties(ava2.touch_game PROPERTIES ENVIRONMENT "AVA2_TEST_RUNDIR=${AVA2_TEST_RUNDIR}" SKIP_RETURN_CODE 77)
add_test(NAME ava2.pack_assets COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/pack_assets_test.py")
endif()