mirror of https://github.com/PCSX2/pcsx2.git
PAD: Move input-related stuff out
This commit is contained in:
parent
256f7b9b0f
commit
59e10bcac6
|
@ -329,8 +329,8 @@ ControllerMacroEditWidget::ControllerMacroEditWidget(ControllerMacroWidget* pare
|
|||
// populate list view
|
||||
for (u32 i = 0; i < cinfo->num_bindings; i++)
|
||||
{
|
||||
const PAD::ControllerBindingInfo& bi = cinfo->bindings[i];
|
||||
if (bi.type == PAD::ControllerBindingType::Motor)
|
||||
const InputBindingInfo& bi = cinfo->bindings[i];
|
||||
if (bi.type == InputBindingInfo::Type::Motor)
|
||||
continue;
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
|
@ -356,7 +356,7 @@ ControllerMacroEditWidget::~ControllerMacroEditWidget() = default;
|
|||
QString ControllerMacroEditWidget::getSummary() const
|
||||
{
|
||||
QString str;
|
||||
for (const PAD::ControllerBindingInfo* bi : m_binds)
|
||||
for (const InputBindingInfo* bi : m_binds)
|
||||
{
|
||||
if (!str.isEmpty())
|
||||
str += static_cast<QChar>('/');
|
||||
|
@ -409,11 +409,11 @@ void ControllerMacroEditWidget::updateBinds()
|
|||
if (!cinfo)
|
||||
return;
|
||||
|
||||
std::vector<const PAD::ControllerBindingInfo*> new_binds;
|
||||
std::vector<const InputBindingInfo*> new_binds;
|
||||
for (u32 i = 0, bind_index = 0; i < cinfo->num_bindings; i++)
|
||||
{
|
||||
const PAD::ControllerBindingInfo& bi = cinfo->bindings[i];
|
||||
if (bi.type == PAD::ControllerBindingType::Motor)
|
||||
const InputBindingInfo& bi = cinfo->bindings[i];
|
||||
if (bi.type == InputBindingInfo::Type::Motor)
|
||||
continue;
|
||||
|
||||
const QListWidgetItem* item = m_ui.bindList->item(static_cast<int>(bind_index));
|
||||
|
@ -434,7 +434,7 @@ void ControllerMacroEditWidget::updateBinds()
|
|||
m_binds = std::move(new_binds);
|
||||
|
||||
std::string binds_string;
|
||||
for (const PAD::ControllerBindingInfo* bi : m_binds)
|
||||
for (const InputBindingInfo* bi : m_binds)
|
||||
{
|
||||
if (!binds_string.empty())
|
||||
binds_string.append(" & ");
|
||||
|
@ -490,12 +490,12 @@ void ControllerCustomSettingsWidget::createSettingWidgets(ControllerBindingWidge
|
|||
|
||||
for (u32 i = 0; i < cinfo->num_settings; i++)
|
||||
{
|
||||
const PAD::ControllerSettingInfo& si = cinfo->settings[i];
|
||||
const SettingInfo& si = cinfo->settings[i];
|
||||
std::string key_name = si.name;
|
||||
|
||||
switch (si.type)
|
||||
{
|
||||
case PAD::ControllerSettingInfo::Type::Boolean:
|
||||
case SettingInfo::Type::Boolean:
|
||||
{
|
||||
QCheckBox* cb = new QCheckBox(qApp->translate(cinfo->name, si.display_name), widget_parent);
|
||||
cb->setObjectName(QString::fromUtf8(si.name));
|
||||
|
@ -506,7 +506,7 @@ void ControllerCustomSettingsWidget::createSettingWidgets(ControllerBindingWidge
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::Integer:
|
||||
case SettingInfo::Type::Integer:
|
||||
{
|
||||
QSpinBox* sb = new QSpinBox(widget_parent);
|
||||
sb->setObjectName(QString::fromUtf8(si.name));
|
||||
|
@ -520,7 +520,7 @@ void ControllerCustomSettingsWidget::createSettingWidgets(ControllerBindingWidge
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::IntegerList:
|
||||
case SettingInfo::Type::IntegerList:
|
||||
{
|
||||
QComboBox* cb = new QComboBox(widget_parent);
|
||||
cb->setObjectName(QString::fromUtf8(si.name));
|
||||
|
@ -533,7 +533,7 @@ void ControllerCustomSettingsWidget::createSettingWidgets(ControllerBindingWidge
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::Float:
|
||||
case SettingInfo::Type::Float:
|
||||
{
|
||||
QDoubleSpinBox* sb = new QDoubleSpinBox(widget_parent);
|
||||
sb->setObjectName(QString::fromUtf8(si.name));
|
||||
|
@ -547,7 +547,7 @@ void ControllerCustomSettingsWidget::createSettingWidgets(ControllerBindingWidge
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::String:
|
||||
case SettingInfo::Type::String:
|
||||
{
|
||||
QLineEdit* le = new QLineEdit(widget_parent);
|
||||
le->setObjectName(QString::fromUtf8(si.name));
|
||||
|
@ -558,7 +558,7 @@ void ControllerCustomSettingsWidget::createSettingWidgets(ControllerBindingWidge
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::Path:
|
||||
case SettingInfo::Type::Path:
|
||||
{
|
||||
QLineEdit* le = new QLineEdit(widget_parent);
|
||||
le->setObjectName(QString::fromUtf8(si.name));
|
||||
|
@ -597,12 +597,12 @@ void ControllerCustomSettingsWidget::restoreDefaults()
|
|||
|
||||
for (u32 i = 0; i < cinfo->num_settings; i++)
|
||||
{
|
||||
const PAD::ControllerSettingInfo& si = cinfo->settings[i];
|
||||
const SettingInfo& si = cinfo->settings[i];
|
||||
const QString key(QString::fromStdString(si.name));
|
||||
|
||||
switch (si.type)
|
||||
{
|
||||
case PAD::ControllerSettingInfo::Type::Boolean:
|
||||
case SettingInfo::Type::Boolean:
|
||||
{
|
||||
QCheckBox* widget = findChild<QCheckBox*>(QString::fromStdString(si.name));
|
||||
if (widget)
|
||||
|
@ -610,7 +610,7 @@ void ControllerCustomSettingsWidget::restoreDefaults()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::Integer:
|
||||
case SettingInfo::Type::Integer:
|
||||
{
|
||||
QSpinBox* widget = findChild<QSpinBox*>(QString::fromStdString(si.name));
|
||||
if (widget)
|
||||
|
@ -618,7 +618,7 @@ void ControllerCustomSettingsWidget::restoreDefaults()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::IntegerList:
|
||||
case SettingInfo::Type::IntegerList:
|
||||
{
|
||||
QComboBox* widget = findChild<QComboBox*>(QString::fromStdString(si.name));
|
||||
if (widget)
|
||||
|
@ -626,7 +626,7 @@ void ControllerCustomSettingsWidget::restoreDefaults()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::Float:
|
||||
case SettingInfo::Type::Float:
|
||||
{
|
||||
QDoubleSpinBox* widget = findChild<QDoubleSpinBox*>(QString::fromStdString(si.name));
|
||||
if (widget)
|
||||
|
@ -634,7 +634,7 @@ void ControllerCustomSettingsWidget::restoreDefaults()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::String:
|
||||
case SettingInfo::Type::String:
|
||||
{
|
||||
QLineEdit* widget = findChild<QLineEdit*>(QString::fromStdString(si.name));
|
||||
if (widget)
|
||||
|
@ -642,7 +642,7 @@ void ControllerCustomSettingsWidget::restoreDefaults()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerSettingInfo::Type::Path:
|
||||
case SettingInfo::Type::Path:
|
||||
{
|
||||
QLineEdit* widget = findChild<QLineEdit*>(QString::fromStdString(si.name));
|
||||
if (widget)
|
||||
|
|
|
@ -122,7 +122,7 @@ private:
|
|||
ControllerBindingWidget* m_bwidget;
|
||||
u32 m_index;
|
||||
|
||||
std::vector<const PAD::ControllerBindingInfo*> m_binds;
|
||||
std::vector<const InputBindingInfo*> m_binds;
|
||||
u32 m_frequency = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,64 @@ class SettingsWrapper;
|
|||
|
||||
enum class CDVD_SourceType : uint8_t;
|
||||
|
||||
/// Generic setting information which can be reused in multiple components.
|
||||
struct SettingInfo
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
Boolean,
|
||||
Integer,
|
||||
IntegerList,
|
||||
Float,
|
||||
String,
|
||||
StringList,
|
||||
Path,
|
||||
};
|
||||
|
||||
Type type;
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
const char* description;
|
||||
const char* default_value;
|
||||
const char* min_value;
|
||||
const char* max_value;
|
||||
const char* step_value;
|
||||
const char* format;
|
||||
const char** options;
|
||||
float multiplier;
|
||||
|
||||
const char* StringDefaultValue() const;
|
||||
bool BooleanDefaultValue() const;
|
||||
s32 IntegerDefaultValue() const;
|
||||
s32 IntegerMinValue() const;
|
||||
s32 IntegerMaxValue() const;
|
||||
s32 IntegerStepValue() const;
|
||||
float FloatDefaultValue() const;
|
||||
float FloatMinValue() const;
|
||||
float FloatMaxValue() const;
|
||||
float FloatStepValue() const;
|
||||
};
|
||||
|
||||
enum class GenericInputBinding : u8;
|
||||
|
||||
struct InputBindingInfo
|
||||
{
|
||||
enum class Type : u8
|
||||
{
|
||||
Unknown,
|
||||
Button,
|
||||
Axis,
|
||||
HalfAxis,
|
||||
Motor,
|
||||
Macro
|
||||
};
|
||||
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
Type type;
|
||||
GenericInputBinding generic_mapping;
|
||||
};
|
||||
|
||||
enum GamefixId
|
||||
{
|
||||
GamefixId_FIRST = 0,
|
||||
|
|
|
@ -350,10 +350,10 @@ namespace FullscreenUI
|
|||
static void DrawClampingModeSetting(SettingsInterface* bsi, const char* title, const char* summary, bool vu);
|
||||
static void PopulateGraphicsAdapterList();
|
||||
static void PopulateGameListDirectoryCache(SettingsInterface* si);
|
||||
static void BeginInputBinding(SettingsInterface* bsi, PAD::ControllerBindingType type, const std::string_view& section,
|
||||
static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section,
|
||||
const std::string_view& key, const std::string_view& display_name);
|
||||
static void DrawInputBindingWindow();
|
||||
static void DrawInputBindingButton(SettingsInterface* bsi, PAD::ControllerBindingType type, const char* section, const char* name,
|
||||
static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, const char* name,
|
||||
const char* display_name, bool show_type = true);
|
||||
static void ClearInputBindingVariables();
|
||||
static void StartAutomaticBinding(u32 port);
|
||||
|
@ -367,7 +367,7 @@ namespace FullscreenUI
|
|||
static std::vector<const HotkeyInfo*> s_hotkey_list_cache;
|
||||
static std::atomic_bool s_settings_changed{false};
|
||||
static std::atomic_bool s_game_settings_changed{false};
|
||||
static PAD::ControllerBindingType s_input_binding_type = PAD::ControllerBindingType::Unknown;
|
||||
static InputBindingInfo::Type s_input_binding_type = InputBindingInfo::Type::Unknown;
|
||||
static std::string s_input_binding_section;
|
||||
static std::string s_input_binding_key;
|
||||
static std::string s_input_binding_display_name;
|
||||
|
@ -806,7 +806,7 @@ void FullscreenUI::Render()
|
|||
if (s_about_window_open)
|
||||
DrawAboutWindow();
|
||||
|
||||
if (s_input_binding_type != PAD::ControllerBindingType::Unknown)
|
||||
if (s_input_binding_type != InputBindingInfo::Type::Unknown)
|
||||
DrawInputBindingWindow();
|
||||
|
||||
ImGuiFullscreen::EndLayout();
|
||||
|
@ -1199,8 +1199,8 @@ s32 FullscreenUI::GetEffectiveIntSetting(SettingsInterface* bsi, const char* sec
|
|||
return Host::Internal::GetBaseSettingsLayer()->GetIntValue(section, key, default_value);
|
||||
}
|
||||
|
||||
void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, PAD::ControllerBindingType type, const char* section, const char* name,
|
||||
const char* display_name, bool show_type)
|
||||
void FullscreenUI::DrawInputBindingButton(
|
||||
SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, const char* name, const char* display_name, bool show_type)
|
||||
{
|
||||
std::string title(fmt::format("{}/{}", section, name));
|
||||
|
||||
|
@ -1218,17 +1218,17 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, PAD::Controlle
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case PAD::ControllerBindingType::Button:
|
||||
case InputBindingInfo::Type::Button:
|
||||
title = fmt::format(ICON_FA_DOT_CIRCLE " {}", display_name);
|
||||
break;
|
||||
case PAD::ControllerBindingType::Axis:
|
||||
case PAD::ControllerBindingType::HalfAxis:
|
||||
case InputBindingInfo::Type::Axis:
|
||||
case InputBindingInfo::Type::HalfAxis:
|
||||
title = fmt::format(ICON_FA_BULLSEYE " {}", display_name);
|
||||
break;
|
||||
case PAD::ControllerBindingType::Motor:
|
||||
case InputBindingInfo::Type::Motor:
|
||||
title = fmt::format(ICON_FA_BELL " {}", display_name);
|
||||
break;
|
||||
case PAD::ControllerBindingType::Macro:
|
||||
case InputBindingInfo::Type::Macro:
|
||||
title = fmt::format(ICON_FA_PIZZA_SLICE " {}", display_name);
|
||||
break;
|
||||
default:
|
||||
|
@ -1261,17 +1261,17 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, PAD::Controlle
|
|||
|
||||
void FullscreenUI::ClearInputBindingVariables()
|
||||
{
|
||||
s_input_binding_type = PAD::ControllerBindingType::Unknown;
|
||||
s_input_binding_type = InputBindingInfo::Type::Unknown;
|
||||
s_input_binding_section = {};
|
||||
s_input_binding_key = {};
|
||||
s_input_binding_display_name = {};
|
||||
s_input_binding_new_bindings = {};
|
||||
}
|
||||
|
||||
void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, PAD::ControllerBindingType type, const std::string_view& section,
|
||||
void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section,
|
||||
const std::string_view& key, const std::string_view& display_name)
|
||||
{
|
||||
if (s_input_binding_type != PAD::ControllerBindingType::Unknown)
|
||||
if (s_input_binding_type != InputBindingInfo::Type::Unknown)
|
||||
{
|
||||
InputManager::RemoveHook();
|
||||
ClearInputBindingVariables();
|
||||
|
@ -1327,7 +1327,7 @@ void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, PAD::ControllerBind
|
|||
|
||||
void FullscreenUI::DrawInputBindingWindow()
|
||||
{
|
||||
pxAssert(s_input_binding_type != PAD::ControllerBindingType::Unknown);
|
||||
pxAssert(s_input_binding_type != InputBindingInfo::Type::Unknown);
|
||||
|
||||
const double time_remaining = INPUT_BINDING_TIMEOUT_SECONDS - s_input_binding_timer.GetTimeSeconds();
|
||||
if (time_remaining <= 0.0)
|
||||
|
@ -3586,7 +3586,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
|
||||
for (u32 i = 0; i < ci->num_bindings; i++)
|
||||
{
|
||||
const PAD::ControllerBindingInfo& bi = ci->bindings[i];
|
||||
const InputBindingInfo& bi = ci->bindings[i];
|
||||
DrawInputBindingButton(bsi, bi.type, section, bi.name, bi.display_name, true);
|
||||
}
|
||||
|
||||
|
@ -3597,7 +3597,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
|
||||
for (u32 macro_index = 0; macro_index < PAD::NUM_MACRO_BUTTONS_PER_CONTROLLER; macro_index++)
|
||||
{
|
||||
DrawInputBindingButton(bsi, PAD::ControllerBindingType::Macro, section, fmt::format("Macro{}", macro_index + 1).c_str(),
|
||||
DrawInputBindingButton(bsi, InputBindingInfo::Type::Macro, section, fmt::format("Macro{}", macro_index + 1).c_str(),
|
||||
fmt::format("Macro {} Trigger", macro_index + 1).c_str());
|
||||
|
||||
std::string binds_string(bsi->GetStringValue(section, fmt::format("Macro{}Binds", macro_index + 1).c_str()));
|
||||
|
@ -3608,9 +3608,9 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
ImGuiFullscreen::ChoiceDialogOptions options;
|
||||
for (u32 i = 0; i < ci->num_bindings; i++)
|
||||
{
|
||||
const PAD::ControllerBindingInfo& bi = ci->bindings[i];
|
||||
if (bi.type != PAD::ControllerBindingType::Button && bi.type != PAD::ControllerBindingType::Axis &&
|
||||
bi.type != PAD::ControllerBindingType::HalfAxis)
|
||||
const InputBindingInfo& bi = ci->bindings[i];
|
||||
if (bi.type != InputBindingInfo::Type::Button && bi.type != InputBindingInfo::Type::Axis &&
|
||||
bi.type != InputBindingInfo::Type::HalfAxis)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -3624,7 +3624,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
std::string_view to_modify;
|
||||
for (u32 j = 0; j < ci->num_bindings; j++)
|
||||
{
|
||||
const PAD::ControllerBindingInfo& bi = ci->bindings[j];
|
||||
const InputBindingInfo& bi = ci->bindings[j];
|
||||
if (bi.display_name == title)
|
||||
{
|
||||
to_modify = bi.name;
|
||||
|
@ -3714,22 +3714,22 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
|
||||
for (u32 i = 0; i < ci->num_settings; i++)
|
||||
{
|
||||
const PAD::ControllerSettingInfo& si = ci->settings[i];
|
||||
const SettingInfo& si = ci->settings[i];
|
||||
std::string title(fmt::format(ICON_FA_COG " {}", si.display_name));
|
||||
switch (si.type)
|
||||
{
|
||||
case PAD::ControllerSettingInfo::Type::Boolean:
|
||||
case SettingInfo::Type::Boolean:
|
||||
DrawToggleSetting(bsi, title.c_str(), si.description, section, si.name, si.BooleanDefaultValue(), true, false);
|
||||
break;
|
||||
case PAD::ControllerSettingInfo::Type::Integer:
|
||||
case SettingInfo::Type::Integer:
|
||||
DrawIntRangeSetting(bsi, title.c_str(), si.description, section, si.name, si.IntegerDefaultValue(),
|
||||
si.IntegerMinValue(), si.IntegerMaxValue(), si.format, true);
|
||||
break;
|
||||
case PAD::ControllerSettingInfo::Type::IntegerList:
|
||||
case SettingInfo::Type::IntegerList:
|
||||
DrawIntListSetting(bsi, title.c_str(), si.description, section, si.name, si.IntegerDefaultValue(), si.options, 0,
|
||||
si.IntegerMinValue(), true);
|
||||
break;
|
||||
case PAD::ControllerSettingInfo::Type::Float:
|
||||
case SettingInfo::Type::Float:
|
||||
DrawFloatSpinBoxSetting(bsi, title.c_str(), si.description, section, si.name, si.FloatDefaultValue(),
|
||||
si.FloatMinValue(), si.FloatMaxValue(), si.FloatStepValue(), si.multiplier, si.format, true);
|
||||
break;
|
||||
|
@ -3760,7 +3760,7 @@ void FullscreenUI::DrawHotkeySettingsPage()
|
|||
last_category = hotkey;
|
||||
}
|
||||
|
||||
DrawInputBindingButton(bsi, PAD::ControllerBindingType::Button, "Hotkeys", hotkey->name, hotkey->display_name, false);
|
||||
DrawInputBindingButton(bsi, InputBindingInfo::Type::Button, "Hotkeys", hotkey->name, hotkey->display_name, false);
|
||||
}
|
||||
|
||||
EndMenuButtons();
|
||||
|
|
|
@ -505,11 +505,11 @@ void ImGuiManager::DrawInputsOverlay()
|
|||
|
||||
for (u32 bind = 0; bind < cinfo->num_bindings; bind++)
|
||||
{
|
||||
const PAD::ControllerBindingInfo& bi = cinfo->bindings[bind];
|
||||
const InputBindingInfo& bi = cinfo->bindings[bind];
|
||||
switch (bi.type)
|
||||
{
|
||||
case PAD::ControllerBindingType::Axis:
|
||||
case PAD::ControllerBindingType::HalfAxis:
|
||||
case InputBindingInfo::Type::Axis:
|
||||
case InputBindingInfo::Type::HalfAxis:
|
||||
{
|
||||
// axes are always shown
|
||||
const float value = static_cast<float>(g_key_status.GetRawPressure(port, bind)) * (1.0f / 255.0f);
|
||||
|
@ -520,7 +520,7 @@ void ImGuiManager::DrawInputsOverlay()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerBindingType::Button:
|
||||
case InputBindingInfo::Type::Button:
|
||||
{
|
||||
// buttons only shown when active
|
||||
const float value = static_cast<float>(g_key_status.GetRawPressure(port, bind)) * (1.0f / 255.0f);
|
||||
|
@ -529,9 +529,9 @@ void ImGuiManager::DrawInputsOverlay()
|
|||
}
|
||||
break;
|
||||
|
||||
case PAD::ControllerBindingType::Motor:
|
||||
case PAD::ControllerBindingType::Macro:
|
||||
case PAD::ControllerBindingType::Unknown:
|
||||
case InputBindingInfo::Type::Motor:
|
||||
case InputBindingInfo::Type::Macro:
|
||||
case InputBindingInfo::Type::Unknown:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -183,62 +183,6 @@ u8 PADpoll(u8 value)
|
|||
return pad_poll(value);
|
||||
}
|
||||
|
||||
const char* PAD::ControllerSettingInfo::StringDefaultValue() const
|
||||
{
|
||||
return default_value ? default_value : "";
|
||||
}
|
||||
|
||||
bool PAD::ControllerSettingInfo::BooleanDefaultValue() const
|
||||
{
|
||||
return default_value ? StringUtil::FromChars<bool>(default_value).value_or(false) : false;
|
||||
}
|
||||
|
||||
s32 PAD::ControllerSettingInfo::IntegerDefaultValue() const
|
||||
{
|
||||
return default_value ? StringUtil::FromChars<s32>(default_value).value_or(0) : 0;
|
||||
}
|
||||
|
||||
s32 PAD::ControllerSettingInfo::IntegerMinValue() const
|
||||
{
|
||||
static constexpr s32 fallback_value = std::numeric_limits<s32>::min();
|
||||
return min_value ? StringUtil::FromChars<s32>(min_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
s32 PAD::ControllerSettingInfo::IntegerMaxValue() const
|
||||
{
|
||||
static constexpr s32 fallback_value = std::numeric_limits<s32>::max();
|
||||
return max_value ? StringUtil::FromChars<s32>(max_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
s32 PAD::ControllerSettingInfo::IntegerStepValue() const
|
||||
{
|
||||
static constexpr s32 fallback_value = 1;
|
||||
return step_value ? StringUtil::FromChars<s32>(step_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
float PAD::ControllerSettingInfo::FloatDefaultValue() const
|
||||
{
|
||||
return default_value ? StringUtil::FromChars<float>(default_value).value_or(0.0f) : 0.0f;
|
||||
}
|
||||
|
||||
float PAD::ControllerSettingInfo::FloatMinValue() const
|
||||
{
|
||||
static constexpr float fallback_value = std::numeric_limits<float>::min();
|
||||
return min_value ? StringUtil::FromChars<float>(min_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
float PAD::ControllerSettingInfo::FloatMaxValue() const
|
||||
{
|
||||
static constexpr float fallback_value = std::numeric_limits<float>::max();
|
||||
return max_value ? StringUtil::FromChars<float>(max_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
float PAD::ControllerSettingInfo::FloatStepValue() const
|
||||
{
|
||||
static constexpr float fallback_value = 0.1f;
|
||||
return step_value ? StringUtil::FromChars<float>(step_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
std::string PAD::GetConfigSection(u32 pad_index)
|
||||
{
|
||||
return fmt::format("Pad{}", pad_index + 1);
|
||||
|
@ -336,21 +280,22 @@ void PAD::SetDefaultControllerConfig(SettingsInterface& si)
|
|||
{
|
||||
for (u32 i = 0; i < ci->num_settings; i++)
|
||||
{
|
||||
const ControllerSettingInfo& csi = ci->settings[i];
|
||||
const SettingInfo& csi = ci->settings[i];
|
||||
switch (csi.type)
|
||||
{
|
||||
case ControllerSettingInfo::Type::Boolean:
|
||||
case SettingInfo::Type::Boolean:
|
||||
si.SetBoolValue(section.c_str(), csi.name, csi.BooleanDefaultValue());
|
||||
break;
|
||||
case ControllerSettingInfo::Type::Integer:
|
||||
case ControllerSettingInfo::Type::IntegerList:
|
||||
case SettingInfo::Type::Integer:
|
||||
case SettingInfo::Type::IntegerList:
|
||||
si.SetIntValue(section.c_str(), csi.name, csi.IntegerDefaultValue());
|
||||
break;
|
||||
case ControllerSettingInfo::Type::Float:
|
||||
case SettingInfo::Type::Float:
|
||||
si.SetFloatValue(section.c_str(), csi.name, csi.FloatDefaultValue());
|
||||
break;
|
||||
case ControllerSettingInfo::Type::String:
|
||||
case ControllerSettingInfo::Type::Path:
|
||||
case SettingInfo::Type::String:
|
||||
case SettingInfo::Type::StringList:
|
||||
case SettingInfo::Type::Path:
|
||||
si.SetStringValue(section.c_str(), csi.name, csi.StringDefaultValue());
|
||||
break;
|
||||
default:
|
||||
|
@ -418,35 +363,35 @@ void PAD::Update()
|
|||
UpdateMacroButtons();
|
||||
}
|
||||
|
||||
static const PAD::ControllerBindingInfo s_dualshock2_binds[] = {
|
||||
{"Up", "D-Pad Up", PAD::ControllerBindingType::Button, GenericInputBinding::DPadUp},
|
||||
{"Right", "D-Pad Right", PAD::ControllerBindingType::Button, GenericInputBinding::DPadRight},
|
||||
{"Down", "D-Pad Down", PAD::ControllerBindingType::Button, GenericInputBinding::DPadDown},
|
||||
{"Left", "D-Pad Left", PAD::ControllerBindingType::Button, GenericInputBinding::DPadLeft},
|
||||
{"Triangle", "Triangle", PAD::ControllerBindingType::Button, GenericInputBinding::Triangle},
|
||||
{"Circle", "Circle", PAD::ControllerBindingType::Button, GenericInputBinding::Circle},
|
||||
{"Cross", "Cross", PAD::ControllerBindingType::Button, GenericInputBinding::Cross},
|
||||
{"Square", "Square", PAD::ControllerBindingType::Button, GenericInputBinding::Square},
|
||||
{"Select", "Select", PAD::ControllerBindingType::Button, GenericInputBinding::Select},
|
||||
{"Start", "Start", PAD::ControllerBindingType::Button, GenericInputBinding::Start},
|
||||
{"L1", "L1 (Left Bumper)", PAD::ControllerBindingType::Button, GenericInputBinding::L1},
|
||||
{"L2", "L2 (Left Trigger)", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::L2},
|
||||
{"R1", "R1 (Right Bumper)", PAD::ControllerBindingType::Button, GenericInputBinding::R1},
|
||||
{"R2", "R2 (Right Trigger)", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::R2},
|
||||
{"L3", "L3 (Left Stick Button)", PAD::ControllerBindingType::Button, GenericInputBinding::L3},
|
||||
{"R3", "R3 (Right Stick Button)", PAD::ControllerBindingType::Button, GenericInputBinding::R3},
|
||||
{"Analog", "Analog Toggle", PAD::ControllerBindingType::Button, GenericInputBinding::System},
|
||||
{"Pressure", "Apply Pressure", PAD::ControllerBindingType::Button, GenericInputBinding::Unknown},
|
||||
{"LUp", "Left Stick Up", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::LeftStickUp},
|
||||
{"LRight", "Left Stick Right", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::LeftStickRight},
|
||||
{"LDown", "Left Stick Down", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::LeftStickDown},
|
||||
{"LLeft", "Left Stick Left", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::LeftStickLeft},
|
||||
{"RUp", "Right Stick Up", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::RightStickUp},
|
||||
{"RRight", "Right Stick Right", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::RightStickRight},
|
||||
{"RDown", "Right Stick Down", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::RightStickDown},
|
||||
{"RLeft", "Right Stick Left", PAD::ControllerBindingType::HalfAxis, GenericInputBinding::RightStickLeft},
|
||||
{"LargeMotor", "Large (Low Frequency) Motor", PAD::ControllerBindingType::Motor, GenericInputBinding::LargeMotor},
|
||||
{"SmallMotor", "Small (High Frequency) Motor", PAD::ControllerBindingType::Motor, GenericInputBinding::SmallMotor},
|
||||
static const InputBindingInfo s_dualshock2_binds[] = {
|
||||
{"Up", "D-Pad Up", InputBindingInfo::Type::Button, GenericInputBinding::DPadUp},
|
||||
{"Right", "D-Pad Right", InputBindingInfo::Type::Button, GenericInputBinding::DPadRight},
|
||||
{"Down", "D-Pad Down", InputBindingInfo::Type::Button, GenericInputBinding::DPadDown},
|
||||
{"Left", "D-Pad Left", InputBindingInfo::Type::Button, GenericInputBinding::DPadLeft},
|
||||
{"Triangle", "Triangle", InputBindingInfo::Type::Button, GenericInputBinding::Triangle},
|
||||
{"Circle", "Circle", InputBindingInfo::Type::Button, GenericInputBinding::Circle},
|
||||
{"Cross", "Cross", InputBindingInfo::Type::Button, GenericInputBinding::Cross},
|
||||
{"Square", "Square", InputBindingInfo::Type::Button, GenericInputBinding::Square},
|
||||
{"Select", "Select", InputBindingInfo::Type::Button, GenericInputBinding::Select},
|
||||
{"Start", "Start", InputBindingInfo::Type::Button, GenericInputBinding::Start},
|
||||
{"L1", "L1 (Left Bumper)", InputBindingInfo::Type::Button, GenericInputBinding::L1},
|
||||
{"L2", "L2 (Left Trigger)", InputBindingInfo::Type::HalfAxis, GenericInputBinding::L2},
|
||||
{"R1", "R1 (Right Bumper)", InputBindingInfo::Type::Button, GenericInputBinding::R1},
|
||||
{"R2", "R2 (Right Trigger)", InputBindingInfo::Type::HalfAxis, GenericInputBinding::R2},
|
||||
{"L3", "L3 (Left Stick Button)", InputBindingInfo::Type::Button, GenericInputBinding::L3},
|
||||
{"R3", "R3 (Right Stick Button)", InputBindingInfo::Type::Button, GenericInputBinding::R3},
|
||||
{"Analog", "Analog Toggle", InputBindingInfo::Type::Button, GenericInputBinding::System},
|
||||
{"Pressure", "Apply Pressure", InputBindingInfo::Type::Button, GenericInputBinding::Unknown},
|
||||
{"LUp", "Left Stick Up", InputBindingInfo::Type::HalfAxis, GenericInputBinding::LeftStickUp},
|
||||
{"LRight", "Left Stick Right", InputBindingInfo::Type::HalfAxis, GenericInputBinding::LeftStickRight},
|
||||
{"LDown", "Left Stick Down", InputBindingInfo::Type::HalfAxis, GenericInputBinding::LeftStickDown},
|
||||
{"LLeft", "Left Stick Left", InputBindingInfo::Type::HalfAxis, GenericInputBinding::LeftStickLeft},
|
||||
{"RUp", "Right Stick Up", InputBindingInfo::Type::HalfAxis, GenericInputBinding::RightStickUp},
|
||||
{"RRight", "Right Stick Right", InputBindingInfo::Type::HalfAxis, GenericInputBinding::RightStickRight},
|
||||
{"RDown", "Right Stick Down", InputBindingInfo::Type::HalfAxis, GenericInputBinding::RightStickDown},
|
||||
{"RLeft", "Right Stick Left", InputBindingInfo::Type::HalfAxis, GenericInputBinding::RightStickLeft},
|
||||
{"LargeMotor", "Large (Low Frequency) Motor", InputBindingInfo::Type::Motor, GenericInputBinding::LargeMotor},
|
||||
{"SmallMotor", "Small (High Frequency) Motor", InputBindingInfo::Type::Motor, GenericInputBinding::SmallMotor},
|
||||
};
|
||||
|
||||
static const char* s_dualshock2_invert_entries[] = {
|
||||
|
@ -456,33 +401,33 @@ static const char* s_dualshock2_invert_entries[] = {
|
|||
"Invert Left/Right + Up/Down",
|
||||
nullptr};
|
||||
|
||||
static const PAD::ControllerSettingInfo s_dualshock2_settings[] = {
|
||||
{PAD::ControllerSettingInfo::Type::IntegerList, "InvertL", "Invert Left Stick",
|
||||
static const SettingInfo s_dualshock2_settings[] = {
|
||||
{SettingInfo::Type::IntegerList, "InvertL", "Invert Left Stick",
|
||||
"Inverts the direction of the left analog stick.",
|
||||
"0", "0", "3", nullptr, nullptr, s_dualshock2_invert_entries, 0.0f},
|
||||
{PAD::ControllerSettingInfo::Type::IntegerList, "InvertR", "Invert Right Stick",
|
||||
{SettingInfo::Type::IntegerList, "InvertR", "Invert Right Stick",
|
||||
"Inverts the direction of the right analog stick.",
|
||||
"0", "0", "3", nullptr, nullptr, s_dualshock2_invert_entries, 0.0f},
|
||||
{PAD::ControllerSettingInfo::Type::Float, "Deadzone", "Analog Deadzone",
|
||||
{SettingInfo::Type::Float, "Deadzone", "Analog Deadzone",
|
||||
"Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored.",
|
||||
"0.00", "0.00", "1.00", "0.01", "%.0f%%", nullptr, 100.0f},
|
||||
{PAD::ControllerSettingInfo::Type::Float, "AxisScale", "Analog Sensitivity",
|
||||
{SettingInfo::Type::Float, "AxisScale", "Analog Sensitivity",
|
||||
"Sets the analog stick axis scaling factor. A value between 1.30 and 1.40 is recommended when using recent "
|
||||
"controllers, e.g. DualShock 4, Xbox One Controller.",
|
||||
"1.33", "0.01", "2.00", "0.01", "%.0f%%", nullptr, 100.0f},
|
||||
{PAD::ControllerSettingInfo::Type::Float, "LargeMotorScale", "Large Motor Vibration Scale",
|
||||
{SettingInfo::Type::Float, "LargeMotorScale", "Large Motor Vibration Scale",
|
||||
"Increases or decreases the intensity of low frequency vibration sent by the game.",
|
||||
"1.00", "0.00", "2.00", "0.01", "%.0f%%", nullptr, 100.0f},
|
||||
{PAD::ControllerSettingInfo::Type::Float, "SmallMotorScale", "Small Motor Vibration Scale",
|
||||
{SettingInfo::Type::Float, "SmallMotorScale", "Small Motor Vibration Scale",
|
||||
"Increases or decreases the intensity of high frequency vibration sent by the game.",
|
||||
"1.00", "0.00", "2.00", "0.01", "%.0f%%", nullptr, 100.0f},
|
||||
{PAD::ControllerSettingInfo::Type::Float, "ButtonDeadzone", "Button/Trigger Deadzone",
|
||||
{SettingInfo::Type::Float, "ButtonDeadzone", "Button/Trigger Deadzone",
|
||||
"Sets the deadzone for activating buttons/triggers, i.e. the fraction of the trigger which will be ignored.",
|
||||
"0.00", "0.00", "1.00", "0.01", "%.0f%%", nullptr, 100.0f},
|
||||
/*{PAD::ControllerSettingInfo::Type::Float, "InitialPressure", "Initial Pressure",
|
||||
/*{SettingInfo::Type::Float, "InitialPressure", "Initial Pressure",
|
||||
"Sets the pressure when the modifier button isn't held.",
|
||||
"1.00", "0.01", "1.00", "0.01", "%.0f%%", nullptr, 100.0f},*/
|
||||
{PAD::ControllerSettingInfo::Type::Float, "PressureModifier", "Modifier Pressure",
|
||||
{SettingInfo::Type::Float, "PressureModifier", "Modifier Pressure",
|
||||
"Sets the pressure when the modifier button is held.",
|
||||
"0.50", "0.01", "1.00", "0.01", "%.0f%%", nullptr, 100.0f},
|
||||
};
|
||||
|
@ -538,8 +483,8 @@ std::vector<std::string> PAD::GetControllerBinds(const std::string_view& type)
|
|||
{
|
||||
for (u32 i = 0; i < info->num_bindings; i++)
|
||||
{
|
||||
const ControllerBindingInfo& bi = info->bindings[i];
|
||||
if (bi.type == ControllerBindingType::Unknown || bi.type == ControllerBindingType::Motor)
|
||||
const InputBindingInfo& bi = info->bindings[i];
|
||||
if (bi.type == InputBindingInfo::Type::Unknown || bi.type == InputBindingInfo::Type::Motor)
|
||||
continue;
|
||||
|
||||
ret.emplace_back(info->bindings[i].name);
|
||||
|
@ -598,7 +543,7 @@ void PAD::CopyConfiguration(SettingsInterface* dest_si, const SettingsInterface&
|
|||
{
|
||||
for (u32 i = 0; i < info->num_bindings; i++)
|
||||
{
|
||||
const ControllerBindingInfo& bi = info->bindings[i];
|
||||
const InputBindingInfo& bi = info->bindings[i];
|
||||
dest_si->CopyStringListValue(src_si, section.c_str(), bi.name);
|
||||
}
|
||||
|
||||
|
@ -622,21 +567,22 @@ void PAD::CopyConfiguration(SettingsInterface* dest_si, const SettingsInterface&
|
|||
|
||||
for (u32 i = 0; i < info->num_settings; i++)
|
||||
{
|
||||
const ControllerSettingInfo& csi = info->settings[i];
|
||||
const SettingInfo& csi = info->settings[i];
|
||||
switch (csi.type)
|
||||
{
|
||||
case ControllerSettingInfo::Type::Boolean:
|
||||
case SettingInfo::Type::Boolean:
|
||||
dest_si->CopyBoolValue(src_si, section.c_str(), csi.name);
|
||||
break;
|
||||
case ControllerSettingInfo::Type::Integer:
|
||||
case ControllerSettingInfo::Type::IntegerList:
|
||||
case SettingInfo::Type::Integer:
|
||||
case SettingInfo::Type::IntegerList:
|
||||
dest_si->CopyIntValue(src_si, section.c_str(), csi.name);
|
||||
break;
|
||||
case ControllerSettingInfo::Type::Float:
|
||||
case SettingInfo::Type::Float:
|
||||
dest_si->CopyFloatValue(src_si, section.c_str(), csi.name);
|
||||
break;
|
||||
case ControllerSettingInfo::Type::String:
|
||||
case ControllerSettingInfo::Type::Path:
|
||||
case SettingInfo::Type::String:
|
||||
case SettingInfo::Type::StringList:
|
||||
case SettingInfo::Type::Path:
|
||||
dest_si->CopyStringValue(src_si, section.c_str(), csi.name);
|
||||
break;
|
||||
default:
|
||||
|
@ -701,7 +647,7 @@ bool PAD::MapController(SettingsInterface& si, u32 controller,
|
|||
u32 num_mappings = 0;
|
||||
for (u32 i = 0; i < info->num_bindings; i++)
|
||||
{
|
||||
const ControllerBindingInfo& bi = info->bindings[i];
|
||||
const InputBindingInfo& bi = info->bindings[i];
|
||||
if (bi.generic_mapping == GenericInputBinding::Unknown)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Config.h"
|
||||
#include "PAD/Host/Global.h"
|
||||
#include "SaveState.h"
|
||||
|
||||
|
@ -46,16 +47,6 @@ namespace PAD
|
|||
Count
|
||||
};
|
||||
|
||||
enum class ControllerBindingType : u8
|
||||
{
|
||||
Unknown,
|
||||
Button,
|
||||
Axis,
|
||||
HalfAxis,
|
||||
Motor,
|
||||
Macro
|
||||
};
|
||||
|
||||
enum class VibrationCapabilities : u8
|
||||
{
|
||||
NoVibration,
|
||||
|
@ -64,61 +55,16 @@ namespace PAD
|
|||
Count
|
||||
};
|
||||
|
||||
struct ControllerBindingInfo
|
||||
{
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
ControllerBindingType type;
|
||||
GenericInputBinding generic_mapping;
|
||||
};
|
||||
|
||||
struct ControllerSettingInfo
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
Boolean,
|
||||
Integer,
|
||||
IntegerList,
|
||||
Float,
|
||||
String,
|
||||
Path,
|
||||
};
|
||||
|
||||
Type type;
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
const char* description;
|
||||
const char* default_value;
|
||||
const char* min_value;
|
||||
const char* max_value;
|
||||
const char* step_value;
|
||||
const char* format;
|
||||
const char** options;
|
||||
float multiplier;
|
||||
|
||||
const char* StringDefaultValue() const;
|
||||
bool BooleanDefaultValue() const;
|
||||
s32 IntegerDefaultValue() const;
|
||||
s32 IntegerMinValue() const;
|
||||
s32 IntegerMaxValue() const;
|
||||
s32 IntegerStepValue() const;
|
||||
float FloatDefaultValue() const;
|
||||
float FloatMinValue() const;
|
||||
float FloatMaxValue() const;
|
||||
float FloatStepValue() const;
|
||||
};
|
||||
|
||||
|
||||
struct ControllerInfo
|
||||
{
|
||||
ControllerType type;
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
const ControllerBindingInfo* bindings;
|
||||
const InputBindingInfo* bindings;
|
||||
u32 num_bindings;
|
||||
const ControllerSettingInfo* settings;
|
||||
const SettingInfo* settings;
|
||||
u32 num_settings;
|
||||
PAD::VibrationCapabilities vibration_caps;
|
||||
VibrationCapabilities vibration_caps;
|
||||
};
|
||||
|
||||
/// Total number of pad ports, across both multitaps.
|
||||
|
|
|
@ -31,6 +31,62 @@
|
|||
#include "GS/GS.h"
|
||||
#endif
|
||||
|
||||
const char* SettingInfo::StringDefaultValue() const
|
||||
{
|
||||
return default_value ? default_value : "";
|
||||
}
|
||||
|
||||
bool SettingInfo::BooleanDefaultValue() const
|
||||
{
|
||||
return default_value ? StringUtil::FromChars<bool>(default_value).value_or(false) : false;
|
||||
}
|
||||
|
||||
s32 SettingInfo::IntegerDefaultValue() const
|
||||
{
|
||||
return default_value ? StringUtil::FromChars<s32>(default_value).value_or(0) : 0;
|
||||
}
|
||||
|
||||
s32 SettingInfo::IntegerMinValue() const
|
||||
{
|
||||
static constexpr s32 fallback_value = std::numeric_limits<s32>::min();
|
||||
return min_value ? StringUtil::FromChars<s32>(min_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
s32 SettingInfo::IntegerMaxValue() const
|
||||
{
|
||||
static constexpr s32 fallback_value = std::numeric_limits<s32>::max();
|
||||
return max_value ? StringUtil::FromChars<s32>(max_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
s32 SettingInfo::IntegerStepValue() const
|
||||
{
|
||||
static constexpr s32 fallback_value = 1;
|
||||
return step_value ? StringUtil::FromChars<s32>(step_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
float SettingInfo::FloatDefaultValue() const
|
||||
{
|
||||
return default_value ? StringUtil::FromChars<float>(default_value).value_or(0.0f) : 0.0f;
|
||||
}
|
||||
|
||||
float SettingInfo::FloatMinValue() const
|
||||
{
|
||||
static constexpr float fallback_value = std::numeric_limits<float>::min();
|
||||
return min_value ? StringUtil::FromChars<float>(min_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
float SettingInfo::FloatMaxValue() const
|
||||
{
|
||||
static constexpr float fallback_value = std::numeric_limits<float>::max();
|
||||
return max_value ? StringUtil::FromChars<float>(max_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
float SettingInfo::FloatStepValue() const
|
||||
{
|
||||
static constexpr float fallback_value = 0.1f;
|
||||
return step_value ? StringUtil::FromChars<float>(step_value).value_or(fallback_value) : fallback_value;
|
||||
}
|
||||
|
||||
namespace EmuFolders
|
||||
{
|
||||
std::string AppRoot;
|
||||
|
|
Loading…
Reference in New Issue