forked from chinosk/gkms-local
GakumasHookMain: Add notes back
This commit is contained in:
parent
3df995e3bc
commit
6fc1873b27
|
|
@ -97,15 +97,25 @@ class GakumasHookMain : XposedModule() {
|
||||||
val motionEvent = chain.getArg(0) as MotionEvent
|
val motionEvent = chain.getArg(0) as MotionEvent
|
||||||
val action = motionEvent.action
|
val action = motionEvent.action
|
||||||
|
|
||||||
|
// 左摇杆的X和Y轴
|
||||||
val leftStickX = motionEvent.getAxisValue(MotionEvent.AXIS_X)
|
val leftStickX = motionEvent.getAxisValue(MotionEvent.AXIS_X)
|
||||||
val leftStickY = motionEvent.getAxisValue(MotionEvent.AXIS_Y)
|
val leftStickY = motionEvent.getAxisValue(MotionEvent.AXIS_Y)
|
||||||
|
|
||||||
|
// 右摇杆的X和Y轴
|
||||||
val rightStickX = motionEvent.getAxisValue(MotionEvent.AXIS_Z)
|
val rightStickX = motionEvent.getAxisValue(MotionEvent.AXIS_Z)
|
||||||
val rightStickY = motionEvent.getAxisValue(MotionEvent.AXIS_RZ)
|
val rightStickY = motionEvent.getAxisValue(MotionEvent.AXIS_RZ)
|
||||||
|
|
||||||
|
// 左扳机
|
||||||
val leftTrigger = motionEvent.getAxisValue(MotionEvent.AXIS_LTRIGGER)
|
val leftTrigger = motionEvent.getAxisValue(MotionEvent.AXIS_LTRIGGER)
|
||||||
|
|
||||||
|
// 右扳机
|
||||||
val rightTrigger = motionEvent.getAxisValue(MotionEvent.AXIS_RTRIGGER)
|
val rightTrigger = motionEvent.getAxisValue(MotionEvent.AXIS_RTRIGGER)
|
||||||
|
|
||||||
|
// 十字键
|
||||||
val hatX = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_X)
|
val hatX = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_X)
|
||||||
val hatY = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_Y)
|
val hatY = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_Y)
|
||||||
|
|
||||||
|
// 处理摇杆和扳机事件
|
||||||
joystickEvent(
|
joystickEvent(
|
||||||
action,
|
action,
|
||||||
leftStickX,
|
leftStickX,
|
||||||
|
|
@ -243,17 +253,17 @@ class GakumasHookMain : XposedModule() {
|
||||||
|
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
val timeTaken = measureTimeMillis {
|
val timeTaken = measureTimeMillis {
|
||||||
val returnValue = pluginCallbackLooper()
|
val returnValue = pluginCallbackLooper() // plugin main thread loop
|
||||||
if (returnValue == 9) {
|
if (returnValue == 9) {
|
||||||
NativeInitProgress.startInit = true
|
NativeInitProgress.startInit = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NativeInitProgress.startInit) {
|
if (NativeInitProgress.startInit) { // if init, update data
|
||||||
NativeInitProgress.pluginInitProgressLooper(NativeInitProgress)
|
NativeInitProgress.pluginInitProgressLooper(NativeInitProgress)
|
||||||
gameActivity?.let { initProgressUI.updateData(it) }
|
gameActivity?.let { initProgressUI.updateData(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gameActivity != null) && (lastFrameStartInit != NativeInitProgress.startInit)) {
|
if ((gameActivity != null) && (lastFrameStartInit != NativeInitProgress.startInit)) { // change status
|
||||||
if (NativeInitProgress.startInit) {
|
if (NativeInitProgress.startInit) {
|
||||||
initProgressUI.createView(gameActivity!!)
|
initProgressUI.createView(gameActivity!!)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -293,18 +303,22 @@ class GakumasHookMain : XposedModule() {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清理本地文件
|
||||||
if (programConfig?.cleanLocalAssets == true) {
|
if (programConfig?.cleanLocalAssets == true) {
|
||||||
FilesChecker.cleanAssets()
|
FilesChecker.cleanAssets()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查 files 版本和 assets 版本并更新
|
||||||
if (programConfig?.checkBuiltInAssets == true) {
|
if (programConfig?.checkBuiltInAssets == true) {
|
||||||
FilesChecker.initAndCheck(activity.filesDir, modulePath)
|
FilesChecker.initAndCheck(activity.filesDir, modulePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 强制导出 assets 文件
|
||||||
if (initConfig?.forceExportResource == true) {
|
if (initConfig?.forceExportResource == true) {
|
||||||
FilesChecker.updateFiles()
|
FilesChecker.updateFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用热更新文件
|
||||||
if ((programConfig?.useRemoteAssets == true) || (programConfig?.useAPIAssets == true)) {
|
if ((programConfig?.useRemoteAssets == true) || (programConfig?.useAPIAssets == true)) {
|
||||||
val dataUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
val dataUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
intent.getParcelableExtra("resource_file", Uri::class.java)
|
intent.getParcelableExtra("resource_file", Uri::class.java)
|
||||||
|
|
@ -323,6 +337,7 @@ class GakumasHookMain : XposedModule() {
|
||||||
else if (programConfig.useAPIAssets) {
|
else if (programConfig.useAPIAssets) {
|
||||||
if (!File(activity.filesDir, localizationFilesDir).exists() &&
|
if (!File(activity.filesDir, localizationFilesDir).exists() &&
|
||||||
(initConfig?.forceExportResource == false)) {
|
(initConfig?.forceExportResource == false)) {
|
||||||
|
// 使用 API 资源,不检查内置,API 资源无效,且游戏内没有插件数据时,释放内置数据
|
||||||
FilesChecker.initAndCheck(activity.filesDir, modulePath)
|
FilesChecker.initAndCheck(activity.filesDir, modulePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -481,6 +496,7 @@ class GakumasHookMain : XposedModule() {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
external fun loadConfig(configJsonStr: String)
|
external fun loadConfig(configJsonStr: String)
|
||||||
|
|
||||||
|
// Toast快速切换内容
|
||||||
private var toast: Toast? = null
|
private var toast: Toast? = null
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
@ -498,8 +514,11 @@ class GakumasHookMain : XposedModule() {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
handler.post {
|
handler.post {
|
||||||
|
// 取消之前的 Toast
|
||||||
toast?.cancel()
|
toast?.cancel()
|
||||||
|
// 创建新的 Toast
|
||||||
toast = Toast.makeText(context, message, Toast.LENGTH_SHORT)
|
toast = Toast.makeText(context, message, Toast.LENGTH_SHORT)
|
||||||
|
// 展示新的 Toast
|
||||||
toast?.show()
|
toast?.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue