diff options
| author | 2022-01-01 20:44:28 -0600 | |
|---|---|---|
| committer | 2022-01-01 21:42:17 -0600 | |
| commit | 133f497f843ded1ce466b8fb76fa2b77d7429f5e (patch) | |
| tree | 5505da9600df19a71ca9665c87b425d81e33ab0c /src | |
| parent | Merge pull request #7654 from Morph1984/dynarmic (diff) | |
| download | yuzu-133f497f843ded1ce466b8fb76fa2b77d7429f5e.tar.gz yuzu-133f497f843ded1ce466b8fb76fa2b77d7429f5e.tar.xz yuzu-133f497f843ded1ce466b8fb76fa2b77d7429f5e.zip | |
controller_applet: Only populate supported controllers
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/applets/qt_controller.cpp | 68 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 53 |
2 files changed, 68 insertions, 53 deletions
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index d63193131..4239c17f5 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp | |||
| @@ -400,36 +400,66 @@ void QtControllerSelectorDialog::SetSupportedControllers() { | |||
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index) { | 402 | void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index) { |
| 403 | const auto npad_style_set = system.HIDCore().GetSupportedStyleTag(); | ||
| 403 | auto& pairs = index_controller_type_pairs[player_index]; | 404 | auto& pairs = index_controller_type_pairs[player_index]; |
| 404 | 405 | ||
| 405 | pairs.clear(); | 406 | pairs.clear(); |
| 406 | emulated_controllers[player_index]->clear(); | 407 | emulated_controllers[player_index]->clear(); |
| 407 | 408 | ||
| 408 | pairs.emplace_back(emulated_controllers[player_index]->count(), | 409 | const auto add_item = [&](Core::HID::NpadStyleIndex controller_type, |
| 409 | Core::HID::NpadStyleIndex::ProController); | 410 | const QString& controller_name) { |
| 410 | emulated_controllers[player_index]->addItem(tr("Pro Controller")); | 411 | pairs.emplace_back(emulated_controllers[player_index]->count(), controller_type); |
| 412 | emulated_controllers[player_index]->addItem(controller_name); | ||
| 413 | }; | ||
| 411 | 414 | ||
| 412 | pairs.emplace_back(emulated_controllers[player_index]->count(), | 415 | if (npad_style_set.fullkey == 1) { |
| 413 | Core::HID::NpadStyleIndex::JoyconDual); | 416 | add_item(Core::HID::NpadStyleIndex::ProController, tr("Pro Controller")); |
| 414 | emulated_controllers[player_index]->addItem(tr("Dual Joycons")); | 417 | } |
| 415 | 418 | ||
| 416 | pairs.emplace_back(emulated_controllers[player_index]->count(), | 419 | if (npad_style_set.joycon_dual == 1) { |
| 417 | Core::HID::NpadStyleIndex::JoyconLeft); | 420 | add_item(Core::HID::NpadStyleIndex::JoyconDual, tr("Dual Joycons")); |
| 418 | emulated_controllers[player_index]->addItem(tr("Left Joycon")); | 421 | } |
| 419 | 422 | ||
| 420 | pairs.emplace_back(emulated_controllers[player_index]->count(), | 423 | if (npad_style_set.joycon_left == 1) { |
| 421 | Core::HID::NpadStyleIndex::JoyconRight); | 424 | add_item(Core::HID::NpadStyleIndex::JoyconLeft, tr("Left Joycon")); |
| 422 | emulated_controllers[player_index]->addItem(tr("Right Joycon")); | 425 | } |
| 423 | 426 | ||
| 424 | if (player_index == 0) { | 427 | if (npad_style_set.joycon_right == 1) { |
| 425 | pairs.emplace_back(emulated_controllers[player_index]->count(), | 428 | add_item(Core::HID::NpadStyleIndex::JoyconRight, tr("Right Joycon")); |
| 426 | Core::HID::NpadStyleIndex::Handheld); | ||
| 427 | emulated_controllers[player_index]->addItem(tr("Handheld")); | ||
| 428 | } | 429 | } |
| 429 | 430 | ||
| 430 | pairs.emplace_back(emulated_controllers[player_index]->count(), | 431 | if (player_index == 0 && npad_style_set.handheld == 1) { |
| 431 | Core::HID::NpadStyleIndex::GameCube); | 432 | add_item(Core::HID::NpadStyleIndex::Handheld, tr("Handheld")); |
| 432 | emulated_controllers[player_index]->addItem(tr("GameCube Controller")); | 433 | } |
| 434 | |||
| 435 | if (npad_style_set.gamecube == 1) { | ||
| 436 | add_item(Core::HID::NpadStyleIndex::GameCube, tr("GameCube Controller")); | ||
| 437 | } | ||
| 438 | |||
| 439 | // Disable all unsupported controllers | ||
| 440 | if (!Settings::values.enable_all_controllers) { | ||
| 441 | return; | ||
| 442 | } | ||
| 443 | |||
| 444 | if (npad_style_set.palma == 1) { | ||
| 445 | add_item(Core::HID::NpadStyleIndex::Pokeball, tr("Poke Ball Plus")); | ||
| 446 | } | ||
| 447 | |||
| 448 | if (npad_style_set.lark == 1) { | ||
| 449 | add_item(Core::HID::NpadStyleIndex::NES, tr("NES Controller")); | ||
| 450 | } | ||
| 451 | |||
| 452 | if (npad_style_set.lucia == 1) { | ||
| 453 | add_item(Core::HID::NpadStyleIndex::SNES, tr("SNES Controller")); | ||
| 454 | } | ||
| 455 | |||
| 456 | if (npad_style_set.lagoon == 1) { | ||
| 457 | add_item(Core::HID::NpadStyleIndex::N64, tr("N64 Controller")); | ||
| 458 | } | ||
| 459 | |||
| 460 | if (npad_style_set.lager == 1) { | ||
| 461 | add_item(Core::HID::NpadStyleIndex::SegaGenesis, tr("Sega Genesis")); | ||
| 462 | } | ||
| 433 | } | 463 | } |
| 434 | 464 | ||
| 435 | Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex( | 465 | Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex( |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index cb6163702..8c6249fc2 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -907,78 +907,63 @@ void ConfigureInputPlayer::UpdateUI() { | |||
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | void ConfigureInputPlayer::SetConnectableControllers() { | 909 | void ConfigureInputPlayer::SetConnectableControllers() { |
| 910 | Core::HID::NpadStyleTag npad_style_set = hid_core.GetSupportedStyleTag(); | 910 | const auto npad_style_set = hid_core.GetSupportedStyleTag(); |
| 911 | index_controller_type_pairs.clear(); | 911 | index_controller_type_pairs.clear(); |
| 912 | ui->comboControllerType->clear(); | 912 | ui->comboControllerType->clear(); |
| 913 | 913 | ||
| 914 | const auto add_item = [&](Core::HID::NpadStyleIndex controller_type, | ||
| 915 | const QString& controller_name) { | ||
| 916 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), controller_type); | ||
| 917 | ui->comboControllerType->addItem(controller_name); | ||
| 918 | }; | ||
| 919 | |||
| 914 | if (npad_style_set.fullkey == 1) { | 920 | if (npad_style_set.fullkey == 1) { |
| 915 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 921 | add_item(Core::HID::NpadStyleIndex::ProController, tr("Pro Controller")); |
| 916 | Core::HID::NpadStyleIndex::ProController); | ||
| 917 | ui->comboControllerType->addItem(tr("Pro Controller")); | ||
| 918 | } | 922 | } |
| 919 | 923 | ||
| 920 | if (npad_style_set.joycon_dual == 1) { | 924 | if (npad_style_set.joycon_dual == 1) { |
| 921 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 925 | add_item(Core::HID::NpadStyleIndex::JoyconDual, tr("Dual Joycons")); |
| 922 | Core::HID::NpadStyleIndex::JoyconDual); | ||
| 923 | ui->comboControllerType->addItem(tr("Dual Joycons")); | ||
| 924 | } | 926 | } |
| 925 | 927 | ||
| 926 | if (npad_style_set.joycon_left == 1) { | 928 | if (npad_style_set.joycon_left == 1) { |
| 927 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 929 | add_item(Core::HID::NpadStyleIndex::JoyconLeft, tr("Left Joycon")); |
| 928 | Core::HID::NpadStyleIndex::JoyconLeft); | ||
| 929 | ui->comboControllerType->addItem(tr("Left Joycon")); | ||
| 930 | } | 930 | } |
| 931 | 931 | ||
| 932 | if (npad_style_set.joycon_right == 1) { | 932 | if (npad_style_set.joycon_right == 1) { |
| 933 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 933 | add_item(Core::HID::NpadStyleIndex::JoyconRight, tr("Right Joycon")); |
| 934 | Core::HID::NpadStyleIndex::JoyconRight); | ||
| 935 | ui->comboControllerType->addItem(tr("Right Joycon")); | ||
| 936 | } | 934 | } |
| 937 | 935 | ||
| 938 | if (player_index == 0 && npad_style_set.handheld == 1) { | 936 | if (player_index == 0 && npad_style_set.handheld == 1) { |
| 939 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 937 | add_item(Core::HID::NpadStyleIndex::Handheld, tr("Handheld")); |
| 940 | Core::HID::NpadStyleIndex::Handheld); | ||
| 941 | ui->comboControllerType->addItem(tr("Handheld")); | ||
| 942 | } | 938 | } |
| 943 | 939 | ||
| 944 | if (npad_style_set.gamecube == 1) { | 940 | if (npad_style_set.gamecube == 1) { |
| 945 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 941 | add_item(Core::HID::NpadStyleIndex::GameCube, tr("GameCube Controller")); |
| 946 | Core::HID::NpadStyleIndex::GameCube); | ||
| 947 | ui->comboControllerType->addItem(tr("GameCube Controller")); | ||
| 948 | } | 942 | } |
| 949 | 943 | ||
| 950 | // Disable all unsupported controllers | 944 | // Disable all unsupported controllers |
| 951 | if (!Settings::values.enable_all_controllers) { | 945 | if (!Settings::values.enable_all_controllers) { |
| 952 | return; | 946 | return; |
| 953 | } | 947 | } |
| 948 | |||
| 954 | if (npad_style_set.palma == 1) { | 949 | if (npad_style_set.palma == 1) { |
| 955 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 950 | add_item(Core::HID::NpadStyleIndex::Pokeball, tr("Poke Ball Plus")); |
| 956 | Core::HID::NpadStyleIndex::Pokeball); | ||
| 957 | ui->comboControllerType->addItem(tr("Poke Ball Plus")); | ||
| 958 | } | 951 | } |
| 959 | 952 | ||
| 960 | if (npad_style_set.lark == 1) { | 953 | if (npad_style_set.lark == 1) { |
| 961 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 954 | add_item(Core::HID::NpadStyleIndex::NES, tr("NES Controller")); |
| 962 | Core::HID::NpadStyleIndex::NES); | ||
| 963 | ui->comboControllerType->addItem(tr("NES Controller")); | ||
| 964 | } | 955 | } |
| 965 | 956 | ||
| 966 | if (npad_style_set.lucia == 1) { | 957 | if (npad_style_set.lucia == 1) { |
| 967 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 958 | add_item(Core::HID::NpadStyleIndex::SNES, tr("SNES Controller")); |
| 968 | Core::HID::NpadStyleIndex::SNES); | ||
| 969 | ui->comboControllerType->addItem(tr("SNES Controller")); | ||
| 970 | } | 959 | } |
| 971 | 960 | ||
| 972 | if (npad_style_set.lagoon == 1) { | 961 | if (npad_style_set.lagoon == 1) { |
| 973 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 962 | add_item(Core::HID::NpadStyleIndex::N64, tr("N64 Controller")); |
| 974 | Core::HID::NpadStyleIndex::N64); | ||
| 975 | ui->comboControllerType->addItem(tr("N64 Controller")); | ||
| 976 | } | 963 | } |
| 977 | 964 | ||
| 978 | if (npad_style_set.lager == 1) { | 965 | if (npad_style_set.lager == 1) { |
| 979 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 966 | add_item(Core::HID::NpadStyleIndex::SegaGenesis, tr("Sega Genesis")); |
| 980 | Core::HID::NpadStyleIndex::SegaGenesis); | ||
| 981 | ui->comboControllerType->addItem(tr("Sega Genesis")); | ||
| 982 | } | 967 | } |
| 983 | } | 968 | } |
| 984 | 969 | ||