Compare commits

..

15 Commits

Author SHA1 Message Date
8ff48c3261 Android #124 2023-11-06 00:57:34 +00:00
dfbc22c291 Merge pull request #11971 from german77/recent
service: am: Set the correct album program id
2023-11-05 18:27:24 -05:00
a5a3167eba service: am: Set the correct album program id 2023-11-05 17:26:34 -06:00
a423e0f9e0 renderer_vulkan: render on bottom of surface clip when flipped (#11894) 2023-11-05 21:47:35 +01:00
511c1f0c8b Merge pull request #11957 from liamwhite/null2
renderer_null: fix
2023-11-05 13:15:19 -05:00
8369fcd71a Merge pull request #11969 from german77/profile
service: acc: Ensure proper profile size
2023-11-05 13:15:14 -05:00
626916e9a4 Merge pull request #11961 from german77/recent
yuzu: Only store games in the recently played list
2023-11-05 13:15:07 -05:00
507f360a81 yuzu: Only store games in the recently played list 2023-11-05 09:34:16 -06:00
5323d9f6b3 service: acc: Ensure proper profile size 2023-11-05 09:28:22 -06:00
770d4b0b72 Merge pull request #11965 from german77/color
core: hid: Signal color updates
2023-11-04 23:26:24 -04:00
e5fed31009 Merge pull request #11963 from Kelebek1/eol_lf
Convert src/ to LF eol
2023-11-04 23:26:09 -04:00
f07484bc64 core: hid: Signal color updates 2023-11-04 14:13:18 -06:00
78b9956a04 Skip git blame 2023-11-04 18:26:49 +00:00
90aa937593 Convert files to LF eol 2023-11-04 18:25:40 +00:00
75de0cadcf renderer_null: fix 2023-11-03 20:54:38 -04:00
28 changed files with 1023 additions and 920 deletions

5
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
# CRLF -> LF
90aa937593e53a5d5e070fb623b228578b0b225f

View File

@ -96,18 +96,7 @@ void EmulatedController::ReloadFromSettings() {
} }
controller.color_values = {}; controller.color_values = {};
controller.colors_state.fullkey = { ReloadColorsFromSettings();
.body = GetNpadColor(player.body_color_left),
.button = GetNpadColor(player.button_color_left),
};
controller.colors_state.left = {
.body = GetNpadColor(player.body_color_left),
.button = GetNpadColor(player.button_color_left),
};
controller.colors_state.right = {
.body = GetNpadColor(player.body_color_right),
.button = GetNpadColor(player.button_color_right),
};
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
@ -128,6 +117,30 @@ void EmulatedController::ReloadFromSettings() {
ReloadInput(); ReloadInput();
} }
void EmulatedController::ReloadColorsFromSettings() {
const auto player_index = NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index];
// Avoid updating colors if overridden by physical controller
if (controller.color_values[LeftIndex].body != 0 &&
controller.color_values[RightIndex].body != 0) {
return;
}
controller.colors_state.fullkey = {
.body = GetNpadColor(player.body_color_left),
.button = GetNpadColor(player.button_color_left),
};
controller.colors_state.left = {
.body = GetNpadColor(player.body_color_left),
.button = GetNpadColor(player.button_color_left),
};
controller.colors_state.right = {
.body = GetNpadColor(player.body_color_right),
.button = GetNpadColor(player.button_color_right),
};
}
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::DRight]; const auto left_joycon = button_params[Settings::NativeButton::DRight];

View File

@ -253,6 +253,9 @@ public:
/// Overrides current mapped devices with the stored configuration and reloads all input devices /// Overrides current mapped devices with the stored configuration and reloads all input devices
void ReloadFromSettings(); void ReloadFromSettings();
/// Updates current colors with the ones stored in the configuration
void ReloadColorsFromSettings();
/// Saves the current mapped configuration /// Saves the current mapped configuration
void SaveCurrentConfig(); void SaveCurrentConfig();

View File

