2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #7663 from german77/applet

controller_applet: Only populate supported controllers
This commit is contained in:
bunnei 2022-01-03 10:51:51 -08:00 committed by GitHub
commit b89d096652
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 56 deletions

View file

@ -400,36 +400,66 @@ void QtControllerSelectorDialog::SetSupportedControllers() {
} }
void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index) { void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index) {
const auto npad_style_set = system.HIDCore().GetSupportedStyleTag();
auto& pairs = index_controller_type_pairs[player_index]; auto& pairs = index_controller_type_pairs[player_index];
pairs.clear(); pairs.clear();
emulated_controllers[player_index]->clear(); emulated_controllers[player_index]->clear();
pairs.emplace_back(emulated_controllers[player_index]->count(), const auto add_item = [&](Core::HID::NpadStyleIndex controller_type,
Core::HID::NpadStyleIndex::ProController); const QString& controller_name) {
emulated_controllers[player_index]->addItem(tr("Pro Controller")); pairs.emplace_back(emulated_controllers[player_index]->count(), controller_type);
emulated_controllers[player_index]->addItem(controller_name);
};
pairs.emplace_back(emulated_controllers[player_index]->count(), if (npad_style_set.fullkey == 1) {
Core::HID::NpadStyleIndex::JoyconDual); add_item(Core::HID::NpadStyleIndex::ProController, tr("Pro Controller"));
emulated_controllers[player_index]->addItem(tr("Dual Joycons"));
pairs.emplace_back(emulated_controllers[player_index]->count(),
Core::HID::NpadStyleIndex::JoyconLeft);
emulated_controllers[player_index]->addItem(tr("Left Joycon"));
pairs.emplace_back(emulated_controllers[player_index]->count(),
Core::HID::NpadStyleIndex::JoyconRight);
emulated_controllers[player_index]->addItem(tr("Right Joycon"));
if (player_index == 0) {
pairs.emplace_back(emulated_controllers[player_index]->count(),
Core::HID::NpadStyleIndex::Handheld);
emulated_controllers[player_index]->addItem(tr("Handheld"));
} }
pairs.emplace_back(emulated_controllers[player_index]->count(), if (npad_style_set.joycon_dual == 1) {
Core::HID::NpadStyleIndex::GameCube); add_item(Core::HID::NpadStyleIndex::JoyconDual, tr("Dual Joycons"));
emulated_controllers[player_index]->addItem(tr("GameCube Controller")); }
if (npad_style_set.joycon_left == 1) {
add_item(Core::HID::NpadStyleIndex::JoyconLeft, tr("Left Joycon"));
}
if (npad_style_set.joycon_right == 1) {
add_item(Core::HID::NpadStyleIndex::JoyconRight, tr("Right Joycon"));
}
if (player_index == 0 && npad_style_set.handheld == 1) {
add_item(Core::HID::NpadStyleIndex::Handheld, tr("Handheld"));
}
if (npad_style_set.gamecube == 1) {
add_item(Core::HID::NpadStyleIndex::GameCube, tr("GameCube Controller"));
}
// Disable all unsupported controllers
if (!Settings::values.enable_all_controllers) {
return;
}
if (npad_style_set.palma == 1) {
add_item(Core::HID::NpadStyleIndex::Pokeball, tr("Poke Ball Plus"));
}
if (npad_style_set.lark == 1) {
add_item(Core::HID::NpadStyleIndex::NES, tr("NES Controller"));
}
if (npad_style_set.lucia == 1) {
add_item(Core::HID::NpadStyleIndex::SNES, tr("SNES Controller"));
}
if (npad_style_set.lagoon == 1) {
add_item(Core::HID::NpadStyleIndex::N64, tr("N64 Controller"));
}
if (npad_style_set.lager == 1) {
add_item(Core::HID::NpadStyleIndex::SegaGenesis, tr("Sega Genesis"));
}
} }
Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex( Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex(

View file

@ -907,78 +907,63 @@ void ConfigureInputPlayer::UpdateUI() {
} }
void ConfigureInputPlayer::SetConnectableControllers() { void ConfigureInputPlayer::SetConnectableControllers() {
Core::HID::NpadStyleTag npad_style_set = hid_core.GetSupportedStyleTag(); const auto npad_style_set = hid_core.GetSupportedStyleTag();
index_controller_type_pairs.clear(); index_controller_type_pairs.clear();
ui->comboControllerType->clear(); ui->comboControllerType->clear();
const auto add_item = [&](Core::HID::NpadStyleIndex controller_type,
const QString& controller_name) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), controller_type);
ui->comboControllerType->addItem(controller_name);
};
if (npad_style_set.fullkey == 1) { if (npad_style_set.fullkey == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::ProController, tr("Pro Controller"));
Core::HID::NpadStyleIndex::ProController);
ui->comboControllerType->addItem(tr("Pro Controller"));
} }
if (npad_style_set.joycon_dual == 1) { if (npad_style_set.joycon_dual == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::JoyconDual, tr("Dual Joycons"));
Core::HID::NpadStyleIndex::JoyconDual);
ui->comboControllerType->addItem(tr("Dual Joycons"));
} }
if (npad_style_set.joycon_left == 1) { if (npad_style_set.joycon_left == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::JoyconLeft, tr("Left Joycon"));
Core::HID::NpadStyleIndex::JoyconLeft);
ui->comboControllerType->addItem(tr("Left Joycon"));
} }
if (npad_style_set.joycon_right == 1) { if (npad_style_set.joycon_right == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::JoyconRight, tr("Right Joycon"));
Core::HID::NpadStyleIndex::JoyconRight);
ui->comboControllerType->addItem(tr("Right Joycon"));
} }
if (player_index == 0 && npad_style_set.handheld == 1) { if (player_index == 0 && npad_style_set.handheld == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::Handheld, tr("Handheld"));
Core::HID::NpadStyleIndex::Handheld);
ui->comboControllerType->addItem(tr("Handheld"));
} }
if (npad_style_set.gamecube == 1) { if (npad_style_set.gamecube == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::GameCube, tr("GameCube Controller"));
Core::HID::NpadStyleIndex::GameCube);
ui->comboControllerType->addItem(tr("GameCube Controller"));
} }
// Disable all unsupported controllers // Disable all unsupported controllers
if (!Settings::values.enable_all_controllers) { if (!Settings::values.enable_all_controllers) {
return; return;
} }
if (npad_style_set.palma == 1) { if (npad_style_set.palma == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::Pokeball, tr("Poke Ball Plus"));
Core::HID::NpadStyleIndex::Pokeball);
ui->comboControllerType->addItem(tr("Poke Ball Plus"));
} }
if (npad_style_set.lark == 1) { if (npad_style_set.lark == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::NES, tr("NES Controller"));
Core::HID::NpadStyleIndex::NES);
ui->comboControllerType->addItem(tr("NES Controller"));
} }
if (npad_style_set.lucia == 1) { if (npad_style_set.lucia == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::SNES, tr("SNES Controller"));
Core::HID::NpadStyleIndex::SNES);
ui->comboControllerType->addItem(tr("SNES Controller"));
} }
if (npad_style_set.lagoon == 1) { if (npad_style_set.lagoon == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::N64, tr("N64 Controller"));
Core::HID::NpadStyleIndex::N64);
ui->comboControllerType->addItem(tr("N64 Controller"));
} }
if (npad_style_set.lager == 1) { if (npad_style_set.lager == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), add_item(Core::HID::NpadStyleIndex::SegaGenesis, tr("Sega Genesis"));
Core::HID::NpadStyleIndex::SegaGenesis);
ui->comboControllerType->addItem(tr("Sega Genesis"));
} }
} }