Files
d2r-mobile/dm/android/Sources/front_headless.c
T
shenleiandClaude Opus 5.5 3c25cd89fc Android: move the shell to dm/android and the Vulkan backend to dm/gfx/vulkan
Mirror the iOS layout instead of nesting Android inside dm/host:
- dm/android/app       GameActivity app (manifest, java, res, build_apk.sh)
- dm/android/Sources   front_app.c, touch_app.c, front_headless.c
- dm/android/Makefile  entry point (apk / lib / install / headless / tests);
                       rules in build.mk (was dm/host/Makefile.android),
                       run with dm/host as cwd; outputs in dm/android/build/
- dm/android/tests     t_vk_perf
- dm/gfx/vulkan        nvn_vk.c and friends, next to the Metal backend

Only include paths, build paths and docs change; no code changes.
The Mac / iOS source lists do not pick up gfx/vulkan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 16:59:36 +09:00

26 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Android 无头前端(adb shell 直接跑 dmhost,先跑通引导链):无窗口、无输入框,客体在当前线程跑;GameActivity 前端接上后由它替换
// Android headless front end (run dmhost straight from adb shell to get the boot chain working first): no window, no input box, the guest runs on the current thread; replaced by the GameActivity front end once that is wired up
#include "../../host/dm.h"
#include "../../host/front.h"
// 客体在 64 MB 栈的线程里跑(与 iOS 壳的 boot_thread 一致;adb shell 主线程栈只有 8 MB)
// The guest runs on a thread with a 64 MB stack (same as the iOS shell's boot_thread; the adb shell main thread has only 8 MB)
static void *guest_thread(void *p) { ((void (*)(void))p)(); return NULL; }
void front_run(void (*guest)(void)) {
pthread_attr_t a; pthread_t t;
pthread_attr_init(&a); pthread_attr_setstacksize(&a, 64 << 20);
if (pthread_create(&t, &a, guest_thread, (void *)guest)) die("建客体线程失败");
pthread_join(t, NULL);
}
void *front_metal_layer(void) { return NULL; }
// 与 front_mac.m 同一规则:DM_GAME_RES=宽x高 指定主机模式分辨率,掌机模式取 4/5
// Same rule as front_mac.m: DM_GAME_RES=WxH sets the docked resolution, handheld takes 4/5 of it
uint64_t front_game_res(int docked) {
unsigned w, h; const char *e = getenv("DM_GAME_RES");
if (e && sscanf(e, "%ux%u", &w, &h) == 2) return docked ? (uint64_t)h << 32 | w : (uint64_t)(h * 4 / 5) << 32 | (w * 4 / 5 + 3) / 4 * 4;
return docked ? 900ull << 32 | 1600 : 720ull << 32 | 1280;
}
int front_text_input(const char *title, const char *sub, const char *guide, const char *initial, int max_chars, char *out, int out_cap) {
(void)title; (void)sub; (void)guide; (void)initial; (void)max_chars; (void)out; (void)out_cap;
return -1;
}