@ -3,11 +3,13 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/fs/file.h" #include "common/fs/file.h"
#include "common/fs/path_util.h" #include "common/fs/path_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/polyfill_ranges.h" #include "common/polyfill_ranges.h"
#include "common/stb.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common/swap.h" #include "common/swap.h"
#include "core/constants.h" #include "core/constants.h"
@ -38,9 +40,36 @@ static std::filesystem::path GetImagePath(const Common::UUID& uuid) {
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
} }
static constexpr u32 SanitizeJPEGSize(std::size_t size) { static void JPGToMemory(void* context, void* data, int len) {
std::vector<u8>* jpg_image = static_cast<std::vector<u8>*>(context);
unsigned char* jpg = static_cast<unsigned char*>(data);
jpg_image->insert(jpg_image->end(), jpg, jpg + len);
}
static void SanitizeJPEGImageSize(std::vector<u8>& image) {
constexpr std::size_t max_jpeg_image_size = 0x20000; constexpr std::size_t max_jpeg_image_size = 0x20000;
return static_cast<u32>(std::min(size, max_jpeg_image_size)); constexpr int profile_dimensions = 256;
int original_width, original_height, color_channels;
const auto plain_image =
stbi_load_from_memory(image.data(), static_cast<int>(image.size()), &original_width,
&original_height, &color_channels, STBI_rgb);
// Resize image to match 256*256
if (original_width != profile_dimensions || original_height != profile_dimensions) {
// Use vector instead of array to avoid overflowing the stack
std::vector<u8> out_image(profile_dimensions * profile_dimensions * STBI_rgb);
stbir_resize_uint8_srgb(plain_image, original_width, original_height, 0, out_image.data(),
profile_dimensions, profile_dimensions, 0, STBI_rgb, 0,
STBIR_FILTER_BOX);
image.clear();
if (!stbi_write_jpg_to_func(JPGToMemory, &image, profile_dimensions, profile_dimensions,
STBI_rgb, out_image.data(), 0)) {
LOG_ERROR(Service_ACC, "Failed to resize the user provided image.");
}
}
image.resize(std::min(image.size(), max_jpeg_image_size));
} }
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> { class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
@ -339,19 +368,20 @@ protected:
LOG_WARNING(Service_ACC, LOG_WARNING(Service_ACC,
"Failed to load user provided image! Falling back to built-in backup..."); "Failed to load user provided image! Falling back to built-in backup...");
ctx.WriteBuffer(Core::Constants::ACCOUNT_BACKUP_JPEG); ctx.WriteBuffer(Core::Constants::ACCOUNT_BACKUP_JPEG);
rb.Push(SanitizeJPEGSize(Core::Constants::ACCOUNT_BACKUP_JPEG.size())); rb.Push(static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()));
return; return;
} }
const u32 size = SanitizeJPEGSize(image.GetSize()); std::vector<u8> buffer(image.GetSize());
std::vector<u8> buffer(size);
if (image.Read(buffer) != buffer.size()) { if (image.Read(buffer) != buffer.size()) {
LOG_ERROR(Service_ACC, "Failed to read all the bytes in the user provided image."); LOG_ERROR(Service_ACC, "Failed to read all the bytes in the user provided image.");
} }
SanitizeJPEGImageSize(buffer);
ctx.WriteBuffer(buffer); ctx.WriteBuffer(buffer);
rb.Push<u32>(size); rb.Push(static_cast<u32>(buffer.size()));
} }
void GetImageSize(HLERequestContext& ctx) { void GetImageSize(HLERequestContext& ctx) {
@ -365,10 +395,18 @@ protected:
if (!image.IsOpen()) { if (!image.IsOpen()) {
LOG_WARNING(Service_ACC, LOG_WARNING(Service_ACC,
"Failed to load user provided image! Falling back to built-in backup..."); "Failed to load user provided image! Falling back to built-in backup...");
rb.Push(SanitizeJPEGSize(Core::Constants::ACCOUNT_BACKUP_JPEG.size())); rb.Push(static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()));
} else { return;
rb.Push(SanitizeJPEGSize(image.GetSize()));
} }
std::vector<u8> buffer(image.GetSize());
if (image.Read(buffer) != buffer.size()) {
LOG_ERROR(Service_ACC, "Failed to read all the bytes in the user provided image.");
}
SanitizeJPEGImageSize(buffer);
rb.Push(static_cast<u32>(buffer.size()));
} }
void Store(HLERequestContext& ctx) { void Store(HLERequestContext& ctx) {

View File

@ -69,6 +69,30 @@ enum class AppletId : u32 {
MyPage = 0x1A, MyPage = 0x1A,
}; };
enum class AppletProgramId : u64 {
QLaunch = 0x0100000000001000ull,
Auth = 0x0100000000001001ull,
Cabinet = 0x0100000000001002ull,
Controller = 0x0100000000001003ull,
DataErase = 0x0100000000001004ull,
Error = 0x0100000000001005ull,
NetConnect = 0x0100000000001006ull,
ProfileSelect = 0x0100000000001007ull,
SoftwareKeyboard = 0x0100000000001008ull,
MiiEdit = 0x0100000000001009ull,
Web = 0x010000000000100Aull,
Shop = 0x010000000000100Bull,
OverlayDisplay = 0x010000000000100Cull,
PhotoViewer = 0x010000000000100Dull,
Settings = 0x010000000000100Eull,
OfflineWeb = 0x010000000000100Full,
LoginShare = 0x0100000000001010ull,
WebAuth = 0x0100000000001011ull,
Starter = 0x0100000000001012ull,
MyPage = 0x0100000000001013ull,
MaxProgramId = 0x0100000000001FFFull,
};
enum class LibraryAppletMode : u32 { enum class LibraryAppletMode : u32 {
AllForeground = 0, AllForeground = 0,
Background = 1, Background = 1,

View File

@ -3,6 +3,7 @@
#include "common/alignment.h" #include "common/alignment.h"
#include "core/memory.h" #include "core/memory.h"
#include "video_core/control/channel_state.h"
#include "video_core/host1x/host1x.h" #include "video_core/host1x/host1x.h"
#include "video_core/memory_manager.h" #include "video_core/memory_manager.h"
#include "video_core/renderer_null/null_rasterizer.h" #include "video_core/renderer_null/null_rasterizer.h"
@ -99,8 +100,14 @@ bool RasterizerNull::AccelerateDisplay(const Tegra::FramebufferConfig& config,
} }
void RasterizerNull::LoadDiskResources(u64 title_id, std::stop_token stop_loading, void RasterizerNull::LoadDiskResources(u64 title_id, std::stop_token stop_loading,
const VideoCore::DiskResourceLoadCallback& callback) {} const VideoCore::DiskResourceLoadCallback& callback) {}
void RasterizerNull::InitializeChannel(Tegra::Control::ChannelState& channel) {} void RasterizerNull::InitializeChannel(Tegra::Control::ChannelState& channel) {
void RasterizerNull::BindChannel(Tegra::Control::ChannelState& channel) {} CreateChannel(channel);
void RasterizerNull::ReleaseChannel(s32 channel_id) {} }
void RasterizerNull::BindChannel(Tegra::Control::ChannelState& channel) {
BindToChannel(channel.bind_id);
}
void RasterizerNull::ReleaseChannel(s32 channel_id) {
EraseChannel(channel_id);
}
} // namespace Null } // namespace Null

View File

@ -82,7 +82,7 @@ VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t in
} }
if (y_negate) { if (y_negate) {
y += height; y += conv(static_cast<f32>(regs.surface_clip.height));
height = -height; height = -height;
} }

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2014 Citra Emulator Project // SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -1,4 +1,4 @@
// Text : Copyright 2022 yuzu Emulator Project // Text : Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#pragma once #pragma once

