mirror of
https://git.chinosk6.cn/chinosk/gkms-localify-dmm.git
synced 2026-10-06 05:18:06 +07:00
Windows 没有陀螺仪,Live 全景拍摄的陀螺仪按钮在 DMM 版被禁用。 新增 enableGyroEmu 开关(GUI 摄像机设置,含灵敏度与轴反转),打开后 按住鼠标右键拖动转动视角,小键盘 4/6 8/2 左右上下、7/9 翻滚、5 复位。 实现分三层,每层都有过失败尝试,原因记录在注释里: - GyroIcall:改写 il2cpp icall 包装里的 static 缓存指针,向 SystemInfo.IsGyroAvailable / Gyroscope.getEnabled/setEnabled/ attitude/gravity 提供假读数。不能 hook 原生 icall——Windows 上它们是 return 常量的桩,被链接器 ICF 合并进 IsDebugBuild 等无关函数,改一个 等于改全局(实测 [Debug] 变 True、开场黑屏);也不能 hook 托管包装—— PC 版 MSVC 把它们内联进了调用方,实测一次不被调用。 - GyroForceInit:PC 版把 IsPanoramaGyroDisabledOnPlatform() 内联成 常量 true,CampusGyroController 根本不会创建,IsGyroReady 永远 false。 在 LivePanoramaCameraManager.LateUpdate 里自己 new 出控制器和 VLGyro, 按 3.3.0 布局置字段后复用游戏自己的 ResetRotation。 - 两个方法体足够大、实测会被调用的托管 hook 放开 UI 闸门。 姿态换算来自反汇编:gyroRotationRaw = base ⊗ (-a.x, -a.y, a.z, a.w), 相对旋转里 base 被消掉,因此 attitude 直接编码相机欧拉角。 顺带:Windows 版日志同步写 gakumas-local/log.txt,便于无控制台排查。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
48 lines
2.4 KiB
C++
48 lines
2.4 KiB
C++
#pragma once
|
|
#include <minhook.h>
|
|
#include <vector>
|
|
|
|
#define ANDROID_LOG_VERBOSE 0
|
|
#define ANDROID_LOG_DEBUG 1
|
|
#define ANDROID_LOG_INFO 2
|
|
#define ANDROID_LOG_ERROR 3
|
|
|
|
#define GKMS_WINDOWS
|
|
|
|
#define LogMinVersion ANDROID_LOG_DEBUG
|
|
|
|
#define PLUGIN_VERSION "v3.4.1"
|
|
|
|
#define ADD_HOOK(name, addr) \
|
|
name##_Addr = reinterpret_cast<name##_Type>(addr); \
|
|
if (addr) { \
|
|
auto stub = hookInstaller->InstallHook(reinterpret_cast<void*>(addr), \
|
|
reinterpret_cast<void*>(name##_Hook), \
|
|
reinterpret_cast<void**>(&name##_Orig)); \
|
|
if (stub) { \
|
|
Log::ErrorFmt("ADD_HOOK: %s at %p failed: %s", #name, addr, \
|
|
MH_StatusToString(static_cast<MH_STATUS>(reinterpret_cast<int>(stub)))); \
|
|
} \
|
|
else { \
|
|
hookedStubs.emplace(stub); \
|
|
GakumasLocal::Log::InfoFmt("ADD_HOOK: %s at %p", #name, addr); \
|
|
} \
|
|
} \
|
|
else GakumasLocal::Log::ErrorFmt("Hook failed: %s is NULL", #name, addr); \
|
|
if (Config::lazyInit) UnityResolveProgress::classProgress.current++
|
|
|
|
|
|
static void __android_log_write(int prio, const char* tag, const char* msg) {
|
|
if (prio < LogMinVersion) return;
|
|
|
|
static const char* logLevels[4] = { "VERBOSE", "DEBUG", "INFO", "ERROR" };
|
|
|
|
if (prio < 0 || prio > 3) {
|
|
prio = 1;
|
|
}
|
|
printf("[%s] %s: %s\n", logLevels[prio], tag, msg);
|
|
// ponytail: 同步落盘,方便无控制台时排查 hook 是否装上
|
|
static FILE* logFile = fopen("gakumas-local/log.txt", "w");
|
|
if (logFile) { fprintf(logFile, "[%s] %s: %s\n", logLevels[prio], tag, msg); fflush(logFile); }
|
|
}
|