#221

Android: true fullscreen on screens narrower than 16:9 (foldable inner panels)

Openvickwvwants to merge intofrom

What changed

Android now uses the "true fullscreen" the iOS (front_ios.m) and HarmonyOS (front_ohos.c) ports already have, for screens narrower than 16:9 (foldable inner panels, 4:3 tablets), and the overlay follows the game on all four edges.

Fullscreen mechanism

  • front_android.c decides it from the screen aspect, calls dm_uiscreen_enable(DM_UISCREEN_BOTTOM) and registers the UI rectangle with the Vulkan engine (xbg_set_ui_rect_fn). In a run the picture is output at the screen aspect and the 3D fills the screen; the game UI is laid out at 16:9 and shifted to the bottom. Front-end pages and the loading screen stay 16:9 centered with margins, because they are designed as whole 16:9 pages.
  • Output size: the screen aspect with a 1080-line short side by default and a 3D scale of about 700 lines (0.65). Native pixels would lift the 3D from 540p to 1100p because the game's 3D scale floors at 0.5 (hle_oe.c), which no Snapdragon 8-class device holds at 60 fps. DM_ANDROID_RES=<short side> overrides the profile, DM_NATIVE_RES=1 uses native pixels and DM_ANDROID_FULL=0 turns true fullscreen off (like DM_IPAD_FULL=0 on iPads).
  • The game only accepts a render size at or below the window texture it created at startup (dm_uiscreen.c), so the first value reported is that cap and later values are the current size; unfolding / folding recomputes it, scales it into the cap and pushes notification 31 so the game rereads.
  • TouchOverlay.java and the native touch layout work in the "game view rectangle": the bottom 16:9 UI block in a run, the centered 16:9 block outside it, and the whole window on screens wider than 16:9 (where nothing changes). Drawing, hit tests, dm_ui_* normalisation and world taps follow it (world_rect/world_norm, as in touch_ohos.c), and touches in the 3D-only strip above the rectangle still reach the world.
  • vulkan_present.cpp keeps the buffer at the window size when the picture aspect differs (front-end pages), so the compositor no longer stretches 16:9 over the whole screen; the letterbox blit filters linearly when it upscales.

Bottom edge: the game floors its UI height at 720 pixels

  • Measured on 3.3.94012 by writing 684 / 756 / 792 and reading the HUD back: the orb-centre gap is 0.667 x {720, 756, 792}, i.e. a written 684 is laid out as 720. The UI was therefore taller than the 16:9 strip, its bottom edge spilled off the picture and every overlay copy sat a few percent off.
  • dm_uiscreen.c now writes max(width*9/16, 720) (DM_UI_MIN_H overrides it) and applies the same floor to the front-end render height, so the character-select page no longer overflows either. The vertical offset, the overlay view rectangle and the UI-text / tap conversions all follow the floored value.

