mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
libretro: Fix breakage with new BIOS detection
This commit is contained in:
parent
df98bfbf04
commit
78f06fb711
|
@ -199,6 +199,11 @@ void HostInterface::AddFormattedOSDMessage(float duration, const char* format, .
|
||||||
AddOSDMessage(std::move(message), duration);
|
AddOSDMessage(std::move(message), duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string HostInterface::GetBIOSDirectory() const
|
||||||
|
{
|
||||||
|
return GetUserDirectoryRelativePath("bios");
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
|
std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
|
||||||
{
|
{
|
||||||
const std::string* bios_path;
|
const std::string* bios_path;
|
||||||
|
@ -221,12 +226,13 @@ std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
|
||||||
if (bios_path->empty())
|
if (bios_path->empty())
|
||||||
{
|
{
|
||||||
// auto-detect
|
// auto-detect
|
||||||
return FindBIOSImageInDirectory(region, GetUserDirectoryRelativePath("bios").c_str());
|
return FindBIOSImageInDirectory(region, GetBIOSDirectory().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// try the configured path
|
// try the configured path
|
||||||
std::optional<BIOS::Image> image = BIOS::LoadImageFromFile(
|
std::optional<BIOS::Image> image = BIOS::LoadImageFromFile(
|
||||||
GetUserDirectoryRelativePath("bios" FS_OSPATH_SEPARATOR_STR "%s", bios_path->c_str()).c_str());
|
StringUtil::StdStringFromFormat("%s" FS_OSPATH_SEPARATOR_STR "%s", GetBIOSDirectory().c_str(), bios_path->c_str())
|
||||||
|
.c_str());
|
||||||
if (!image.has_value())
|
if (!image.has_value())
|
||||||
{
|
{
|
||||||
g_host_interface->ReportFormattedError(
|
g_host_interface->ReportFormattedError(
|
||||||
|
|
|
@ -118,6 +118,9 @@ public:
|
||||||
virtual TinyString TranslateString(const char* context, const char* str) const;
|
virtual TinyString TranslateString(const char* context, const char* str) const;
|
||||||
virtual std::string TranslateStdString(const char* context, const char* str) const;
|
virtual std::string TranslateStdString(const char* context, const char* str) const;
|
||||||
|
|
||||||
|
/// Returns the path to the directory to search for BIOS images.
|
||||||
|
virtual std::string GetBIOSDirectory() const;
|
||||||
|
|
||||||
/// Loads the BIOS image for the specified region.
|
/// Loads the BIOS image for the specified region.
|
||||||
std::optional<std::vector<u8>> GetBIOSImage(ConsoleRegion region);
|
std::optional<std::vector<u8>> GetBIOSImage(ConsoleRegion region);
|
||||||
|
|
||||||
|
|
|
@ -254,38 +254,31 @@ bool LibretroHostInterface::retro_load_game(const struct retro_game_info* game)
|
||||||
bp.force_software_renderer = !m_hw_render_callback_valid;
|
bp.force_software_renderer = !m_hw_render_callback_valid;
|
||||||
|
|
||||||
struct retro_input_descriptor desc[] = {
|
struct retro_input_descriptor desc[] = {
|
||||||
#define JOYP(port) \
|
#define JOYP(port) \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select"}, \
|
||||||
{ port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, \
|
{port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start"}, \
|
||||||
{ port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, \
|
{port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X"}, \
|
||||||
{ port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, \
|
{port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y"}, \
|
||||||
{ port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, \
|
{port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X"}, \
|
||||||
{ port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" },
|
{port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y"},
|
||||||
|
|
||||||
JOYP(0)
|
JOYP(0) JOYP(1) JOYP(2) JOYP(3) JOYP(4) JOYP(5) JOYP(6) JOYP(7)
|
||||||
JOYP(1)
|
|
||||||
JOYP(2)
|
|
||||||
JOYP(3)
|
|
||||||
JOYP(4)
|
|
||||||
JOYP(5)
|
|
||||||
JOYP(6)
|
|
||||||
JOYP(7)
|
|
||||||
|
|
||||||
{ 0 },
|
{0},
|
||||||
};
|
};
|
||||||
|
|
||||||
g_retro_environment_callback(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
|
g_retro_environment_callback(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
|
||||||
|
@ -653,17 +646,21 @@ bool LibretroHostInterface::HasCoreVariablesChanged()
|
||||||
return (g_retro_environment_callback(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &changed) && changed);
|
return (g_retro_environment_callback(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &changed) && changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string LibretroHostInterface::GetBIOSDirectory() const
|
||||||
|
{
|
||||||
|
// Assume BIOS files are located in system directory.
|
||||||
|
const char* system_directory = nullptr;
|
||||||
|
if (!g_retro_environment_callback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory) || !system_directory)
|
||||||
|
return GetProgramDirectoryRelativePath("system");
|
||||||
|
else
|
||||||
|
return system_directory;
|
||||||
|
}
|
||||||
|
|
||||||
void LibretroHostInterface::LoadSettings()
|
void LibretroHostInterface::LoadSettings()
|
||||||
{
|
{
|
||||||
LibretroSettingsInterface si;
|
LibretroSettingsInterface si;
|
||||||
HostInterface::LoadSettings(si);
|
HostInterface::LoadSettings(si);
|
||||||
|
|
||||||
// Assume BIOS files are located in system directory.
|
|
||||||
const char* system_directory = nullptr;
|
|
||||||
if (!g_retro_environment_callback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory) || !system_directory)
|
|
||||||
system_directory = "bios";
|
|
||||||
g_settings.bios_path = StringUtil::StdStringFromFormat("%s" FS_OSPATH_SEPARATOR_STR "scph1001.bin", system_directory);
|
|
||||||
|
|
||||||
// Ensure we don't use the standalone memcard directory in shared mode.
|
// Ensure we don't use the standalone memcard directory in shared mode.
|
||||||
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
|
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
|
||||||
g_settings.memory_card_paths[i] = GetSharedMemoryCardPath(i);
|
g_settings.memory_card_paths[i] = GetSharedMemoryCardPath(i);
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
std::string GetGameMemoryCardPath(const char* game_code, u32 slot) const override;
|
std::string GetGameMemoryCardPath(const char* game_code, u32 slot) const override;
|
||||||
std::string GetShaderCacheBasePath() const override;
|
std::string GetShaderCacheBasePath() const override;
|
||||||
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override;
|
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override;
|
||||||
|
std::string GetBIOSDirectory() const override;
|
||||||
|
|
||||||
// Called by frontend
|
// Called by frontend
|
||||||
void retro_get_system_av_info(struct retro_system_av_info* info);
|
void retro_get_system_av_info(struct retro_system_av_info* info);
|
||||||
|
|
Loading…
Reference in a new issue