mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-24 08:43:02 +00:00
input_common: Add support for analog toggle
This commit is contained in:
parent
199f77b92f
commit
2898be69f4
|
@ -102,6 +102,8 @@ struct AnalogProperties {
|
||||||
float offset{};
|
float offset{};
|
||||||
// Invert direction of the sensor data
|
// Invert direction of the sensor data
|
||||||
bool inverted{};
|
bool inverted{};
|
||||||
|
// Press once to activate, press again to release
|
||||||
|
bool toggle{};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Single analog sensor data
|
// Single analog sensor data
|
||||||
|
@ -115,8 +117,11 @@ struct AnalogStatus {
|
||||||
struct ButtonStatus {
|
struct ButtonStatus {
|
||||||
Common::UUID uuid{};
|
Common::UUID uuid{};
|
||||||
bool value{};
|
bool value{};
|
||||||
|
// Invert value of the button
|
||||||
bool inverted{};
|
bool inverted{};
|
||||||
|
// Press once to activate, press again to release
|
||||||
bool toggle{};
|
bool toggle{};
|
||||||
|
// Internal lock for the toggle status
|
||||||
bool locked{};
|
bool locked{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatu
|
||||||
Common::Input::ButtonStatus status{};
|
Common::Input::ButtonStatus status{};
|
||||||
switch (callback.type) {
|
switch (callback.type) {
|
||||||
case Common::Input::InputType::Analog:
|
case Common::Input::InputType::Analog:
|
||||||
|
status.value = TransformToTrigger(callback).pressed.value;
|
||||||
|
status.toggle = callback.analog_status.properties.toggle;
|
||||||
|
break;
|
||||||
case Common::Input::InputType::Trigger:
|
case Common::Input::InputType::Trigger:
|
||||||
status.value = TransformToTrigger(callback).pressed.value;
|
status.value = TransformToTrigger(callback).pressed.value;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -824,6 +824,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
||||||
.threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f),
|
.threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f),
|
||||||
.offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f),
|
.offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f),
|
||||||
.inverted = params.Get("invert", "+") == "-",
|
.inverted = params.Get("invert", "+") == "-",
|
||||||
|
.toggle = static_cast<bool>(params.Get("toggle", false)),
|
||||||
};
|
};
|
||||||
input_engine->PreSetController(identifier);
|
input_engine->PreSetController(identifier);
|
||||||
input_engine->PreSetAxis(identifier, axis);
|
input_engine->PreSetAxis(identifier, axis);
|
||||||
|
|
|
@ -382,6 +382,12 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
||||||
button_map[button_id]->setText(ButtonToText(param));
|
button_map[button_id]->setText(ButtonToText(param));
|
||||||
emulated_controller->SetButtonParam(button_id, param);
|
emulated_controller->SetButtonParam(button_id, param);
|
||||||
});
|
});
|
||||||
|
context_menu.addAction(tr("Toggle axis"), [&] {
|
||||||
|
const bool toggle_value = !param.Get("toggle", false);
|
||||||
|
param.Set("toggle", toggle_value);
|
||||||
|
button_map[button_id]->setText(ButtonToText(param));
|
||||||
|
emulated_controller->SetButtonParam(button_id, param);
|
||||||
|
});
|
||||||
context_menu.addAction(tr("Set threshold"), [&] {
|
context_menu.addAction(tr("Set threshold"), [&] {
|
||||||
const int button_threshold =
|
const int button_threshold =
|
||||||
static_cast<int>(param.Get("threshold", 0.5f) * 100.0f);
|
static_cast<int>(param.Get("threshold", 0.5f) * 100.0f);
|
||||||
|
|
Loading…
Reference in a new issue