rpcsx/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp

103 lines
2.3 KiB
C++
Raw Normal View History

#include "stdafx.h"
#include "Emu/System.h"
2016-03-21 20:43:03 +01:00
#include "Emu/Cell/PPUModule.h"
#include "cellUserInfo.h"
#include "Utilities/StrUtil.h"
2016-05-13 15:55:34 +02:00
logs::channel cellUserInfo("cellUserInfo", logs::level::notice);
2015-07-09 17:30:37 +02:00
s32 cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
{
cellUserInfo.warning("cellUserInfoGetStat(id=%d, stat=*0x%x)", id, stat);
if (id > CELL_SYSUTIL_USERID_MAX)
{
return CELL_USERINFO_ERROR_NOUSER;
}
if (id == CELL_SYSUTIL_USERID_CURRENT)
{
// TODO: Return current user/profile when that is implemented
id = 1;
}
2016-03-21 20:43:03 +01:00
const std::string& path = vfs::get(fmt::format("/dev_hdd0/home/%08d/", id));
2016-03-21 20:43:03 +01:00
if (!fs::is_dir(path))
{
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_NOUSER. User %d doesn't exist. Did you delete the user folder?", id);
return CELL_USERINFO_ERROR_NOUSER;
}
2016-03-21 20:43:03 +01:00
const fs::file f(path + "localusername");
2016-03-21 20:43:03 +01:00
if (!f)
{
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_INTERNAL. Username for user %d doesn't exist. Did you delete the username file?", id);
return CELL_USERINFO_ERROR_INTERNAL;
}
stat->id = id;
2016-03-21 20:43:03 +01:00
strcpy_trunc(stat->name, f.to_string());
return CELL_OK;
}
2015-07-09 17:30:37 +02:00
s32 cellUserInfoSelectUser_ListType()
{
UNIMPLEMENTED_FUNC(cellUserInfo);
return CELL_OK;
}
2015-07-09 17:30:37 +02:00
s32 cellUserInfoSelectUser_SetList()
{
UNIMPLEMENTED_FUNC(cellUserInfo);
return CELL_OK;
}
2015-07-09 17:30:37 +02:00
s32 cellUserInfoEnableOverlay()
{
UNIMPLEMENTED_FUNC(cellUserInfo);
return CELL_OK;
}
ppu_error_code cellUserInfoGetList(vm::ptr<u32> listNum, vm::ptr<CellUserInfoUserList> listBuf, vm::ptr<u32> currentUserId)
{
cellUserInfo.todo("cellUserInfoGetList(listNum=*0x%x, listBuf=*0x%x, currentUserId=*0x%x)", listNum, listBuf, currentUserId);
// If only listNum is NULL, an error will be returned
2014-09-01 02:51:48 +02:00
if (listBuf && !listNum)
{
return CELL_USERINFO_ERROR_PARAM;
}
2014-09-01 02:51:48 +02:00
if (listNum)
{
2014-09-01 02:51:48 +02:00
*listNum = 1;
}
2014-09-01 02:51:48 +02:00
if (listBuf)
{
listBuf->userId[0] = 1;
}
2014-09-01 02:51:48 +02:00
if (currentUserId)
{
// TODO: Properly set the current user ID here, once implemented
2014-09-01 02:51:48 +02:00
*currentUserId = 1;
}
return CELL_OK;
}
2016-03-21 20:43:03 +01:00
DECLARE(ppu_module_manager::cellUserInfo)("cellUserInfo", []()
{
REG_FUNC(cellUserInfo, cellUserInfoGetStat);
REG_FUNC(cellUserInfo, cellUserInfoSelectUser_ListType);
REG_FUNC(cellUserInfo, cellUserInfoSelectUser_SetList);
REG_FUNC(cellUserInfo, cellUserInfoEnableOverlay);
REG_FUNC(cellUserInfo, cellUserInfoGetList);
});