From ebdeb341afd5a0a7fe92f9ea857cd46b54ecc45e Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 27 Nov 2021 11:46:29 +0100 Subject: [PATCH] early-access version 2246 --- README.md | 2 +- src/common/settings_input.h | 2 - src/core/hid/emulated_controller.cpp | 5 +- src/video_core/texture_cache/texture_cache.h | 28 ++----- src/yuzu/applets/qt_controller.cpp | 23 +++--- src/yuzu/configuration/config.cpp | 17 ----- .../configuration/configure_vibration.cpp | 74 ------------------- src/yuzu/configuration/configure_vibration.h | 3 - src/yuzu/main.cpp | 2 - 9 files changed, 23 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index d5fa567a6..1c6efce22 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2244. +This is the source code for early-access 2246. ## Legal Notice diff --git a/src/common/settings_input.h b/src/common/settings_input.h index 9a8804488..9e3df7376 100755 --- a/src/common/settings_input.h +++ b/src/common/settings_input.h @@ -357,7 +357,6 @@ constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods; using AnalogsRaw = std::array; using ButtonsRaw = std::array; using MotionsRaw = std::array; -using VibrationsRaw = std::array; constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; @@ -378,7 +377,6 @@ struct PlayerInput { ControllerType controller_type; ButtonsRaw buttons; AnalogsRaw analogs; - VibrationsRaw vibrations; MotionsRaw motions; bool vibration_enabled; diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 54d4ed93d..06ae41c3e 100755 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -92,10 +92,11 @@ void EmulatedController::ReloadFromSettings() { ReloadInput(); } + void EmulatedController::LoadDevices() { // TODO(german77): Use more buttons to detect the correct device - const auto left_joycon = button_params[Settings::NativeButton::A]; - const auto right_joycon = button_params[Settings::NativeButton::DRight]; + const auto left_joycon = button_params[Settings::NativeButton::DRight]; + const auto right_joycon = button_params[Settings::NativeButton::A]; // Triggers for GC controllers trigger_params[LeftIndex] = button_params[Settings::NativeButton::ZL]; diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 74f93491a..f24de9a38 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -1103,26 +1103,6 @@ typename TextureCache

::BlitImages TextureCache

