Merge pull request #8272 from german77/stick_range

yuzu: config: Improve analog stick mapping
This commit is contained in:
bunnei 2022-05-03 14:36:39 -07:00 committed by GitHub
commit b06f9f2606
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 9 deletions

View file

@ -327,7 +327,7 @@ void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogS
raw_y += properties_y.offset; raw_y += properties_y.offset;
// Apply X scale correction from offset // Apply X scale correction from offset
if (std::abs(properties_x.offset) < 0.5f) { if (std::abs(properties_x.offset) < 0.75f) {
if (raw_x > 0) { if (raw_x > 0) {
raw_x /= 1 + properties_x.offset; raw_x /= 1 + properties_x.offset;
} else { } else {
@ -336,7 +336,7 @@ void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogS
} }
// Apply Y scale correction from offset // Apply Y scale correction from offset
if (std::abs(properties_y.offset) < 0.5f) { if (std::abs(properties_y.offset) < 0.75f) {
if (raw_y > 0) { if (raw_y > 0) {
raw_y /= 1 + properties_y.offset; raw_y /= 1 + properties_y.offset;
} else { } else {

View file

@ -732,7 +732,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice(
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
const Common::ParamPackage& params) { const Common::ParamPackage& params) {
const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f);
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); const auto range = std::clamp(params.Get("range", 0.95f), 0.25f, 1.50f);
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
const PadIdentifier identifier = { const PadIdentifier identifier = {
.guid = Common::UUID{params.Get("guid", "")}, .guid = Common::UUID{params.Get("guid", "")},

View file

@ -520,7 +520,28 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
QMenu context_menu; QMenu context_menu;
Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
context_menu.addAction(tr("Clear"), [&] { context_menu.addAction(tr("Clear"), [&] {
if (param.Get("engine", "") != "analog_from_button") {
emulated_controller->SetStickParam(analog_id, {}); emulated_controller->SetStickParam(analog_id, {});
for (auto button : analog_map_buttons[analog_id]) {
button->setText(tr("[not set]"));
}
return;
}
switch (sub_button_id) {
case 0:
param.Erase("up");
break;
case 1:
param.Erase("down");
break;
case 2:
param.Erase("left");
break;
case 3:
param.Erase("right");
break;
}
emulated_controller->SetStickParam(analog_id, param);
analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]")); analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
}); });
context_menu.addAction(tr("Center axis"), [&] { context_menu.addAction(tr("Center axis"), [&] {
@ -988,7 +1009,7 @@ void ConfigureInputPlayer::UpdateUI() {
slider_value = static_cast<int>(param.Get("deadzone", 0.15f) * 100); slider_value = static_cast<int>(param.Get("deadzone", 0.15f) * 100);
deadzone_label->setText(tr("Deadzone: %1%").arg(slider_value)); deadzone_label->setText(tr("Deadzone: %1%").arg(slider_value));
deadzone_slider->setValue(slider_value); deadzone_slider->setValue(slider_value);
range_spinbox->setValue(static_cast<int>(param.Get("range", 1.0f) * 100)); range_spinbox->setValue(static_cast<int>(param.Get("range", 0.95f) * 100));
} else { } else {
slider_value = static_cast<int>(param.Get("modifier_scale", 0.5f) * 100); slider_value = static_cast<int>(param.Get("modifier_scale", 0.5f) * 100);
modifier_label->setText(tr("Modifier Range: %1%").arg(slider_value)); modifier_label->setText(tr("Modifier Range: %1%").arg(slider_value));

View file

@ -754,13 +754,13 @@
<string>%</string> <string>%</string>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>50</number> <number>25</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>150</number> <number>150</number>
</property> </property>
<property name="value"> <property name="value">
<number>100</number> <number>95</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -2985,13 +2985,13 @@
<string>%</string> <string>%</string>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>50</number> <number>25</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>150</number> <number>150</number>
</property> </property>
<property name="value"> <property name="value">
<number>100</number> <number>95</number>
</property> </property>
</widget> </widget>
</item> </item>