Scripting - barisyild/airpsx GitHub Wiki

Custom Functions

sceRegMgrGetInt(key:cpp.lib.type.RegMgrKey):cpp.Int32;
sceRegMgrGetInt64(key:cpp.lib.type.RegMgrKey):cpp.Int64;
sceRegMgrGetStr(key:cpp.lib.type.RegMgrKey, size:cpp.Int32):Null<String>;
sceRegMgrGetBinBase64(key:cpp.lib.type.RegMgrKey, size:cpp.Int32):Null<String>;
sceRegMgrGetBin(key:cpp.lib.type.RegMgrKey, size:cpp.Int32):Null<Array<cpp.UInt8>>;
sceRegMgrSetInt(key:cpp.lib.type.RegMgrKey, val:cpp.Int32):cpp.Int32;
sceRegMgrSetBin(key:cpp.lib.type.RegMgrKey, val:Array<cpp.UInt8>):cpp.Int32;
sceRegMgrSetStr(key:cpp.lib.type.RegMgrKey, val:String):cpp.Int32;
customRegMgrGenerateNum(a:Int, b:Int, c:Int, d:Int, e:Int):cpp.lib.type.RegMgrKey;
statvfs(path:String):Null<cpp.lib.sys.StatVFSTypedef>;
statvfs_formatted(path:String):Null<{ used:haxe.Int64, total:haxe.Int64, free:haxe.Int64, available:haxe.Int64 }>;
sceKernelGetCpuTemperature():Int;
sceKernelGetCpuFrequency():Float;
sceKernelSendNotificationRequest(message:String):Void;
sceKernelGetHwModelName():String;
sceKernelGetHwSerialNumber():String;
sceKernelGetSocSensorTemperature(?sensor:Int):Int;
sceKernelGetAppInfo(pid:cpp.PidT):cpp.extern.AppInfoTypedef;
sceKernelGetAppCategoryType(pid:cpp.PidT):cpp.extern.ApplicationCategoryType;
sceRandomGetRandomNumber(array:Array<cpp.UInt8>):Void;
sceLncUtilLaunchApp(titleId:String, ?userId:Null<Int>, ?appOpt:Int, ?crashReport:Int, ?checkFlag:cpp.lib.LncAppParamFlag):cpp.lib.LncAppErrorType;
sceSystemServiceLaunchWebBrowser(url:String):Bool;
sceUserServiceGetForegroundUser():Int;
statfs(path:String):Null<cpp.lib.sys.StatFSTypedef>;
appInstUtilInstallByPackage(uri:String, ?contentName:String, ?iconUrl:String):Void;
sceAppInstUtilAppUnInstall(titleId:String):cpp.Int32;
sysctlbyname(key:String):Null<haxe.io.Bytes>;
sceRemoteplayInitialize():Bool;
sceRemoteplayGeneratePinCode():cpp.Int32;
sceRemoteplayConfirmDeviceRegist():Null<{ result:cpp.Int32, pair_stat:cpp.Int32, pair_err:cpp.Int32 }>;
sceRemoteplayNotifyPinCodeError(errorCode:cpp.Int32):cpp.Int32;

You can directly call any function with “@:hscriptVariable” macros from within the project.

image

RuleScript

Std Classes

You can use Haxe's std classes.

Example

import sys.FileSystem;

FileSystem.readDirectory("/system_data").join(","); // eap,priv,common,temp,music_core,settings,nobackup,game,playgo,httpcache,savedata,savedata_prospero

Samples

Hello World

sceKernelSendNotificationRequest("Hello World");

Kernel Boot Time

import haxe.io.BytesInput;

var bytes = sysctlbyname("kern.boottime");
var bytesInput = new BytesInput(bytes);
Date.fromTime(bytesInput.readInt32() * 1000);

Temperature Notification

var cpuTemp = sceKernelGetCpuTemperature();
var socTemp = sceKernelGetSocSensorTemperature(0);
sceKernelSendNotificationRequest('CPU temp: ${cpuTemp} °C\nSoC temp: ${socTemp} °C');

sceRandomGetRandomNumber

var array = [0,0,0,0,0,0];
sceRandomGetRandomNumber(array);
return array; // [252,79,72,37,82,252]

SQLite

import hx.well.facades.DBStatic;

var db = DBStatic.connection("app");
var resultSet = db.query('SELECT titleName FROM tbl_contentinfo WHERE titleId = ?', ["PPSA01325"]);
var result = resultSet.next();
result.titleName; // ASTRO's PLAYROOM

Lua

Lua support is limited so I recommend using rulescript.

Samples

Hello World

function main()
	sceKernelSendNotificationRequest("Hello World")
end

Kernel Boot Time

function main()
	local data = string.char(table.unpack(sysctlbyname("kern.boottime").getData()))
	local sec = string.unpack("<i4", data)
	print(sec * 1000)
end

Temperature Notification

function main()
	local cpuTemp = sceKernelGetCpuTemperature()
	local socTemp = sceKernelGetSocSensorTemperature(0)

	local message = string.format("CPU temp: %d °C\nSoC temp: %d °C", cpuTemp, socTemp)
	sceKernelSendNotificationRequest(message)
end

sceRandomGetRandomNumber

function main()
	local array = {0, 0, 0, 0, 0, 0}
	array = sceRandomGetRandomNumber(array)
	print(array) // [100,27,134,6,220,3]
end
⚠️ **GitHub.com Fallback** ⚠️