Top and right edges: lifted widgets and the game's top-right block

  • xbg_game.cpp: UI draws that bind the same projection constant buffer as a recognised UI draw are shifted too (the minimap geometry uses a different vertex signature, so it stayed unshifted and the host's lift pushed it off the picture), and a top widget the host lifts above the UI rectangle receives an empty scissor from the game -- clip it to the picture's top strip instead of dropping it. The minimap and the party bar are back in true fullscreen.
  • touch_android.c: in true fullscreen the game draws the minimap and the area-name label past the picture's right edge, so the game's side gets a default right safe area to move that block inward. The touch layout keeps the real insets (test_touch_snapshot caught an earlier version that moved the action buttons as well).

Left and right edges: the overlay moves with the game's HUD centreline

  • The game lays its HUD out for 16:9, so the HUD centreline always sits 1920 layout units (= 1173.6 mockup pixels) from the UI rectangle's left edge: the rectangle's centreline on 16:9, right of it on anything narrower (which is what the 720-pixel floor produces).
  • front_android_view_rect derives that difference from the current resolution and shifts the overlay's view rectangle by it, so the self-drawn HUD, the action buttons and the touch mapping move together (world_rect adds -vr_x back, so world taps are unaffected). Nothing device specific is hard-coded: 16:9 and wider work out to 0.
  • TouchOverlay.java therefore keeps drawing on the mockup centreline (1434) and the canvas is translated to the shifted view origin.

Diagnostics

  • xbg_game.cpp logs the first real UI shift, so a player log shows whether the UI-anchor path engaged.
  • A debug-only dmNoHud launch extra skips all overlay drawing, used to measure the game's own HUD while calibrating.

Why

On a foldable inner panel (vivo X Fold3: 2480x2200, aspect 1.127) the 16:9 picture was letterboxed with black bars at the top and bottom, and the shell's own HUD (drawn at the bottom of the physical screen) came apart from the game's HUD (drawn at the bottom of the 16:9 picture): the HUD appeared twice on screen. Reported with a screenshot and a video; the fix follows the design already shipped on iOS and HarmonyOS.

After the first round the reporter still saw the HUD contents a few percent off inside the self-drawn bar, the minimap missing and the area-name label clipped. Reproducing that on a Xiaomi 12T Pro forced to the same 2480x2200 shape with wm size gave the four root causes above (UI-height floor, unshifted minimap draws, empty scissor on lifted widgets, HUD centreline offset).

Checks run

No game files needed:

  • python3 dm/i18n/scan_literals.py — I18N OK:中文字面量 474 条全在白名单(111 行)
  • python3 dm/ios/tools/dm_i18n.py --check — dm_i18n OK 467 条

Android build and tests (no Apple host was available):

  • gradle -p dm/android :app:assembleDebug (NDK 29.0.14206865, AGP 9.4.1) — builds app-debug.apk
  • dm/android/tests/test_touch_snapshot.c, aarch64, run on a device — RESULT PASS cases=16 assertions=6770; the two new cases are android_view_rect_coordinates and android_world_tap_fullscreen
  • Device checks (Redmi 12T Pro, Android 16, APK + r45 import pack, in a run, wm size used to simulate each shape, wm size reset afterwards):
    • 2480x2200 (vivo X Fold3 inner panel, 1.127 — exercises the 720 UI-height floor): picture fills, one HUD, belt potions centered in the self-drawn cells, badges and life/mana labels aligned, minimap visible top-right, area name fully on screen, buttons clear of the mana orb.
    • 2448x1848 (Galaxy Z Fold 8 inner panel, 1.325) and 1972x1248 (Galaxy Z Fold 8 cover display, 1.58): same, and the horizontal offset computes to 0 for both.
    • 2480x1995 and 2480x1900 (other narrow shapes, floor not triggered): HUD aligned, minimap visible.
    • native 2712x1220 (2.22): 画面:真全屏 关(屏幕 2712x1220,比例 2.223);出图 2000x900;窗口纹理上限 2000x900 — the wide-screen path is unchanged.
  • make -C dm/host/tests run, make -C dm/gfx/tests run, make -C dm/ios/tests test, dm/verify/regress.sh, dm/ios/tools/smoke_mac.sh, dm/ios/tools/check_hud_gen.sh — not run: no macOS/iOS host here; the change touches the shared Vulkan engine and dm_uiscreen.c, both exercised on the Android device above.

Visible changes

  • Something on screen changes — on screens narrower than 16:9 only: in a run the picture fills the screen, the UI sits at 16:9 at the bottom, and the overlay follows it on all four edges.
  • New on-screen text is in dm/i18n/ui_text.tsv — no new on-screen text (the added Chinese strings go to logs only).

No game content

  • This change contains no game files, nothing generated from game files, no keys, and no built package
  • It does not carry the local rewrites ./setup.sh makes to dm/gfx/tools/dmsh_chain.lock, dm/gfx/nvn/dmsh_chain.h and dm/gfx/nvn/c1_full.tsv

Comments

  • New and changed comments are in both Chinese and English

Known limitations

  • Starting on the wide outer screen and then unfolding can only scale into the cap reported at startup: the picture fills but is softer than starting unfolded (see the README).
  • Front-end pages at extreme aspects (e.g. a 1:1 test shape) can still spill a panel outside the 16:9 page; in-run play is unaffected.

Activity

11
thatskullkid-cloud23d ago

Hey! I have a Samsung Galaxy Z Fold 8 and would love to test this implementation on an actual foldable device. Would you be willing to share a debug APK built from this branch so I can test the fullscreen behavior and report back on HUD alignment, aspect ratio, and touch controls?

Thanks for working on this!

vickwv23d ago

Follow-up commit from testing on a foldable-shaped screen (Xiaomi 12T Pro forced to 2480x2200 with wm size, i.e. the same 1.127 aspect as an X Fold3 inner panel) — reported symptoms were the HUD contents sitting a few percent off inside the self-drawn bar and the top-right minimap/area name missing.

Root cause of the HUD offset: the game floors its UI height at 720 pixels (its HUD is designed at 720p). Writing width*9/16 = 684 for a 1.127 screen made the game lay the UI out at 720 anyway, so the UI was taller than the 16:9 strip the host computed and its bottom edge spilled off the picture. Measured by writing 684 / 756 / 792 and reading the HUD orb-centre gap back: 481 / 504 / 529 game pixels = 0.667x{720, 756, 792}.

  • dm/host/dm_uiscreen.c: write max(width*9/16, 720) (DM_UI_MIN_H overrides it) and apply the same floor to the front-end render height, so the shift, the overlay view rectangle and the UI-text/tap conversions all follow the real UI rectangle.
  • dm/gfx/vulkan/engine/xbg_game.cpp: UI draws binding the same projection constant buffer as a recognised UI draw are shifted too (the minimap geometry uses a different vertex signature and stayed unshifted, so the host lift pushed it off the picture), and a lifted top widget that gets an empty scissor from the game is clipped to the picture top strip instead of being dropped.
  • TouchOverlay.java: in true fullscreen the game HUD is centred 44 mockup pixels right of the 16:9 mockup centreline (measured ~50 screen pixels), draw the self-drawn cells/numbers/badges on the same reference.
  • touch_android.c: report a small default right safe area in true fullscreen so the top-right minimap and the area-name label move inside the picture.
  • A debug-only dmNoHud launch extra skips all overlay drawing, used to measure the game HUD while calibrating.

Verified at 2480x2200 (HUD aligned, minimap visible, area name fully on screen), 2480x1995 and 2480x1900, plus native 2712x1220 (wide path unchanged). dm/android/tests/test_touch_snapshot.c passes 16 cases / 6770 assertions on the device; scan_literals.py and dm_i18n.py --check are clean.

vickwv23d ago

Updated with three more commits from foldable-shape testing. Summary of where it stands (head 78759de, MERGEABLE):

  • HUD was a few percent off / minimap missing: the game floors its UI height at 720 px (0.667 x {720, 756, 792} measured by writing 684 / 756 / 792), so writing width*9/16 = 684 on a 1.127 screen made the UI taller than the 16:9 strip. The host now writes max(width*9/16, 720) and applies the same floor to the front-end render height. The Vulkan engine also shifts UI draws that share the UI projection constant buffer (the minimap geometry has a different vertex signature) and clips lifted widgets with an empty scissor to the picture top strip instead of dropping them.
  • Horizontal reference is derived, not hard-coded: the game lays its HUD out for 16:9, so its centreline is always 1920 layout units (= 1173.6 mockup pixels) from the UI rectangle left edge. front_android_view_rect computes that difference from the current resolution and shifts the whole overlay view rectangle by it (self-drawn HUD + buttons + touch mapping together; world_rect adds -vr_x back so world taps are unaffected). 16:9 and wider work out to 0.
  • Top-right block: the game side gets a default right safe area in true fullscreen so the minimap and area-name label move inside the picture; the touch layout keeps the real insets (test_touch_snapshot caught an earlier version that moved the action buttons too).

Verification on a Xiaomi 12T Pro with wm size (reset afterwards): 2480x2200 (X Fold3 inner panel — HUD cells/belt content/labels aligned, minimap visible, area name complete), 2448x1848 and 1972x1248 (Galaxy Z Fold 8 inner panel and cover display — offset computes to 0), 2480x1995 / 2480x1900, and native 2712x1220 unchanged. test_touch_snapshot 16 cases / 6770 assertions PASS on the device; the two i18n checks are clean.

vickwv23d ago

Hey! I have a Samsung Galaxy Z Fold 8 and would love to test this implementation on an actual foldable device. Would you be willing to share a debug APK built from this branch so I can test the fullscreen behavior and report back on HUD alignment, aspect ratio, and touch controls?

Thanks for working on this!

I have fix it

thatskullkid-cloud23d ago

Thank you! How can I download tbis update?

jhaizhou-ops23d ago

Merged as b79c57e (you're the author), thanks — this is a solid piece of work, and the 720-floor root cause was a good find.

Checked here on a vivo X200 Ultra (Adreno 830): the normal 20:9 run is unchanged, and with wm size 1080x1217 (your 1.127 foldable aspect) true fullscreen comes on, the 3D fills the screen, and the bottom bar, the right-hand buttons and the top-right area name all sit where they should.

One follow-up from us, dc14610: #214 (merged just before) added a Custom page "3D resolution" row, and DM_3D_SCALE now overrides it. default_3d_scale() writes DM_3D_SCALE_DEFAULT instead, so your ~700-line value becomes the "balanced" level (0.65 on that shape) and power saver / sharp still work.

@thatskullkid-cloud: it'll be in the next Android release on the Releases page.