::GetBlitImages( dst_info.format == src_info.format && copy.filter == Tegra::Engines::Fermi2D::Filter::Point; ImageId dst_id; ImageId src_id; - const auto convert_depth_format = [](PixelFormat format) { - switch (format) { - case PixelFormat::R16_UNORM: - return PixelFormat::D16_UNORM; - case PixelFormat::A8B8G8R8_UNORM: - return PixelFormat::S8_UINT_D24_UNORM; - case PixelFormat::R32_FLOAT: - return PixelFormat::D32_FLOAT; - default: - return format; - } - }; - auto insert_images = [&]() { - if (!src_id) { - src_id = InsertImage(src_info, src_addr, RelaxedOptions{}); - } - if (!dst_id) { - dst_id = InsertImage(dst_info, dst_addr, RelaxedOptions{}); - } - }; RelaxedOptions try_options = FIND_OPTIONS; if (can_be_depth_blit) { try_options |= RelaxedOptions::Format; @@ -1148,9 +1128,15 @@ typename TextureCache

::BlitImages TextureCache

::GetBlitImages( continue; } } - insert_images(); + if (!src_id) { + src_id = InsertImage(src_info, src_addr, RelaxedOptions{}); + } + if (!dst_id) { + dst_id = InsertImage(dst_info, dst_addr, RelaxedOptions{}); + } } while (has_deleted_images); if (GetFormatType(dst_info.format) != SurfaceType::ColorTexture) { + // Make sure the images are depth and/or stencil textures. src_id = FindOrInsertImage(src_info, src_addr, RelaxedOptions{}); dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{}); } diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index 6a2cdda63..589e0577a 100755 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp @@ -29,7 +29,7 @@ namespace { void UpdateController(Core::HID::EmulatedController* controller, Core::HID::NpadStyleIndex controller_type, bool connected) { - if (controller->IsConnected()) { + if (controller->IsConnected(true)) { controller->Disconnect(); } controller->SetNpadStyleIndex(controller_type); @@ -139,6 +139,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( DisableUnsupportedPlayers(); for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { + system.HIDCore().GetEmulatedControllerByIndex(player_index)->EnableConfiguration(); SetEmulatedControllers(player_index); } @@ -233,20 +234,24 @@ void QtControllerSelectorDialog::ApplyConfiguration() { Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked()); Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked()); + for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { + system.HIDCore().GetEmulatedControllerByIndex(player_index)->DisableConfiguration(); + } } void QtControllerSelectorDialog::LoadConfiguration() { const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); - const auto connected = controller->IsConnected() || (index == 0 && handheld->IsConnected()); + const auto connected = + controller->IsConnected(true) || (index == 0 && handheld->IsConnected(true)); player_groupboxes[index]->setChecked(connected); connected_controller_checkboxes[index]->setChecked(connected); emulated_controllers[index]->setCurrentIndex( - GetIndexFromControllerType(controller->GetNpadStyleIndex(), index)); + GetIndexFromControllerType(controller->GetNpadStyleIndex(true), index)); } - UpdateDockedState(handheld->IsConnected()); + UpdateDockedState(handheld->IsConnected(true)); ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue()); ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue()); @@ -510,18 +515,14 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index) const auto player_connected = player_groupboxes[player_index]->isChecked() && controller_type != Core::HID::NpadStyleIndex::Handheld; - if (controller->GetNpadStyleIndex() == controller_type && - controller->IsConnected() == player_connected) { - // Set vibration devices in the event that the input device has changed. - ConfigureVibration::SetVibrationDevices(player_index); + if (controller->GetNpadStyleIndex(true) == controller_type && + controller->IsConnected(true) == player_connected) { return; } // Disconnect the controller first. UpdateController(controller, controller_type, false); - ConfigureVibration::SetVibrationDevices(player_index); - // Handheld if (player_index == 0) { if (controller_type == Core::HID::NpadStyleIndex::Handheld) { @@ -633,7 +634,7 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() { for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) { auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); // Disconnect any unsupported players here and disable or hide them if applicable. - UpdateController(controller, controller->GetNpadStyleIndex(), false); + UpdateController(controller, controller->GetNpadStyleIndex(true), false); // Hide the player widgets when max_supported_controllers is less than or equal to 4. if (max_supported_players <= 4) { player_widgets[index]->hide(); diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 38fd6e93b..2c70d0548 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -273,18 +273,6 @@ void Config::ReadPlayerValue(std::size_t player_index) { } } - for (int i = 0; i < Settings::NativeVibration::NumVibrations; ++i) { - auto& player_vibrations = player.vibrations[i]; - - player_vibrations = - qt_config - ->value(QStringLiteral("%1").arg(player_prefix) + - QString::fromUtf8(Settings::NativeVibration::mapping[i]), - QString{}) - .toString() - .toStdString(); - } - for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); auto& player_motions = player.motions[i]; @@ -891,11 +879,6 @@ void Config::SavePlayerValue(std::size_t player_index) { QString::fromStdString(player.analogs[i]), QString::fromStdString(default_param)); } - for (int i = 0; i < Settings::NativeVibration::NumVibrations; ++i) { - WriteSetting(QStringLiteral("%1").arg(player_prefix) + - QString::fromStdString(Settings::NativeVibration::mapping[i]), - QString::fromStdString(player.vibrations[i]), QString{}); - } for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); WriteSetting(QStringLiteral("%1").arg(player_prefix) + diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp index f1ce7205d..adce04b27 100755 --- a/src/yuzu/configuration/configure_vibration.cpp +++ b/src/yuzu/configuration/configure_vibration.cpp @@ -59,80 +59,6 @@ void ConfigureVibration::ApplyConfiguration() { ui->checkBoxAccurateVibration->isChecked()); } -void ConfigureVibration::SetVibrationDevices(std::size_t player_index) { - using namespace Settings::NativeButton; - static constexpr std::array, 2> buttons{{ - {DLeft, DUp, DRight, DDown, L, ZL}, // Left Buttons - {A, B, X, Y, R, ZR}, // Right Buttons - }}; - - auto& player = Settings::values.players.GetValue()[player_index]; - - for (std::size_t device_idx = 0; device_idx < buttons.size(); ++device_idx) { - std::unordered_map params_count; - - for (const auto button_index : buttons[device_idx]) { - const auto& player_button = player.buttons[button_index]; - - if (params_count.find(player_button) != params_count.end()) { - ++params_count[player_button]; - continue; - } - - params_count.insert_or_assign(player_button, 1); - } - - const auto it = std::max_element( - params_count.begin(), params_count.end(), - [](const auto& lhs, const auto& rhs) { return lhs.second < rhs.second; }); - - auto& vibration_param_str = player.vibrations[device_idx]; - vibration_param_str.clear(); - - if (it->first.empty()) { - continue; - } - - const auto param = Common::ParamPackage(it->first); - - const auto engine = param.Get("engine", ""); - const auto guid = param.Get("guid", ""); - const auto port = param.Get("port", 0); - - if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") { - continue; - } - - vibration_param_str += fmt::format("engine:{}", engine); - - if (port != 0) { - vibration_param_str += fmt::format(",port:{}", port); - } - if (!guid.empty()) { - vibration_param_str += fmt::format(",guid:{}", guid); - } - } - - if (player.vibrations[0] != player.vibrations[1]) { - return; - } - - if (!player.vibrations[0].empty() && - player.controller_type != Settings::ControllerType::RightJoycon) { - player.vibrations[1].clear(); - } else if (!player.vibrations[1].empty() && - player.controller_type == Settings::ControllerType::RightJoycon) { - player.vibrations[0].clear(); - } -} - -void ConfigureVibration::SetAllVibrationDevices() { - // Set vibration devices for all player indices including handheld - for (std::size_t player_idx = 0; player_idx < NUM_PLAYERS + 1; ++player_idx) { - SetVibrationDevices(player_idx); - } -} - void ConfigureVibration::changeEvent(QEvent* event) { if (event->type() == QEvent::LanguageChange) { RetranslateUI(); diff --git a/src/yuzu/configuration/configure_vibration.h b/src/yuzu/configuration/configure_vibration.h index 07411a86f..37bbc2653 100755 --- a/src/yuzu/configuration/configure_vibration.h +++ b/src/yuzu/configuration/configure_vibration.h @@ -24,9 +24,6 @@ public: void ApplyConfiguration(); - static void SetVibrationDevices(std::size_t player_index); - static void SetAllVibrationDevices(); - private: void changeEvent(QEvent* event) override; void RetranslateUI(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 523f33629..9bd0db10a 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1380,8 +1380,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig); } - ConfigureVibration::SetAllVibrationDevices(); - // Disable fps limit toggle when booting a new title Settings::values.disable_fps_limit.SetValue(false);