diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index 909c33306..c43e6fd8b 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -62,7 +62,7 @@ void AnalogController::Reset() if (m_force_analog_on_reset) { - if (g_settings.controller_disable_analog_mode_forcing || System::IsRunningUnknownGame()) + if (!CanStartInAnalogMode(ControllerType::AnalogController)) { Host::AddIconOSDMessage( fmt::format("Controller{}AnalogMode", m_index), ICON_PF_GAMEPAD_ALT, diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 76cf4a3a5..84edd0c91 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -1,19 +1,23 @@ -// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "controller.h" #include "analog_controller.h" #include "analog_joystick.h" #include "digital_controller.h" -#include "fmt/format.h" +#include "game_database.h" #include "guncon.h" #include "host.h" #include "justifier.h" #include "negcon.h" #include "negcon_rumble.h" #include "playstation_mouse.h" +#include "system.h" + #include "util/state_wrapper.h" +#include "fmt/format.h" + static const Controller::ControllerInfo s_none_info = {ControllerType::None, "None", TRANSLATE_NOOP("ControllerType", "Not Connected"), @@ -229,3 +233,13 @@ bool Controller::InCircularDeadzone(float deadzone, float pos_x, float pos_y) const bool in_y = (pos_y < 0.0f) ? (pos_y > dz_y) : (pos_y <= dz_y); return (in_x && in_y); } + +bool Controller::CanStartInAnalogMode(ControllerType ctype) +{ + const GameDatabase::Entry* dbentry = System::GetGameDatabaseEntry(); + if (!dbentry) + return false; + + return ((dbentry->supported_controllers & (1u << static_cast(ctype))) != 0 && + !dbentry->HasTrait(GameDatabase::Trait::DisableAutoAnalogMode)); +} diff --git a/src/core/controller.h b/src/core/controller.h index 32c20ef5d..3499b9fc0 100644 --- a/src/core/controller.h +++ b/src/core/controller.h @@ -134,5 +134,8 @@ public: static bool InCircularDeadzone(float deadzone, float pos_x, float pos_y); protected: + /// Returns true if automatic analog mode can be used. + static bool CanStartInAnalogMode(ControllerType ctype); + u32 m_index; }; diff --git a/src/core/game_database.cpp b/src/core/game_database.cpp index db4c6a095..10a978179 100644 --- a/src/core/game_database.cpp +++ b/src/core/game_database.cpp @@ -36,7 +36,7 @@ namespace GameDatabase { enum : u32 { GAME_DATABASE_CACHE_SIGNATURE = 0x45434C48, - GAME_DATABASE_CACHE_VERSION = 13, + GAME_DATABASE_CACHE_VERSION = 14, }; static Entry* GetMutableEntry(std::string_view serial); @@ -68,6 +68,7 @@ static constexpr const std::array(GameDatabase::Tr "ForceRoundTextureCoordinates", "ForceAccurateBlending", "ForceInterlacing", + "DisableAutoAnalogMode", "DisableTrueColor", "DisableUpscaling", "DisableTextureFiltering", @@ -96,6 +97,7 @@ static constexpr const std::array(GameDatabase::Tr TRANSLATE_NOOP("GameDatabase", "Force Round Texture Coordinates"), TRANSLATE_NOOP("GameDatabase", "Force Accurate Blending"), TRANSLATE_NOOP("GameDatabase", "Force Interlacing"), + TRANSLATE_NOOP("GameDatabase", "Disable Automatic Analog Mode"), TRANSLATE_NOOP("GameDatabase", "Disable True Color"), TRANSLATE_NOOP("GameDatabase", "Disable Upscaling"), TRANSLATE_NOOP("GameDatabase", "Disable Texture Filtering"), @@ -732,7 +734,6 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes if (ctype == ControllerType::AnalogController && (supported_controllers & BIT_FOR(ControllerType::DigitalController)) != 0) { - settings.controller_disable_analog_mode_forcing = true; continue; } diff --git a/src/core/game_database.h b/src/core/game_database.h index 64b821172..b0661b2a1 100644 --- a/src/core/game_database.h +++ b/src/core/game_database.h @@ -34,6 +34,7 @@ enum class Trait : u32 ForceRoundUpscaledTextureCoordinates, ForceAccurateBlending, ForceInterlacing, + DisableAutoAnalogMode, DisableTrueColor, DisableUpscaling, DisableTextureFiltering, diff --git a/src/core/negcon_rumble.cpp b/src/core/negcon_rumble.cpp index 3fd0e51ed..6bad03bee 100644 --- a/src/core/negcon_rumble.cpp +++ b/src/core/negcon_rumble.cpp @@ -68,7 +68,7 @@ void NeGconRumble::Reset() if (m_force_analog_on_reset) { - if (g_settings.controller_disable_analog_mode_forcing || System::IsRunningUnknownGame()) + if (!CanStartInAnalogMode(ControllerType::AnalogController)) { Host::AddIconOSDMessage( fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD, diff --git a/src/core/settings.h b/src/core/settings.h index 3382085e5..492eef216 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -266,8 +266,6 @@ struct Settings bool enable_8mb_ram : 1 = false; std::array controller_types{}; - bool controller_disable_analog_mode_forcing = false; - std::array memory_card_types{}; std::array memory_card_paths{}; bool memory_card_use_playlist_title = true;