GameList: Use MCP_TitleListByAppType to request specific app catergories

This commit is contained in:
rw-r-r-0644 2020-05-02 21:50:46 +02:00
parent 96fa65a5ff
commit 36c92744b7
No known key found for this signature in database
GPG Key ID: 9F89C03279187405
2 changed files with 34 additions and 16 deletions

View File

@ -77,30 +77,47 @@ int32_t GameList::readGameList() {
} }
std::vector<struct MCPTitleListType> titles(titleCount); std::vector<struct MCPTitleListType> titles(titleCount);
uint32_t realTitleCount; uint32_t realTitleCount = 0;
MCPError err = MCP_TitleList(mcp, &realTitleCount, titles.data(), titles.size() * sizeof(decltype(titles)::value_type)); static const std::vector<MCPAppType> menuAppTypes {
if (err < 0) { MCP_APP_TYPE_GAME,
MCP_Close(mcp); MCP_APP_TYPE_GAME_WII,
return 0; MCP_APP_TYPE_SYSTEM_APPS,
MCP_APP_TYPE_SYSTEM_SETTINGS,
MCP_APP_TYPE_FRIEND_LIST,
MCP_APP_TYPE_MIIVERSE,
MCP_APP_TYPE_ESHOP,
MCP_APP_TYPE_BROWSER,
MCP_APP_TYPE_DOWNLOAD_MANAGEMENT,
MCP_APP_TYPE_ACCOUNT_APPS,
};
for (auto appType : menuAppTypes) {
uint32_t titleCountByType = 0;
MCPError err = MCP_TitleListByAppType(mcp, appType, &titleCountByType, titles.data() + realTitleCount,
(titles.size() - realTitleCount) * sizeof(decltype(titles)::value_type));
if (err < 0) {
MCP_Close(mcp);
return 0;
}
realTitleCount += titleCountByType;
} }
if (realTitleCount != titles.size()) { if (realTitleCount != titles.size()) {
titles.resize(realTitleCount); titles.resize(realTitleCount);
} }
for (auto title_candidate : titles) { for (auto title_candidate : titles) {
if(true || (title_candidate.titleId & 0xFFFFFFFF00000000L) == 0x0005000000000000L) { gameInfo* newGameInfo = new gameInfo;
gameInfo* newGameInfo = new gameInfo; newGameInfo->titleId = title_candidate.titleId;
newGameInfo->titleId = title_candidate.titleId; newGameInfo->appType = title_candidate.appType;
newGameInfo->gamePath = title_candidate.path; newGameInfo->gamePath = title_candidate.path;
newGameInfo->name = "<unknown>"; newGameInfo->name = "<unknown>";
newGameInfo->imageData = NULL; newGameInfo->imageData = NULL;
DCFlushRange(newGameInfo, sizeof(gameInfo)); DCFlushRange(newGameInfo, sizeof(gameInfo));
fullGameList.push_back(newGameInfo); fullGameList.push_back(newGameInfo);
titleAdded(newGameInfo); titleAdded(newGameInfo);
cnt++; cnt++;
}
} }
AsyncExecutor::execute([this] { AsyncExecutor::execute([this] {

View File

@ -11,6 +11,7 @@
typedef struct _gameInfo { typedef struct _gameInfo {
uint64_t titleId; uint64_t titleId;
MCPAppType appType;
std::string name; std::string name;
std::string gamePath; std::string gamePath;
GuiImageData * imageData; GuiImageData * imageData;