From 68a9002b4a31c96069dd121a5b9ab8b745dba11b Mon Sep 17 00:00:00 2001 From: yellows8 Date: Fri, 18 Oct 2019 16:56:58 -0400 Subject: [PATCH] Updated app-playstats for latest libnx, and updated for using more cmds etc. --- applet/app-playstats/source/main.c | 71 +++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/applet/app-playstats/source/main.c b/applet/app-playstats/source/main.c index 18fd90e..a5b19fa 100644 --- a/applet/app-playstats/source/main.c +++ b/applet/app-playstats/source/main.c @@ -24,16 +24,27 @@ int main(int argc, char* argv[]) Result rc=0; PdmApplicationPlayStatistics stats[1]; - PdmApplicationEvent events[1]; + PdmAppletEvent 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; + // Only needed when using the cmds which require the Uid. + AccountUid preselected_uid={0}; + rc = accountInitialize(); + if (R_SUCCEEDED(rc)) { + rc = accountGetPreselectedUser(&preselected_uid); + accountExit(); + } + if (R_FAILED(rc)) printf("Failed to get user: 0x%x\n", rc); + // 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; + if (R_SUCCEEDED(rc)) { + 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"); @@ -58,8 +69,12 @@ int main(int argc, char* argv[]) memset(stats, 0, sizeof(stats)); total_out = 0; - rc = appletQueryApplicationPlayStatistics(stats, titleIDs, sizeof(titleIDs)/sizeof(u64), &total_out); - printf("appletQueryApplicationPlayStatistics(): 0x%x\n", rc); + if (R_SUCCEEDED(rc)) { + rc = appletQueryApplicationPlayStatistics(stats, titleIDs, sizeof(titleIDs)/sizeof(u64), &total_out); + printf("appletQueryApplicationPlayStatistics(): 0x%x\n", rc); + //rc = appletQueryApplicationPlayStatisticsByUid(&preselected_uid, stats, titleIDs, sizeof(titleIDs)/sizeof(u64), &total_out); + //printf("appletQueryApplicationPlayStatisticsByUid(): 0x%x\n", rc); + } if (R_SUCCEEDED(rc)) { printf("total_out: %d\n", total_out); for (i=0; i