Skip to content

Commit fbbe905

Browse files
committed
app-playstats: Updated for latest libnx, etc.
1 parent 454610b commit fbbe905

File tree

1 file changed

+19
-6
lines changed
  • applet/app-playstats/source

1 file changed

+19
-6
lines changed

applet/app-playstats/source/main.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int main(int argc, char* argv[])
8686
printf("total_out: %d\n", total_out);
8787
for (i=0; i<total_out; i++) {
8888
printf("%d: ", i);
89-
printf("application_id = 0x%08lX, totalPlayTime = %lu (%llu seconds), totalLaunches = %lu\n", stats[i].application_id, stats[i].totalPlayTime, stats[i].totalPlayTime / 1000000000ULL, stats[i].totalLaunches);
89+
printf("application_id = 0x%08lX, playtime = %lu (%lu seconds), total_launches = %lu\n", stats[i].application_id, stats[i].playtime, stats[i].playtime / 1000000000UL, stats[i].total_launches);
9090
}
9191
}
9292
}
@@ -101,38 +101,51 @@ int main(int argc, char* argv[])
101101
if (R_SUCCEEDED(rc)) {
102102
printf("total_out: %d\n", total_out);
103103
for (i=0; i<total_out; i++) {
104-
time_t tmptime = pdmPlayTimestampToPosix(events[i].timestampUser);
104+
time_t tmptime = events[i].timestamp_user;
105105

106106
printf("%d: ", i);
107-
printf("program_id = 0x%08lX, entry_index = 0x%x, timestampUser = %u, timestampNetwork = %u, eventType = %u, timestampUser = %s\n", events[i].program_id, events[i].entry_index, events[i].timestampUser, events[i].timestampNetwork, events[i].eventType, ctime(&tmptime));
107+
printf("program_id = 0x%08lX, entry_index = 0x%x, timestamp_user = %lu, timestamp_network = %lu, event_type = %u, timestamp_user = %s\n", events[i].program_id, events[i].entry_index, events[i].timestamp_user, events[i].timestamp_network, events[i].event_type, ctime(&tmptime));
108108
}
109109
}
110110

111111
// Get PdmPlayStatistics for the specified ApplicationId.
112112
PdmPlayStatistics playstats[1]={0};
113113
rc = pdmqryQueryPlayStatisticsByApplicationId(application_ids[0], false, &playstats[0]);
114114
printf("pdmqryQueryPlayStatisticsByApplicationId(): 0x%x\n", rc);
115-
if (R_SUCCEEDED(rc)) printf("application_id = 0x%08lX, playtimeMinutes = %u, totalLaunches = %u\n", playstats[0].application_id, playstats[0].playtimeMinutes, playstats[0].totalLaunches);
115+
if (R_SUCCEEDED(rc)) printf("program_id = 0x%016lX, playtime = %lu (%lu seconds), total_launches = %u\n", playstats[0].program_id, playstats[0].playtime, playstats[0].playtime / 1000000000UL, playstats[0].total_launches);
116116

117117
// Get PdmPlayStatistics for the specified ApplicationId and user.
118118
rc = pdmqryQueryPlayStatisticsByApplicationIdAndUserAccountId(application_ids[0], preselected_uid, false, &playstats[0]);
119119
printf("pdmqryQueryPlayStatisticsByApplicationIdAndUserAccountId(): 0x%x\n", rc);
120-
if (R_SUCCEEDED(rc)) printf("application_id = 0x%08lX, playtimeMinutes = %u, totalLaunches = %u\n", playstats[0].application_id, playstats[0].playtimeMinutes, playstats[0].totalLaunches);
120+
if (R_SUCCEEDED(rc)) printf("program_id = 0x%016lX, playtime = %lu (%lu seconds), total_launches = %u\n", playstats[0].program_id, playstats[0].playtime, playstats[0].playtime / 1000000000UL, playstats[0].total_launches);
121121

122122
// Get a listing of PdmLastPlayTime for the specified applications.
123123
PdmLastPlayTime playtimes[1]={0};
124124
rc = pdmqryQueryLastPlayTime(false, playtimes, application_ids, 1, &total_out);
125125
printf("pdmqryQueryLastPlayTime(): 0x%x, %d\n", rc, total_out);
126126
if (R_SUCCEEDED(rc)) {
127127
for (i=0; i<total_out; i++)
128-
printf("%d: timestampUser = %lu\n", i, pdmPlayTimestampToPosix(playtimes[i].timestampUser));
128+
printf("%d: timestamp_user = %lu\n", i, pdmPlayTimestampToPosix(playtimes[i].timestamp_user));
129129
}
130130

131131
// Get the available range for reading events, see pdm.h.
132132
s32 total_entries=0, start_entryindex=0, end_entryindex=0;
133133
rc = pdmqryGetAvailablePlayEventRange(&total_entries, &start_entryindex, &end_entryindex);
134134
printf("pdmqryGetAvailablePlayEventRange(): 0x%x, 0x%x, 0x%x, 0x%x\n", rc, total_entries, start_entryindex, end_entryindex);
135135

136+
// Get account events.
137+
PdmAccountEvent accevents[5]={};
138+
rc = pdmqryQueryAccountEvent(0, accevents, 5, &total_out);
139+
printf("pdmqryQueryAccountEvent(): 0x%x\n", rc);
140+
if (R_SUCCEEDED(rc)) {
141+
printf("total_out: %d\n", total_out);
142+
for (i=0; i<total_out; i++) {
143+
time_t tmptime = accevents[i].timestamp_user;
144+
printf("%d: ", i);
145+
printf("uid = 0x%lx 0x%lx, program_id = 0x%016lX, entry_index = 0x%x, timestamp_user = %lu, timestamp_network = %lu, event_type = %u, timestamp_user = %s\n", accevents[i].uid.uid[0], accevents[i].uid.uid[1], accevents[i].program_id, accevents[i].entry_index, accevents[i].timestamp_user, accevents[i].timestamp_network, accevents[i].type, ctime(&tmptime));
146+
}
147+
}
148+
136149
// For more cmds, see pdm.h.
137150
}
138151

0 commit comments

Comments
 (0)