#include "SceTypes.hpp" #include "prx/libc/include/general/VabiMacros.hpp" #include #include #include extern "C" { int APS5_VABI sceNpGameIntentInitParamInit(NpGameIntentInitParam* param); int APS5_VABI sceNpGameIntentInfoInit(NpGameIntentInfo* info); int APS5_VABI sceNpGameIntentInitialize(const void* initParam); int APS5_VABI sceNpGameIntentReceiveIntent(NpGameIntentInfo* intentInfo); int APS5_VABI sceNpGameIntentGetPropertyValueString(const NpGameIntentData* intentData, const char* key, char* valueBuf, size_t bufSize); int APS5_VABI sceNpGameIntentVshInitialize(void); int APS5_VABI sceNpGameIntentVshTerminate(void); int APS5_VABI sceNpGameIntentTerminate(void); int APS5_VABI sceNpAppLauncherInitialize(const void* initParam); int APS5_VABI sceNpAppLauncherLaunchApp(void); int APS5_VABI sceNpAppLauncherTerminate(void); } static void Require(bool value, const char* what) { if (value) return; std::printf("NpGameIntent: %s\n", what); std::abort(); } template static bool Throws(TCall call) { try { call(); } catch (const TError&) { return true; } return false; } int main() { constexpr int kIntentNotFound = -2141898746; constexpr int kValueNotFound = -2141898745; Require(Throws([] { sceNpGameIntentInitParamInit(nullptr); }), "null param init did not throw"); NpGameIntentInitParam initParam{}; Require(sceNpGameIntentInitParamInit(&initParam) == 0, "param init failed"); Require(initParam.size == sizeof(NpGameIntentInitParam), "param size mismatch"); Require(Throws([] { sceNpGameIntentInfoInit(nullptr); }), "null info init did not throw"); NpGameIntentInfo info{}; Require(sceNpGameIntentInfoInit(&info) == 0, "info init failed"); Require(info.size == sizeof(NpGameIntentInfo), "info size mismatch"); Require(info.user_id == -1, "info user_id mismatch"); Require(sceNpGameIntentInitialize(&initParam) == 0, "initialization failed"); Require(sceNpGameIntentReceiveIntent(&info) == kIntentNotFound, "receive intent mismatch"); char buf[64]{}; Require(sceNpGameIntentGetPropertyValueString(&info.intent_data, "key", buf, sizeof(buf)) == kValueNotFound, "get property value mismatch"); Require(sceNpGameIntentVshInitialize() == 0, "vsh init failed"); Require(sceNpGameIntentVshTerminate() == 0, "vsh terminate failed"); Require(sceNpGameIntentTerminate() == 0, "terminate failed"); unsigned char appLauncherParam[0x28]{}; *reinterpret_cast(appLauncherParam) = 0x28; Require(sceNpAppLauncherInitialize(appLauncherParam) == 0, "app launcher init failed"); Require(Throws([] { sceNpAppLauncherLaunchApp(); }), "app launcher launch must throw until implemented"); Require(sceNpAppLauncherTerminate() == 0, "app launcher terminate failed"); *reinterpret_cast(appLauncherParam) = 0x10; Require(sceNpAppLauncherInitialize(appLauncherParam) == 0, "app launcher init must accept any init parameter"); std::puts("NpGameIntent tests passed"); return 0; }