Input/SDL: Don't pass stdio handle to SDL

Apparently on cmake, SDL isn't compiled with stdio support...
This commit is contained in:
Stenzek 2023-07-08 13:09:05 +10:00 committed by Connor McLaughlin
parent 9162f176a2
commit 20420da326
1 changed files with 4 additions and 4 deletions

View File

@ -225,15 +225,15 @@ void SDLInputSource::SetHints()
bool SDLInputSource::LoadControllerDB() bool SDLInputSource::LoadControllerDB()
{ {
Error error; Error error;
std::FILE* fp = auto fp = FileSystem::OpenManagedCFile(Path::Combine(EmuFolders::Resources, CONTROLLER_DB_FILENAME).c_str(), "rb", &error);
FileSystem::OpenCFile(Path::Combine(EmuFolders::Resources, CONTROLLER_DB_FILENAME).c_str(), "rb", &error); std::optional<std::string> data;
if (!fp) if (!fp || !(data = FileSystem::ReadFileToString(fp.get())))
{ {
Console.Error(fmt::format("SDLInputSource: Failed to open controller database: {}", error.GetDescription())); Console.Error(fmt::format("SDLInputSource: Failed to open controller database: {}", error.GetDescription()));
return false; return false;
} }
if (SDL_GameControllerAddMappingsFromRW(SDL_RWFromFP(fp, SDL_TRUE), SDL_TRUE) < 0) if (SDL_GameControllerAddMappingsFromRW(SDL_RWFromConstMem(data->c_str(), data->length()), SDL_TRUE) < 0)
{ {
Console.Error(fmt::format("SDLInputSource: SDL_GameControllerAddMappingsFromRW() failed: {}", SDL_GetError())); Console.Error(fmt::format("SDLInputSource: SDL_GameControllerAddMappingsFromRW() failed: {}", SDL_GetError()));
return false; return false;