diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index e82a32868..668ef6037 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -83,6 +83,39 @@ struct AppletSlotData { // Holds data about the concurrently running applets in the system. static std::array applet_slots = {}; +struct AppletTitleData { + // There are two possible applet ids for each applet. + std::array applet_ids; + + // There's a specific TitleId per region for each applet. + static constexpr size_t NumRegions = 7; + std::array title_ids; +}; + +static constexpr size_t NumApplets = 29; +static constexpr std::array applet_titleids = {{ + {AppletId::HomeMenu, AppletId::None, 0x4003000008202, 0x4003000008F02, 0x4003000009802, + 0x4003000008202, 0x400300000A102, 0x400300000A902, 0x400300000B102}, + {AppletId::SoftwareKeyboard1, AppletId::SoftwareKeyboard2, 0x400300000C002, 0x400300000C802, + 0x400300000D002, 0x400300000C002, 0x400300000D802, 0x400300000DE02, 0x400300000E402}, + {AppletId::Error, AppletId::Error2, 0x400300000C502, 0x400300000C502, 0x400300000C502, + 0x400300000C502, 0x400300000CF02, 0x400300000CF02, 0x400300000CF02}, + // TODO(Subv): Fill in the rest of the titleids +}}; + +static u64 GetTitleIdForApplet(AppletId id) { + ASSERT_MSG(id != AppletId::None, "Invalid applet id"); + + auto itr = std::find_if(applet_titleids.begin(), applet_titleids.end(), + [id](const AppletTitleData& data) { + return data.applet_ids[0] == id || data.applet_ids[1] == id; + }); + + ASSERT_MSG(itr != applet_titleids.end(), "Unknown applet id"); + + return itr->title_ids[CFG::GetRegionValue()]; +} + // This overload returns nullptr if no applet with the specified id has been started. static AppletSlotData* GetAppletSlotData(AppletId id) { auto GetSlot = [](AppletSlot slot) -> AppletSlotData* {