mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
GameDatabase: Add DisableAutoAnalogMode trait
For games that can handle analog controllers, but the sticks do not do anything.
This commit is contained in:
parent
ddce1b2752
commit
04656761e4
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ enum class Trait : u32
|
|||
ForceRoundUpscaledTextureCoordinates,
|
||||
ForceAccurateBlending,
|
||||
ForceInterlacing,
|
||||
DisableAutoAnalogMode,
|
||||
DisableTrueColor,
|
||||
DisableUpscaling,
|
||||
DisableTextureFiltering,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue