generated from shadow3aaa/fas-rs-extension-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
126 lines (125 loc) · 4.3 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
-- fas-rs 使用它来提供指定版本的api
-- fas-rs use this to provide version-specified api
API_VERSION = 3
--
-- 中文:
-- 该枚举对应的lua函数
-- 在 fas-rs 中将被 fas-rs 回调
-- pub enum Api {
-- LoadFas(pid_t, String), --------> function load_fas(pid, pkg)
-- UnloadFas(pid_t, String), ------> function unload_fas(pid, pkg)
-- StartFas, ----------------------> function start_fas()
-- StopFas, -----------------------> function stop_fas()
-- InitCpuFreq, -------------------> function init_cpu_freq()
-- ResetCpuFreq, ------------------> function reset_cpu_freq()
-- TargetFpsChange(u32, String) ---> function target_fps_change(target_fps, pkg)
-- }
--
-- 可注册的函数说明:
-- function load_fas(pid, pkg)
-- 当 fas-rs 加载到目标游戏时调用,
-- 参数为目标应用程序的pid和包名
--
-- function unload_fas(pid, pkg)
-- 当 fas-rs 卸载到目标游戏时调用,
-- 参数为目标应用程序的pid和包名
--
-- function start_fas()
-- 切换到fas-rs工作状态时调用。
--
-- function stop_fas()
-- 切换到 fas-rs 不工作状态时调用。
--
-- function init_cpu_freq()
-- 当cpu控制器进入控制状态时调用。
--
-- function reset_cpu_freq()
-- 当cpu控制器退出控制状态时调用。
--
-- target_fps_change(target_fps, pkg)
-- 当fas目标帧率改变时调用
--
-- 附加: 在函数外的lua代码会在插件加载时被执行,
-- 如果你有执行初始化内容的需求,这样做很方便。
--
-- fas-rs提供的函数:
-- log_info("message")
-- 打印一个info等级日志到/sdcard/Android/fas-rs/fas_log.txt
--
-- log_error("message")
-- 打印一个error等级日志到/sdcard/Android/fas-rs/fas_log.txt
--
-- log_debug("message")
-- 打印一个debug等级日志到/sdcard/Android/fas-rs/fas_log.txt,
-- 此等级在fas-rs的release build不开启
--
-- set_policy_freq_offset(policy, offset)
-- 设置指定集群的fas频率偏移量,可为负数
--
-- set_ignore_policy(policy, val)
-- 设置是否对指定集群开启fas频率控制,val为bool
--
-- ------------------------------------
--
-- EN:
-- The lua function corresponding to this enumeration
-- in fas-rs will be called back by fas-rs
-- pub enum Api {
-- LoadFas(pid_t, String), --------> function load_fas(pid, pkg)
-- UnloadFas(pid_t, String), ------> function unload_fas(pid, pkg)
-- StartFas, ----------------------> function start_fas()
-- StopFas, -----------------------> function stop_fas()
-- InitCpuFreq, -------------------> function init_cpu_freq()
-- ResetCpuFreq, ------------------> function reset_cpu_freq()
-- TargetFpsChange(u32, String) ---> function target_fps_change(target_fps, pkg)
-- }
--
-- Registerable function description:
-- function load_fas(pid, pkg)
-- Called when fas-rs is loaded into the target game,
-- The parameters are the pid and package name of the target application
--
-- function unload_fas(pid, pkg)
-- Called when fas-rs is unloaded to the target game,
-- The parameters are the pid and package name of the target application
--
-- function start_fas()
-- Called when switching to fas-rs working state.
--
-- function stop_fas()
-- Called when switching to fas-rs not-working state.
--
-- function init_cpu_freq()
-- Called when the cpu controller enters the control state.
--
-- function reset_cpu_freq()
-- Called when the cpu controller exits the control state.
--
-- target_fps_change(target_fps, pkg)
-- Called when target fps changes.
--
-- Extra: Lua code outside the function will be
-- executed when the extension is loaded, if you need to
-- execute initialization content, this is convenient.
--
-- Functions provided by fas-rs:
-- log_info("message")
-- Print an info level log to /sdcard/Android/fas-rs/fas_log.txt
--
-- log_error("message")
-- Print an error level log to /sdcard/Android/fas-rs/fas_log.txt
--
-- log_debug("message")
-- Print a debug level log to /sdcard/Android/fas-rs/fas_log.txt,
-- This level is not enabled in the release build of fas-rs.
--
-- set_policy_freq_offset(policy, offset)
-- Sets the FAS frequency offset for the specified cluster, which can be a negative number.
--
-- set_ignore_policy(policy, val)
-- Sets whether to enable FAS frequency control for the specified cluster, val is a bool.
--
log_info("hello world") -- Initial
function start_fas() -- A example for callback functions
log_info("fas started")
end