GameDatabase: Add DisableAutoAnalogMode trait

For games that can handle analog controllers, but the sticks do not do
anything.
This commit is contained in:
Stenzek 2024-08-18 20:33:15 +10:00
parent ddce1b2752
commit 04656761e4
No known key found for this signature in database
7 changed files with 25 additions and 8 deletions

View file

@ -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,

View file

@ -1,19 +1,23 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// 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<u8>(ctype))) != 0 &&
!dbentry->HasTrait(GameDatabase::Trait::DisableAutoAnalogMode));
}

View file

@ -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;
};

View file

@ -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<const char*, static_cast<u32>(GameDatabase::Tr
"ForceRoundTextureCoordinates",
"ForceAccurateBlending",
"ForceInterlacing",
"DisableAutoAnalogMode",
"DisableTrueColor",
"DisableUpscaling",
"DisableTextureFiltering",
@ -96,6 +97,7 @@ static constexpr const std::array<const char*, static_cast<u32>(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;
}

View file

@ -34,6 +34,7 @@ enum class Trait : u32
ForceRoundUpscaledTextureCoordinates,
ForceAccurateBlending,
ForceInterlacing,
DisableAutoAnalogMode,
DisableTrueColor,
DisableUpscaling,
DisableTextureFiltering,

View file

@ -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,

View file

@ -266,8 +266,6 @@ struct Settings
bool enable_8mb_ram : 1 = false;
std::array<ControllerType, NUM_CONTROLLER_AND_CARD_PORTS> controller_types{};
bool controller_disable_analog_mode_forcing = false;
std::array<MemoryCardType, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_types{};
std::array<std::string, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_paths{};
bool memory_card_use_playlist_title = true;