feat(platform): add mobile touch input and app lifecycle for iOS/Android - #659
Conversation
Implement cross-platform touch input handling and app lifecycle management using winit's platform-agnostic Touch events and suspended/resumed callbacks. Touch input: - TouchPhase enum, TouchId type, and TouchState tracking in InputManager - Multi-touch support with per-finger position and delta tracking - Touch-to-pointer emulation: touch 0 maps to MouseButton::Left + mouse position - 6 new FFI functions (touch count, active, position, delta, just_pressed/released) - 14 unit tests covering all touch scenarios App lifecycle: - AppSuspended/AppResumed event types in core events - PlatformBackend trait gains on_suspended/on_resumed/is_suspended with defaults - WinitPlatform implements suspended/resumed callbacks and Touch event handling - wgpu surface becomes Option<Surface> with drop_surface/recreate_surface methods - WindowState detects suspend/resume transitions and manages GPU surface lifecycle Platform cfg gates widened to include target_os = "android" and "ios" for winit_platform and native_runtime modules. Closes #278, closes #279, closes #286, closes #303 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @aram-devdocs's task in 3m 7s —— View job PR Review: feat(platform): add mobile touch input and app lifecycle for iOS/AndroidTasks:
Phase 1 — ContextLayers touched: Core (input_manager, events, providers), Libs (platform/winit, graphics/wgpu_backend, native_backend), FFI (input/touch, window/state), SDKs (C#, Python, TypeScript, Go, Kotlin, Swift, Lua, JNI) PR type: Additive feature — new touch input API + mobile app lifecycle Phase 2 — Architecture
Phase 3 — Anti-Pattern Scan
Phase 4 — Quality AssessmentPositives:
Warnings: W1 — Misleading comment in
// Reset moved touches back to started for next frame's delta detection
for state in self.touches_current.values_mut() {
state.previous_position = state.position;
}The comment says "reset moved touches back to started" but the phase is not reset — only W2 — Missing test:
W3 — FFI doc for
The guard used is W4 —
Phase 5 — Security
The double- Phase 6 — Scope
Verdict: APPROVED ✅This is a well-structured additive PR. The Rust-first architecture is followed, FFI patterns are correct, all 6+ SDK targets are updated, and the 14 unit tests cover the expected edge cases. The four warnings above are non-blocking but W1 and W2 are easy fixes worth landing before or shortly after merge.
|
… stubs pump_app_events is only available on desktop targets (via winit's pump_events platform extension). Gate the import and call sites behind cfg(not(target_os = "android/ios")), and provide a stub new() on mobile. Add touch method stubs to the TypeScript web wrapper so the GoudGame class correctly implements the IGoudGame interface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ck repos Kotlin 1.9.22 Gradle plugin failed to resolve from the Gradle Plugin Portal (transient POM parse error). Upgrade to Kotlin 2.0.21 and add pluginManagement with both gradlePluginPortal() and mavenCentral() as fallback repositories to improve reliability. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update drop_surface/recreate_surface cfg gates on NativeRenderBackend to match the new any(wgpu-backend, xbox-gdk) pattern from the merged xbox-gdk POC. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The xbox_init.rs path creates WgpuBackend without a winit window. Make the window field Option<Arc<Window>> so Xbox can pass None while desktop/mobile paths pass Some(window) for surface recreation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Overview
Type: feature
Summary:
Cross-platform touch input handling and app lifecycle management for iOS and Android using winit's platform-agnostic Touch events and suspended/resumed callbacks.
Related Issues: Closes #278, Closes #279, Closes #286, Closes #303
Changes Made
Engine Core (
goud_engine/src/)TouchPhaseenum,TouchIdtype alias,max_touch_pointstoInputCapabilitiesincore/providers/input_types.rsAppSuspendedandAppResumedlifecycle events incore/events/app.rsTouchStatestruct incore/input_manager/types.rstouch.rsmodule toInputManagerwith multi-touch tracking, touch-to-pointer emulation, and frame-based state cyclingcore/input_manager/tests/touch.rsFFI Layer (
goud_engine/src/ffi/)ffi/input/touch.rswith 6 FFI functions:goud_input_touch_count,goud_input_touch_active,goud_input_touch_position,goud_input_touch_just_pressed,goud_input_touch_just_released,goud_input_touch_deltaffi/window/state.rsC# SDK (
sdks/csharp/)Python SDK (
sdks/python/)TypeScript SDK (
sdks/typescript/)Codegen Pipeline (
codegen/)goud_sdk.schema.json)Proc Macros (
goud_engine_macros/)No changes
Tools (
tools/)No changes
WASM (
goud_engine/src/wasm/)No changes
Examples (
examples/)No changes
Documentation
No changes
Architectural Compliance
#[no_mangle] extern "C"and#[repr(C)]where neededunsafeblock without a// SAFETY:commentTesting
cargo testpasses (4736 lib tests, 0 failures)cargo clippy -- -D warningsis cleancargo fmt --all -- --checkpassespython3 codegen/validate.py && python3 codegen/validate_coverage.py)Code Quality
todo!()orunimplemented!()in production code#[allow(unused)]without justification commentResult, notunwrap()/expect()in library codeDocumentation
Breaking Changes
None
Version Bump
Bump type: minor
Justification: New touch input and lifecycle APIs (additive feature)
Security
unsafeblocks each have// SAFETY:comments (touch_position and touch_delta FFI functions)Performance
N/A — Touch input tracking uses HashMap<u64, TouchState> which is negligible overhead. Surface lifecycle (drop/recreate) only occurs on mobile suspend/resume transitions.
Deployment
Reviewer Notes
MouseButton::Left+ mouse position. Existing game code works on touch devices without changes.AppSuspended/AppResumedevents are defined but not yet emitted to the ECS event bus — the WinitPlatform doesn't have access to the World. Event emission will be integrated when the mobile event loop inversion (run_app()) is implemented.WindowState::poll_events()transition detection.pump_app_eventsis desktop-only in winit — the cfg gates are widened for mobile but the actual mobile event loop integration is a separate architectural task.🤖 Generated with Claude Code