Qt: Implement per-game controller configuration

This commit is contained in:
Stenzek
2024-08-24 14:10:25 +10:00
parent 9e3507e0f4
commit bda6869084
24 changed files with 427 additions and 179 deletions

View File

@ -74,16 +74,23 @@ INISettingsInterface::~INISettingsInterface()
Save();
}
bool INISettingsInterface::Load()
bool INISettingsInterface::Load(Error* error /* = nullptr */)
{
if (m_filename.empty())
{
Error::SetStringView(error, "Filename is not set.");
return false;
}
std::unique_lock lock(s_ini_load_save_mutex);
SI_Error err = SI_FAIL;
auto fp = FileSystem::OpenManagedCFile(m_filename.c_str(), "rb");
auto fp = FileSystem::OpenManagedCFile(m_filename.c_str(), "rb", error);
if (fp)
{
err = m_ini.LoadFile(fp.get());
if (err != SI_OK)
Error::SetStringFmt(error, "INI LoadFile() failed: {}", static_cast<int>(err));
}
return (err == SI_OK);
}

View File

@ -18,7 +18,7 @@ public:
const std::string& GetFileName() const { return m_filename; }
bool Load();
bool Load(Error* error = nullptr);
bool Save(Error* error = nullptr) override;
void Clear() override;

View File

@ -1809,8 +1809,7 @@ bool InputManager::DoEventHook(InputBindingKey key, float value)
// Binding Updater
// ------------------------------------------------------------------------
void InputManager::ReloadBindings(SettingsInterface& si, SettingsInterface& binding_si,
SettingsInterface& hotkey_binding_si)
void InputManager::ReloadBindings(SettingsInterface& binding_si, SettingsInterface& hotkey_binding_si)
{
PauseVibration();
@ -1843,8 +1842,8 @@ void InputManager::ReloadBindings(SettingsInterface& si, SettingsInterface& bind
// From lilypad: 1 mouse pixel = 1/8th way down.
const float default_scale = (axis <= static_cast<u32>(InputPointerAxis::Y)) ? 8.0f : 1.0f;
s_pointer_axis_scale[axis] =
1.0f / std::max(si.GetFloatValue("Pad", fmt::format("Pointer{}Scale", s_pointer_axis_names[axis]).c_str(),
default_scale),
1.0f / std::max(binding_si.GetFloatValue("Pad", fmt::format("Pointer{}Scale", s_pointer_axis_names[axis]).c_str(),
default_scale),
1.0f);
}

View File

@ -253,7 +253,7 @@ GenericInputBindingMapping GetGenericBindingMapping(std::string_view device);
bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type);
/// Re-parses the config and registers all hotkey and pad bindings.
void ReloadBindings(SettingsInterface& si, SettingsInterface& binding_si, SettingsInterface& hotkey_binding_si);
void ReloadBindings(SettingsInterface& si, SettingsInterface& hotkey_binding_si);
/// Re-parses the sources part of the config and initializes any backends.
void ReloadSources(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock);