lime_qt: Add diagonal directional input bindings for circlepad and c-stick (#404)
Some checks are pending
lime-build / source (push) Waiting to run
lime-build / linux (appimage) (push) Waiting to run
lime-build / linux (fresh) (push) Waiting to run
lime-build / macos (arm64) (push) Waiting to run
lime-build / macos (x86_64) (push) Waiting to run
lime-build / macos-universal (push) Blocked by required conditions
lime-build / windows (msvc) (push) Waiting to run
lime-build / windows (msys2) (push) Waiting to run
lime-build / android (push) Waiting to run
lime-build / release (push) Blocked by required conditions
lime-format / clang-format (push) Waiting to run
lime-transifex / transifex (push) Waiting to run

Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
This commit is contained in:
Kleidis 2024-10-29 20:15:51 +01:00 committed by GitHub
parent da2912e75f
commit 21aec70f67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 417 additions and 167 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2017 Citra Emulator Project
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -10,11 +10,12 @@ class Analog final : public Input::AnalogDevice {
public:
using Button = std::unique_ptr<Input::ButtonDevice>;
Analog(Button up_, Button down_, Button left_, Button right_, Button modifier_,
float modifier_scale_)
Analog(Button up_, Button down_, Button left_, Button right_, Button up_left_, Button up_right_,
Button down_left_, Button down_right_, Button modifier_, float modifier_scale_)
: up(std::move(up_)), down(std::move(down_)), left(std::move(left_)),
right(std::move(right_)), modifier(std::move(modifier_)),
modifier_scale(modifier_scale_) {}
right(std::move(right_)), up_left(std::move(up_left_)), up_right(std::move(up_right_)),
down_left(std::move(down_left_)), down_right(std::move(down_right_)),
modifier(std::move(modifier_)), modifier_scale(modifier_scale_) {}
std::tuple<float, float> GetStatus() const override {
constexpr float SQRT_HALF = 0.707106781f;
@ -28,6 +29,22 @@ public:
++y;
if (down->GetStatus())
--y;
if (up_right->GetStatus()) {
++x;
++y;
}
if (up_left->GetStatus()) {
--x;
++y;
}
if (down_right->GetStatus()) {
++x;
--y;
}
if (down_left->GetStatus()) {
--x;
--y;
}
float coef = modifier->GetStatus() ? modifier_scale : 1.0f;
return std::make_tuple(x * coef * (y == 0 ? 1.0f : SQRT_HALF),
@ -39,6 +56,10 @@ private:
Button down;
Button left;
Button right;
Button up_left;
Button up_right;
Button down_left;
Button down_right;
Button modifier;
float modifier_scale;
};
@ -49,10 +70,17 @@ std::unique_ptr<Input::AnalogDevice> AnalogFromButton::Create(const Common::Para
auto down = Input::CreateDevice<Input::ButtonDevice>(params.Get("down", null_engine));
auto left = Input::CreateDevice<Input::ButtonDevice>(params.Get("left", null_engine));
auto right = Input::CreateDevice<Input::ButtonDevice>(params.Get("right", null_engine));
auto up_left = Input::CreateDevice<Input::ButtonDevice>(params.Get("up_left", null_engine));
auto up_right = Input::CreateDevice<Input::ButtonDevice>(params.Get("up_right", null_engine));
auto down_left = Input::CreateDevice<Input::ButtonDevice>(params.Get("down_left", null_engine));
auto down_right =
Input::CreateDevice<Input::ButtonDevice>(params.Get("down_right", null_engine));
auto modifier = Input::CreateDevice<Input::ButtonDevice>(params.Get("modifier", null_engine));
auto modifier_scale = params.Get("modifier_scale", 0.5f);
return std::make_unique<Analog>(std::move(up), std::move(down), std::move(left),
std::move(right), std::move(modifier), modifier_scale);
std::move(right), std::move(up_left), std::move(up_right),
std::move(down_left), std::move(down_right),
std::move(modifier), modifier_scale);
}
} // namespace InputCommon

View file

@ -382,10 +382,11 @@ void QtConfig::ReadControlValues() {
std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
default_analogs[i][0], default_analogs[i][1], default_analogs[i][2],
default_analogs[i][3], default_analogs[i][4], 0.5f);
profile.analogs[i] = ReadSetting(QString::fromUtf8(Settings::NativeAnalog::mapping[i]),
QString::fromStdString(default_param))
.toString()
.toStdString();
profile.analogs[i] =
ReadSetting(QString::fromStdString(Settings::NativeAnalog::mapping[i]),
QString::fromStdString(default_param))
.toString()
.toStdString();
if (profile.analogs[i].empty())
profile.analogs[i] = default_param;
}

View file

@ -1,4 +1,4 @@
// Copyright 2016 Citra Emulator Project
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -25,6 +25,10 @@ const std::array<std::string, ConfigureInput::ANALOG_SUB_BUTTONS_NUM>
"down",
"left",
"right",
"up_left",
"up_right",
"down_left",
"down_right",
"modifier",
}};
@ -33,6 +37,10 @@ enum class AnalogSubButtons {
down,
left,
right,
up_left,
up_right,
down_left,
down_right,
modifier,
};
@ -172,6 +180,10 @@ ConfigureInput::ConfigureInput(Core::System& _system, QWidget* parent)
ui->buttonCircleDown,
ui->buttonCircleLeft,
ui->buttonCircleRight,
ui->buttonCircleUpLeft,
ui->buttonCircleUpRight,
ui->buttonCircleDownLeft,
ui->buttonCircleDownRight,
nullptr,
},
{
@ -179,6 +191,10 @@ ConfigureInput::ConfigureInput(Core::System& _system, QWidget* parent)
ui->buttonCStickDown,
ui->buttonCStickLeft,
ui->buttonCStickRight,
ui->buttonCStickUpLeft,
ui->buttonCStickUpRight,
ui->buttonCStickDownLeft,
ui->buttonCStickDownRight,
nullptr,
},
}};
@ -469,12 +485,10 @@ void ConfigureInput::RestoreDefaults() {
}
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
QtConfig::default_analogs[analog_id][sub_button_id])};
SetAnalogButton(params, analogs_param[analog_id], analog_sub_buttons[sub_button_id]);
}
analogs_param[analog_id].Set("modifier_scale", 0.5f);
analogs_param[analog_id] = Common::ParamPackage{InputCommon::GenerateAnalogParamFromKeys(
QtConfig::default_analogs[analog_id][0], QtConfig::default_analogs[analog_id][1],
QtConfig::default_analogs[analog_id][2], QtConfig::default_analogs[analog_id][3],
QtConfig::default_analogs[analog_id][4], 0.5f)};
}
UpdateButtonLabels();

View file

@ -1,4 +1,4 @@
// Copyright 2016 Citra Emulator Project
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -62,7 +62,7 @@ private:
std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param;
std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param;
static constexpr int ANALOG_SUB_BUTTONS_NUM = 5;
static constexpr int ANALOG_SUB_BUTTONS_NUM = 9;
/// Each button input is represented by a QPushButton.
std::array<QPushButton*, Settings::NativeButton::NumButtons> button_map;

View file

