46std::unordered_map<int, ProtonDBGameInfo> ProtonDBService::cache_;
47std::mutex ProtonDBService::cacheMutex_;
87 const std::string num = std::to_string(value);
88 for (
const char* sep : {
"\":",
"\": "})
90 const std::string base = std::string(
"\"") + key + sep + num;
91 size_t pos = response.find(base);
92 while (pos != std::string::npos)
94 const size_t after = pos + base.size();
95 if (after >= response.size() ||
96 !std::isdigit(
static_cast<unsigned char>(response[after])))
98 pos = response.find(base, after);
109std::string ProtonDBService::httpGet(
const std::string& url)
112 std::string command =
113 "curl -s -L --proto =https --connect-timeout 10 --max-time 30 --max-redirs 10 " +
116 std::array<char, 4096> buffer;
119 std::unique_ptr<FILE, int (*)(FILE*)> pipe(popen(command.c_str(),
"r"), pclose);
126 constexpr size_t kMaxResponse = 16u * 1024 * 1024;
127 while (fgets(buffer.data(),
static_cast<int>(buffer.size()), pipe.get()) !=
nullptr)
129 result += buffer.data();
130 if (result.size() > kMaxResponse)
132 Logger::warn(
"[ProtonDB] HTTP response too large, truncating");
140std::string ProtonDBService::urlEncode(
const std::string& str)
142 std::ostringstream encoded;
148 if (std::isalnum(
static_cast<unsigned char>(c)) || c ==
'-' || c ==
'_' || c ==
'.' ||
155 encoded << std::uppercase;
156 encoded << '%' << std::setw(2) << static_cast<int>(
static_cast<unsigned char>(c));
157 encoded << std::nouppercase;
161 return encoded.str();
174 std::string searchKey =
"\"" + key +
"\"";
175 size_t pos =
json.find(searchKey);
176 if (pos == std::string::npos)
179 pos =
json.find(
':', pos);
180 if (pos == std::string::npos)
185 while (pos <
json.size() && std::isspace(
static_cast<unsigned char>(
json[pos])))
188 if (pos >=
json.size() ||
json[pos] !=
'"')
195 while (end <
json.size())
197 if (
json[end] ==
'"' && (end == 0 ||
json[end - 1] !=
'\\'))
202 return json.substr(pos, end - pos);
208 std::string searchKey =
"\"" + key +
"\"";
209 size_t pos =
json.find(searchKey);
210 if (pos == std::string::npos)
213 pos =
json.find(
':', pos);
214 if (pos == std::string::npos)
218 while (pos <
json.size() && std::isspace(
static_cast<unsigned char>(
json[pos])))
223 return std::stod(
json.substr(pos));
240 std::vector<std::string> elements;
242 size_t start =
json.find(
'[');
243 if (start == std::string::npos)
248 bool inString =
false;
249 bool escaped =
false;
250 size_t elementStart = start;
252 for (
size_t i = start; i <
json.size(); i++)
279 else if ((c ==
',' || c ==
']') && braceCount == 0)
281 std::string element =
json.substr(elementStart, i - elementStart);
283 size_t first = element.find_first_not_of(
" \t\n\r");
284 size_t last = element.find_last_not_of(
" \t\n\r");
285 if (first != std::string::npos && last != std::string::npos)
287 element = element.substr(first, last - first + 1);
288 if (!element.empty() && element[0] ==
'{')
290 elements.push_back(element);
293 elementStart = i + 1;
296 if (c ==
']' && braceCount == 0)
311 ProtonDBGameInfo info;
326 if (!info.
tier.empty())
334std::vector<ProtonDBSearchResult> ProtonDBService::parseSearchJson(
const std::string&
json)
336 std::vector<ProtonDBSearchResult> results;
339 for (
const auto& elem : elements)
341 ProtonDBSearchResult result;
346 results.push_back(result);
355 ProtonDBTweaks tweaks;
358 tweaks.
reportCount =
static_cast<int>(reports.size());
361 std::map<std::string, int> envVarCounts;
362 std::map<std::string, int> dllOverrideCounts;
363 std::map<std::string, int> protonVersionCounts;
364 std::map<std::string, int> launchArgCounts;
366 for (
const auto& report : reports)
370 std::string protonVersion =
jsonGetString(report,
"protonVersion");
373 if (!protonVersion.empty() && protonVersion !=
"null")
375 protonVersionCounts[protonVersion]++;
379 if (rating ==
"Platinum" || rating ==
"Gold")
382 extractTweaksFromNote(notes, tweaks);
388 for (
const auto& [version, count] : protonVersionCounts)
390 if (count > maxCount)
404void ProtonDBService::extractTweaksFromNote(
const std::string& note,
ProtonDBTweaks& tweaks)
411 static const std::vector<std::pair<std::regex, std::string>> envVarPatterns = {
413 {std::regex(R
"(PROTON_USE_WINED3D\s*=\s*(\d))"), "PROTON_USE_WINED3D"},
414 {std::regex(R
"(PROTON_NO_ESYNC\s*=\s*(\d))"), "PROTON_NO_ESYNC"},
415 {std::regex(R
"(PROTON_NO_FSYNC\s*=\s*(\d))"), "PROTON_NO_FSYNC"},
416 {std::regex(R
"(PROTON_NO_NTSYNC\s*=\s*(\d))"), "PROTON_NO_NTSYNC"},
417 {std::regex(R
"(PROTON_FORCE_NVAPI\s*=\s*(\d))"), "PROTON_FORCE_NVAPI"},
418 {std::regex(R
"(PROTON_HIDE_NVIDIA_GPU\s*=\s*(\d))"), "PROTON_HIDE_NVIDIA_GPU"},
419 {std::regex(R
"(PROTON_FORCE_LARGE_ADDRESS_AWARE\s*=\s*(\d))"),
420 "PROTON_FORCE_LARGE_ADDRESS_AWARE"},
421 {std::regex(R
"(PROTON_USE_WOW64\s*=\s*(\d))"), "PROTON_USE_WOW64"},
422 {std::regex(R
"(PROTON_NO_WRITE_WATCH\s*=\s*(\d))"), "PROTON_NO_WRITE_WATCH"},
423 {std::regex(R
"(PROTON_USE_XALIA\s*=\s*(\d))"), "PROTON_USE_XALIA"},
424 {std::regex(R
"(PROTON_NVIDIA_LIBS\s*=\s*(\d))"), "PROTON_NVIDIA_LIBS"},
425 {std::regex(R
"(PROTON_OLD_GL_STRING\s*=\s*(\d))"), "PROTON_OLD_GL_STRING"},
426 {std::regex(R
"(PROTON_USE_SECCOMP\s*=\s*(\d))"), "PROTON_USE_SECCOMP"},
427 {std::regex(R
"(PROTON_ENABLE_HDR\s*=\s*(\d))"), "PROTON_ENABLE_HDR"},
428 {std::regex(R
"(PROTON_ENABLE_WAYLAND\s*=\s*(\d))"), "PROTON_ENABLE_WAYLAND"},
429 {std::regex(R
"(PROTON_PREFER_SDL\s*=\s*(\d))"), "PROTON_PREFER_SDL"},
430 {std::regex(R
"(PROTON_NO_STEAMINPUT\s*=\s*(\d))"), "PROTON_NO_STEAMINPUT"},
431 {std::regex(R
"(PROTON_PRESERVE_GAMEPAD_ORDER\s*=\s*(\d))"),
432 "PROTON_PRESERVE_GAMEPAD_ORDER"},
433 {std::regex(R
"(PROTON_CPU_TOPOLOGY\s*=\s*([^\s,;]+))"), "PROTON_CPU_TOPOLOGY"},
436 {std::regex(R
"(PROTON_DLSS_UPGRADE\s*=\s*(\d))"), "PROTON_DLSS_UPGRADE"},
437 {std::regex(R
"(PROTON_FSR4_RDNA3_UPGRADE\s*=\s*(\d))"), "PROTON_FSR4_RDNA3_UPGRADE"},
438 {std::regex(R
"(PROTON_XESS_UPGRADE\s*=\s*(\d))"), "PROTON_XESS_UPGRADE"},
443 {std::regex(R
"(DXVK_ASYNC\s*=\s*(\d))"), "DXVK_ASYNC"},
444 {std::regex(R
"(PROTON_DXVK_LLASYNC\s*=\s*(\d))"), "PROTON_DXVK_LLASYNC"},
445 {std::regex(R
"(DXVK_HUD\s*=\s*([^\s,;]+))"), "DXVK_HUD"},
446 {std::regex(R
"(DXVK_HDR\s*=\s*(\d))"), "DXVK_HDR"},
447 {std::regex(R
"(DXVK_STATE_CACHE\s*=\s*(\d))"), "DXVK_STATE_CACHE"},
448 {std::regex(R
"(DXVK_STATE_CACHE_PATH\s*=\s*([^\s,;]+))"), "DXVK_STATE_CACHE_PATH"},
451 {std::regex(R
"(DXVK_CONFIG_FILE\s*=\s*([^\s,;]+))"), "DXVK_CONFIG_FILE"},
457 {std::regex(R
"(VKD3D_CONFIG\s*=\s*([^\s,;]+))"), "VKD3D_CONFIG"},
458 {std::regex(R
"(VKD3D_FEATURE_LEVEL\s*=\s*([^\s,;]+))"), "VKD3D_FEATURE_LEVEL"},
459 {std::regex(R
"(VKD3D_DEBUG\s*=\s*([^\s,;]+))"), "VKD3D_DEBUG"},
462 {std::regex(R
"(RADV_PERFTEST\s*=\s*([^\s,;]+))"), "RADV_PERFTEST"},
463 {std::regex(R
"(RADV_DEBUG\s*=\s*([^\s,;]+))"), "RADV_DEBUG"},
464 {std::regex(R
"(AMD_VULKAN_ICD\s*=\s*([^\s,;]+))"), "AMD_VULKAN_ICD"},
465 {std::regex(R
"(mesa_glthread\s*=\s*([^\s,;]+))"), "mesa_glthread"},
466 {std::regex(R
"(MESA_SHADER_CACHE_MAX_SIZE\s*=\s*([^\s,;]+))"),
467 "MESA_SHADER_CACHE_MAX_SIZE"},
468 {std::regex(R
"(ENABLE_LAYER_MESA_ANTI_LAG\s*=\s*(\d))"), "ENABLE_LAYER_MESA_ANTI_LAG"},
471 {std::regex(R
"(SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS\s*=\s*(\d))"),
472 "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"},
473 {std::regex(R
"(SDL_AUDIODRIVER\s*=\s*([^\s,;]+))"), "SDL_AUDIODRIVER"},
474 {std::regex(R
"(SDL_GAMECONTROLLERCONFIG\s*=\s*([^\s,;]+))"), "SDL_GAMECONTROLLERCONFIG"},
477 {std::regex(R
"(WINE_FULLSCREEN_FSR\s*=\s*(\d))"), "WINE_FULLSCREEN_FSR"},
478 {std::regex(R
"(WINE_FULLSCREEN_FSR_STRENGTH\s*=\s*(\d+))"), "WINE_FULLSCREEN_FSR_STRENGTH"},
479 {std::regex(R
"(WINEFSYNC\s*=\s*(\d))"), "WINEFSYNC"},
480 {std::regex(R
"(WINEESYNC\s*=\s*(\d))"), "WINEESYNC"},
481 {std::regex(R
"(WINEDEBUG\s*=\s*([^\s,;]+))"), "WINEDEBUG"},
482 {std::regex(R
"(WINE_LARGE_ADDRESS_AWARE\s*=\s*(\d))"), "WINE_LARGE_ADDRESS_AWARE"},
485 {std::regex(R
"(MANGOHUD\s*=\s*(\d))"), "MANGOHUD"},
488 {std::regex(R
"(GAMEMODE_AUTO\s*=\s*(\d))"), "GAMEMODE_AUTO"},
491 {std::regex(R
"(GAMESCOPE_FSR_SHARPNESS\s*=\s*(\d+))"), "GAMESCOPE_FSR_SHARPNESS"},
494 {std::regex(R
"(__GL_THREADED_OPTIMIZATION\s*=\s*(\d))"), "__GL_THREADED_OPTIMIZATION"},
495 {std::regex(R
"(__GL_SHADER_DISK_CACHE\s*=\s*(\d))"), "__GL_SHADER_DISK_CACHE"},
496 {std::regex(R
"(__GL_SHADER_DISK_CACHE_SKIP_CLEANUP\s*=\s*(\d))"),
497 "__GL_SHADER_DISK_CACHE_SKIP_CLEANUP"},
501 for (
const auto& [pattern, varName] : envVarPatterns)
504 if (std::regex_search(note, match, pattern) && match.size() > 1)
511 static const std::regex dllOverridePattern(R
"(WINEDLLOVERRIDES\s*=\s*["\']?([^"'\s;]+)["\']?)");
512 std::smatch dllMatch;
513 if (std::regex_search(note, dllMatch, dllOverridePattern) && dllMatch.size() > 1)
522 static const std::regex dllPattern(R
"(([\w]+)=(native|builtin|native,builtin|builtin,native))");
523 std::string::const_iterator searchStart(note.cbegin());
524 std::smatch dllResults;
525 while (std::regex_search(searchStart, note.cend(), dllResults, dllPattern))
527 std::string dll = dllResults[1].str() +
"=" + dllResults[2].str();
532 else if (tweaks.
dllOverrides.find(dllResults[1].str()) == std::string::npos)
536 searchStart = dllResults.suffix().first;
540 static const std::vector<std::string> commonArgs = {
541 "-nojoy",
"-windowed",
"-fullscreen",
"-novid",
"-skipintro",
"-dx11",
"-dx12",
"-vulkan"};
543 for (
const auto& arg : commonArgs)
545 if (note.find(arg) != std::string::npos)
556 static const std::regex geProtonPattern(R
"(GE-Proton[\d-]+)");
558 if (std::regex_search(note, geMatch, geProtonPattern))
567 if (note.length() > 10 && note.length() < 500)
570 bool hasUsefulContent =
571 note.find(
"=") != std::string::npos || note.find(
"work") != std::string::npos ||
572 note.find(
"fix") != std::string::npos || note.find(
"issue") != std::string::npos;
574 if (hasUsefulContent && tweaks.
notes.size() < 5)
576 tweaks.
notes.push_back(note);
595 auto cached = protondbCache().get(steamAppId);
598 Logger::debug(
"ProtonDB: Cache hit for App ID {}", steamAppId);
602 Logger::info(
"ProtonDB: Fetching info for App ID {}", steamAppId);
605 std::string summaryUrl =
606 "https://www.protondb.com/api/v1/reports/summaries/" + std::to_string(steamAppId) +
".json";
607 std::string summaryJson = httpGet(summaryUrl);
614 std::string reportsUrl =
615 "https://protondb.max-p.me/games/" + std::to_string(steamAppId) +
"/reports/";
616 std::string reportsJson = httpGet(reportsUrl);
618 if (!reportsJson.empty() && reportsJson[0] ==
'[')
620 info.
tweaks = parseReportsJson(reportsJson);
624 protondbCache().put(steamAppId, info);
627 auto stats = protondbCache().getStats();
628 if (stats.currentSize % 50 == 0)
630 Logger::debug(
"ProtonDB cache: {} entries, {:.1f}% hit rate, {} evictions",
631 stats.currentSize, stats.hitRate() * 100.0f, stats.evictions);
636 Logger::warn(
"ProtonDB: No data found for App ID {}", steamAppId);
645 if (gameName.empty())
653 std::string url =
"https://protondb.max-p.me/games/";
654 std::string
json = httpGet(url);
662 auto allGames = parseSearchJson(
json);
665 std::string searchLower = gameName;
666 std::transform(searchLower.begin(), searchLower.end(), searchLower.begin(),
667 [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
669 std::vector<ProtonDBSearchResult> matches;
670 for (
const auto& game : allGames)
672 std::string nameLower = game.gameName;
673 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(),
674 [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
676 if (nameLower.find(searchLower) != std::string::npos)
678 matches.push_back(game);
679 if (
static_cast<int>(matches.size()) >= maxResults)
716 [](
const std::shared_ptr<std::future<void>>& f)
718 return f->wait_for(std::chrono::milliseconds(0)) ==
719 std::future_status::ready;
730 auto future = std::make_shared<std::future<void>>(std::async(std::launch::async,
731 [steamAppId, callback]()
740 storeAsyncFuture(future);
746 auto future = std::make_shared<std::future<void>>(std::async(std::launch::async,
747 [gameName, callback, maxResults]()
750 gameName, maxResults);
756 storeAsyncFuture(future);
763 if (gameName.empty())
769 Logger::info(
"ProtonDB: Finding game by name '{}'", gameName);
776 Logger::warn(
"ProtonDB: No games found matching '{}'", gameName);
782 std::string searchLower = gameName;
783 std::transform(searchLower.begin(), searchLower.end(), searchLower.begin(),
784 [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
787 auto removeCommonWords = [](std::string& str)
789 std::vector<std::string> wordsToRemove = {
"the",
"a",
"an",
"of",
"and",
"or"};
790 for (
const auto& word : wordsToRemove)
793 while ((pos = str.find(
" " + word +
" ")) != std::string::npos)
795 str.erase(pos, word.length() + 1);
800 removeCommonWords(searchLower);
802 int bestMatchScore = 0;
803 int bestMatchAppId = 0;
805 for (
const auto& match : matches)
807 std::string matchLower = match.gameName;
808 std::transform(matchLower.begin(), matchLower.end(), matchLower.begin(),
809 [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
814 if (matchLower == searchLower)
819 else if (matchLower.find(searchLower) != std::string::npos)
822 score = 500 -
static_cast<int>(matchLower.length() - searchLower.length());
825 else if (searchLower.find(matchLower) != std::string::npos)
827 score = 400 -
static_cast<int>(searchLower.length() - matchLower.length());
833 std::istringstream searchStream(searchLower);
834 std::string searchWord;
835 int matchingWords = 0;
837 while (searchStream >> searchWord)
839 if (matchLower.find(searchWord) != std::string::npos)
844 score = matchingWords * 50;
847 if (score > bestMatchScore)
849 bestMatchScore = score;
850 bestMatchAppId = match.steamAppId;
854 if (bestMatchAppId > 0)
856 Logger::info(
"ProtonDB: Best match for '{}' is App ID {} (score: {})", gameName,
857 bestMatchAppId, bestMatchScore);
862 Logger::info(
"ProtonDB: Using first match App ID {}", matches[0].steamAppId);
869 auto future = std::make_shared<std::future<void>>(std::async(std::launch::async,
870 [gameName, callback]()
879 storeAsyncFuture(future);
888 if (tier ==
"native")
889 return "Native Linux version available";
890 if (tier ==
"platinum")
891 return "Works perfectly out of the box";
893 return "Works after minor tweaks";
894 if (tier ==
"silver")
895 return "Works with some issues";
896 if (tier ==
"bronze")
897 return "Runs with significant issues";
898 if (tier ==
"borked")
899 return "Does not work or crashes frequently";
900 return "Unknown compatibility";
907 if (tier ==
"native")
913 else if (tier ==
"platinum")
919 else if (tier ==
"gold")
925 else if (tier ==
"silver")
931 else if (tier ==
"bronze")
937 else if (tier ==
"borked")
955 std::lock_guard<std::mutex> lock(cacheMutex_);
960 protondbCache().clear();
961 steamDeckCache().clear();
962 steamAppCache().clear();
963 lutrisCache().clear();
965 Logger::info(
"ProtonDB: All caches cleared (ProtonDB, Steam Deck, Steam Store, Lutris)");
982 auto cached = steamDeckCache().get(steamAppId);
985 Logger::debug(
"Steam Deck: Cache hit for app {}", steamAppId);
989 Logger::debug(
"Fetching Steam Deck compatibility for app {}", steamAppId);
993 "https://store.steampowered.com/saleaction/ajaxgetdeckappcompatibilityreport?nAppID=" +
994 std::to_string(steamAppId);
996 std::string response = httpGet(url);
997 if (response.empty())
999 Logger::warn(
"Steam Deck API: Empty response for app {}", steamAppId);
1015 std::string categoryStr = jsonGetString(response,
"resolved_category");
1019 if (categoryStr.empty())
1021 category = jsonGetInt(response,
"resolved_category");
1027 category = std::stoi(categoryStr);
1058 if (containsIntField(response,
"display_type", 3))
1062 if (containsIntField(response,
"input", 3))
1076 steamDeckCache().put(steamAppId, info);
1083 int steamAppId,
const std::function<
void(
const SteamDeckInfo&)>& callback)
1086 std::make_shared<std::future<void>>(std::async(std::launch::async,
1087 [steamAppId, callback]()
1095 storeAsyncFuture(future);
1107 if (steamAppId <= 0)
1113 auto cached = steamAppCache().get(steamAppId);
1116 Logger::debug(
"Steam Store: Cache hit for app {}", steamAppId);
1120 Logger::debug(
"Fetching Steam app info for {}", steamAppId);
1124 "https://store.steampowered.com/api/appdetails?appids=" + std::to_string(steamAppId);
1126 std::string response = httpGet(url);
1127 if (response.empty())
1129 Logger::warn(
"Steam Store API: Empty response for app {}", steamAppId);
1135 if (response.find(
"\"success\":true") == std::string::npos &&
1136 response.find(
"\"success\": true") == std::string::npos)
1138 Logger::warn(
"Steam Store API: Failed response for app {}", steamAppId);
1143 info.
name = jsonGetString(response,
"name");
1147 info.
supportsLinux = (response.find(
"\"linux\":true") != std::string::npos ||
1148 response.find(
"\"linux\": true") != std::string::npos);
1149 info.
supportsWindows = (response.find(
"\"windows\":true") != std::string::npos ||
1150 response.find(
"\"windows\": true") != std::string::npos);
1151 info.
supportsMac = (response.find(
"\"mac\":true") != std::string::npos ||
1152 response.find(
"\"mac\": true") != std::string::npos);
1160 containsIntField(response,
"id", 36) ||
1161 containsIntField(response,
"id", 37);
1167 size_t drmPos = response.find(
"\"drm_notice\"");
1168 if (drmPos != std::string::npos)
1170 info.
drmNotice = jsonGetString(response,
"drm_notice");
1175 size_t genreStart = response.find(
"\"genres\"");
1176 if (genreStart != std::string::npos)
1178 size_t genreEnd = response.find(
"]", genreStart);
1179 if (genreEnd != std::string::npos)
1181 std::string genreSection = response.substr(genreStart, genreEnd - genreStart + 1);
1184 while ((pos = genreSection.find(
"\"description\":\"", pos)) != std::string::npos)
1187 size_t end = genreSection.find(
"\"", pos);
1188 if (end != std::string::npos)
1190 info.
genres.push_back(genreSection.substr(pos, end - pos));
1198 info.
developer = jsonGetString(response,
"developers");
1199 info.
publisher = jsonGetString(response,
"publishers");
1205 Logger::info(
"Steam Store: {} - Linux={}, Controller={}, Multiplayer={}", info.
name,
1211 steamAppCache().put(steamAppId, info);
1218 const std::function<
void(
const SteamAppInfo&)>& callback)
1221 std::make_shared<std::future<void>>(std::async(std::launch::async,
1222 [steamAppId, callback]()
1230 storeAsyncFuture(future);
1241 if (steamAppId <= 0)
1247 auto cached = lutrisCache().get(steamAppId);
1250 Logger::debug(
"Lutris: Cache hit for Steam app {}", steamAppId);
1254 Logger::debug(
"Fetching Lutris info for Steam app {}", steamAppId);
1257 std::string url =
"https://lutris.net/api/games?steamid=" + std::to_string(steamAppId);
1259 std::string response = httpGet(url);
1260 if (response.empty())
1262 Logger::warn(
"Lutris API: Empty response for Steam app {}", steamAppId);
1268 info.
slug = jsonGetString(response,
"slug");
1269 info.
name = jsonGetString(response,
"name");
1272 if (info.
slug.empty())
1275 size_t resultsPos = response.find(
"\"results\"");
1276 if (resultsPos != std::string::npos)
1278 size_t slugPos = response.find(
"\"slug\":\"", resultsPos);
1279 if (slugPos != std::string::npos)
1282 size_t end = response.find(
"\"", slugPos);
1283 if (end != std::string::npos)
1285 info.
slug = response.substr(slugPos, end - slugPos);
1288 size_t namePos = response.find(
"\"name\":\"", resultsPos);
1289 if (namePos != std::string::npos)
1292 size_t end = response.find(
"\"", namePos);
1293 if (end != std::string::npos)
1295 info.
name = response.substr(namePos, end - namePos);
1301 if (info.
slug.empty())
1303 Logger::debug(
"Lutris: No game found for Steam app {}", steamAppId);
1308 std::string installersUrl =
"https://lutris.net/api/games/" + info.
slug +
"/installers";
1309 std::string installersResponse = httpGet(installersUrl);
1311 if (!installersResponse.empty())
1315 auto installerObjects = jsonSplitArray(installersResponse);
1317 for (
const auto& installerJson : installerObjects)
1320 installer.
slug = jsonGetString(installerJson,
"slug");
1321 installer.
name = jsonGetString(installerJson,
"name");
1322 installer.
runner = jsonGetString(installerJson,
"runner");
1323 installer.
version = jsonGetString(installerJson,
"version");
1326 if (installer.
runner ==
"wine" || installer.
runner ==
"steam" ||
1327 installer.
runner.find(
"proton") != std::string::npos)
1330 size_t winePos = installerJson.find(
"\"wine\"");
1331 if (winePos != std::string::npos)
1333 installer.
wineVersion = jsonGetString(installerJson.substr(winePos),
"version");
1337 size_t envPos = installerJson.find(
"\"env\"");
1338 if (envPos != std::string::npos)
1341 size_t start = installerJson.find(
"{", envPos);
1342 size_t end = installerJson.find(
"}", start);
1343 if (start != std::string::npos && end != std::string::npos)
1345 std::string envSection = installerJson.substr(start, end - start + 1);
1348 static const std::vector<std::string> envVars = {
1349 "PROTON_USE_WINED3D",
1352 "PROTON_FORCE_NVAPI",
1355 "PROTON_FORCE_LARGE_ADDRESS_AWARE",
1357 for (
const auto& var : envVars)
1359 std::string val = jsonGetString(envSection, var);
1369 std::string dllOverrides = jsonGetString(installerJson,
"WINEDLLOVERRIDES");
1370 if (!dllOverrides.empty())
1380 const auto flagSet = [](
const std::string& s)
1381 {
return s ==
"true" || s ==
"1" || s ==
"True" || s ==
"TRUE"; };
1382 std::string eacVal = jsonGetString(installerJson,
"eac");
1383 std::string beVal = jsonGetString(installerJson,
"battleye");
1384 installer.
eac = flagSet(eacVal);
1385 installer.
battleye = flagSet(beVal);
1388 installer.
found =
true;
1389 info.
installers.push_back(std::move(installer));
1396 { return a.downloadCount > b.downloadCount; });
1406 lutrisCache().put(steamAppId, info);
1416 if (gameSlug.empty())
1421 Logger::debug(
"Fetching Lutris info for slug {}", gameSlug);
1424 std::string url =
"https://lutris.net/api/games/" + urlEncode(gameSlug);
1426 std::string response = httpGet(url);
1427 if (response.empty() || response.find(
"\"detail\":\"Not found\"") != std::string::npos)
1432 info.
slug = gameSlug;
1433 info.
name = jsonGetString(response,
"name");
1434 info.
steamId = jsonGetInt(response,
"steamid");
1435 info.
gogId = jsonGetInt(response,
"gogid");
1454 auto future = std::make_shared<std::future<void>>(std::async(std::launch::async,
1455 [steamAppId, callback]()
1464 storeAsyncFuture(future);
Thread-safe LRU cache with optional TTL support.
static void info(const std::string &message, Args &&... args)
Log info message (general information).
static void debug(const std::string &message, Args &&... args)
Log debug message (verbose development info).
static void error(const std::string &message, Args &&... args)
Log error message (recoverable failure).
static void warn(const std::string &message, Args &&... args)
Log warning message (non-critical issue).
static SteamAppInfo getSteamAppInfo(int steamAppId)
Get Steam store information (native Linux, genres, DRM, etc.).
std::function< void(const ProtonDBGameInfo &)> GameInfoCallback
static std::vector< ProtonDBSearchResult > searchByName(const std::string &gameName, int maxResults=10)
Search for games by name.
static LutrisGameInfo getLutrisInfoBySlug(const std::string &gameSlug)
Get Lutris info by game slug.
static void findGameByNameAsync(const std::string &gameName, const GameInfoCallback &callback)
Find game info by name asynchronously.
static void searchByNameAsync(const std::string &gameName, const SearchCallback &callback, int maxResults=10)
Search for games by name asynchronously.
static void clearCache()
Clear cached data.
static ProtonDBGameInfo findGameByName(const std::string &gameName)
Find game info by name (searches for matching game, returns full info).
static std::string getTier(int steamAppId)
Get compatibility tier for a game (quick lookup).
static void getSteamDeckInfoAsync(int steamAppId, const std::function< void(const SteamDeckInfo &)> &callback)
Get Steam Deck compatibility asynchronously.
std::function< void(const std::vector< ProtonDBSearchResult > &)> SearchCallback
static LutrisGameInfo getLutrisInfo(int steamAppId)
Get Lutris game info and installers.
static ProtonDBGameInfo getGameInfo(int steamAppId)
Get game info by Steam App ID.
static void getTierColor(const std::string &tier, float &r, float &g, float &b, float &a)
Get tier color for UI display (RGBA).
static void getLutrisInfoAsync(int steamAppId, const std::function< void(const LutrisGameInfo &)> &callback)
Get Lutris info asynchronously.
static std::string getTierDescription(const std::string &tier)
Get human-readable tier description.
static void getSteamAppInfoAsync(int steamAppId, const std::function< void(const SteamAppInfo &)> &callback)
Get Steam app info asynchronously.
static SteamDeckInfo getSteamDeckInfo(int steamAppId)
Get Steam Deck compatibility status from Valve's testing.
static void getGameInfoAsync(int steamAppId, const GameInfoCallback &callback)
Get game info asynchronously.
static std::string escapeArg(const std::string &arg)
Escape a string for safe use as a shell argument.
std::string jsonGetString(const std::string &json, const std::string &key)
std::vector< std::string > jsonSplitArray(const std::string &json, const std::string &arrayKey)
int jsonGetInt(const std::string &json, const std::string &key)
double jsonGetNumber(const std::string &json, const std::string &key)
LRUCache< int, SteamDeckInfo > & steamDeckCache()
int jsonGetInt(const std::string &json, const std::string &key)
LRUCache< int, ProtonDBGameInfo > & protondbCache()
void storeAsyncFuture(std::shared_ptr< std::future< void > > future)
std::vector< std::shared_ptr< std::future< void > > > activeFutures_
std::vector< std::string > jsonSplitArray(const std::string &json)
std::mutex asyncFuturesMutex_
double jsonGetNumber(const std::string &json, const std::string &key)
std::string jsonGetString(const std::string &json, const std::string &key)
bool containsIntField(const std::string &response, const char *key, int value)
LRUCache< int, SteamAppInfo > & steamAppCache()
LRUCache< int, LutrisGameInfo > & lutrisCache()
static constexpr size_t PROTONDB_CACHE_MAX_SIZE
static constexpr size_t STEAM_DECK_CACHE_MAX_SIZE
static constexpr int PROTONDB_CACHE_TTL_SECONDS
static constexpr size_t LUTRIS_CACHE_MAX_SIZE
static constexpr int LUTRIS_CACHE_TTL_SECONDS
static constexpr int STEAM_DECK_CACHE_TTL_SECONDS
static constexpr size_t STEAM_APP_CACHE_MAX_SIZE
static constexpr int STEAM_APP_CACHE_TTL_SECONDS
Lutris database entry for a game.
std::vector< LutrisInstaller > installers
Installation script from Lutris with working configurations.
std::map< std::string, std::string > environmentVariables
Complete ProtonDB information for a game.
Recommended tweaks extracted from ProtonDB reports.
std::string dllOverrides
DLL overrides (e.g., "d3d11=native,builtin").
std::map< std::string, std::string > environmentVariables
Environment variables to set (e.g., PROTON_USE_WINED3D=1).
std::string recommendedProtonVersion
Recommended Proton version (e.g., "GE-Proton8-25").
int reportCount
Number of reports these tweaks were extracted from.
std::string launchArguments
Launch arguments to add.
std::vector< std::string > notes
Notes/warnings from reports.
Basic Steam store information for a game.
std::vector< std::string > genres
std::string controllerSupport
Steam Deck compatibility information from Valve.
SteamDeckCompatibility compatibility
std::string compatibilityString