View File

@ -152,7 +152,7 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged, connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged,
[this](bool is_handheld) { UpdateDockedState(is_handheld); }); [this](bool is_handheld) { UpdateDockedState(is_handheld); });
advanced = new ConfigureInputAdvanced(this); advanced = new ConfigureInputAdvanced(hid_core, this);
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced)); ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
ui->tabAdvanced->layout()->addWidget(advanced); ui->tabAdvanced->layout()->addWidget(advanced);

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -4,11 +4,13 @@
#include <QColorDialog> #include <QColorDialog>
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h" #include "core/core.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
#include "ui_configure_input_advanced.h" #include "ui_configure_input_advanced.h"
#include "yuzu/configuration/configure_input_advanced.h" #include "yuzu/configuration/configure_input_advanced.h"
ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent) ConfigureInputAdvanced::ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputAdvanced>()) { : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputAdvanced>()), hid_core{hid_core_} {
ui->setupUi(this); ui->setupUi(this);
controllers_color_buttons = {{ controllers_color_buttons = {{
@ -123,6 +125,8 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
player.button_color_left = colors[1]; player.button_color_left = colors[1];
player.body_color_right = colors[2]; player.body_color_right = colors[2];
player.button_color_right = colors[3]; player.button_color_right = colors[3];
hid_core.GetEmulatedControllerByIndex(player_idx)->ReloadColorsFromSettings();
} }
Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked();

View File

@ -14,11 +14,15 @@ namespace Ui {
class ConfigureInputAdvanced; class ConfigureInputAdvanced;
} }
namespace Core::HID {
class HIDCore;
} // namespace Core::HID
class ConfigureInputAdvanced : public QWidget { class ConfigureInputAdvanced : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigureInputAdvanced(QWidget* parent = nullptr); explicit ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent = nullptr);
~ConfigureInputAdvanced() override; ~ConfigureInputAdvanced() override;
void ApplyConfiguration(); void ApplyConfiguration();
@ -44,4 +48,6 @@ private:
std::array<std::array<QColor, 4>, 8> controllers_colors; std::array<std::array<QColor, 4>, 8> controllers_colors;
std::array<std::array<QPushButton*, 4>, 8> controllers_color_buttons; std::array<std::array<QPushButton*, 4>, 8> controllers_color_buttons;
Core::HID::HIDCore& hid_core;
}; };

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -306,10 +306,10 @@ void ConfigureProfileManager::SetUserImage() {
return; return;
} }
// Some games crash when the profile image is too big. Resize any image bigger than 256x256 // Profile image must be 256x256
QImage image(image_path); QImage image(image_path);
if (image.width() > 256 || image.height() > 256) { if (image.width() != 256 || image.height() != 256) {
image = image.scaled(256, 256, Qt::KeepAspectRatio); image = image.scaled(256, 256, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
if (!image.save(image_path)) { if (!image.save(image_path)) {
QMessageBox::warning(this, tr("Error resizing user image"), QMessageBox::warning(this, tr("Error resizing user image"),
tr("Unable to resize image")); tr("Unable to resize image"));

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once

View File

@ -1908,7 +1908,10 @@ void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) {
void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index, void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index,
StartGameType type, AmLaunchType launch_type) { StartGameType type, AmLaunchType launch_type) {
LOG_INFO(Frontend, "yuzu starting..."); LOG_INFO(Frontend, "yuzu starting...");
if (program_id > static_cast<u64>(Service::AM::Applets::AppletProgramId::MaxProgramId)) {
StoreRecentFile(filename); // Put the filename on top of the list StoreRecentFile(filename); // Put the filename on top of the list
}
// Save configurations // Save configurations
UpdateUISettings(); UpdateUISettings();
@ -4273,7 +4276,7 @@ void GMainWindow::OnToggleStatusBar() {
} }
void GMainWindow::OnAlbum() { void GMainWindow::OnAlbum() {
constexpr u64 AlbumId = 0x010000000000100Dull; constexpr u64 AlbumId = static_cast<u64>(Service::AM::Applets::AppletProgramId::PhotoViewer);
auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
if (!bis_system) { if (!bis_system) {
QMessageBox::warning(this, tr("No firmware available"), QMessageBox::warning(this, tr("No firmware available"),
@ -4296,7 +4299,7 @@ void GMainWindow::OnAlbum() {
} }
void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) { void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
constexpr u64 CabinetId = 0x0100000000001002ull; constexpr u64 CabinetId = static_cast<u64>(Service::AM::Applets::AppletProgramId::Cabinet);
auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
if (!bis_system) { if (!bis_system) {
QMessageBox::warning(this, tr("No firmware available"), QMessageBox::warning(this, tr("No firmware available"),
@ -4320,7 +4323,7 @@ void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
} }
void GMainWindow::OnMiiEdit() { void GMainWindow::OnMiiEdit() {
constexpr u64 MiiEditId = 0x0100000000001009ull; constexpr u64 MiiEditId = static_cast<u64>(Service::AM::Applets::AppletProgramId::MiiEdit);
auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
if (!bis_system) { if (!bis_system) {
QMessageBox::warning(this, tr("No firmware available"), QMessageBox::warning(this, tr("No firmware available"),