summaryrefslogtreecommitdiffstats
path: root/src/yuzu/configuration/configure_input_player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/configuration/configure_input_player.cpp')
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 6b9bd05f1..3aab5d5f8 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -44,8 +44,7 @@ namespace {
constexpr std::size_t HANDHELD_INDEX = 8;
void UpdateController(Settings::ControllerType controller_type, std::size_t npad_index,
- bool connected) {
- Core::System& system{Core::System::GetInstance()};
+ bool connected, Core::System& system) {
if (!system.IsPoweredOn()) {
return;
}
@@ -124,6 +123,19 @@ QString ButtonToText(const Common::ParamPackage& param) {
return GetKeyName(param.Get("code", 0));
}
+ if (param.Get("engine", "") == "tas") {
+ if (param.Has("axis")) {
+ const QString axis_str = QString::fromStdString(param.Get("axis", ""));
+
+ return QObject::tr("TAS Axis %1").arg(axis_str);
+ }
+ if (param.Has("button")) {
+ const QString button_str = QString::number(int(std::log2(param.Get("button", 0))));
+ return QObject::tr("TAS Btn %1").arg(button_str);
+ }
+ return GetKeyName(param.Get("code", 0));
+ }
+
if (param.Get("engine", "") == "cemuhookudp") {
if (param.Has("pad_index")) {
const QString motion_str = QString::fromStdString(param.Get("pad_index", ""));
@@ -187,7 +199,8 @@ QString AnalogToText(const Common::ParamPackage& param, const std::string& dir)
const QString axis_y_str = QString::fromStdString(param.Get("axis_y", ""));
const bool invert_x = param.Get("invert_x", "+") == "-";
const bool invert_y = param.Get("invert_y", "+") == "-";
- if (engine_str == "sdl" || engine_str == "gcpad" || engine_str == "mouse") {
+ if (engine_str == "sdl" || engine_str == "gcpad" || engine_str == "mouse" ||
+ engine_str == "tas") {
if (dir == "modifier") {
return QObject::tr("[unused]");
}
@@ -218,11 +231,12 @@ QString AnalogToText(const Common::ParamPackage& param, const std::string& dir)
ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index,
QWidget* bottom_row,
InputCommon::InputSubsystem* input_subsystem_,
- InputProfiles* profiles_, bool debug)
+ InputProfiles* profiles_, Core::System& system_,
+ bool debug)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index(player_index),
debug(debug), input_subsystem{input_subsystem_}, profiles(profiles_),
timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()),
- bottom_row(bottom_row) {
+ bottom_row(bottom_row), system{system_} {
ui->setupUi(this);
setFocusPolicy(Qt::ClickFocus);
@@ -309,11 +323,14 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
buttons_param[button_id].Clear();
button_map[button_id]->setText(tr("[not set]"));
});
- context_menu.addAction(tr("Toggle button"), [&] {
- const bool toggle_value = !buttons_param[button_id].Get("toggle", false);
- buttons_param[button_id].Set("toggle", toggle_value);
- button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
- });
+ if (buttons_param[button_id].Has("toggle")) {
+ context_menu.addAction(tr("Toggle button"), [&] {
+ const bool toggle_value =
+ !buttons_param[button_id].Get("toggle", false);
+ buttons_param[button_id].Set("toggle", toggle_value);
+ 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>(
@@ -666,7 +683,7 @@ void ConfigureInputPlayer::TryConnectSelectedController() {
controller_type == Settings::ControllerType::Handheld;
// Connect only if handheld is going from disconnected to connected
if (!handheld.connected && handheld_connected) {
- UpdateController(controller_type, HANDHELD_INDEX, true);
+ UpdateController(controller_type, HANDHELD_INDEX, true, system);
}
handheld.connected = handheld_connected;
}
@@ -686,7 +703,7 @@ void ConfigureInputPlayer::TryConnectSelectedController() {
return;
}
- UpdateController(controller_type, player_index, true);
+ UpdateController(controller_type, player_index, true, system);
}
void ConfigureInputPlayer::TryDisconnectSelectedController() {
@@ -704,7 +721,7 @@ void ConfigureInputPlayer::TryDisconnectSelectedController() {
controller_type == Settings::ControllerType::Handheld;
// Disconnect only if handheld is going from connected to disconnected
if (handheld.connected && !handheld_connected) {
- UpdateController(controller_type, HANDHELD_INDEX, false);
+ UpdateController(controller_type, HANDHELD_INDEX, false, system);
}
return;
}
@@ -720,7 +737,7 @@ void ConfigureInputPlayer::TryDisconnectSelectedController() {
}
// Disconnect the controller first.
- UpdateController(controller_type, player_index, false);
+ UpdateController(controller_type, player_index, false, system);
}
void ConfigureInputPlayer::showEvent(QShowEvent* event) {
@@ -923,9 +940,9 @@ void ConfigureInputPlayer::UpdateUI() {
int slider_value;
auto& param = analogs_param[analog_id];
- const bool is_controller = param.Get("engine", "") == "sdl" ||
- param.Get("engine", "") == "gcpad" ||
- param.Get("engine", "") == "mouse";
+ const bool is_controller =
+ param.Get("engine", "") == "sdl" || param.Get("engine", "") == "gcpad" ||
+ param.Get("engine", "") == "mouse" || param.Get("engine", "") == "tas";
if (is_controller) {
if (!param.Has("deadzone")) {
@@ -1000,8 +1017,6 @@ void ConfigureInputPlayer::SetConnectableControllers() {
}
};
- Core::System& system{Core::System::GetInstance()};
-
if (!system.IsPoweredOn()) {
add_controllers(true);
return;
@@ -1042,8 +1057,12 @@ int ConfigureInputPlayer::GetIndexFromControllerType(Settings::ControllerType ty
void ConfigureInputPlayer::UpdateInputDevices() {
input_devices = input_subsystem->GetInputDevices();
ui->comboDevices->clear();
- for (auto device : input_devices) {
- ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {});
+ for (auto& device : input_devices) {
+ const std::string display = device.Get("display", "Unknown");
+ ui->comboDevices->addItem(QString::fromStdString(display), {});
+ if (display == "TAS") {
+ device.Set("pad", static_cast<u8>(player_index));
+ }
}
}