early-access version 2246

This commit is contained in:
pineappleEA 2021-11-27 11:46:29 +01:00
parent 1d3de2a1d7
commit ebdeb341af
9 changed files with 23 additions and 133 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 2244. This is the source code for early-access 2246.
## Legal Notice ## Legal Notice

View file

@ -357,7 +357,6 @@ constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>; using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>; using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>; using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>;
using VibrationsRaw = std::array<std::string, NativeVibration::NumVibrations>;
constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
@ -378,7 +377,6 @@ struct PlayerInput {
ControllerType controller_type; ControllerType controller_type;
ButtonsRaw buttons; ButtonsRaw buttons;
AnalogsRaw analogs; AnalogsRaw analogs;
VibrationsRaw vibrations;
MotionsRaw motions; MotionsRaw motions;
bool vibration_enabled; bool vibration_enabled;

View file

@ -92,10 +92,11 @@ void EmulatedController::ReloadFromSettings() {
ReloadInput(); ReloadInput();
} }
void EmulatedController::LoadDevices() { void EmulatedController::LoadDevices() {
// TODO(german77): Use more buttons to detect the correct device // TODO(german77): Use more buttons to detect the correct device
const auto left_joycon = button_params[Settings::NativeButton::A]; const auto left_joycon = button_params[Settings::NativeButton::DRight];
const auto right_joycon = button_params[Settings::NativeButton::DRight]; const auto right_joycon = button_params[Settings::NativeButton::A];
// Triggers for GC controllers // Triggers for GC controllers
trigger_params[LeftIndex] = button_params[Settings::NativeButton::ZL]; trigger_params[LeftIndex] = button_params[Settings::NativeButton::ZL];

View file

@ -1103,26 +1103,6 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages(
dst_info.format == src_info.format && copy.filter == Tegra::Engines::Fermi2D::Filter::Point; dst_info.format == src_info.format && copy.filter == Tegra::Engines::Fermi2D::Filter::Point;
ImageId dst_id; ImageId dst_id;
ImageId src_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; RelaxedOptions try_options = FIND_OPTIONS;
if (can_be_depth_blit) { if (can_be_depth_blit) {
try_options |= RelaxedOptions::Format; try_options |= RelaxedOptions::Format;
@ -1148,9 +1128,15 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages(
continue; 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); } while (has_deleted_images);
if (GetFormatType(dst_info.format) != SurfaceType::ColorTexture) { 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{}); src_id = FindOrInsertImage(src_info, src_addr, RelaxedOptions{});
dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{}); dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{});
} }

View file

@ -29,7 +29,7 @@ namespace {
void UpdateController(Core::HID::EmulatedController* controller, void UpdateController(Core::HID::EmulatedController* controller,
Core::HID::NpadStyleIndex controller_type, bool connected) { Core::HID::NpadStyleIndex controller_type, bool connected) {
if (controller->IsConnected()) { if (controller->IsConnected(true)) {
controller->Disconnect(); controller->Disconnect();
} }
controller->SetNpadStyleIndex(controller_type); controller->SetNpadStyleIndex(controller_type);
@ -139,6 +139,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
DisableUnsupportedPlayers(); DisableUnsupportedPlayers();
for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
system.HIDCore().GetEmulatedControllerByIndex(player_index)->EnableConfiguration();
SetEmulatedControllers(player_index); SetEmulatedControllers(player_index);
} }
@ -233,20 +234,24 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked()); Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
Settings::values.motion_enabled.SetValue(ui->motionGroup->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() { void QtControllerSelectorDialog::LoadConfiguration() {
const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(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); player_groupboxes[index]->setChecked(connected);
connected_controller_checkboxes[index]->setChecked(connected); connected_controller_checkboxes[index]->setChecked(connected);
emulated_controllers[index]->setCurrentIndex( 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->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
ui->motionGroup->setChecked(Settings::values.motion_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() && const auto player_connected = player_groupboxes[player_index]->isChecked() &&
controller_type != Core::HID::NpadStyleIndex::Handheld; controller_type != Core::HID::NpadStyleIndex::Handheld;
if (controller->GetNpadStyleIndex() == controller_type && if (controller->GetNpadStyleIndex(true) == controller_type &&
controller->IsConnected() == player_connected) { controller->IsConnected(true) == player_connected) {
// Set vibration devices in the event that the input device has changed.
ConfigureVibration::SetVibrationDevices(player_index);
return; return;
} }
// Disconnect the controller first. // Disconnect the controller first.
UpdateController(controller, controller_type, false); UpdateController(controller, controller_type, false);
ConfigureVibration::SetVibrationDevices(player_index);
// Handheld // Handheld
if (player_index == 0) { if (player_index == 0) {
if (controller_type == Core::HID::NpadStyleIndex::Handheld) { 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) { for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) {
auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
// Disconnect any unsupported players here and disable or hide them if applicable. // 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. // Hide the player widgets when max_supported_controllers is less than or equal to 4.
if (max_supported_players <= 4) { if (max_supported_players <= 4) {
player_widgets[index]->hide(); player_widgets[index]->hide();

View file

@ -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) { for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]);
auto& player_motions = player.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(player.analogs[i]),
QString::fromStdString(default_param)); 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) { for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]);
WriteSetting(QStringLiteral("%1").arg(player_prefix) + WriteSetting(QStringLiteral("%1").arg(player_prefix) +

View file

@ -59,80 +59,6 @@ void ConfigureVibration::ApplyConfiguration() {
ui->checkBoxAccurateVibration->isChecked()); ui->checkBoxAccurateVibration->isChecked());
} }
void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
using namespace Settings::NativeButton;
static constexpr std::array<std::array<Settings::NativeButton::Values, 6>, 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<std::string, int> 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) { void ConfigureVibration::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) { if (event->type() == QEvent::LanguageChange) {
RetranslateUI(); RetranslateUI();

View file

@ -24,9 +24,6 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
static void SetVibrationDevices(std::size_t player_index);
static void SetAllVibrationDevices();
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
void RetranslateUI(); void RetranslateUI();

View file

@ -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); Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig);
} }
ConfigureVibration::SetAllVibrationDevices();
// Disable fps limit toggle when booting a new title // Disable fps limit toggle when booting a new title
Settings::values.disable_fps_limit.SetValue(false); Settings::values.disable_fps_limit.SetValue(false);