@ -71,6 +71,93 @@
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout_7">
<item row="2" column="0">
<widget class="QGroupBox" name="faceButtons_3">
<property name="title">
<string>Shoulder Buttons</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>ZR:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonZR">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>L:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonL">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>ZL:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonZL">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLabel" name="label_19">
<property name="text">
<string>R:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonR">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="faceButtons">
<property name="title">
@ -398,35 +485,27 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_19">
<item row="11" column="2">
<widget class="QPushButton" name="buttonCircleUpRight">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="1" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label_24">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Up:</string>
<string>Up Left:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleUp">
<property name="text">
<widget class="QPushButton" name="buttonCircleUpLeft">
<property name="toolTip">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Right:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleRight">
<property name="text">
<string/>
</property>
@ -452,13 +531,6 @@
</item>
</layout>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="buttonCircleAnalog">
<property name="text">
<string>Set Analog Stick</string>
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
@ -477,7 +549,25 @@
</item>
</layout>
</item>
<item row="3" column="1" colspan="2">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QLabel" name="label_24">
<property name="text">
<string>Up:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleUp">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="20" column="1" colspan="2">
<layout class="QVBoxLayout" name="sliderCirclePadDeadzoneAndModifierVerticalLayout">
<item>
<layout class="QHBoxLayout" name="sliderCirclePadDeadzoneAndModifierHorizontalLayout">
@ -503,8 +593,114 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleAnalog">
<property name="text">
<string>Set Analog Stick</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Right:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleRight">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="2">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Up Right:</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_38">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_14">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Diagonals</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="12" column="2">
<layout class="QVBoxLayout" name="verticalLayout_30">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Down Right:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleDownRight">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="12" column="1">
<layout class="QVBoxLayout" name="verticalLayout_29">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Down Left:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCircleDownLeft">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="14" column="1" colspan="2">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -520,6 +716,24 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_24">
<item>
<widget class="QLabel" name="label_26">
<property name="text">
<string>Down:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickDown">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_22">
<item>
@ -538,24 +752,6 @@
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>Left:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickLeft">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_23">
<item>
@ -574,24 +770,17 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="buttonCStickAnalog">
<property name="text">
<string>Set Analog Stick</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_24">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QLabel" name="label_26">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Down:</string>
<string>Left:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickDown">
<widget class="QPushButton" name="buttonCStickLeft">
<property name="text">
<string/>
</property>
@ -599,7 +788,100 @@
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<item row="5" column="1">
<layout class="QVBoxLayout" name="verticalLayout_35">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Up Right:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickUpRight">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<layout class="QVBoxLayout" name="verticalLayout_36">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Down Left:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickDownLeft">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<layout class="QVBoxLayout" name="verticalLayout_37">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Down Right:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickDownRight">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QVBoxLayout" name="verticalLayout_31">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Up Left:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCStickUpLeft">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_39">
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Diagonals</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<layout class="QVBoxLayout" name="sliderCStickDeadzoneAndModifierVerticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
@ -625,94 +907,21 @@
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="faceButtons_3">
<property name="title">
<string>Shoulder Buttons</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QLabel" name="label_18">
<widget class="QPushButton" name="buttonCStickAnalog">
<property name="text">
<string>ZR:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonZR">
<property name="text">
<string/>
<string>Set Analog Stick</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>ZL:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonZL">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>L:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonL">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLabel" name="label_19">
<property name="text">
<string>R:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonR">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
<item row="7" column="0" colspan="2">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
@ -842,11 +1051,11 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="use_artic_controller">
<property name="text">
<string>Use Artic Controller when connected to Artic Base Server</string>
</property>
</widget>
<widget class="QCheckBox" name="use_artic_controller">
<property name="text">
<string>Use Artic Controller when connected to Artic Base Server</string>
</property>
</widget>
</item>
</layout>
</item>
@ -869,13 +1078,11 @@
<tabstop>buttonCircleRight</tabstop>
<tabstop>buttonCircleUp</tabstop>
<tabstop>buttonCircleDown</tabstop>
<tabstop>buttonCircleAnalog</tabstop>
<tabstop>sliderCirclePadDeadzoneAndModifier</tabstop>
<tabstop>buttonCStickLeft</tabstop>
<tabstop>buttonCStickRight</tabstop>
<tabstop>buttonCStickUp</tabstop>
<tabstop>buttonCStickDown</tabstop>
<tabstop>buttonCStickAnalog</tabstop>
<tabstop>sliderCStickDeadzoneAndModifier</tabstop>
<tabstop>buttonL</tabstop>
<tabstop>buttonR</tabstop>