diff --git a/applet/app-playstats/source/main.c b/applet/app-playstats/source/main.c index 6bd72d2..57f9da6 100644 --- a/applet/app-playstats/source/main.c +++ b/applet/app-playstats/source/main.c @@ -2,11 +2,13 @@ #include #include #include +#include // Include the main libnx system header, for Switch development #include // This example shows how to use applet to get playstats for applications. See also libnx applet.h. See applet.h for the requirements for using this. +// This also shows how to use pdmqry, see also libnx pdm.h. /// Main program entrypoint int main(int argc, char* argv[]) @@ -18,15 +20,23 @@ int main(int argc, char* argv[]) // take a look at the graphics/opengl set of examples, which uses EGL instead. consoleInit(NULL); - printf("applet application play-stats example\n"); + printf("application play-stats example\n"); Result rc=0; PdmApplicationPlayStatistics stats[1]; + PdmApplicationEvent events[1]; u64 titleIDs[1] = {0x010021B002EEA000}; // Change this to the titleID of the current-process / the titleID you want to use. s32 total_out; s32 i; + bool initflag=0; + + // Not needed if you just want to use the applet cmds. + rc = pdmqryInitialize(); + if (R_FAILED(rc)) printf("pdmqryInitialize(): 0x%x\n", rc); + if (R_SUCCEEDED(rc)) initflag = true; printf("Press A to get playstats.\n"); + if (initflag) printf("Press X to use pdmqry.\n"); printf("Press + to exit.\n"); // Main loop @@ -59,10 +69,31 @@ int main(int argc, char* argv[]) } } + if (initflag && (kDown & KEY_X)) { + memset(events, 0, sizeof(events)); + total_out = 0; + + rc = pdmqryQueryApplicationEvent(0, events, sizeof(events)/sizeof(PdmApplicationEvent), &total_out); + printf("pdmqryQueryApplicationEvent(): 0x%x\n", rc); + if (R_SUCCEEDED(rc)) { + printf("total_out: %d\n", total_out); + for (i=0; i