mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 05:12:40 +02:00
Use accountGetPreselectedUser for getting the userID in the account and fs/save examples.
This commit is contained in:
parent
f89c1572bc
commit
927256ce99
@ -3,14 +3,13 @@
|
|||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
//This example shows how to get info for the current user account. See libnx acc.h.
|
//This example shows how to get info for the preselected user account. See libnx acc.h.
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
|
|
||||||
u128 userID=0;
|
u128 userID=0;
|
||||||
bool account_selected=0;
|
|
||||||
AccountProfile profile;
|
AccountProfile profile;
|
||||||
AccountUserData userdata;
|
AccountUserData userdata;
|
||||||
AccountProfileBase profilebase;
|
AccountProfileBase profilebase;
|
||||||
@ -28,14 +27,10 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
rc = accountGetActiveUser(&userID, &account_selected);
|
rc = accountGetPreselectedUser(&userID);
|
||||||
|
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
printf("accountGetActiveUser() failed: 0x%x\n", rc);
|
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
|
||||||
}
|
|
||||||
else if(!account_selected) {
|
|
||||||
printf("No user is currently selected.\n");
|
|
||||||
rc = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
@ -48,14 +48,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
FsFileSystem tmpfs;
|
FsFileSystem tmpfs;
|
||||||
u128 userID=0;
|
u128 userID=0;
|
||||||
bool account_selected=0;
|
|
||||||
u64 titleID=0x01007ef00011e000;//titleID of the save to mount, in this case BOTW.
|
u64 titleID=0x01007ef00011e000;//titleID of the save to mount, in this case BOTW.
|
||||||
|
|
||||||
consoleInit(NULL);
|
consoleInit(NULL);
|
||||||
|
|
||||||
//Get the userID for save mounting. To mount common savedata, use FS_SAVEDATA_USERID_COMMONSAVE.
|
//Get the userID for save mounting. To mount common savedata, use FS_SAVEDATA_USERID_COMMONSAVE.
|
||||||
|
|
||||||
//Try to find savedata to use with get_save() first, otherwise fallback to the above hard-coded TID + the userID from accountGetActiveUser(). Note that you can use either method.
|
//Try to find savedata to use with get_save() first, otherwise fallback to the above hard-coded TID + the userID from accountGetPreselectedUser(). Note that you can use either method.
|
||||||
//See the account example for getting account info for an userID.
|
//See the account example for getting account info for an userID.
|
||||||
//See also the app_controldata example for getting info for a titleID.
|
//See also the app_controldata example for getting info for a titleID.
|
||||||
if (R_FAILED(get_save(&titleID, &userID))) {
|
if (R_FAILED(get_save(&titleID, &userID))) {
|
||||||
@ -65,15 +64,11 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
rc = accountGetActiveUser(&userID, &account_selected);
|
rc = accountGetPreselectedUser(&userID);
|
||||||
accountExit();
|
accountExit();
|
||||||
|
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
printf("accountGetActiveUser() failed: 0x%x\n", rc);
|
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
|
||||||
}
|
|
||||||
else if(!account_selected) {
|
|
||||||
printf("No user is currently selected.\n");
|
|
||||||
rc = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user