mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-11 13:24:56 +00:00
input_common: Make button threshold customizable
This commit is contained in:
parent
3cd3230295
commit
240019feca
|
@ -660,7 +660,8 @@ public:
|
||||||
|
|
||||||
if (params.Has("axis")) {
|
if (params.Has("axis")) {
|
||||||
const int axis = params.Get("axis", 0);
|
const int axis = params.Get("axis", 0);
|
||||||
const float threshold = params.Get("threshold", 0.5f);
|
// Convert range from (0.0, 1.0) to (-1.0, 1.0)
|
||||||
|
const float threshold = (params.Get("threshold", 0.5f) - 0.5f) * 2.0f;
|
||||||
const std::string direction_name = params.Get("direction", "");
|
const std::string direction_name = params.Get("direction", "");
|
||||||
bool trigger_if_greater;
|
bool trigger_if_greater;
|
||||||
if (direction_name == "+") {
|
if (direction_name == "+") {
|
||||||
|
@ -933,12 +934,11 @@ Common::ParamPackage BuildAnalogParamPackageForButton(int port, std::string guid
|
||||||
params.Set("port", port);
|
params.Set("port", port);
|
||||||
params.Set("guid", std::move(guid));
|
params.Set("guid", std::move(guid));
|
||||||
params.Set("axis", axis);
|
params.Set("axis", axis);
|
||||||
|
params.Set("threshold", "0.5");
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
params.Set("direction", "+");
|
params.Set("direction", "+");
|
||||||
params.Set("threshold", "0.5");
|
|
||||||
} else {
|
} else {
|
||||||
params.Set("direction", "-");
|
params.Set("direction", "-");
|
||||||
params.Set("threshold", "-0.5");
|
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,6 +313,16 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
||||||
buttons_param[button_id].Set("toggle", toggle_value);
|
buttons_param[button_id].Set("toggle", toggle_value);
|
||||||
button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
|
button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
|
||||||
});
|
});
|
||||||
|
if (buttons_param[button_id].Has("threshold")) {
|
||||||
|
context_menu.addAction(tr("Set threshold"), [&] {
|
||||||
|
const int button_threshold = static_cast<int>(
|
||||||
|
buttons_param[button_id].Get("threshold", 0.5f) * 100.0f);
|
||||||
|
const int new_threshold = QInputDialog::getInt(
|
||||||
|
this, tr("Set threshold"), tr("Choose a value between 0% and 100%"),
|
||||||
|
button_threshold, 0, 100);
|
||||||
|
buttons_param[button_id].Set("threshold", new_threshold / 100.0f);
|
||||||
|
});
|
||||||
|
}
|
||||||
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
||||||
ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
|
ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue