Compare commits
3 Commits
android-13
...
android-13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5d0c6a58e | ||
|
|
67bb87db29 | ||
|
|
0543726586 |
@@ -1,7 +1,7 @@
|
||||
| Pull Request | Commit | Title | Author | Merged? |
|
||||
|----|----|----|----|----|
|
||||
| [11535](https://github.com/yuzu-emu/yuzu//pull/11535) | [`50bcfa5fb`](https://github.com/yuzu-emu/yuzu//pull/11535/files) | renderer_vulkan: Introduce separate cmd buffer for uploads | [GPUCode](https://github.com/GPUCode/) | Yes |
|
||||
| [12074](https://github.com/yuzu-emu/yuzu//pull/12074) | [`20b671baa`](https://github.com/yuzu-emu/yuzu//pull/12074/files) | Implement Native Code Execution (NCE) | [GPUCode](https://github.com/GPUCode/) | Yes |
|
||||
| [12074](https://github.com/yuzu-emu/yuzu//pull/12074) | [`d0285e882`](https://github.com/yuzu-emu/yuzu//pull/12074/files) | Implement Native Code Execution (NCE) | [GPUCode](https://github.com/GPUCode/) | Yes |
|
||||
|
||||
|
||||
End of merge log. You can find the original README.md below the break.
|
||||
|
||||
5
dist/languages/.tx/config
vendored
5
dist/languages/.tx/config
vendored
@@ -6,8 +6,3 @@ file_filter = <lang>.ts
|
||||
source_file = en.ts
|
||||
source_lang = en
|
||||
type = QT
|
||||
|
||||
[o:yuzu-emulator:p:yuzu:r:yuzu-android]
|
||||
file_filter = ../../src/android/app/src/main/res/values-<lang>/strings.xml
|
||||
source_file = ../../src/android/app/src/main/res/values/strings.xml
|
||||
type = ANDROID
|
||||
|
||||
@@ -301,11 +301,6 @@ object NativeLibrary {
|
||||
*/
|
||||
external fun getPerfStats(): DoubleArray
|
||||
|
||||
/**
|
||||
* Returns the current CPU backend.
|
||||
*/
|
||||
external fun getCpuBackend(): String
|
||||
|
||||
/**
|
||||
* Notifies the core emulation that the orientation has changed.
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,7 @@ abstract class SettingsItem(
|
||||
R.string.frame_limit_slider,
|
||||
R.string.frame_limit_slider_description,
|
||||
1,
|
||||
400,
|
||||
200,
|
||||
"%"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -414,10 +414,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
perfStatsUpdater = {
|
||||
if (emulationViewModel.emulationStarted.value) {
|
||||
val perfStats = NativeLibrary.getPerfStats()
|
||||
val cpuBackend = NativeLibrary.getCpuBackend()
|
||||
if (_binding != null) {
|
||||
binding.showFpsText.text =
|
||||
String.format("FPS: %.1f\n%s", perfStats[FPS], cpuBackend)
|
||||
binding.showFpsText.text = String.format("FPS: %.1f", perfStats[FPS])
|
||||
}
|
||||
perfStatsUpdateHandler.postDelayed(perfStatsUpdater!!, 800)
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.yuzu.yuzu_emu.databinding.FragmentInstallablesBinding
|
||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
import org.yuzu.yuzu_emu.model.Installable
|
||||
import org.yuzu.yuzu_emu.ui.main.MainActivity
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class InstallableFragment : Fragment() {
|
||||
private var _binding: FragmentInstallablesBinding? = null
|
||||
@@ -80,15 +78,7 @@ class InstallableFragment : Fragment() {
|
||||
R.string.manage_save_data,
|
||||
R.string.import_export_saves_description,
|
||||
install = { mainActivity.importSaves.launch(arrayOf("application/zip")) },
|
||||
export = {
|
||||
mainActivity.exportSaves.launch(
|
||||
"yuzu saves - ${
|
||||
LocalDateTime.now().format(
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
|
||||
)
|
||||
}.zip"
|
||||
)
|
||||
}
|
||||
export = { mainActivity.exportSave() }
|
||||
)
|
||||
} else {
|
||||
Installable(
|
||||
|
||||
@@ -18,8 +18,8 @@ class Game(
|
||||
val version: String = "",
|
||||
val isHomebrew: Boolean = false
|
||||
) : Parcelable {
|
||||
val keyAddedToLibraryTime get() = "${path}_AddedToLibraryTime"
|
||||
val keyLastPlayedTime get() = "${path}_LastPlayed"
|
||||
val keyAddedToLibraryTime get() = "${programId}_AddedToLibraryTime"
|
||||
val keyLastPlayedTime get() = "${programId}_LastPlayed"
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is Game) {
|
||||
|
||||
@@ -6,6 +6,7 @@ package org.yuzu.yuzu_emu.ui.main
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.DocumentsContract
|
||||
import android.view.View
|
||||
import android.view.ViewGroup.MarginLayoutParams
|
||||
import android.view.WindowManager
|
||||
@@ -19,6 +20,7 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
@@ -39,6 +41,7 @@ import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
||||
import org.yuzu.yuzu_emu.databinding.ActivityMainBinding
|
||||
import org.yuzu.yuzu_emu.features.DocumentProvider
|
||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||
import org.yuzu.yuzu_emu.fragments.IndeterminateProgressDialogFragment
|
||||
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
||||
@@ -50,6 +53,9 @@ import org.yuzu.yuzu_emu.model.TaskViewModel
|
||||
import org.yuzu.yuzu_emu.utils.*
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
@@ -67,6 +73,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
|
||||
// Get first subfolder in saves folder (should be the user folder)
|
||||
val savesFolderRoot get() = File(savesFolder).listFiles()?.firstOrNull()?.canonicalPath ?: ""
|
||||
private var lastZipCreated: File? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
val splashScreen = installSplashScreen()
|
||||
@@ -649,31 +656,75 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
}.show(supportFragmentManager, IndeterminateProgressDialogFragment.TAG)
|
||||
}
|
||||
|
||||
/**
|
||||
* Zips the save files located in the given folder path and creates a new zip file with the current date and time.
|
||||
* @return true if the zip file is successfully created, false otherwise.
|
||||
*/
|
||||
private fun zipSave(): Boolean {
|
||||
try {
|
||||
val tempFolder = File(getPublicFilesDir().canonicalPath, "temp")
|
||||
tempFolder.mkdirs()
|
||||
val saveFolder = File(savesFolderRoot)
|
||||
val outputZipFile = File(
|
||||
tempFolder,
|
||||
"yuzu saves - ${
|
||||
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))
|
||||
}.zip"
|
||||
)
|
||||
outputZipFile.createNewFile()
|
||||
val result = FileUtil.zipFromInternalStorage(
|
||||
saveFolder,
|
||||
savesFolderRoot,
|
||||
BufferedOutputStream(FileOutputStream(outputZipFile))
|
||||
)
|
||||
if (result == TaskState.Failed) {
|
||||
return false
|
||||
}
|
||||
lastZipCreated = outputZipFile
|
||||
} catch (e: Exception) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the save file located in the given folder path by creating a zip file and sharing it via intent.
|
||||
*/
|
||||
val exportSaves = registerForActivityResult(
|
||||
ActivityResultContracts.CreateDocument("application/zip")
|
||||
) { result ->
|
||||
if (result == null) {
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
IndeterminateProgressDialogFragment.newInstance(
|
||||
this,
|
||||
R.string.save_files_exporting,
|
||||
false
|
||||
) {
|
||||
val zipResult = FileUtil.zipFromInternalStorage(
|
||||
File(savesFolderRoot),
|
||||
savesFolderRoot,
|
||||
BufferedOutputStream(contentResolver.openOutputStream(result))
|
||||
)
|
||||
return@newInstance when (zipResult) {
|
||||
TaskState.Completed -> getString(R.string.export_success)
|
||||
TaskState.Cancelled, TaskState.Failed -> getString(R.string.export_failed)
|
||||
fun exportSave() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val wasZipCreated = zipSave()
|
||||
val lastZipFile = lastZipCreated
|
||||
if (!wasZipCreated || lastZipFile == null) {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(
|
||||
this@MainActivity,
|
||||
getString(R.string.export_save_failed),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
return@launch
|
||||
}
|
||||
}.show(supportFragmentManager, IndeterminateProgressDialogFragment.TAG)
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
val file = DocumentFile.fromSingleUri(
|
||||
this@MainActivity,
|
||||
DocumentsContract.buildDocumentUri(
|
||||
DocumentProvider.AUTHORITY,
|
||||
"${DocumentProvider.ROOT_ID}/temp/${lastZipFile.name}"
|
||||
)
|
||||
)!!
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
.setDataAndType(file.uri, "application/zip")
|
||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.putExtra(Intent.EXTRA_STREAM, file.uri)
|
||||
startForResultExportSave.launch(
|
||||
Intent.createChooser(
|
||||
intent,
|
||||
getString(R.string.share_save_file)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val startForResultExportSave =
|
||||
|
||||
@@ -707,14 +707,6 @@ jdoubleArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPerfStats(JNIEnv* env, jcl
|
||||
return j_stats;
|
||||
}
|
||||
|
||||
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCpuBackend(JNIEnv* env, jclass clazz) {
|
||||
if (Settings::IsNceEnabled()) {
|
||||
return ToJString(env, "NCE");
|
||||
}
|
||||
|
||||
return ToJString(env, "JIT");
|
||||
}
|
||||
|
||||
void Java_org_yuzu_yuzu_1emu_utils_DirectoryInitialization_setSysDirectory(JNIEnv* env,
|
||||
jclass clazz,
|
||||
jstring j_path) {}
|
||||
|
||||
@@ -127,7 +127,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:paddingVertical="4dp"
|
||||
app:checkedChip="@id/chip_recently_played"
|
||||
app:chipSpacingHorizontal="12dp"
|
||||
app:singleLine="true"
|
||||
app:singleSelection="true">
|
||||
|
||||
@@ -91,7 +91,6 @@
|
||||
<string name="manage_save_data">Manage save data</string>
|
||||
<string name="manage_save_data_description">Save data found. Please select an option below.</string>
|
||||
<string name="import_export_saves_description">Import or export save files</string>
|
||||
<string name="save_files_exporting">Exporting save files…</string>
|
||||
<string name="save_file_imported_success">Imported successfully</string>
|
||||
<string name="save_file_invalid_zip_structure">Invalid save directory structure</string>
|
||||
<string name="save_file_invalid_zip_structure_description">The first subfolder name must be the title ID of the game.</string>
|
||||
@@ -258,7 +257,6 @@
|
||||
<string name="cancelling">Cancelling</string>
|
||||
<string name="install">Install</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="export_success">Exported successfully</string>
|
||||
|
||||
<!-- GPU driver installation -->
|
||||
<string name="select_gpu_driver">Select GPU driver</string>
|
||||
|
||||
@@ -160,7 +160,7 @@ static bool is_nce_enabled = false;
|
||||
|
||||
void SetNceEnabled(bool is_39bit) {
|
||||
const bool is_nce_selected = values.cpu_backend.GetValue() == CpuBackend::Nce;
|
||||
is_nce_enabled = IsFastmemEnabled() && is_nce_selected && is_39bit;
|
||||
is_nce_enabled = is_nce_selected && is_39bit;
|
||||
if (is_nce_selected && !is_nce_enabled) {
|
||||
LOG_WARNING(
|
||||
Common,
|
||||
|
||||
@@ -921,8 +921,7 @@ if (ENABLE_WEB_SERVICE)
|
||||
target_link_libraries(core PRIVATE web_service)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_arm64 AND (ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"))
|
||||
target_compile_definitions(core PRIVATE -DHAS_NCE)
|
||||
if (ARCHITECTURE_arm64)
|
||||
enable_language(C ASM)
|
||||
set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
|
||||
|
||||
|
||||
@@ -201,8 +201,6 @@ void ARM_Interface::Run() {
|
||||
if (True(hr & HaltReason::DataAbort)) {
|
||||
if (system.DebuggerEnabled()) {
|
||||
system.GetDebugger().NotifyThreadWatchpoint(current_thread, *HaltedWatchpoint());
|
||||
} else {
|
||||
LogBacktrace();
|
||||
}
|
||||
current_thread->RequestSuspend(SuspendType::Debug);
|
||||
break;
|
||||
|
||||
@@ -116,18 +116,10 @@ bool ARM_NCE::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* ra
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can't handle the access, so determine why we crashed.
|
||||
// We can't handle the access, so trigger an exception.
|
||||
const bool is_prefetch_abort = host_ctx.pc == reinterpret_cast<u64>(info->si_addr);
|
||||
|
||||
// For data aborts, skip the instruction and return to guest code.
|
||||
// This will allow games to continue in many scenarios where they would otherwise crash.
|
||||
if (!is_prefetch_abort) {
|
||||
host_ctx.pc += 4;
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is a prefetch abort.
|
||||
guest_ctx->esr_el1.fetch_or(static_cast<u64>(HaltReason::PrefetchAbort));
|
||||
guest_ctx->esr_el1.fetch_or(
|
||||
static_cast<u64>(is_prefetch_abort ? HaltReason::PrefetchAbort : HaltReason::DataAbort));
|
||||
|
||||
// Forcibly mark the context as locked. We are still running.
|
||||
// We may race with SignalInterrupt here:
|
||||
|
||||
@@ -20,7 +20,6 @@ using namespace oaknut::util;
|
||||
using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters;
|
||||
|
||||
constexpr size_t MaxRelativeBranch = 128_MiB;
|
||||
constexpr u32 ModuleCodeIndex = 0x24 / sizeof(u32);
|
||||
|
||||
Patcher::Patcher() : c(m_patch_instructions) {}
|
||||
|
||||
@@ -43,7 +42,7 @@ void Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
std::span<const u32>{reinterpret_cast<const u32*>(text.data()), text.size() / sizeof(u32)};
|
||||
|
||||
// Loop through instructions, patching as needed.
|
||||
for (u32 i = ModuleCodeIndex; i < static_cast<u32>(text_words.size()); i++) {
|
||||
for (u32 i = 0; i < static_cast<u32>(text_words.size()); i++) {
|
||||
const u32 inst = text_words[i];
|
||||
|
||||
const auto AddRelocations = [&] {
|
||||
@@ -162,8 +161,8 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
}
|
||||
|
||||
// Cortex-A57 seems to treat all exclusives as ordered, but newer processors do not.
|
||||
// Convert to ordered to preserve this assumption.
|
||||
for (u32 i = ModuleCodeIndex; i < static_cast<u32>(text_words.size()); i++) {
|
||||
// Convert to ordered to preserve this assumption
|
||||
for (u32 i = 0; i < static_cast<u32>(text_words.size()); i++) {
|
||||
const u32 inst = text_words[i];
|
||||
if (auto exclusive = Exclusive{inst}; exclusive.Verify()) {
|
||||
text_words[i] = exclusive.AsOrdered();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
constexpr size_t VirtualReserveSize = 1ULL << 38;
|
||||
#else
|
||||
constexpr size_t VirtualReserveSize = 1ULL << 39;
|
||||
|
||||
@@ -218,13 +218,6 @@ enum class NpadIdType : u32 {
|
||||
Invalid = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
enum class NpadInterfaceType : u8 {
|
||||
Bluetooth = 1,
|
||||
Rail = 2,
|
||||
Usb = 3,
|
||||
Embedded = 4,
|
||||
};
|
||||
|
||||
// This is nn::hid::NpadStyleIndex
|
||||
enum class NpadStyleIndex : u8 {
|
||||
None = 0,
|
||||
|
||||
@@ -75,7 +75,6 @@ struct CodeSet final {
|
||||
return segments[2];
|
||||
}
|
||||
|
||||
#ifdef HAS_NCE
|
||||
Segment& PatchSegment() {
|
||||
return patch_segment;
|
||||
}
|
||||
@@ -83,17 +82,13 @@ struct CodeSet final {
|
||||
const Segment& PatchSegment() const {
|
||||
return patch_segment;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// The overall data that backs this code set.
|
||||
Kernel::PhysicalMemory memory;
|
||||
|
||||
/// The segments that comprise this code set.
|
||||
std::array<Segment, 3> segments;
|
||||
|
||||
#ifdef HAS_NCE
|
||||
Segment patch_segment;
|
||||
#endif
|
||||
|
||||
/// The entry point address for this code set.
|
||||
KProcessAddress entrypoint = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@ constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{
|
||||
{ .bit_width = 36, .address = 2_GiB , .size = 64_GiB - 2_GiB , .type = KAddressSpaceInfo::Type::MapLarge, },
|
||||
{ .bit_width = 36, .address = Size_Invalid, .size = 8_GiB , .type = KAddressSpaceInfo::Type::Heap, },
|
||||
{ .bit_width = 36, .address = Size_Invalid, .size = 6_GiB , .type = KAddressSpaceInfo::Type::Alias, },
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
// With NCE, we use a 38-bit address space due to memory limitations. This should (safely) truncate ASLR region.
|
||||
{ .bit_width = 39, .address = 128_MiB , .size = 256_GiB - 128_MiB, .type = KAddressSpaceInfo::Type::Map39Bit, },
|
||||
#else
|
||||
|
||||
@@ -96,7 +96,7 @@ constexpr Common::MemoryPermission ConvertToMemoryPermission(KMemoryPermission p
|
||||
if (True(perm & KMemoryPermission::UserWrite)) {
|
||||
perms |= Common::MemoryPermission::Write;
|
||||
}
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
if (True(perm & KMemoryPermission::UserExecute)) {
|
||||
perms |= Common::MemoryPermission::Execute;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ private:
|
||||
std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_pinned_threads{};
|
||||
std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS> m_watchpoints{};
|
||||
std::map<KProcessAddress, u64> m_debug_page_refcounts{};
|
||||
std::unordered_map<u64, u64> m_post_handlers{};
|
||||
std::atomic<s64> m_cpu_time{};
|
||||
std::atomic<s64> m_num_process_switches{};
|
||||
std::atomic<s64> m_num_thread_switches{};
|
||||
@@ -120,9 +121,6 @@ private:
|
||||
std::atomic<s64> m_num_ipc_messages{};
|
||||
std::atomic<s64> m_num_ipc_replies{};
|
||||
std::atomic<s64> m_num_ipc_receives{};
|
||||
#ifdef HAS_NCE
|
||||
std::unordered_map<u64, u64> m_post_handlers{};
|
||||
#endif
|
||||
|
||||
private:
|
||||
Result StartTermination();
|
||||
@@ -470,11 +468,9 @@ public:
|
||||
|
||||
static void Switch(KProcess* cur_process, KProcess* next_process);
|
||||
|
||||
#ifdef HAS_NCE
|
||||
std::unordered_map<u64, u64>& GetPostHandlers() noexcept {
|
||||
return m_post_handlers;
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Attempts to insert a watchpoint into a free slot. Returns false if none are available.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/settings.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_32.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_64.h"
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
#include "core/arm/nce/arm_nce.h"
|
||||
#endif
|
||||
#include "core/core.h"
|
||||
@@ -33,7 +33,7 @@ PhysicalCore::PhysicalCore(std::size_t core_index, Core::System& system, KSchedu
|
||||
PhysicalCore::~PhysicalCore() = default;
|
||||
|
||||
void PhysicalCore::Initialize(bool is_64_bit) {
|
||||
#if defined(HAS_NCE)
|
||||
#if defined(ARCHITECTURE_arm64)
|
||||
if (Settings::IsNceEnabled()) {
|
||||
m_arm_interface = std::make_unique<Core::ARM_NCE>(m_system, m_system.Kernel().IsMulticore(),
|
||||
m_core_index);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/file_sys/savedata_factory.h"
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/kernel/k_transfer_memory.h"
|
||||
#include "core/hle/result.h"
|
||||
@@ -22,7 +21,6 @@
|
||||
#include "core/hle/service/am/applet_ae.h"
|
||||
#include "core/hle/service/am/applet_oe.h"
|
||||
#include "core/hle/service/am/applets/applet_cabinet.h"
|
||||
#include "core/hle/service/am/applets/applet_controller.h"
|
||||
#include "core/hle/service/am/applets/applet_mii_edit_types.h"
|
||||
#include "core/hle/service/am/applets/applet_profile_select.h"
|
||||
#include "core/hle/service/am/applets/applet_software_keyboard_types.h"
|
||||
@@ -37,7 +35,6 @@
|
||||
#include "core/hle/service/caps/caps_su.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/ns/ns.h"
|
||||
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
|
||||
@@ -76,7 +73,7 @@ IWindowController::IWindowController(Core::System& system_)
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "CreateWindow"},
|
||||
{1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
|
||||
{2, &IWindowController::GetAppletResourceUserIdOfCallerApplet, "GetAppletResourceUserIdOfCallerApplet"},
|
||||
{2, nullptr, "GetAppletResourceUserIdOfCallerApplet"},
|
||||
{10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
|
||||
{11, nullptr, "ReleaseForegroundRights"},
|
||||
{12, nullptr, "RejectToChangeIntoBackground"},
|
||||
@@ -100,16 +97,6 @@ void IWindowController::GetAppletResourceUserId(HLERequestContext& ctx) {
|
||||
rb.Push<u64>(process_id);
|
||||
}
|
||||
|
||||
void IWindowController::GetAppletResourceUserIdOfCallerApplet(HLERequestContext& ctx) {
|
||||
const u64 process_id = 0;
|
||||
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u64>(process_id);
|
||||
}
|
||||
|
||||
void IWindowController::AcquireForegroundRights(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -1578,7 +1565,7 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_)
|
||||
{6, nullptr, "GetPopInteractiveInDataEvent"},
|
||||
{10, &ILibraryAppletSelfAccessor::ExitProcessAndReturn, "ExitProcessAndReturn"},
|
||||
{11, &ILibraryAppletSelfAccessor::GetLibraryAppletInfo, "GetLibraryAppletInfo"},
|
||||
{12, &ILibraryAppletSelfAccessor::GetMainAppletIdentityInfo, "GetMainAppletIdentityInfo"},
|
||||
{12, nullptr, "GetMainAppletIdentityInfo"},
|
||||
{13, nullptr, "CanUseApplicationCore"},
|
||||
{14, &ILibraryAppletSelfAccessor::GetCallerAppletIdentityInfo, "GetCallerAppletIdentityInfo"},
|
||||
{15, nullptr, "GetMainAppletApplicationControlProperty"},
|
||||
@@ -1622,9 +1609,6 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_)
|
||||
case Applets::AppletId::SoftwareKeyboard:
|
||||
PushInShowSoftwareKeyboard();
|
||||
break;
|
||||
case Applets::AppletId::Controller:
|
||||
PushInShowController();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1682,33 +1666,13 @@ void ILibraryAppletSelfAccessor::GetLibraryAppletInfo(HLERequestContext& ctx) {
|
||||
rb.PushRaw(applet_info);
|
||||
}
|
||||
|
||||
void ILibraryAppletSelfAccessor::GetMainAppletIdentityInfo(HLERequestContext& ctx) {
|
||||
struct AppletIdentityInfo {
|
||||
Applets::AppletId applet_id;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
u64 application_id;
|
||||
};
|
||||
static_assert(sizeof(AppletIdentityInfo) == 0x10, "AppletIdentityInfo has incorrect size.");
|
||||
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
|
||||
const AppletIdentityInfo applet_info{
|
||||
.applet_id = Applets::AppletId::QLaunch,
|
||||
.application_id = 0x0100000000001000ull,
|
||||
};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(applet_info);
|
||||
}
|
||||
|
||||
void ILibraryAppletSelfAccessor::GetCallerAppletIdentityInfo(HLERequestContext& ctx) {
|
||||
struct AppletIdentityInfo {
|
||||
Applets::AppletId applet_id;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
u64 application_id;
|
||||
};
|
||||
static_assert(sizeof(AppletIdentityInfo) == 0x10, "AppletIdentityInfo has incorrect size.");
|
||||
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
|
||||
const AppletIdentityInfo applet_info{
|
||||
@@ -1773,55 +1737,6 @@ void ILibraryAppletSelfAccessor::PushInShowAlbum() {
|
||||
queue_data.emplace_back(std::move(settings_data));
|
||||
}
|
||||
|
||||
void ILibraryAppletSelfAccessor::PushInShowController() {
|
||||
const Applets::CommonArguments common_args = {
|
||||
.arguments_version = Applets::CommonArgumentVersion::Version3,
|
||||
.size = Applets::CommonArgumentSize::Version3,
|
||||
.library_version = static_cast<u32>(Applets::ControllerAppletVersion::Version8),
|
||||
.theme_color = Applets::ThemeColor::BasicBlack,
|
||||
.play_startup_sound = true,
|
||||
.system_tick = system.CoreTiming().GetClockTicks(),
|
||||
};
|
||||
|
||||
Applets::ControllerSupportArgNew user_args = {
|
||||
.header = {.player_count_min = 1,
|
||||
.player_count_max = 4,
|
||||
.enable_take_over_connection = true,
|
||||
.enable_left_justify = false,
|
||||
.enable_permit_joy_dual = true,
|
||||
.enable_single_mode = false,
|
||||
.enable_identification_color = false},
|
||||
.identification_colors = {},
|
||||
.enable_explain_text = false,
|
||||
.explain_text = {},
|
||||
};
|
||||
|
||||
Applets::ControllerSupportArgPrivate private_args = {
|
||||
.arg_private_size = sizeof(Applets::ControllerSupportArgPrivate),
|
||||
.arg_size = sizeof(Applets::ControllerSupportArgNew),
|
||||
.is_home_menu = true,
|
||||
.flag_1 = true,
|
||||
.mode = Applets::ControllerSupportMode::ShowControllerSupport,
|
||||
.caller = Applets::ControllerSupportCaller::
|
||||
Application, // switchbrew: Always zero except with
|
||||
// ShowControllerFirmwareUpdateForSystem/ShowControllerKeyRemappingForSystem,
|
||||
// which sets this to the input param
|
||||
.style_set = Core::HID::NpadStyleSet::None,
|
||||
.joy_hold_type = 0,
|
||||
};
|
||||
std::vector<u8> common_args_data(sizeof(common_args));
|
||||
std::vector<u8> private_args_data(sizeof(private_args));
|
||||
std::vector<u8> user_args_data(sizeof(user_args));
|
||||
|
||||
std::memcpy(common_args_data.data(), &common_args, sizeof(common_args));
|
||||
std::memcpy(private_args_data.data(), &private_args, sizeof(private_args));
|
||||
std::memcpy(user_args_data.data(), &user_args, sizeof(user_args));
|
||||
|
||||
queue_data.emplace_back(std::move(common_args_data));
|
||||
queue_data.emplace_back(std::move(private_args_data));
|
||||
queue_data.emplace_back(std::move(user_args_data));
|
||||
}
|
||||
|
||||
void ILibraryAppletSelfAccessor::PushInShowCabinetData() {
|
||||
const Applets::CommonArguments arguments{
|
||||
.arguments_version = Applets::CommonArgumentVersion::Version3,
|
||||
|
||||
@@ -87,7 +87,6 @@ public:
|
||||
|
||||
private:
|
||||
void GetAppletResourceUserId(HLERequestContext& ctx);
|
||||
void GetAppletResourceUserIdOfCallerApplet(HLERequestContext& ctx);
|
||||
void AcquireForegroundRights(HLERequestContext& ctx);
|
||||
};
|
||||
|
||||
@@ -346,7 +345,6 @@ private:
|
||||
void PopInData(HLERequestContext& ctx);
|
||||
void PushOutData(HLERequestContext& ctx);
|
||||
void GetLibraryAppletInfo(HLERequestContext& ctx);
|
||||
void GetMainAppletIdentityInfo(HLERequestContext& ctx);
|
||||
void ExitProcessAndReturn(HLERequestContext& ctx);
|
||||
void GetCallerAppletIdentityInfo(HLERequestContext& ctx);
|
||||
void GetDesirableKeyboardLayout(HLERequestContext& ctx);
|
||||
@@ -357,7 +355,6 @@ private:
|
||||
void PushInShowCabinetData();
|
||||
void PushInShowMiiEditData();
|
||||
void PushInShowSoftwareKeyboard();
|
||||
void PushInShowController();
|
||||
|
||||
std::deque<std::vector<u8>> queue_data;
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ enum class ControllerSupportResult : u32 {
|
||||
struct ControllerSupportArgPrivate {
|
||||
u32 arg_private_size{};
|
||||
u32 arg_size{};
|
||||
bool is_home_menu{};
|
||||
bool flag_0{};
|
||||
bool flag_1{};
|
||||
ControllerSupportMode mode{};
|
||||
ControllerSupportCaller caller{};
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
|
||||
private:
|
||||
void GetCore(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "called");
|
||||
LOG_DEBUG(Service_BTM, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -263,13 +263,13 @@ public:
|
||||
explicit IBtmSystemCore(Core::System& system_) : ServiceFramework{system_, "IBtmSystemCore"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IBtmSystemCore::StartGamepadPairing, "StartGamepadPairing"},
|
||||
{1, &IBtmSystemCore::CancelGamepadPairing, "CancelGamepadPairing"},
|
||||
{0, nullptr, "StartGamepadPairing"},
|
||||
{1, nullptr, "CancelGamepadPairing"},
|
||||
{2, nullptr, "ClearGamepadPairingDatabase"},
|
||||
{3, nullptr, "GetPairedGamepadCount"},
|
||||
{4, nullptr, "EnableRadio"},
|
||||
{5, nullptr, "DisableRadio"},
|
||||
{6, &IBtmSystemCore::IsRadioEnabled, "IsRadioEnabled"},
|
||||
{6, nullptr, "GetRadioOnOff"},
|
||||
{7, nullptr, "AcquireRadioEvent"},
|
||||
{8, nullptr, "AcquireGamepadPairingEvent"},
|
||||
{9, nullptr, "IsGamepadPairingStarted"},
|
||||
@@ -280,58 +280,18 @@ public:
|
||||
{14, nullptr, "AcquireAudioDeviceConnectionEvent"},
|
||||
{15, nullptr, "ConnectAudioDevice"},
|
||||
{16, nullptr, "IsConnectingAudioDevice"},
|
||||
{17, &IBtmSystemCore::GetConnectedAudioDevices, "GetConnectedAudioDevices"},
|
||||
{17, nullptr, "GetConnectedAudioDevices"},
|
||||
{18, nullptr, "DisconnectAudioDevice"},
|
||||
{19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"},
|
||||
{20, nullptr, "GetPairedAudioDevices"},
|
||||
{21, nullptr, "RemoveAudioDevicePairing"},
|
||||
{22, &IBtmSystemCore::RequestAudioDeviceConnectionRejection, "RequestAudioDeviceConnectionRejection"},
|
||||
{23, &IBtmSystemCore::CancelAudioDeviceConnectionRejection, "CancelAudioDeviceConnectionRejection"}
|
||||
{22, nullptr, "RequestAudioDeviceConnectionRejection"},
|
||||
{23, nullptr, "CancelAudioDeviceConnectionRejection"}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void IsRadioEnabled(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(true);
|
||||
}
|
||||
|
||||
void StartGamepadPairing(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void CancelGamepadPairing(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void CancelAudioDeviceConnectionRejection(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void GetConnectedAudioDevices(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u32>(0);
|
||||
}
|
||||
|
||||
void RequestAudioDeviceConnectionRejection(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
class BTM_SYS final : public ServiceFramework<BTM_SYS> {
|
||||
@@ -348,7 +308,7 @@ public:
|
||||
|
||||
private:
|
||||
void GetCore(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_BTM, "called");
|
||||
LOG_DEBUG(Service_BTM, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
{10200, nullptr, "SendFriendRequestForApplication"},
|
||||
{10211, nullptr, "AddFacedFriendRequestForApplication"},
|
||||
{10400, &IFriendService::GetBlockedUserListIds, "GetBlockedUserListIds"},
|
||||
{10420, &IFriendService::CheckBlockedUserListAvailability, "CheckBlockedUserListAvailability"},
|
||||
{10420, nullptr, "IsBlockedUserListCacheAvailable"},
|
||||
{10421, nullptr, "EnsureBlockedUserListAvailable"},
|
||||
{10500, nullptr, "GetProfileList"},
|
||||
{10600, nullptr, "DeclareOpenOnlinePlaySession"},
|
||||
@@ -206,17 +206,6 @@ private:
|
||||
rb.Push(true);
|
||||
}
|
||||
|
||||
void CheckBlockedUserListAvailability(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto uuid{rp.PopRaw<Common::UUID>()};
|
||||
|
||||
LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(true);
|
||||
}
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
|
||||
Kernel::KEvent* completion_event;
|
||||
|
||||
@@ -344,7 +344,6 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
controller.device->SetPollingMode(Core::HID::EmulatedDeviceIndex::AllDevices,
|
||||
Common::Input::PollingMode::Active);
|
||||
}
|
||||
|
||||
SignalStyleSetChangedEvent(npad_id);
|
||||
WriteEmptyEntry(controller.shared_memory);
|
||||
hid_core.SetLastActiveController(npad_id);
|
||||
@@ -1727,19 +1726,4 @@ const Controller_NPad::SixaxisParameters& Controller_NPad::GetSixaxisState(
|
||||
}
|
||||
}
|
||||
|
||||
Controller_NPad::AppletDetailedUiType Controller_NPad::GetAppletDetailedUiType(
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
|
||||
auto controller = GetControllerFromNpadIdType(npad_id);
|
||||
auto shared_memory = controller.shared_memory;
|
||||
Service::HID::Controller_NPad::AppletFooterUiType applet_footer_type =
|
||||
shared_memory->applet_footer_type;
|
||||
|
||||
Controller_NPad::AppletDetailedUiType detailed_ui_type{
|
||||
.ui_variant = 0,
|
||||
.footer = applet_footer_type,
|
||||
};
|
||||
return detailed_ui_type;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -78,46 +78,6 @@ public:
|
||||
MaxActivationMode = 3,
|
||||
};
|
||||
|
||||
// This is nn::hid::system::AppletFooterUiAttributesSet
|
||||
struct AppletFooterUiAttributes {
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
};
|
||||
|
||||
// This is nn::hid::system::AppletFooterUiType
|
||||
enum class AppletFooterUiType : u8 {
|
||||
None = 0,
|
||||
HandheldNone = 1,
|
||||
HandheldJoyConLeftOnly = 2,
|
||||
HandheldJoyConRightOnly = 3,
|
||||
HandheldJoyConLeftJoyConRight = 4,
|
||||
JoyDual = 5,
|
||||
JoyDualLeftOnly = 6,
|
||||
JoyDualRightOnly = 7,
|
||||
JoyLeftHorizontal = 8,
|
||||
JoyLeftVertical = 9,
|
||||
JoyRightHorizontal = 10,
|
||||
JoyRightVertical = 11,
|
||||
SwitchProController = 12,
|
||||
CompatibleProController = 13,
|
||||
CompatibleJoyCon = 14,
|
||||
LarkHvc1 = 15,
|
||||
LarkHvc2 = 16,
|
||||
LarkNesLeft = 17,
|
||||
LarkNesRight = 18,
|
||||
Lucia = 19,
|
||||
Verification = 20,
|
||||
Lagon = 21,
|
||||
};
|
||||
|
||||
using AppletFooterUiVariant = u8;
|
||||
|
||||
// This is "nn::hid::system::AppletDetailedUiType".
|
||||
struct AppletDetailedUiType {
|
||||
AppletFooterUiVariant ui_variant;
|
||||
INSERT_PADDING_BYTES(0x2);
|
||||
AppletFooterUiType footer;
|
||||
};
|
||||
static_assert(sizeof(AppletDetailedUiType) == 0x4, "AppletDetailedUiType is an invalid size");
|
||||
// This is nn::hid::NpadCommunicationMode
|
||||
enum class NpadCommunicationMode : u64 {
|
||||
Mode_5ms = 0,
|
||||
@@ -243,7 +203,6 @@ public:
|
||||
static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
|
||||
static Result VerifyValidSixAxisSensorHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id);
|
||||
|
||||
private:
|
||||
static constexpr std::size_t NPAD_COUNT = 10;
|
||||
@@ -401,6 +360,37 @@ private:
|
||||
static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18,
|
||||
"NfcXcdDeviceHandleStateImpl is an invalid size");
|
||||
|
||||
// This is nn::hid::system::AppletFooterUiAttributesSet
|
||||
struct AppletFooterUiAttributes {
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
};
|
||||
|
||||
// This is nn::hid::system::AppletFooterUiType
|
||||
enum class AppletFooterUiType : u8 {
|
||||
None = 0,
|
||||
HandheldNone = 1,
|
||||
HandheldJoyConLeftOnly = 2,
|
||||
HandheldJoyConRightOnly = 3,
|
||||
HandheldJoyConLeftJoyConRight = 4,
|
||||
JoyDual = 5,
|
||||
JoyDualLeftOnly = 6,
|
||||
JoyDualRightOnly = 7,
|
||||
JoyLeftHorizontal = 8,
|
||||
JoyLeftVertical = 9,
|
||||
JoyRightHorizontal = 10,
|
||||
JoyRightVertical = 11,
|
||||
SwitchProController = 12,
|
||||
CompatibleProController = 13,
|
||||
CompatibleJoyCon = 14,
|
||||
LarkHvc1 = 15,
|
||||
LarkHvc2 = 16,
|
||||
LarkNesLeft = 17,
|
||||
LarkNesRight = 18,
|
||||
Lucia = 19,
|
||||
Verification = 20,
|
||||
Lagon = 21,
|
||||
};
|
||||
|
||||
// This is nn::hid::NpadLarkType
|
||||
enum class NpadLarkType : u32 {
|
||||
Invalid,
|
||||
|
||||
@@ -1222,8 +1222,8 @@ void IHidServer::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) {
|
||||
controller.SetNpadMode(new_npad_id, parameters.npad_id, {},
|
||||
Controller_NPad::NpadJoyAssignmentMode::Dual);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
|
||||
parameters.applet_resource_user_id); // Spams a lot when controller applet is open
|
||||
LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -1563,7 +1563,7 @@ void IHidServer::CreateActiveVibrationDeviceList(HLERequestContext& ctx) {
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IActiveVibrationDeviceList>(system, GetResourceManager());
|
||||
rb.PushIpcInterface<IActiveVibrationDeviceList>(system, resource_manager);
|
||||
}
|
||||
|
||||
void IHidServer::PermitVibration(HLERequestContext& ctx) {
|
||||
|
||||
@@ -36,24 +36,24 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{233, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{301, nullptr, "ActivateNpadSystem"},
|
||||
{303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
|
||||
{304, &IHidSystemServer::EnableAssigningSingleOnSlSrPress, "EnableAssigningSingleOnSlSrPress"},
|
||||
{305, &IHidSystemServer::DisableAssigningSingleOnSlSrPress, "DisableAssigningSingleOnSlSrPress"},
|
||||
{304, nullptr, "EnableAssigningSingleOnSlSrPress"},
|
||||
{305, nullptr, "DisableAssigningSingleOnSlSrPress"},
|
||||
{306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"},
|
||||
{307, nullptr, "GetNpadSystemExtStyle"},
|
||||
{308, &IHidSystemServer::ApplyNpadSystemCommonPolicyFull, "ApplyNpadSystemCommonPolicyFull"},
|
||||
{309, &IHidSystemServer::GetNpadFullKeyGripColor, "GetNpadFullKeyGripColor"},
|
||||
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
|
||||
{308, nullptr, "ApplyNpadSystemCommonPolicyFull"},
|
||||
{309, nullptr, "GetNpadFullKeyGripColor"},
|
||||
{310, nullptr, "GetMaskedSupportedNpadStyleSet"},
|
||||
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
|
||||
{312, &IHidSystemServer::SetSupportedNpadStyleSetAll, "SetSupportedNpadStyleSetAll"},
|
||||
{312, nullptr, "SetSupportedNpadStyleSetAll"},
|
||||
{313, nullptr, "GetNpadCaptureButtonAssignment"},
|
||||
{314, nullptr, "GetAppletFooterUiType"},
|
||||
{315, &IHidSystemServer::GetAppletDetailedUiType, "GetAppletDetailedUiType"},
|
||||
{316, &IHidSystemServer::GetNpadInterfaceType, "GetNpadInterfaceType"},
|
||||
{317, &IHidSystemServer::GetNpadLeftRightInterfaceType, "GetNpadLeftRightInterfaceType"},
|
||||
{318, &IHidSystemServer::HasBattery, "HasBattery"},
|
||||
{319, &IHidSystemServer::HasLeftRightBattery, "HasLeftRightBattery"},
|
||||
{315, nullptr, "GetAppletDetailedUiType"},
|
||||
{316, nullptr, "GetNpadInterfaceType"},
|
||||
{317, nullptr, "GetNpadLeftRightInterfaceType"},
|
||||
{318, nullptr, "HasBattery"},
|
||||
{319, nullptr, "HasLeftRightBattery"},
|
||||
{321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
|
||||
{322, &IHidSystemServer::GetIrSensorState, "GetIrSensorState"},
|
||||
{322, nullptr, "GetIrSensorState"},
|
||||
{323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{324, nullptr, "GetUniquePadButtonSet"},
|
||||
{325, nullptr, "GetUniquePadColor"},
|
||||
@@ -85,15 +85,15 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{541, nullptr, "GetPlayReportControllerUsages"},
|
||||
{542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"},
|
||||
{543, nullptr, "GetRegisteredDevicesOld"},
|
||||
{544, &IHidSystemServer::AcquireConnectionTriggerTimeoutEvent, "AcquireConnectionTriggerTimeoutEvent"},
|
||||
{544, nullptr, "AcquireConnectionTriggerTimeoutEvent"},
|
||||
{545, nullptr, "SendConnectionTrigger"},
|
||||
{546, &IHidSystemServer::AcquireDeviceRegisteredEventForControllerSupport, "AcquireDeviceRegisteredEventForControllerSupport"},
|
||||
{546, nullptr, "AcquireDeviceRegisteredEventForControllerSupport"},
|
||||
{547, nullptr, "GetAllowedBluetoothLinksCount"},
|
||||
{548, &IHidSystemServer::GetRegisteredDevices, "GetRegisteredDevices"},
|
||||
{548, nullptr, "GetRegisteredDevices"},
|
||||
{549, nullptr, "GetConnectableRegisteredDevices"},
|
||||
{700, nullptr, "ActivateUniquePad"},
|
||||
{702, &IHidSystemServer::AcquireUniquePadConnectionEventHandle, "AcquireUniquePadConnectionEventHandle"},
|
||||
{703, &IHidSystemServer::GetUniquePadIds, "GetUniquePadIds"},
|
||||
{702, nullptr, "AcquireUniquePadConnectionEventHandle"},
|
||||
{703, nullptr, "GetUniquePadIds"},
|
||||
{751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"},
|
||||
{800, nullptr, "ListSixAxisSensorHandles"},
|
||||
{801, nullptr, "IsSixAxisSensorUserCalibrationSupported"},
|
||||
@@ -123,10 +123,10 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
|
||||
{851, nullptr, "EnableUsbFullKeyController"},
|
||||
{852, nullptr, "IsUsbConnected"},
|
||||
{870, &IHidSystemServer::IsHandheldButtonPressedOnConsoleMode, "IsHandheldButtonPressedOnConsoleMode"},
|
||||
{870, nullptr, "IsHandheldButtonPressedOnConsoleMode"},
|
||||
{900, nullptr, "ActivateInputDetector"},
|
||||
{901, nullptr, "NotifyInputDetector"},
|
||||
{1000, &IHidSystemServer::InitializeFirmwareUpdate, "InitializeFirmwareUpdate"},
|
||||
{1000, nullptr, "InitializeFirmwareUpdate"},
|
||||
{1001, nullptr, "GetFirmwareVersion"},
|
||||
{1002, nullptr, "GetAvailableFirmwareVersion"},
|
||||
{1003, nullptr, "IsFirmwareUpdateAvailable"},
|
||||
@@ -149,7 +149,6 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{1132, nullptr, "CheckUsbFirmwareUpdateRequired"},
|
||||
{1133, nullptr, "StartUsbFirmwareUpdate"},
|
||||
{1134, nullptr, "GetUsbFirmwareUpdateState"},
|
||||
{1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
|
||||
{1150, nullptr, "SetTouchScreenMagnification"},
|
||||
{1151, nullptr, "GetTouchScreenFirmwareVersion"},
|
||||
{1152, nullptr, "SetTouchScreenDefaultConfiguration"},
|
||||
@@ -221,20 +220,11 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
joy_detach_event = service_context.CreateEvent("IHidSystemServer::JoyDetachEvent");
|
||||
acquire_device_registered_event =
|
||||
service_context.CreateEvent("IHidSystemServer::AcquireDeviceRegisteredEvent");
|
||||
acquire_connection_trigger_timeout_event =
|
||||
service_context.CreateEvent("IHidSystemServer::AcquireConnectionTriggerTimeoutEvent");
|
||||
unique_pad_connection_event =
|
||||
service_context.CreateEvent("IHidSystemServer::AcquireUniquePadConnectionEventHandle");
|
||||
joy_detach_event = service_context.CreateEvent("HidSys::JoyDetachEvent");
|
||||
}
|
||||
|
||||
IHidSystemServer::~IHidSystemServer() {
|
||||
service_context.CloseEvent(joy_detach_event);
|
||||
service_context.CloseEvent(acquire_device_registered_event);
|
||||
service_context.CloseEvent(acquire_connection_trigger_timeout_event);
|
||||
service_context.CloseEvent(unique_pad_connection_event);
|
||||
};
|
||||
|
||||
void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
|
||||
@@ -248,241 +238,29 @@ void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called"); // Spams a lot when controller applet is running
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(system.HIDCore().GetLastActiveController());
|
||||
}
|
||||
|
||||
void IHidSystemServer::ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "called");
|
||||
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.ApplyNpadSystemCommonPolicy();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetNpadFullKeyGripColor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
Core::HID::NpadColor left_color{};
|
||||
Core::HID::NpadColor right_color{};
|
||||
// TODO: Get colors from Npad
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(left_color);
|
||||
rb.PushRaw(right_color);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
LOG_INFO(Service_HID, "(STUBBED) called");
|
||||
|
||||
Core::HID::NpadStyleSet supported_styleset =
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.GetSupportedStyleSet()
|
||||
.raw;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(supported_styleset);
|
||||
}
|
||||
|
||||
void IHidSystemServer::SetSupportedNpadStyleSetAll(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
LOG_INFO(Service_HID, "(STUBBED) called");
|
||||
|
||||
Core::HID::NpadStyleSet supported_styleset =
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.GetSupportedStyleSet()
|
||||
.raw;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(supported_styleset);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetAppletDetailedUiType(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
const Service::HID::Controller_NPad::AppletDetailedUiType detailed_ui_type =
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.GetAppletDetailedUiType(npad_id_type);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(detailed_ui_type);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetNpadInterfaceType(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(Core::HID::NpadInterfaceType::Bluetooth);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetNpadLeftRightInterfaceType(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(Core::HID::NpadInterfaceType::Bluetooth);
|
||||
rb.PushEnum(Core::HID::NpadInterfaceType::Bluetooth);
|
||||
}
|
||||
|
||||
void IHidSystemServer::HasBattery(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(false);
|
||||
}
|
||||
|
||||
void IHidSystemServer::HasLeftRightBattery(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
struct LeftRightBattery {
|
||||
bool left;
|
||||
bool right;
|
||||
};
|
||||
|
||||
LeftRightBattery left_right_battery{
|
||||
.left = false,
|
||||
.right = false,
|
||||
};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(left_right_battery);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetUniquePadsFromNpad(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type);
|
||||
|
||||
const std::vector<Core::HID::UniquePadId> unique_pads{};
|
||||
|
||||
if (!unique_pads.empty()) {
|
||||
ctx.WriteBuffer(unique_pads);
|
||||
}
|
||||
ctx.WriteBuffer(unique_pads);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(static_cast<u32>(unique_pads.size()));
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetIrSensorState(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_AM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushCopyObjects(acquire_device_registered_event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void IHidSystemServer::AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushCopyObjects(acquire_device_registered_event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetRegisteredDevices(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
struct RegisterData {
|
||||
std::array<u8, 0x68> data;
|
||||
};
|
||||
static_assert(sizeof(RegisterData) == 0x68, "RegisterData is an invalid size");
|
||||
std::vector<RegisterData> registered_devices{};
|
||||
|
||||
if (!registered_devices.empty()) {
|
||||
ctx.WriteBuffer(registered_devices);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u64>(registered_devices.size());
|
||||
}
|
||||
|
||||
void IHidSystemServer::AcquireUniquePadConnectionEventHandle(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.PushCopyObjects(unique_pad_connection_event->GetReadableEvent());
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetUniquePadIds(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u64>(0);
|
||||
}
|
||||
|
||||
void IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_AM, "called");
|
||||
|
||||
@@ -501,31 +279,6 @@ void IHidSystemServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
|
||||
rb.Push(is_enabled);
|
||||
}
|
||||
|
||||
void IHidSystemServer::IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx) {
|
||||
const bool button_pressed = false;
|
||||
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called, is_enabled={}",
|
||||
button_pressed); // Spams a lot when controller applet is open
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(button_pressed);
|
||||
}
|
||||
|
||||
void IHidSystemServer::InitializeFirmwareUpdate(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
|
||||
|
||||
@@ -24,38 +24,15 @@ public:
|
||||
|
||||
private:
|
||||
void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx);
|
||||
void EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
|
||||
void DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
|
||||
void GetLastActiveNpad(HLERequestContext& ctx);
|
||||
void ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx);
|
||||
void GetNpadFullKeyGripColor(HLERequestContext& ctx);
|
||||
void GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx);
|
||||
void SetSupportedNpadStyleSetAll(HLERequestContext& ctx);
|
||||
void GetAppletDetailedUiType(HLERequestContext& ctx);
|
||||
void GetNpadInterfaceType(HLERequestContext& ctx);
|
||||
void GetNpadLeftRightInterfaceType(HLERequestContext& ctx);
|
||||
void HasBattery(HLERequestContext& ctx);
|
||||
void HasLeftRightBattery(HLERequestContext& ctx);
|
||||
void GetUniquePadsFromNpad(HLERequestContext& ctx);
|
||||
void GetIrSensorState(HLERequestContext& ctx);
|
||||
void AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx);
|
||||
void AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx);
|
||||
void GetRegisteredDevices(HLERequestContext& ctx);
|
||||
void AcquireUniquePadConnectionEventHandle(HLERequestContext& ctx);
|
||||
void GetUniquePadIds(HLERequestContext& ctx);
|
||||
void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx);
|
||||
void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
|
||||
void IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx);
|
||||
void InitializeFirmwareUpdate(HLERequestContext& ctx);
|
||||
void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
|
||||
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<ResourceManager> GetResourceManager();
|
||||
|
||||
Kernel::KEvent* acquire_connection_trigger_timeout_event;
|
||||
Kernel::KEvent* acquire_device_registered_event;
|
||||
Kernel::KEvent* joy_detach_event;
|
||||
Kernel::KEvent* unique_pad_connection_event;
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
std::shared_ptr<ResourceManager> resource_manager;
|
||||
};
|
||||
|
||||
@@ -115,20 +115,12 @@ public:
|
||||
{400, nullptr, "InitializeSystem"},
|
||||
{401, nullptr, "FinalizeSystem"},
|
||||
{402, nullptr, "SetOperationMode"},
|
||||
{403, &ISystemLocalCommunicationService::InitializeSystem2, "InitializeSystem2"},
|
||||
{403, nullptr, "InitializeSystem2"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeSystem2(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
class IUserLocalCommunicationService final
|
||||
|
||||
@@ -431,7 +431,8 @@ void SET_SYS::GetAutoUpdateEnableFlag(HLERequestContext& ctx) {
|
||||
void SET_SYS::GetBatteryPercentageFlag(HLERequestContext& ctx) {
|
||||
u8 battery_percentage_flag{1};
|
||||
|
||||
LOG_DEBUG(Service_SET, "(STUBBED) called, battery_percentage_flag={}", battery_percentage_flag);
|
||||
LOG_WARNING(Service_SET, "(STUBBED) called, battery_percentage_flag={}",
|
||||
battery_percentage_flag);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -491,29 +492,6 @@ void SET_SYS::GetChineseTraditionalInputMethod(HLERequestContext& ctx) {
|
||||
rb.PushEnum(ChineseTraditionalInputMethod::Unknown0);
|
||||
}
|
||||
|
||||
void SET_SYS::GetHomeMenuScheme(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "(STUBBED) called");
|
||||
|
||||
const HomeMenuScheme default_color = {
|
||||
.main = 0xFF323232,
|
||||
.back = 0xFF323232,
|
||||
.sub = 0xFFFFFFFF,
|
||||
.bezel = 0xFFFFFFFF,
|
||||
.extra = 0xFF000000,
|
||||
};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 7};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(default_color);
|
||||
}
|
||||
|
||||
void SET_SYS::GetHomeMenuSchemeModel(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_SET, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(0);
|
||||
}
|
||||
void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_SET, "(STUBBED) called");
|
||||
|
||||
@@ -696,7 +674,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
|
||||
{171, nullptr, "SetChineseTraditionalInputMethod"},
|
||||
{172, nullptr, "GetPtmCycleCountReliability"},
|
||||
{173, nullptr, "SetPtmCycleCountReliability"},
|
||||
{174, &SET_SYS::GetHomeMenuScheme, "GetHomeMenuScheme"},
|
||||
{174, nullptr, "GetHomeMenuScheme"},
|
||||
{175, nullptr, "GetThemeSettings"},
|
||||
{176, nullptr, "SetThemeSettings"},
|
||||
{177, nullptr, "GetThemeKey"},
|
||||
@@ -707,7 +685,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
|
||||
{182, nullptr, "SetT"},
|
||||
{183, nullptr, "GetPlatformRegion"},
|
||||
{184, nullptr, "SetPlatformRegion"},
|
||||
{185, &SET_SYS::GetHomeMenuSchemeModel, "GetHomeMenuSchemeModel"},
|
||||
{185, nullptr, "GetHomeMenuSchemeModel"},
|
||||
{186, nullptr, "GetMemoryUsageRateFlag"},
|
||||
{187, nullptr, "GetTouchScreenMode"},
|
||||
{188, nullptr, "SetTouchScreenMode"},
|
||||
|
||||
@@ -269,16 +269,6 @@ private:
|
||||
};
|
||||
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
|
||||
|
||||
/// This is nn::settings::system::HomeMenuScheme
|
||||
struct HomeMenuScheme {
|
||||
u32 main;
|
||||
u32 back;
|
||||
u32 sub;
|
||||
u32 bezel;
|
||||
u32 extra;
|
||||
};
|
||||
static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size");
|
||||
|
||||
void SetLanguageCode(HLERequestContext& ctx);
|
||||
void GetFirmwareVersion(HLERequestContext& ctx);
|
||||
void GetFirmwareVersion2(HLERequestContext& ctx);
|
||||
@@ -315,8 +305,6 @@ private:
|
||||
void GetKeyboardLayout(HLERequestContext& ctx);
|
||||
void GetChineseTraditionalInputMethod(HLERequestContext& ctx);
|
||||
void GetFieldTestingFlag(HLERequestContext& ctx);
|
||||
void GetHomeMenuScheme(HLERequestContext& ctx);
|
||||
void GetHomeMenuSchemeModel(HLERequestContext& ctx);
|
||||
|
||||
AccountSettings account_settings{
|
||||
.flags = {},
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "core/loader/deconstructed_rom_directory.h"
|
||||
#include "core/loader/nso.h"
|
||||
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
#include "core/arm/nce/patch.h"
|
||||
#endif
|
||||
|
||||
@@ -141,12 +141,12 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
|
||||
std::size_t code_size{};
|
||||
|
||||
// Define an nce patch context for each potential module.
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
std::array<Core::NCE::Patcher, 13> module_patchers;
|
||||
#endif
|
||||
|
||||
const auto GetPatcher = [&](size_t i) -> Core::NCE::Patcher* {
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
if (Settings::IsNceEnabled()) {
|
||||
return &module_patchers[i];
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "core/loader/nso.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
#include "core/arm/nce/patch.h"
|
||||
#endif
|
||||
|
||||
@@ -201,7 +201,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process,
|
||||
program_image.resize(static_cast<u32>(program_image.size()) + bss_size);
|
||||
size_t image_size = program_image.size();
|
||||
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
const auto& code = codeset.CodeSegment();
|
||||
|
||||
// NROs always have a 39-bit address space.
|
||||
@@ -247,7 +247,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process,
|
||||
|
||||
// Relocate code patch and copy to the program_image if running under NCE.
|
||||
// This needs to be after LoadFromMetadata so we can use the process entry point.
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
if (Settings::IsNceEnabled()) {
|
||||
patch.RelocateAndCopy(process.GetEntryPoint(), code, program_image,
|
||||
&process.GetPostHandlers());
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "core/loader/nso.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
#include "core/arm/nce/patch.h"
|
||||
#endif
|
||||
|
||||
@@ -93,7 +93,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
|
||||
|
||||
// Allocate some space at the beginning if we are patching in PreText mode.
|
||||
const size_t module_start = [&]() -> size_t {
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::PreText) {
|
||||
return patch->GetSectionSize();
|
||||
}
|
||||
@@ -145,19 +145,17 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
|
||||
// Apply patches if necessary
|
||||
const auto name = nso_file.GetName();
|
||||
if (pm && (pm->HasNSOPatch(nso_header.build_id, name) || Settings::values.dump_nso)) {
|
||||
std::span<u8> patchable_section(program_image.data() + module_start,
|
||||
program_image.size() - module_start);
|
||||
std::vector<u8> pi_header(sizeof(NSOHeader) + patchable_section.size());
|
||||
std::vector<u8> pi_header(sizeof(NSOHeader) + program_image.size());
|
||||
std::memcpy(pi_header.data(), &nso_header, sizeof(NSOHeader));
|
||||
std::memcpy(pi_header.data() + sizeof(NSOHeader), patchable_section.data(),
|
||||
patchable_section.size());
|
||||
std::memcpy(pi_header.data() + sizeof(NSOHeader), program_image.data(),
|
||||
program_image.size());
|
||||
|
||||
pi_header = pm->PatchNSO(pi_header, name);
|
||||
|
||||
std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), patchable_section.data());
|
||||
std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data());
|
||||
}
|
||||
|
||||
#ifdef HAS_NCE
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
// If we are computing the process code layout and using nce backend, patch.
|
||||
const auto& code = codeset.CodeSegment();
|
||||
if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::None) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
add_subdirectory(host_shaders)
|
||||
|
||||
if(LIBVA_FOUND)
|
||||
set_source_files_properties(host1x/ffmpeg/ffmpeg.cpp
|
||||
set_source_files_properties(host1x/codecs/codec.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS LIBVA_FOUND=1)
|
||||
list(APPEND FFmpeg_LIBRARIES ${LIBVA_LIBRARIES})
|
||||
endif()
|
||||
@@ -67,8 +67,6 @@ add_library(video_core STATIC
|
||||
host1x/codecs/vp9.cpp
|
||||
host1x/codecs/vp9.h
|
||||
host1x/codecs/vp9_types.h
|
||||
host1x/ffmpeg/ffmpeg.cpp
|
||||
host1x/ffmpeg/ffmpeg.h
|
||||
host1x/control.cpp
|
||||
host1x/control.h
|
||||
host1x/host1x.cpp
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "common/assert.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/host1x/codecs/codec.h"
|
||||
#include "video_core/host1x/codecs/h264.h"
|
||||
@@ -10,17 +14,242 @@
|
||||
#include "video_core/host1x/host1x.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/opt.h>
|
||||
#ifdef LIBVA_FOUND
|
||||
// for querying VAAPI driver information
|
||||
#include <libavutil/hwcontext_vaapi.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Tegra {
|
||||
namespace {
|
||||
constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12;
|
||||
constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P;
|
||||
constexpr std::array PREFERRED_GPU_DECODERS = {
|
||||
AV_HWDEVICE_TYPE_CUDA,
|
||||
#ifdef _WIN32
|
||||
AV_HWDEVICE_TYPE_D3D11VA,
|
||||
AV_HWDEVICE_TYPE_DXVA2,
|
||||
#elif defined(__unix__)
|
||||
AV_HWDEVICE_TYPE_VAAPI,
|
||||
AV_HWDEVICE_TYPE_VDPAU,
|
||||
#endif
|
||||
// last resort for Linux Flatpak (w/ NVIDIA)
|
||||
AV_HWDEVICE_TYPE_VULKAN,
|
||||
};
|
||||
|
||||
void AVPacketDeleter(AVPacket* ptr) {
|
||||
av_packet_free(&ptr);
|
||||
}
|
||||
|
||||
using AVPacketPtr = std::unique_ptr<AVPacket, decltype(&AVPacketDeleter)>;
|
||||
|
||||
AVPixelFormat GetGpuFormat(AVCodecContext* av_codec_ctx, const AVPixelFormat* pix_fmts) {
|
||||
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||
if (*p == av_codec_ctx->pix_fmt) {
|
||||
return av_codec_ctx->pix_fmt;
|
||||
}
|
||||
}
|
||||
LOG_INFO(Service_NVDRV, "Could not find compatible GPU AV format, falling back to CPU");
|
||||
av_buffer_unref(&av_codec_ctx->hw_device_ctx);
|
||||
av_codec_ctx->pix_fmt = PREFERRED_CPU_FMT;
|
||||
return PREFERRED_CPU_FMT;
|
||||
}
|
||||
|
||||
// List all the currently available hwcontext in ffmpeg
|
||||
std::vector<AVHWDeviceType> ListSupportedContexts() {
|
||||
std::vector<AVHWDeviceType> contexts{};
|
||||
AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
|
||||
do {
|
||||
current_device_type = av_hwdevice_iterate_types(current_device_type);
|
||||
contexts.push_back(current_device_type);
|
||||
} while (current_device_type != AV_HWDEVICE_TYPE_NONE);
|
||||
return contexts;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AVFrameDeleter(AVFrame* ptr) {
|
||||
av_frame_free(&ptr);
|
||||
}
|
||||
|
||||
Codec::Codec(Host1x::Host1x& host1x_, const Host1x::NvdecCommon::NvdecRegisters& regs)
|
||||
: host1x(host1x_), state{regs}, h264_decoder(std::make_unique<Decoder::H264>(host1x)),
|
||||
vp8_decoder(std::make_unique<Decoder::VP8>(host1x)),
|
||||
vp9_decoder(std::make_unique<Decoder::VP9>(host1x)) {}
|
||||
|
||||
Codec::~Codec() = default;
|
||||
Codec::~Codec() {
|
||||
if (!initialized) {
|
||||
return;
|
||||
}
|
||||
// Free libav memory
|
||||
avcodec_free_context(&av_codec_ctx);
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
|
||||
if (filters_initialized) {
|
||||
avfilter_graph_free(&av_filter_graph);
|
||||
}
|
||||
}
|
||||
|
||||
bool Codec::CreateGpuAvDevice() {
|
||||
static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX;
|
||||
static const auto supported_contexts = ListSupportedContexts();
|
||||
for (const auto& type : PREFERRED_GPU_DECODERS) {
|
||||
if (std::none_of(supported_contexts.begin(), supported_contexts.end(),
|
||||
[&type](const auto& context) { return context == type; })) {
|
||||
LOG_DEBUG(Service_NVDRV, "{} explicitly unsupported", av_hwdevice_get_type_name(type));
|
||||
continue;
|
||||
}
|
||||
// Avoid memory leak from not cleaning up after av_hwdevice_ctx_create
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
const int hwdevice_res = av_hwdevice_ctx_create(&av_gpu_decoder, type, nullptr, nullptr, 0);
|
||||
if (hwdevice_res < 0) {
|
||||
LOG_DEBUG(Service_NVDRV, "{} av_hwdevice_ctx_create failed {}",
|
||||
av_hwdevice_get_type_name(type), hwdevice_res);
|
||||
continue;
|
||||
}
|
||||
#ifdef LIBVA_FOUND
|
||||
if (type == AV_HWDEVICE_TYPE_VAAPI) {
|
||||
// we need to determine if this is an impersonated VAAPI driver
|
||||
AVHWDeviceContext* hwctx =
|
||||
static_cast<AVHWDeviceContext*>(static_cast<void*>(av_gpu_decoder->data));
|
||||
AVVAAPIDeviceContext* vactx = static_cast<AVVAAPIDeviceContext*>(hwctx->hwctx);
|
||||
const char* vendor_name = vaQueryVendorString(vactx->display);
|
||||
if (strstr(vendor_name, "VDPAU backend")) {
|
||||
// VDPAU impersonated VAAPI impl's are super buggy, we need to skip them
|
||||
LOG_DEBUG(Service_NVDRV, "Skipping vdapu impersonated VAAPI driver");
|
||||
continue;
|
||||
} else {
|
||||
// according to some user testing, certain vaapi driver (Intel?) could be buggy
|
||||
// so let's log the driver name which may help the developers/supporters
|
||||
LOG_DEBUG(Service_NVDRV, "Using VAAPI driver: {}", vendor_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig* config = avcodec_get_hw_config(av_codec, i);
|
||||
if (!config) {
|
||||
LOG_DEBUG(Service_NVDRV, "{} decoder does not support device type {}.",
|
||||
av_codec->name, av_hwdevice_get_type_name(type));
|
||||
break;
|
||||
}
|
||||
if ((config->methods & HW_CONFIG_METHOD) != 0 && config->device_type == type) {
|
||||
LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type));
|
||||
av_codec_ctx->pix_fmt = config->pix_fmt;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Codec::InitializeAvCodecContext() {
|
||||
av_codec_ctx = avcodec_alloc_context3(av_codec);
|
||||
av_opt_set(av_codec_ctx->priv_data, "tune", "zerolatency", 0);
|
||||
av_codec_ctx->thread_count = 0;
|
||||
av_codec_ctx->thread_type &= ~FF_THREAD_FRAME;
|
||||
}
|
||||
|
||||
void Codec::InitializeGpuDecoder() {
|
||||
if (!CreateGpuAvDevice()) {
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
return;
|
||||
}
|
||||
auto* hw_device_ctx = av_buffer_ref(av_gpu_decoder);
|
||||
ASSERT_MSG(hw_device_ctx, "av_buffer_ref failed");
|
||||
av_codec_ctx->hw_device_ctx = hw_device_ctx;
|
||||
av_codec_ctx->get_format = GetGpuFormat;
|
||||
}
|
||||
|
||||
void Codec::InitializeAvFilters(AVFrame* frame) {
|
||||
const AVFilter* buffer_src = avfilter_get_by_name("buffer");
|
||||
const AVFilter* buffer_sink = avfilter_get_by_name("buffersink");
|
||||
AVFilterInOut* inputs = avfilter_inout_alloc();
|
||||
AVFilterInOut* outputs = avfilter_inout_alloc();
|
||||
SCOPE_EXIT({
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
});
|
||||
|
||||
// Don't know how to get the accurate time_base but it doesn't matter for yadif filter
|
||||
// so just use 1/1 to make buffer filter happy
|
||||
std::string args = fmt::format("video_size={}x{}:pix_fmt={}:time_base=1/1", frame->width,
|
||||
frame->height, frame->format);
|
||||
|
||||
av_filter_graph = avfilter_graph_alloc();
|
||||
int ret = avfilter_graph_create_filter(&av_filter_src_ctx, buffer_src, "in", args.c_str(),
|
||||
nullptr, av_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_create_filter source error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_create_filter(&av_filter_sink_ctx, buffer_sink, "out", nullptr, nullptr,
|
||||
av_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_create_filter sink error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = av_filter_sink_ctx;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = nullptr;
|
||||
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = av_filter_src_ctx;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = nullptr;
|
||||
|
||||
const char* description = "yadif=1:-1:0";
|
||||
ret = avfilter_graph_parse_ptr(av_filter_graph, description, &inputs, &outputs, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_parse_ptr error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_config(av_filter_graph, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_config error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
filters_initialized = true;
|
||||
}
|
||||
|
||||
void Codec::Initialize() {
|
||||
initialized = decode_api.Initialize(current_codec);
|
||||
const AVCodecID codec = [&] {
|
||||
switch (current_codec) {
|
||||
case Host1x::NvdecCommon::VideoCodec::H264:
|
||||
return AV_CODEC_ID_H264;
|
||||
case Host1x::NvdecCommon::VideoCodec::VP8:
|
||||
return AV_CODEC_ID_VP8;
|
||||
case Host1x::NvdecCommon::VideoCodec::VP9:
|
||||
return AV_CODEC_ID_VP9;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown codec {}", current_codec);
|
||||
return AV_CODEC_ID_NONE;
|
||||
}
|
||||
}();
|
||||
av_codec = avcodec_find_decoder(codec);
|
||||
|
||||
InitializeAvCodecContext();
|
||||
if (Settings::values.nvdec_emulation.GetValue() == Settings::NvdecEmulation::Gpu) {
|
||||
InitializeGpuDecoder();
|
||||
}
|
||||
if (const int res = avcodec_open2(av_codec_ctx, av_codec, nullptr); res < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed with result {}", res);
|
||||
avcodec_free_context(&av_codec_ctx);
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
return;
|
||||
}
|
||||
if (!av_codec_ctx->hw_device_ctx) {
|
||||
LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding");
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void Codec::SetTargetCodec(Host1x::NvdecCommon::VideoCodec codec) {
|
||||
@@ -35,18 +264,14 @@ void Codec::Decode() {
|
||||
if (is_first_frame) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Assemble bitstream.
|
||||
bool vp9_hidden_frame = false;
|
||||
size_t configuration_size = 0;
|
||||
const auto packet_data = [&]() {
|
||||
const auto& frame_data = [&]() {
|
||||
switch (current_codec) {
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::H264:
|
||||
return h264_decoder->ComposeFrame(state, &configuration_size, is_first_frame);
|
||||
return h264_decoder->ComposeFrame(state, is_first_frame);
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP8:
|
||||
return vp8_decoder->ComposeFrame(state);
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP9:
|
||||
@@ -58,35 +283,89 @@ void Codec::Decode() {
|
||||
return std::span<const u8>{};
|
||||
}
|
||||
}();
|
||||
|
||||
// Send assembled bitstream to decoder.
|
||||
if (!decode_api.SendPacket(packet_data, configuration_size)) {
|
||||
AVPacketPtr packet{av_packet_alloc(), AVPacketDeleter};
|
||||
if (!packet) {
|
||||
LOG_ERROR(Service_NVDRV, "av_packet_alloc failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Only receive/store visible frames.
|
||||
packet->data = const_cast<u8*>(frame_data.data());
|
||||
packet->size = static_cast<s32>(frame_data.size());
|
||||
if (const int res = avcodec_send_packet(av_codec_ctx, packet.get()); res != 0) {
|
||||
LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", res);
|
||||
return;
|
||||
}
|
||||
// Only receive/store visible frames
|
||||
if (vp9_hidden_frame) {
|
||||
return;
|
||||
}
|
||||
AVFramePtr initial_frame{av_frame_alloc(), AVFrameDeleter};
|
||||
AVFramePtr final_frame{nullptr, AVFrameDeleter};
|
||||
ASSERT_MSG(initial_frame, "av_frame_alloc initial_frame failed");
|
||||
if (const int ret = avcodec_receive_frame(av_codec_ctx, initial_frame.get()); ret) {
|
||||
LOG_DEBUG(Service_NVDRV, "avcodec_receive_frame error {}", ret);
|
||||
return;
|
||||
}
|
||||
if (initial_frame->width == 0 || initial_frame->height == 0) {
|
||||
LOG_WARNING(Service_NVDRV, "Zero width or height in frame");
|
||||
return;
|
||||
}
|
||||
bool is_interlaced = initial_frame->interlaced_frame != 0;
|
||||
if (av_codec_ctx->hw_device_ctx) {
|
||||
final_frame = AVFramePtr{av_frame_alloc(), AVFrameDeleter};
|
||||
ASSERT_MSG(final_frame, "av_frame_alloc final_frame failed");
|
||||
// Can't use AV_PIX_FMT_YUV420P and share code with software decoding in vic.cpp
|
||||
// because Intel drivers crash unless using AV_PIX_FMT_NV12
|
||||
final_frame->format = PREFERRED_GPU_FMT;
|
||||
const int ret = av_hwframe_transfer_data(final_frame.get(), initial_frame.get(), 0);
|
||||
ASSERT_MSG(!ret, "av_hwframe_transfer_data error {}", ret);
|
||||
} else {
|
||||
final_frame = std::move(initial_frame);
|
||||
}
|
||||
if (final_frame->format != PREFERRED_CPU_FMT && final_frame->format != PREFERRED_GPU_FMT) {
|
||||
UNIMPLEMENTED_MSG("Unexpected video format: {}", final_frame->format);
|
||||
return;
|
||||
}
|
||||
if (!is_interlaced) {
|
||||
av_frames.push(std::move(final_frame));
|
||||
} else {
|
||||
if (!filters_initialized) {
|
||||
InitializeAvFilters(final_frame.get());
|
||||
}
|
||||
if (const int ret = av_buffersrc_add_frame_flags(av_filter_src_ctx, final_frame.get(),
|
||||
AV_BUFFERSRC_FLAG_KEEP_REF);
|
||||
ret) {
|
||||
LOG_DEBUG(Service_NVDRV, "av_buffersrc_add_frame_flags error {}", ret);
|
||||
return;
|
||||
}
|
||||
while (true) {
|
||||
auto filter_frame = AVFramePtr{av_frame_alloc(), AVFrameDeleter};
|
||||
|
||||
// Receive output frames from decoder.
|
||||
decode_api.ReceiveFrames(frames);
|
||||
int ret = av_buffersink_get_frame(av_filter_sink_ctx, filter_frame.get());
|
||||
|
||||
while (frames.size() > 10) {
|
||||
LOG_DEBUG(HW_GPU, "ReceiveFrames overflow, dropped frame");
|
||||
frames.pop();
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR(AVERROR_EOF))
|
||||
break;
|
||||
if (ret < 0) {
|
||||
LOG_DEBUG(Service_NVDRV, "av_buffersink_get_frame error {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
av_frames.push(std::move(filter_frame));
|
||||
}
|
||||
}
|
||||
while (av_frames.size() > 10) {
|
||||
LOG_TRACE(Service_NVDRV, "av_frames.push overflow dropped frame");
|
||||
av_frames.pop();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<FFmpeg::Frame> Codec::GetCurrentFrame() {
|
||||
AVFramePtr Codec::GetCurrentFrame() {
|
||||
// Sometimes VIC will request more frames than have been decoded.
|
||||
// in this case, return a blank frame and don't overwrite previous data.
|
||||
if (frames.empty()) {
|
||||
return {};
|
||||
// in this case, return a nullptr and don't overwrite previous frame data
|
||||
if (av_frames.empty()) {
|
||||
return AVFramePtr{nullptr, AVFrameDeleter};
|
||||
}
|
||||
|
||||
auto frame = std::move(frames.front());
|
||||
frames.pop();
|
||||
AVFramePtr frame = std::move(av_frames.front());
|
||||
av_frames.pop();
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <queue>
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/host1x/ffmpeg/ffmpeg.h"
|
||||
#include "video_core/host1x/nvdec_common.h"
|
||||
|
||||
extern "C" {
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
void AVFrameDeleter(AVFrame* ptr);
|
||||
using AVFramePtr = std::unique_ptr<AVFrame, decltype(&AVFrameDeleter)>;
|
||||
|
||||
namespace Decoder {
|
||||
class H264;
|
||||
class VP8;
|
||||
@@ -38,7 +51,7 @@ public:
|
||||
void Decode();
|
||||
|
||||
/// Returns next decoded frame
|
||||
[[nodiscard]] std::unique_ptr<FFmpeg::Frame> GetCurrentFrame();
|
||||
[[nodiscard]] AVFramePtr GetCurrentFrame();
|
||||
|
||||
/// Returns the value of current_codec
|
||||
[[nodiscard]] Host1x::NvdecCommon::VideoCodec GetCurrentCodec() const;
|
||||
@@ -47,9 +60,25 @@ public:
|
||||
[[nodiscard]] std::string_view GetCurrentCodecName() const;
|
||||
|
||||
private:
|
||||
void InitializeAvCodecContext();
|
||||
|
||||
void InitializeAvFilters(AVFrame* frame);
|
||||
|
||||
void InitializeGpuDecoder();
|
||||
|
||||
bool CreateGpuAvDevice();
|
||||
|
||||
bool initialized{};
|
||||
bool filters_initialized{};
|
||||
Host1x::NvdecCommon::VideoCodec current_codec{Host1x::NvdecCommon::VideoCodec::None};
|
||||
FFmpeg::DecodeApi decode_api;
|
||||
|
||||
const AVCodec* av_codec{nullptr};
|
||||
AVCodecContext* av_codec_ctx{nullptr};
|
||||
AVBufferRef* av_gpu_decoder{nullptr};
|
||||
|
||||
AVFilterContext* av_filter_src_ctx{nullptr};
|
||||
AVFilterContext* av_filter_sink_ctx{nullptr};
|
||||
AVFilterGraph* av_filter_graph{nullptr};
|
||||
|
||||
Host1x::Host1x& host1x;
|
||||
const Host1x::NvdecCommon::NvdecRegisters& state;
|
||||
@@ -57,7 +86,7 @@ private:
|
||||
std::unique_ptr<Decoder::VP8> vp8_decoder;
|
||||
std::unique_ptr<Decoder::VP9> vp9_decoder;
|
||||
|
||||
std::queue<std::unique_ptr<FFmpeg::Frame>> frames{};
|
||||
std::queue<AVFramePtr> av_frames{};
|
||||
};
|
||||
|
||||
} // namespace Tegra
|
||||
|
||||
@@ -30,7 +30,7 @@ H264::H264(Host1x::Host1x& host1x_) : host1x{host1x_} {}
|
||||
H264::~H264() = default;
|
||||
|
||||
std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
||||
size_t* out_configuration_size, bool is_first_frame) {
|
||||
bool is_first_frame) {
|
||||
H264DecoderContext context;
|
||||
host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context,
|
||||
sizeof(H264DecoderContext));
|
||||
@@ -39,7 +39,6 @@ std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters
|
||||
if (!is_first_frame && frame_number != 0) {
|
||||
frame.resize_destructive(context.stream_len);
|
||||
host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size());
|
||||
*out_configuration_size = 0;
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -158,7 +157,6 @@ std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters
|
||||
frame.resize(encoded_header.size() + context.stream_len);
|
||||
std::memcpy(frame.data(), encoded_header.data(), encoded_header.size());
|
||||
|
||||
*out_configuration_size = encoded_header.size();
|
||||
host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset,
|
||||
frame.data() + encoded_header.size(), context.stream_len);
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
|
||||
/// Compose the H264 frame for FFmpeg decoding
|
||||
[[nodiscard]] std::span<const u8> ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
||||
size_t* out_configuration_size,
|
||||
bool is_first_frame = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/host1x/ffmpeg/ffmpeg.h"
|
||||
|
||||
extern "C" {
|
||||
#ifdef LIBVA_FOUND
|
||||
// for querying VAAPI driver information
|
||||
#include <libavutil/hwcontext_vaapi.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace FFmpeg {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr AVPixelFormat PreferredGpuFormat = AV_PIX_FMT_NV12;
|
||||
constexpr AVPixelFormat PreferredCpuFormat = AV_PIX_FMT_YUV420P;
|
||||
constexpr std::array PreferredGpuDecoders = {
|
||||
AV_HWDEVICE_TYPE_CUDA,
|
||||
#ifdef _WIN32
|
||||
AV_HWDEVICE_TYPE_D3D11VA,
|
||||
AV_HWDEVICE_TYPE_DXVA2,
|
||||
#elif defined(__unix__)
|
||||
AV_HWDEVICE_TYPE_VAAPI,
|
||||
AV_HWDEVICE_TYPE_VDPAU,
|
||||
#endif
|
||||
// last resort for Linux Flatpak (w/ NVIDIA)
|
||||
AV_HWDEVICE_TYPE_VULKAN,
|
||||
};
|
||||
|
||||
AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* pix_fmts) {
|
||||
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||
if (*p == codec_context->pix_fmt) {
|
||||
return codec_context->pix_fmt;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO(HW_GPU, "Could not find compatible GPU AV format, falling back to CPU");
|
||||
av_buffer_unref(&codec_context->hw_device_ctx);
|
||||
|
||||
codec_context->pix_fmt = PreferredCpuFormat;
|
||||
return codec_context->pix_fmt;
|
||||
}
|
||||
|
||||
std::string AVError(int errnum) {
|
||||
char errbuf[AV_ERROR_MAX_STRING_SIZE] = {};
|
||||
av_make_error_string(errbuf, sizeof(errbuf) - 1, errnum);
|
||||
return errbuf;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Packet::Packet(std::span<const u8> data) {
|
||||
m_packet = av_packet_alloc();
|
||||
m_packet->data = const_cast<u8*>(data.data());
|
||||
m_packet->size = static_cast<s32>(data.size());
|
||||
}
|
||||
|
||||
Packet::~Packet() {
|
||||
av_packet_free(&m_packet);
|
||||
}
|
||||
|
||||
Frame::Frame() {
|
||||
m_frame = av_frame_alloc();
|
||||
}
|
||||
|
||||
Frame::~Frame() {
|
||||
av_frame_free(&m_frame);
|
||||
}
|
||||
|
||||
Decoder::Decoder(Tegra::Host1x::NvdecCommon::VideoCodec codec) {
|
||||
const AVCodecID av_codec = [&] {
|
||||
switch (codec) {
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::H264:
|
||||
return AV_CODEC_ID_H264;
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP8:
|
||||
return AV_CODEC_ID_VP8;
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP9:
|
||||
return AV_CODEC_ID_VP9;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown codec {}", codec);
|
||||
return AV_CODEC_ID_NONE;
|
||||
}
|
||||
}();
|
||||
|
||||
m_codec = avcodec_find_decoder(av_codec);
|
||||
}
|
||||
|
||||
bool Decoder::SupportsDecodingOnDevice(AVPixelFormat* out_pix_fmt, AVHWDeviceType type) const {
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig* config = avcodec_get_hw_config(m_codec, i);
|
||||
if (!config) {
|
||||
LOG_DEBUG(HW_GPU, "{} decoder does not support device type {}", m_codec->name,
|
||||
av_hwdevice_get_type_name(type));
|
||||
break;
|
||||
}
|
||||
if ((config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) != 0 &&
|
||||
config->device_type == type) {
|
||||
LOG_INFO(HW_GPU, "Using {} GPU decoder", av_hwdevice_get_type_name(type));
|
||||
*out_pix_fmt = config->pix_fmt;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<AVHWDeviceType> HardwareContext::GetSupportedDeviceTypes() {
|
||||
std::vector<AVHWDeviceType> types;
|
||||
AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
|
||||
|
||||
while (true) {
|
||||
current_device_type = av_hwdevice_iterate_types(current_device_type);
|
||||
if (current_device_type == AV_HWDEVICE_TYPE_NONE) {
|
||||
return types;
|
||||
}
|
||||
|
||||
types.push_back(current_device_type);
|
||||
}
|
||||
}
|
||||
|
||||
HardwareContext::~HardwareContext() {
|
||||
av_buffer_unref(&m_gpu_decoder);
|
||||
}
|
||||
|
||||
bool HardwareContext::InitializeForDecoder(DecoderContext& decoder_context,
|
||||
const Decoder& decoder) {
|
||||
const auto supported_types = GetSupportedDeviceTypes();
|
||||
for (const auto type : PreferredGpuDecoders) {
|
||||
AVPixelFormat hw_pix_fmt;
|
||||
|
||||
if (std::ranges::find(supported_types, type) == supported_types.end()) {
|
||||
LOG_DEBUG(HW_GPU, "{} explicitly unsupported", av_hwdevice_get_type_name(type));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this->InitializeWithType(type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (decoder.SupportsDecodingOnDevice(&hw_pix_fmt, type)) {
|
||||
decoder_context.InitializeHardwareDecoder(*this, hw_pix_fmt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HardwareContext::InitializeWithType(AVHWDeviceType type) {
|
||||
av_buffer_unref(&m_gpu_decoder);
|
||||
|
||||
if (const int ret = av_hwdevice_ctx_create(&m_gpu_decoder, type, nullptr, nullptr, 0);
|
||||
ret < 0) {
|
||||
LOG_DEBUG(HW_GPU, "av_hwdevice_ctx_create({}) failed: {}", av_hwdevice_get_type_name(type),
|
||||
AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef LIBVA_FOUND
|
||||
if (type == AV_HWDEVICE_TYPE_VAAPI) {
|
||||
// We need to determine if this is an impersonated VAAPI driver.
|
||||
auto* hwctx = reinterpret_cast<AVHWDeviceContext*>(m_gpu_decoder->data);
|
||||
auto* vactx = static_cast<AVVAAPIDeviceContext*>(hwctx->hwctx);
|
||||
const char* vendor_name = vaQueryVendorString(vactx->display);
|
||||
if (strstr(vendor_name, "VDPAU backend")) {
|
||||
// VDPAU impersonated VAAPI impls are super buggy, we need to skip them.
|
||||
LOG_DEBUG(HW_GPU, "Skipping VDPAU impersonated VAAPI driver");
|
||||
return false;
|
||||
} else {
|
||||
// According to some user testing, certain VAAPI drivers (Intel?) could be buggy.
|
||||
// Log the driver name just in case.
|
||||
LOG_DEBUG(HW_GPU, "Using VAAPI driver: {}", vendor_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DecoderContext::DecoderContext(const Decoder& decoder) {
|
||||
m_codec_context = avcodec_alloc_context3(decoder.GetCodec());
|
||||
av_opt_set(m_codec_context->priv_data, "tune", "zerolatency", 0);
|
||||
m_codec_context->thread_count = 0;
|
||||
m_codec_context->thread_type &= ~FF_THREAD_FRAME;
|
||||
}
|
||||
|
||||
DecoderContext::~DecoderContext() {
|
||||
av_buffer_unref(&m_codec_context->hw_device_ctx);
|
||||
avcodec_free_context(&m_codec_context);
|
||||
}
|
||||
|
||||
void DecoderContext::InitializeHardwareDecoder(const HardwareContext& context,
|
||||
AVPixelFormat hw_pix_fmt) {
|
||||
m_codec_context->hw_device_ctx = av_buffer_ref(context.GetBufferRef());
|
||||
m_codec_context->get_format = GetGpuFormat;
|
||||
m_codec_context->pix_fmt = hw_pix_fmt;
|
||||
}
|
||||
|
||||
bool DecoderContext::OpenContext(const Decoder& decoder) {
|
||||
if (const int ret = avcodec_open2(m_codec_context, decoder.GetCodec(), nullptr); ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avcodec_open2 error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_codec_context->hw_device_ctx) {
|
||||
LOG_INFO(HW_GPU, "Using FFmpeg software decoding");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DecoderContext::SendPacket(const Packet& packet) {
|
||||
if (const int ret = avcodec_send_packet(m_codec_context, packet.GetPacket()); ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avcodec_send_packet error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Frame> DecoderContext::ReceiveFrame(bool* out_is_interlaced) {
|
||||
auto dst_frame = std::make_unique<Frame>();
|
||||
|
||||
const auto ReceiveImpl = [&](AVFrame* frame) {
|
||||
if (const int ret = avcodec_receive_frame(m_codec_context, frame); ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avcodec_receive_frame error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_is_interlaced = frame->interlaced_frame != 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
if (m_codec_context->hw_device_ctx) {
|
||||
// If we have a hardware context, make a separate frame here to receive the
|
||||
// hardware result before sending it to the output.
|
||||
Frame intermediate_frame;
|
||||
|
||||
if (!ReceiveImpl(intermediate_frame.GetFrame())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
dst_frame->SetFormat(PreferredGpuFormat);
|
||||
if (const int ret =
|
||||
av_hwframe_transfer_data(dst_frame->GetFrame(), intermediate_frame.GetFrame(), 0);
|
||||
ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "av_hwframe_transfer_data error: {}", AVError(ret));
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
// Otherwise, decode the frame as normal.
|
||||
if (!ReceiveImpl(dst_frame->GetFrame())) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return dst_frame;
|
||||
}
|
||||
|
||||
DeinterlaceFilter::DeinterlaceFilter(const Frame& frame) {
|
||||
const AVFilter* buffer_src = avfilter_get_by_name("buffer");
|
||||
const AVFilter* buffer_sink = avfilter_get_by_name("buffersink");
|
||||
AVFilterInOut* inputs = avfilter_inout_alloc();
|
||||
AVFilterInOut* outputs = avfilter_inout_alloc();
|
||||
SCOPE_EXIT({
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
});
|
||||
|
||||
// Don't know how to get the accurate time_base but it doesn't matter for yadif filter
|
||||
// so just use 1/1 to make buffer filter happy
|
||||
std::string args = fmt::format("video_size={}x{}:pix_fmt={}:time_base=1/1", frame.GetWidth(),
|
||||
frame.GetHeight(), static_cast<int>(frame.GetPixelFormat()));
|
||||
|
||||
m_filter_graph = avfilter_graph_alloc();
|
||||
int ret = avfilter_graph_create_filter(&m_source_context, buffer_src, "in", args.c_str(),
|
||||
nullptr, m_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_create_filter source error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_create_filter(&m_sink_context, buffer_sink, "out", nullptr, nullptr,
|
||||
m_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_create_filter sink error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = m_sink_context;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = nullptr;
|
||||
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = m_source_context;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = nullptr;
|
||||
|
||||
const char* description = "yadif=1:-1:0";
|
||||
ret = avfilter_graph_parse_ptr(m_filter_graph, description, &inputs, &outputs, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_parse_ptr error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_config(m_filter_graph, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_config error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
bool DeinterlaceFilter::AddSourceFrame(const Frame& frame) {
|
||||
if (const int ret = av_buffersrc_add_frame_flags(m_source_context, frame.GetFrame(),
|
||||
AV_BUFFERSRC_FLAG_KEEP_REF);
|
||||
ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "av_buffersrc_add_frame_flags error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Frame> DeinterlaceFilter::DrainSinkFrame() {
|
||||
auto dst_frame = std::make_unique<Frame>();
|
||||
const int ret = av_buffersink_get_frame(m_sink_context, dst_frame->GetFrame());
|
||||
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR(AVERROR_EOF)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "av_buffersink_get_frame error: {}", AVError(ret));
|
||||
return {};
|
||||
}
|
||||
|
||||
return dst_frame;
|
||||
}
|
||||
|
||||
DeinterlaceFilter::~DeinterlaceFilter() {
|
||||
avfilter_graph_free(&m_filter_graph);
|
||||
}
|
||||
|
||||
void DecodeApi::Reset() {
|
||||
m_deinterlace_filter.reset();
|
||||
m_hardware_context.reset();
|
||||
m_decoder_context.reset();
|
||||
m_decoder.reset();
|
||||
}
|
||||
|
||||
bool DecodeApi::Initialize(Tegra::Host1x::NvdecCommon::VideoCodec codec) {
|
||||
this->Reset();
|
||||
m_decoder.emplace(codec);
|
||||
m_decoder_context.emplace(*m_decoder);
|
||||
|
||||
// Enable GPU decoding if requested.
|
||||
if (Settings::values.nvdec_emulation.GetValue() == Settings::NvdecEmulation::Gpu) {
|
||||
m_hardware_context.emplace();
|
||||
m_hardware_context->InitializeForDecoder(*m_decoder_context, *m_decoder);
|
||||
}
|
||||
|
||||
// Open the decoder context.
|
||||
if (!m_decoder_context->OpenContext(*m_decoder)) {
|
||||
this->Reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DecodeApi::SendPacket(std::span<const u8> packet_data, size_t configuration_size) {
|
||||
FFmpeg::Packet packet(packet_data);
|
||||
return m_decoder_context->SendPacket(packet);
|
||||
}
|
||||
|
||||
void DecodeApi::ReceiveFrames(std::queue<std::unique_ptr<Frame>>& frame_queue) {
|
||||
// Receive raw frame from decoder.
|
||||
bool is_interlaced;
|
||||
auto frame = m_decoder_context->ReceiveFrame(&is_interlaced);
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_interlaced) {
|
||||
// If the frame is not interlaced, we can pend it now.
|
||||
frame_queue.push(std::move(frame));
|
||||
} else {
|
||||
// Create the deinterlacer if needed.
|
||||
if (!m_deinterlace_filter) {
|
||||
m_deinterlace_filter.emplace(*frame);
|
||||
}
|
||||
|
||||
// Add the frame we just received.
|
||||
if (!m_deinterlace_filter->AddSourceFrame(*frame)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Pend output fields.
|
||||
while (true) {
|
||||
auto filter_frame = m_deinterlace_filter->DrainSinkFrame();
|
||||
if (!filter_frame) {
|
||||
break;
|
||||
}
|
||||
|
||||
frame_queue.push(std::move(filter_frame));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace FFmpeg
|
||||
@@ -1,213 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/host1x/nvdec_common.h"
|
||||
|
||||
extern "C" {
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/opt.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace FFmpeg {
|
||||
|
||||
class Packet;
|
||||
class Frame;
|
||||
class Decoder;
|
||||
class HardwareContext;
|
||||
class DecoderContext;
|
||||
class DeinterlaceFilter;
|
||||
|
||||
// Wraps an AVPacket, a container for compressed bitstream data.
|
||||
class Packet {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(Packet);
|
||||
YUZU_NON_MOVEABLE(Packet);
|
||||
|
||||
explicit Packet(std::span<const u8> data);
|
||||
~Packet();
|
||||
|
||||
AVPacket* GetPacket() const {
|
||||
return m_packet;
|
||||
}
|
||||
|
||||
private:
|
||||
AVPacket* m_packet{};
|
||||
};
|
||||
|
||||
// Wraps an AVFrame, a container for audio and video stream data.
|
||||
class Frame {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(Frame);
|
||||
YUZU_NON_MOVEABLE(Frame);
|
||||
|
||||
explicit Frame();
|
||||
~Frame();
|
||||
|
||||
int GetWidth() const {
|
||||
return m_frame->width;
|
||||
}
|
||||
|
||||
int GetHeight() const {
|
||||
return m_frame->height;
|
||||
}
|
||||
|
||||
AVPixelFormat GetPixelFormat() const {
|
||||
return static_cast<AVPixelFormat>(m_frame->format);
|
||||
}
|
||||
|
||||
int GetStride(int plane) const {
|
||||
return m_frame->linesize[plane];
|
||||
}
|
||||
|
||||
int* GetStrides() const {
|
||||
return m_frame->linesize;
|
||||
}
|
||||
|
||||
u8* GetData(int plane) const {
|
||||
return m_frame->data[plane];
|
||||
}
|
||||
|
||||
u8** GetPlanes() const {
|
||||
return m_frame->data;
|
||||
}
|
||||
|
||||
void SetFormat(int format) {
|
||||
m_frame->format = format;
|
||||
}
|
||||
|
||||
AVFrame* GetFrame() const {
|
||||
return m_frame;
|
||||
}
|
||||
|
||||
private:
|
||||
AVFrame* m_frame{};
|
||||
};
|
||||
|
||||
// Wraps an AVCodec, a type containing information about a codec.
|
||||
class Decoder {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(Decoder);
|
||||
YUZU_NON_MOVEABLE(Decoder);
|
||||
|
||||
explicit Decoder(Tegra::Host1x::NvdecCommon::VideoCodec codec);
|
||||
~Decoder() = default;
|
||||
|
||||
bool SupportsDecodingOnDevice(AVPixelFormat* out_pix_fmt, AVHWDeviceType type) const;
|
||||
|
||||
const AVCodec* GetCodec() const {
|
||||
return m_codec;
|
||||
}
|
||||
|
||||
private:
|
||||
const AVCodec* m_codec{};
|
||||
};
|
||||
|
||||
// Wraps AVBufferRef for an accelerated decoder.
|
||||
class HardwareContext {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(HardwareContext);
|
||||
YUZU_NON_MOVEABLE(HardwareContext);
|
||||
|
||||
static std::vector<AVHWDeviceType> GetSupportedDeviceTypes();
|
||||
|
||||
explicit HardwareContext() = default;
|
||||
~HardwareContext();
|
||||
|
||||
bool InitializeForDecoder(DecoderContext& decoder_context, const Decoder& decoder);
|
||||
|
||||
AVBufferRef* GetBufferRef() const {
|
||||
return m_gpu_decoder;
|
||||
}
|
||||
|
||||
private:
|
||||
bool InitializeWithType(AVHWDeviceType type);
|
||||
|
||||
AVBufferRef* m_gpu_decoder{};
|
||||
};
|
||||
|
||||
// Wraps an AVCodecContext.
|
||||
class DecoderContext {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(DecoderContext);
|
||||
YUZU_NON_MOVEABLE(DecoderContext);
|
||||
|
||||
explicit DecoderContext(const Decoder& decoder);
|
||||
~DecoderContext();
|
||||
|
||||
void InitializeHardwareDecoder(const HardwareContext& context, AVPixelFormat hw_pix_fmt);
|
||||
bool OpenContext(const Decoder& decoder);
|
||||
bool SendPacket(const Packet& packet);
|
||||
std::unique_ptr<Frame> ReceiveFrame(bool* out_is_interlaced);
|
||||
|
||||
AVCodecContext* GetCodecContext() const {
|
||||
return m_codec_context;
|
||||
}
|
||||
|
||||
private:
|
||||
AVCodecContext* m_codec_context{};
|
||||
};
|
||||
|
||||
// Wraps an AVFilterGraph.
|
||||
class DeinterlaceFilter {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(DeinterlaceFilter);
|
||||
YUZU_NON_MOVEABLE(DeinterlaceFilter);
|
||||
|
||||
explicit DeinterlaceFilter(const Frame& frame);
|
||||
~DeinterlaceFilter();
|
||||
|
||||
bool AddSourceFrame(const Frame& frame);
|
||||
std::unique_ptr<Frame> DrainSinkFrame();
|
||||
|
||||
private:
|
||||
AVFilterGraph* m_filter_graph{};
|
||||
AVFilterContext* m_source_context{};
|
||||
AVFilterContext* m_sink_context{};
|
||||
bool m_initialized{};
|
||||
};
|
||||
|
||||
class DecodeApi {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(DecodeApi);
|
||||
YUZU_NON_MOVEABLE(DecodeApi);
|
||||
|
||||
DecodeApi() = default;
|
||||
~DecodeApi() = default;
|
||||
|
||||
bool Initialize(Tegra::Host1x::NvdecCommon::VideoCodec codec);
|
||||
void Reset();
|
||||
|
||||
bool SendPacket(std::span<const u8> packet_data, size_t configuration_size);
|
||||
void ReceiveFrames(std::queue<std::unique_ptr<Frame>>& frame_queue);
|
||||
|
||||
private:
|
||||
std::optional<FFmpeg::Decoder> m_decoder;
|
||||
std::optional<FFmpeg::DecoderContext> m_decoder_context;
|
||||
std::optional<FFmpeg::HardwareContext> m_hardware_context;
|
||||
std::optional<FFmpeg::DeinterlaceFilter> m_deinterlace_filter;
|
||||
};
|
||||
|
||||
} // namespace FFmpeg
|
||||
@@ -28,7 +28,7 @@ void Nvdec::ProcessMethod(u32 method, u32 argument) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<FFmpeg::Frame> Nvdec::GetFrame() {
|
||||
AVFramePtr Nvdec::GetFrame() {
|
||||
return codec->GetCurrentFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void ProcessMethod(u32 method, u32 argument);
|
||||
|
||||
/// Return most recently decoded frame
|
||||
[[nodiscard]] std::unique_ptr<FFmpeg::Frame> GetFrame();
|
||||
[[nodiscard]] AVFramePtr GetFrame();
|
||||
|
||||
private:
|
||||
/// Invoke codec to decode a frame
|
||||
|
||||
@@ -82,26 +82,27 @@ void Vic::Execute() {
|
||||
return;
|
||||
}
|
||||
const VicConfig config{host1x.MemoryManager().Read<u64>(config_struct_address + 0x20)};
|
||||
auto frame = nvdec_processor->GetFrame();
|
||||
const AVFramePtr frame_ptr = nvdec_processor->GetFrame();
|
||||
const auto* frame = frame_ptr.get();
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
const u64 surface_width = config.surface_width_minus1 + 1;
|
||||
const u64 surface_height = config.surface_height_minus1 + 1;
|
||||
if (static_cast<u64>(frame->GetWidth()) != surface_width ||
|
||||
static_cast<u64>(frame->GetHeight()) != surface_height) {
|
||||
if (static_cast<u64>(frame->width) != surface_width ||
|
||||
static_cast<u64>(frame->height) != surface_height) {
|
||||
// TODO: Properly support multiple video streams with differing frame dimensions
|
||||
LOG_WARNING(Service_NVDRV, "Frame dimensions {}x{} don't match surface dimensions {}x{}",
|
||||
frame->GetWidth(), frame->GetHeight(), surface_width, surface_height);
|
||||
frame->width, frame->height, surface_width, surface_height);
|
||||
}
|
||||
switch (config.pixel_format) {
|
||||
case VideoPixelFormat::RGBA8:
|
||||
case VideoPixelFormat::BGRA8:
|
||||
case VideoPixelFormat::RGBX8:
|
||||
WriteRGBFrame(std::move(frame), config);
|
||||
WriteRGBFrame(frame, config);
|
||||
break;
|
||||
case VideoPixelFormat::YUV420:
|
||||
WriteYUVFrame(std::move(frame), config);
|
||||
WriteYUVFrame(frame, config);
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown video pixel format {:X}", config.pixel_format.Value());
|
||||
@@ -109,14 +110,10 @@ void Vic::Execute() {
|
||||
}
|
||||
}
|
||||
|
||||
void Vic::WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config) {
|
||||
void Vic::WriteRGBFrame(const AVFrame* frame, const VicConfig& config) {
|
||||
LOG_TRACE(Service_NVDRV, "Writing RGB Frame");
|
||||
|
||||
const auto frame_width = frame->GetWidth();
|
||||
const auto frame_height = frame->GetHeight();
|
||||
const auto frame_format = frame->GetPixelFormat();
|
||||
|
||||
if (!scaler_ctx || frame_width != scaler_width || frame_height != scaler_height) {
|
||||
if (!scaler_ctx || frame->width != scaler_width || frame->height != scaler_height) {
|
||||
const AVPixelFormat target_format = [pixel_format = config.pixel_format]() {
|
||||
switch (pixel_format) {
|
||||
case VideoPixelFormat::RGBA8:
|
||||
@@ -132,26 +129,27 @@ void Vic::WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
|
||||
sws_freeContext(scaler_ctx);
|
||||
// Frames are decoded into either YUV420 or NV12 formats. Convert to desired RGB format
|
||||
scaler_ctx = sws_getContext(frame_width, frame_height, frame_format, frame_width,
|
||||
frame_height, target_format, 0, nullptr, nullptr, nullptr);
|
||||
scaler_width = frame_width;
|
||||
scaler_height = frame_height;
|
||||
scaler_ctx = sws_getContext(frame->width, frame->height,
|
||||
static_cast<AVPixelFormat>(frame->format), frame->width,
|
||||
frame->height, target_format, 0, nullptr, nullptr, nullptr);
|
||||
scaler_width = frame->width;
|
||||
scaler_height = frame->height;
|
||||
converted_frame_buffer.reset();
|
||||
}
|
||||
if (!converted_frame_buffer) {
|
||||
const size_t frame_size = frame_width * frame_height * 4;
|
||||
const size_t frame_size = frame->width * frame->height * 4;
|
||||
converted_frame_buffer = AVMallocPtr{static_cast<u8*>(av_malloc(frame_size)), av_free};
|
||||
}
|
||||
const std::array<int, 4> converted_stride{frame_width * 4, frame_height * 4, 0, 0};
|
||||
const std::array<int, 4> converted_stride{frame->width * 4, frame->height * 4, 0, 0};
|
||||
u8* const converted_frame_buf_addr{converted_frame_buffer.get()};
|
||||
sws_scale(scaler_ctx, frame->GetPlanes(), frame->GetStrides(), 0, frame_height,
|
||||
&converted_frame_buf_addr, converted_stride.data());
|
||||
sws_scale(scaler_ctx, frame->data, frame->linesize, 0, frame->height, &converted_frame_buf_addr,
|
||||
converted_stride.data());
|
||||
|
||||
// Use the minimum of surface/frame dimensions to avoid buffer overflow.
|
||||
const u32 surface_width = static_cast<u32>(config.surface_width_minus1) + 1;
|
||||
const u32 surface_height = static_cast<u32>(config.surface_height_minus1) + 1;
|
||||
const u32 width = std::min(surface_width, static_cast<u32>(frame_width));
|
||||
const u32 height = std::min(surface_height, static_cast<u32>(frame_height));
|
||||
const u32 width = std::min(surface_width, static_cast<u32>(frame->width));
|
||||
const u32 height = std::min(surface_height, static_cast<u32>(frame->height));
|
||||
const u32 blk_kind = static_cast<u32>(config.block_linear_kind);
|
||||
if (blk_kind != 0) {
|
||||
// swizzle pitch linear to block linear
|
||||
@@ -171,23 +169,23 @@ void Vic::WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
}
|
||||
}
|
||||
|
||||
void Vic::WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config) {
|
||||
void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) {
|
||||
LOG_TRACE(Service_NVDRV, "Writing YUV420 Frame");
|
||||
|
||||
const std::size_t surface_width = config.surface_width_minus1 + 1;
|
||||
const std::size_t surface_height = config.surface_height_minus1 + 1;
|
||||
const std::size_t aligned_width = (surface_width + 0xff) & ~0xffUL;
|
||||
// Use the minimum of surface/frame dimensions to avoid buffer overflow.
|
||||
const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->GetWidth()));
|
||||
const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->GetHeight()));
|
||||
const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width));
|
||||
const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height));
|
||||
|
||||
const auto stride = static_cast<size_t>(frame->GetStride(0));
|
||||
const auto stride = static_cast<size_t>(frame->linesize[0]);
|
||||
|
||||
luma_buffer.resize_destructive(aligned_width * surface_height);
|
||||
chroma_buffer.resize_destructive(aligned_width * surface_height / 2);
|
||||
|
||||
// Populate luma buffer
|
||||
const u8* luma_src = frame->GetData(0);
|
||||
const u8* luma_src = frame->data[0];
|
||||
for (std::size_t y = 0; y < frame_height; ++y) {
|
||||
const std::size_t src = y * stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
@@ -198,16 +196,16 @@ void Vic::WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
|
||||
// Chroma
|
||||
const std::size_t half_height = frame_height / 2;
|
||||
const auto half_stride = static_cast<size_t>(frame->GetStride(1));
|
||||
const auto half_stride = static_cast<size_t>(frame->linesize[1]);
|
||||
|
||||
switch (frame->GetPixelFormat()) {
|
||||
switch (frame->format) {
|
||||
case AV_PIX_FMT_YUV420P: {
|
||||
// Frame from FFmpeg software
|
||||
// Populate chroma buffer from both channels with interleaving.
|
||||
const std::size_t half_width = frame_width / 2;
|
||||
u8* chroma_buffer_data = chroma_buffer.data();
|
||||
const u8* chroma_b_src = frame->GetData(1);
|
||||
const u8* chroma_r_src = frame->GetData(2);
|
||||
const u8* chroma_b_src = frame->data[1];
|
||||
const u8* chroma_r_src = frame->data[2];
|
||||
for (std::size_t y = 0; y < half_height; ++y) {
|
||||
const std::size_t src = y * half_stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
@@ -221,7 +219,7 @@ void Vic::WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
case AV_PIX_FMT_NV12: {
|
||||
// Frame from VA-API hardware
|
||||
// This is already interleaved so just copy
|
||||
const u8* chroma_src = frame->GetData(1);
|
||||
const u8* chroma_src = frame->data[1];
|
||||
for (std::size_t y = 0; y < half_height; ++y) {
|
||||
const std::size_t src = y * stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
|
||||
@@ -39,9 +39,9 @@ public:
|
||||
private:
|
||||
void Execute();
|
||||
|
||||
void WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config);
|
||||
void WriteRGBFrame(const AVFrame* frame, const VicConfig& config);
|
||||
|
||||
void WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config);
|
||||
void WriteYUVFrame(const AVFrame* frame, const VicConfig& config);
|
||||
|
||||
Host1x& host1x;
|
||||
std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor;
|
||||
|
||||
@@ -252,7 +252,6 @@ file(GLOB_RECURSE THEMES ${PROJECT_SOURCE_DIR}/dist/qt_themes/*)
|
||||
if (ENABLE_QT_TRANSLATION)
|
||||
set(YUZU_QT_LANGUAGES "${PROJECT_SOURCE_DIR}/dist/languages" CACHE PATH "Path to the translation bundle for the Qt frontend")
|
||||
option(GENERATE_QT_TRANSLATION "Generate en.ts as the translation source file" OFF)
|
||||
option(WORKAROUND_BROKEN_LUPDATE "Run lupdate directly through CMake if Qt's convenience wrappers don't work" OFF)
|
||||
|
||||
# Update source TS file if enabled
|
||||
if (GENERATE_QT_TRANSLATION)
|
||||
@@ -260,51 +259,19 @@ if (ENABLE_QT_TRANSLATION)
|
||||
# these calls to qt_create_translation also creates a rule to generate en.qm which conflicts with providing english plurals
|
||||
# so we have to set a OUTPUT_LOCATION so that we don't have multiple rules to generate en.qm
|
||||
set_source_files_properties(${YUZU_QT_LANGUAGES}/en.ts PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
|
||||
if (WORKAROUND_BROKEN_LUPDATE)
|
||||
add_custom_command(OUTPUT ${YUZU_QT_LANGUAGES}/en.ts
|
||||
COMMAND lupdate
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
${SRCS}
|
||||
${UIS}
|
||||
-ts ${YUZU_QT_LANGUAGES}/en.ts
|
||||
DEPENDS
|
||||
${SRCS}
|
||||
${UIS}
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
else()
|
||||
qt_create_translation(QM_FILES
|
||||
${SRCS}
|
||||
${UIS}
|
||||
${YUZU_QT_LANGUAGES}/en.ts
|
||||
OPTIONS
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
)
|
||||
endif()
|
||||
qt_create_translation(QM_FILES
|
||||
${SRCS}
|
||||
${UIS}
|
||||
${YUZU_QT_LANGUAGES}/en.ts
|
||||
OPTIONS
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
)
|
||||
|
||||
# Generate plurals into dist/english_plurals/generated_en.ts so it can be used to revise dist/english_plurals/en.ts
|
||||
set(GENERATED_PLURALS_FILE ${PROJECT_SOURCE_DIR}/dist/english_plurals/generated_en.ts)
|
||||
set_source_files_properties(${GENERATED_PLURALS_FILE} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/plurals")
|
||||
if (WORKAROUND_BROKEN_LUPDATE)
|
||||
add_custom_command(OUTPUT ${GENERATED_PLURALS_FILE}
|
||||
COMMAND lupdate
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
${SRCS}
|
||||
${UIS}
|
||||
-ts ${GENERATED_PLURALS_FILE}
|
||||
DEPENDS
|
||||
${SRCS}
|
||||
${UIS}
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
else()
|
||||
qt_create_translation(QM_FILES ${SRCS} ${UIS} ${GENERATED_PLURALS_FILE} OPTIONS -pluralonly -source-language en_US -target-language en_US)
|
||||
endif()
|
||||
qt_create_translation(QM_FILES ${SRCS} ${UIS} ${GENERATED_PLURALS_FILE} OPTIONS -pluralonly -source-language en_US -target-language en_US)
|
||||
|
||||
add_custom_target(translation ALL DEPENDS ${YUZU_QT_LANGUAGES}/en.ts ${GENERATED_PLURALS_FILE})
|
||||
endif()
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/time_zone.h"
|
||||
#include "yuzu/configuration/shared_translation.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <QCoreApplication>
|
||||
#include <QWidget>
|
||||
#include "common/settings.h"
|
||||
#include "common/settings_enums.h"
|
||||
#include "common/settings_setting.h"
|
||||
#include "common/time_zone.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
|
||||
namespace ConfigurationShared {
|
||||
@@ -22,135 +21,123 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); };
|
||||
|
||||
#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \
|
||||
translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}})
|
||||
translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{tr((NAME)), tr((TOOLTIP))}})
|
||||
|
||||
// A setting can be ignored by giving it a blank name
|
||||
|
||||
// Audio
|
||||
INSERT(Settings, sink_id, tr("Output Engine:"), QStringLiteral());
|
||||
INSERT(Settings, audio_output_device_id, tr("Output Device:"), QStringLiteral());
|
||||
INSERT(Settings, audio_input_device_id, tr("Input Device:"), QStringLiteral());
|
||||
INSERT(Settings, audio_muted, tr("Mute audio"), QStringLiteral());
|
||||
INSERT(Settings, volume, tr("Volume:"), QStringLiteral());
|
||||
INSERT(Settings, dump_audio_commands, QStringLiteral(), QStringLiteral());
|
||||
INSERT(UISettings, mute_when_in_background, tr("Mute audio when in background"),
|
||||
QStringLiteral());
|
||||
INSERT(Settings, sink_id, "Output Engine:", "");
|
||||
INSERT(Settings, audio_output_device_id, "Output Device:", "");
|
||||
INSERT(Settings, audio_input_device_id, "Input Device:", "");
|
||||
INSERT(Settings, audio_muted, "Mute audio", "");
|
||||
INSERT(Settings, volume, "Volume:", "");
|
||||
INSERT(Settings, dump_audio_commands, "", "");
|
||||
INSERT(UISettings, mute_when_in_background, "Mute audio when in background", "");
|
||||
|
||||
// Core
|
||||
INSERT(Settings, use_multi_core, tr("Multicore CPU Emulation"), QStringLiteral());
|
||||
INSERT(Settings, memory_layout_mode, tr("Memory Layout"), QStringLiteral());
|
||||
INSERT(Settings, use_speed_limit, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, speed_limit, tr("Limit Speed Percent"), QStringLiteral());
|
||||
INSERT(Settings, use_multi_core, "Multicore CPU Emulation", "");
|
||||
INSERT(Settings, memory_layout_mode, "Memory Layout", "");
|
||||
INSERT(Settings, use_speed_limit, "", "");
|
||||
INSERT(Settings, speed_limit, "Limit Speed Percent", "");
|
||||
|
||||
// Cpu
|
||||
INSERT(Settings, cpu_accuracy, tr("Accuracy:"), QStringLiteral());
|
||||
INSERT(Settings, cpu_accuracy, "Accuracy:", "");
|
||||
|
||||
// Cpu Debug
|
||||
|
||||
// Cpu Unsafe
|
||||
INSERT(Settings, cpuopt_unsafe_unfuse_fma,
|
||||
"Unfuse FMA (improve performance on CPUs without FMA)",
|
||||
"This option improves speed by reducing accuracy of fused-multiply-add instructions on "
|
||||
"CPUs without native FMA support.");
|
||||
INSERT(Settings, cpuopt_unsafe_reduce_fp_error, "Faster FRSQRTE and FRECPE",
|
||||
"This option improves the speed of some approximate floating-point functions by using "
|
||||
"less accurate native approximations.");
|
||||
INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr, "Faster ASIMD instructions (32 bits only)",
|
||||
"This option improves the speed of 32 bits ASIMD floating-point functions by running "
|
||||
"with incorrect rounding modes.");
|
||||
INSERT(Settings, cpuopt_unsafe_inaccurate_nan, "Inaccurate NaN handling",
|
||||
"This option improves speed by removing NaN checking. Please note this also reduces "
|
||||
"accuracy of certain floating-point instructions.");
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_unfuse_fma,
|
||||
tr("Unfuse FMA (improve performance on CPUs without FMA)"),
|
||||
tr("This option improves speed by reducing accuracy of fused-multiply-add instructions on "
|
||||
"CPUs without native FMA support."));
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_reduce_fp_error, tr("Faster FRSQRTE and FRECPE"),
|
||||
tr("This option improves the speed of some approximate floating-point functions by using "
|
||||
"less accurate native approximations."));
|
||||
INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr,
|
||||
tr("Faster ASIMD instructions (32 bits only)"),
|
||||
tr("This option improves the speed of 32 bits ASIMD floating-point functions by running "
|
||||
"with incorrect rounding modes."));
|
||||
INSERT(Settings, cpuopt_unsafe_inaccurate_nan, tr("Inaccurate NaN handling"),
|
||||
tr("This option improves speed by removing NaN checking. Please note this also reduces "
|
||||
"accuracy of certain floating-point instructions."));
|
||||
INSERT(Settings, cpuopt_unsafe_fastmem_check, tr("Disable address space checks"),
|
||||
tr("This option improves speed by eliminating a safety check before every memory "
|
||||
"read/write "
|
||||
"in guest. Disabling it may allow a game to read/write the emulator's memory."));
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_ignore_global_monitor, tr("Ignore global monitor"),
|
||||
tr("This option improves speed by relying only on the semantics of cmpxchg to ensure "
|
||||
Settings, cpuopt_unsafe_fastmem_check, "Disable address space checks",
|
||||
"This option improves speed by eliminating a safety check before every memory read/write "
|
||||
"in guest. Disabling it may allow a game to read/write the emulator's memory.");
|
||||
INSERT(Settings, cpuopt_unsafe_ignore_global_monitor, "Ignore global monitor",
|
||||
"This option improves speed by relying only on the semantics of cmpxchg to ensure "
|
||||
"safety of exclusive access instructions. Please note this may result in deadlocks and "
|
||||
"other race conditions."));
|
||||
"other race conditions.");
|
||||
|
||||
// Renderer
|
||||
INSERT(Settings, renderer_backend, tr("API:"), QStringLiteral());
|
||||
INSERT(Settings, vulkan_device, tr("Device:"), QStringLiteral());
|
||||
INSERT(Settings, shader_backend, tr("Shader Backend:"), QStringLiteral());
|
||||
INSERT(Settings, resolution_setup, tr("Resolution:"), QStringLiteral());
|
||||
INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QStringLiteral());
|
||||
INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"), QStringLiteral());
|
||||
INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"), QStringLiteral());
|
||||
INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"), QStringLiteral());
|
||||
INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"), QStringLiteral());
|
||||
INSERT(Settings, use_disk_shader_cache, tr("Use disk pipeline cache"), QStringLiteral());
|
||||
INSERT(Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"),
|
||||
QStringLiteral());
|
||||
INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"), QStringLiteral());
|
||||
INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"), QStringLiteral());
|
||||
INSERT(Settings, astc_recompression, tr("ASTC Recompression Method:"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, vsync_mode, tr("VSync Mode:"),
|
||||
tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen "
|
||||
INSERT(Settings, renderer_backend, "API:", "");
|
||||
INSERT(Settings, vulkan_device, "Device:", "");
|
||||
INSERT(Settings, shader_backend, "Shader Backend:", "");
|
||||
INSERT(Settings, resolution_setup, "Resolution:", "");
|
||||
INSERT(Settings, scaling_filter, "Window Adapting Filter:", "");
|
||||
INSERT(Settings, fsr_sharpening_slider, "FSR Sharpness:", "");
|
||||
INSERT(Settings, anti_aliasing, "Anti-Aliasing Method:", "");
|
||||
INSERT(Settings, fullscreen_mode, "Fullscreen Mode:", "");
|
||||
INSERT(Settings, aspect_ratio, "Aspect Ratio:", "");
|
||||
INSERT(Settings, use_disk_shader_cache, "Use disk pipeline cache", "");
|
||||
INSERT(Settings, use_asynchronous_gpu_emulation, "Use asynchronous GPU emulation", "");
|
||||
INSERT(Settings, nvdec_emulation, "NVDEC emulation:", "");
|
||||
INSERT(Settings, accelerate_astc, "ASTC Decoding Method:", "");
|
||||
INSERT(Settings, astc_recompression, "ASTC Recompression Method:", "");
|
||||
INSERT(Settings, vsync_mode, "VSync Mode:",
|
||||
"FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen "
|
||||
"refresh rate.\nFIFO Relaxed is similar to FIFO but allows tearing as it recovers from "
|
||||
"a slow down.\nMailbox can have lower latency than FIFO and does not tear but may drop "
|
||||
"frames.\nImmediate (no synchronization) just presents whatever is available and can "
|
||||
"exhibit tearing."));
|
||||
INSERT(Settings, bg_red, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, bg_green, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, bg_blue, QStringLiteral(), QStringLiteral());
|
||||
"exhibit tearing.");
|
||||
INSERT(Settings, bg_red, "", "");
|
||||
INSERT(Settings, bg_green, "", "");
|
||||
INSERT(Settings, bg_blue, "", "");
|
||||
|
||||
// Renderer (Advanced Graphics)
|
||||
INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"),
|
||||
QStringLiteral());
|
||||
INSERT(
|
||||
Settings, renderer_force_max_clock, tr("Force maximum clocks (Vulkan only)"),
|
||||
tr("Runs work in the background while waiting for graphics commands to keep the GPU from "
|
||||
"lowering its clock speed."));
|
||||
INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"), QStringLiteral());
|
||||
INSERT(Settings, gpu_accuracy, tr("Accuracy Level:"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, use_asynchronous_shaders, tr("Use asynchronous shader building (Hack)"),
|
||||
tr("Enables asynchronous shader compilation, which may reduce shader stutter. This feature "
|
||||
"is experimental."));
|
||||
INSERT(Settings, use_fast_gpu_time, tr("Use Fast GPU Time (Hack)"),
|
||||
tr("Enables Fast GPU Time. This option will force most games to run at their highest "
|
||||
"native resolution."));
|
||||
INSERT(Settings, use_vulkan_driver_pipeline_cache, tr("Use Vulkan pipeline cache"),
|
||||
tr("Enables GPU vendor-specific pipeline cache. This option can improve shader loading "
|
||||
"time significantly in cases where the Vulkan driver does not store pipeline cache "
|
||||
"files internally."));
|
||||
INSERT(
|
||||
Settings, enable_compute_pipelines, tr("Enable Compute Pipelines (Intel Vulkan Only)"),
|
||||
tr("Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
|
||||
INSERT(Settings, async_presentation, "Enable asynchronous presentation (Vulkan only)", "");
|
||||
INSERT(Settings, renderer_force_max_clock, "Force maximum clocks (Vulkan only)",
|
||||
"Runs work in the background while waiting for graphics commands to keep the GPU from "
|
||||
"lowering its clock speed.");
|
||||
INSERT(Settings, max_anisotropy, "Anisotropic Filtering:", "");
|
||||
INSERT(Settings, gpu_accuracy, "Accuracy Level:", "");
|
||||
INSERT(Settings, use_asynchronous_shaders, "Use asynchronous shader building (Hack)",
|
||||
"Enables asynchronous shader compilation, which may reduce shader stutter. This feature "
|
||||
"is experimental.");
|
||||
INSERT(Settings, use_fast_gpu_time, "Use Fast GPU Time (Hack)",
|
||||
"Enables Fast GPU Time. This option will force most games to run at their highest "
|
||||
"native resolution.");
|
||||
INSERT(Settings, use_vulkan_driver_pipeline_cache, "Use Vulkan pipeline cache",
|
||||
"Enables GPU vendor-specific pipeline cache. This option can improve shader loading "
|
||||
"time significantly in cases where the Vulkan driver does not store pipeline cache "
|
||||
"files internally.");
|
||||
INSERT(Settings, enable_compute_pipelines, "Enable Compute Pipelines (Intel Vulkan Only)",
|
||||
"Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
|
||||
"proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled "
|
||||
"on all other drivers."));
|
||||
INSERT(
|
||||
Settings, use_reactive_flushing, tr("Enable Reactive Flushing"),
|
||||
tr("Uses reactive flushing instead of predictive flushing, allowing more accurate memory "
|
||||
"syncing."));
|
||||
INSERT(Settings, use_video_framerate, tr("Sync to framerate of video playback"),
|
||||
tr("Run the game at normal speed during video playback, even when the framerate is "
|
||||
"unlocked."));
|
||||
INSERT(Settings, barrier_feedback_loops, tr("Barrier feedback loops"),
|
||||
tr("Improves rendering of transparency effects in specific games."));
|
||||
"on all other drivers.");
|
||||
INSERT(Settings, use_reactive_flushing, "Enable Reactive Flushing",
|
||||
"Uses reactive flushing instead of predictive flushing, allowing more accurate memory "
|
||||
"syncing.");
|
||||
INSERT(Settings, use_video_framerate, "Sync to framerate of video playback",
|
||||
"Run the game at normal speed during video playback, even when the framerate is "
|
||||
"unlocked.");
|
||||
INSERT(Settings, barrier_feedback_loops, "Barrier feedback loops",
|
||||
"Improves rendering of transparency effects in specific games.");
|
||||
|
||||
// Renderer (Debug)
|
||||
|
||||
// System
|
||||
INSERT(Settings, rng_seed, tr("RNG Seed"), QStringLiteral());
|
||||
INSERT(Settings, rng_seed_enabled, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, device_name, tr("Device Name"), QStringLiteral());
|
||||
INSERT(Settings, custom_rtc, tr("Custom RTC"), QStringLiteral());
|
||||
INSERT(Settings, custom_rtc_enabled, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, language_index, tr("Language:"),
|
||||
tr("Note: this can be overridden when region setting is auto-select"));
|
||||
INSERT(Settings, region_index, tr("Region:"), QStringLiteral());
|
||||
INSERT(Settings, time_zone_index, tr("Time Zone:"), QStringLiteral());
|
||||
INSERT(Settings, sound_index, tr("Sound Output Mode:"), QStringLiteral());
|
||||
INSERT(Settings, use_docked_mode, tr("Console Mode:"), QStringLiteral());
|
||||
INSERT(Settings, current_user, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, rng_seed, "RNG Seed", "");
|
||||
INSERT(Settings, rng_seed_enabled, "", "");
|
||||
INSERT(Settings, device_name, "Device Name", "");
|
||||
INSERT(Settings, custom_rtc, "Custom RTC", "");
|
||||
INSERT(Settings, custom_rtc_enabled, "", "");
|
||||
INSERT(Settings, language_index,
|
||||
"Language:", "Note: this can be overridden when region setting is auto-select");
|
||||
INSERT(Settings, region_index, "Region:", "");
|
||||
INSERT(Settings, time_zone_index, "Time Zone:", "");
|
||||
INSERT(Settings, sound_index, "Sound Output Mode:", "");
|
||||
INSERT(Settings, use_docked_mode, "Console Mode:", "");
|
||||
INSERT(Settings, current_user, "", "");
|
||||
|
||||
// Controls
|
||||
|
||||
@@ -167,14 +154,11 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
// Ui
|
||||
|
||||
// Ui General
|
||||
INSERT(UISettings, select_user_on_boot, tr("Prompt for user on game boot"), QStringLiteral());
|
||||
INSERT(UISettings, pause_when_in_background, tr("Pause emulation when in background"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, confirm_before_stopping, tr("Confirm before stopping emulation"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), QStringLiteral());
|
||||
INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, select_user_on_boot, "Prompt for user on game boot", "");
|
||||
INSERT(UISettings, pause_when_in_background, "Pause emulation when in background", "");
|
||||
INSERT(UISettings, confirm_before_stopping, "Confirm before stopping emulation", "");
|
||||
INSERT(UISettings, hide_mouse, "Hide mouse on inactivity", "");
|
||||
INSERT(UISettings, controller_applet_disabled, "Disable controller applet", "");
|
||||
|
||||
// Ui Debugging
|
||||
|
||||
@@ -194,141 +178,140 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
||||
return parent->tr(text, context);
|
||||
};
|
||||
|
||||
#define PAIR(ENUM, VALUE, TRANSLATION) {static_cast<u32>(Settings::ENUM::VALUE), (TRANSLATION)}
|
||||
#define PAIR(ENUM, VALUE, TRANSLATION) \
|
||||
{ static_cast<u32>(Settings::ENUM::VALUE), tr(TRANSLATION) }
|
||||
#define CTX_PAIR(ENUM, VALUE, TRANSLATION, CONTEXT) \
|
||||
{ static_cast<u32>(Settings::ENUM::VALUE), tr(TRANSLATION, CONTEXT) }
|
||||
|
||||
// Intentionally skipping VSyncMode to let the UI fill that one out
|
||||
|
||||
translations->insert({Settings::EnumMetadata<Settings::AstcDecodeMode>::Index(),
|
||||
{
|
||||
PAIR(AstcDecodeMode, Cpu, tr("CPU")),
|
||||
PAIR(AstcDecodeMode, Gpu, tr("GPU")),
|
||||
PAIR(AstcDecodeMode, CpuAsynchronous, tr("CPU Asynchronous")),
|
||||
PAIR(AstcDecodeMode, Cpu, "CPU"),
|
||||
PAIR(AstcDecodeMode, Gpu, "GPU"),
|
||||
PAIR(AstcDecodeMode, CpuAsynchronous, "CPU Asynchronous"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AstcRecompression>::Index(),
|
||||
{
|
||||
PAIR(AstcRecompression, Uncompressed, "Uncompressed (Best quality)"),
|
||||
PAIR(AstcRecompression, Bc1, "BC1 (Low quality)"),
|
||||
PAIR(AstcRecompression, Bc3, "BC3 (Medium quality)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::AstcRecompression>::Index(),
|
||||
{
|
||||
PAIR(AstcRecompression, Uncompressed, tr("Uncompressed (Best quality)")),
|
||||
PAIR(AstcRecompression, Bc1, tr("BC1 (Low quality)")),
|
||||
PAIR(AstcRecompression, Bc3, tr("BC3 (Medium quality)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(),
|
||||
{
|
||||
#ifdef HAS_OPENGL
|
||||
PAIR(RendererBackend, OpenGL, tr("OpenGL")),
|
||||
PAIR(RendererBackend, OpenGL, "OpenGL"),
|
||||
#endif
|
||||
PAIR(RendererBackend, Vulkan, tr("Vulkan")),
|
||||
PAIR(RendererBackend, Null, tr("Null")),
|
||||
PAIR(RendererBackend, Vulkan, "Vulkan"),
|
||||
PAIR(RendererBackend, Null, "Null"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
|
||||
{
|
||||
PAIR(ShaderBackend, Glsl, "GLSL"),
|
||||
PAIR(ShaderBackend, Glasm, "GLASM (Assembly Shaders, NVIDIA Only)"),
|
||||
PAIR(ShaderBackend, SpirV, "SPIR-V (Experimental, Mesa Only)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
|
||||
{
|
||||
PAIR(ShaderBackend, Glsl, tr("GLSL")),
|
||||
PAIR(ShaderBackend, Glasm, tr("GLASM (Assembly Shaders, NVIDIA Only)")),
|
||||
PAIR(ShaderBackend, SpirV, tr("SPIR-V (Experimental, Mesa Only)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::GpuAccuracy>::Index(),
|
||||
{
|
||||
PAIR(GpuAccuracy, Normal, tr("Normal")),
|
||||
PAIR(GpuAccuracy, High, tr("High")),
|
||||
PAIR(GpuAccuracy, Extreme, tr("Extreme")),
|
||||
PAIR(GpuAccuracy, Normal, "Normal"),
|
||||
PAIR(GpuAccuracy, High, "High"),
|
||||
PAIR(GpuAccuracy, Extreme, "Extreme"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
|
||||
{
|
||||
PAIR(CpuAccuracy, Auto, "Auto"),
|
||||
PAIR(CpuAccuracy, Accurate, "Accurate"),
|
||||
PAIR(CpuAccuracy, Unsafe, "Unsafe"),
|
||||
PAIR(CpuAccuracy, Paranoid, "Paranoid (disables most optimizations)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
|
||||
{
|
||||
PAIR(CpuAccuracy, Auto, tr("Auto")),
|
||||
PAIR(CpuAccuracy, Accurate, tr("Accurate")),
|
||||
PAIR(CpuAccuracy, Unsafe, tr("Unsafe")),
|
||||
PAIR(CpuAccuracy, Paranoid, tr("Paranoid (disables most optimizations)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::FullscreenMode>::Index(),
|
||||
{
|
||||
PAIR(FullscreenMode, Borderless, tr("Borderless Windowed")),
|
||||
PAIR(FullscreenMode, Exclusive, tr("Exclusive Fullscreen")),
|
||||
PAIR(FullscreenMode, Borderless, "Borderless Windowed"),
|
||||
PAIR(FullscreenMode, Exclusive, "Exclusive Fullscreen"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::NvdecEmulation>::Index(),
|
||||
{
|
||||
PAIR(NvdecEmulation, Off, tr("No Video Output")),
|
||||
PAIR(NvdecEmulation, Cpu, tr("CPU Video Decoding")),
|
||||
PAIR(NvdecEmulation, Gpu, tr("GPU Video Decoding (Default)")),
|
||||
PAIR(NvdecEmulation, Off, "No Video Output"),
|
||||
PAIR(NvdecEmulation, Cpu, "CPU Video Decoding"),
|
||||
PAIR(NvdecEmulation, Gpu, "GPU Video Decoding (Default)"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ResolutionSetup>::Index(),
|
||||
{
|
||||
PAIR(ResolutionSetup, Res1_2X, "0.5X (360p/540p) [EXPERIMENTAL]"),
|
||||
PAIR(ResolutionSetup, Res3_4X, "0.75X (540p/810p) [EXPERIMENTAL]"),
|
||||
PAIR(ResolutionSetup, Res1X, "1X (720p/1080p)"),
|
||||
PAIR(ResolutionSetup, Res3_2X, "1.5X (1080p/1620p) [EXPERIMENTAL]"),
|
||||
PAIR(ResolutionSetup, Res2X, "2X (1440p/2160p)"),
|
||||
PAIR(ResolutionSetup, Res3X, "3X (2160p/3240p)"),
|
||||
PAIR(ResolutionSetup, Res4X, "4X (2880p/4320p)"),
|
||||
PAIR(ResolutionSetup, Res5X, "5X (3600p/5400p)"),
|
||||
PAIR(ResolutionSetup, Res6X, "6X (4320p/6480p)"),
|
||||
PAIR(ResolutionSetup, Res7X, "7X (5040p/7560p)"),
|
||||
PAIR(ResolutionSetup, Res8X, "8X (5760p/8640p)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ResolutionSetup>::Index(),
|
||||
{
|
||||
PAIR(ResolutionSetup, Res1_2X, tr("0.5X (360p/540p) [EXPERIMENTAL]")),
|
||||
PAIR(ResolutionSetup, Res3_4X, tr("0.75X (540p/810p) [EXPERIMENTAL]")),
|
||||
PAIR(ResolutionSetup, Res1X, tr("1X (720p/1080p)")),
|
||||
PAIR(ResolutionSetup, Res3_2X, tr("1.5X (1080p/1620p) [EXPERIMENTAL]")),
|
||||
PAIR(ResolutionSetup, Res2X, tr("2X (1440p/2160p)")),
|
||||
PAIR(ResolutionSetup, Res3X, tr("3X (2160p/3240p)")),
|
||||
PAIR(ResolutionSetup, Res4X, tr("4X (2880p/4320p)")),
|
||||
PAIR(ResolutionSetup, Res5X, tr("5X (3600p/5400p)")),
|
||||
PAIR(ResolutionSetup, Res6X, tr("6X (4320p/6480p)")),
|
||||
PAIR(ResolutionSetup, Res7X, tr("7X (5040p/7560p)")),
|
||||
PAIR(ResolutionSetup, Res8X, tr("8X (5760p/8640p)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ScalingFilter>::Index(),
|
||||
{
|
||||
PAIR(ScalingFilter, NearestNeighbor, tr("Nearest Neighbor")),
|
||||
PAIR(ScalingFilter, Bilinear, tr("Bilinear")),
|
||||
PAIR(ScalingFilter, Bicubic, tr("Bicubic")),
|
||||
PAIR(ScalingFilter, Gaussian, tr("Gaussian")),
|
||||
PAIR(ScalingFilter, ScaleForce, tr("ScaleForce")),
|
||||
PAIR(ScalingFilter, Fsr, tr("AMD FidelityFX™️ Super Resolution")),
|
||||
PAIR(ScalingFilter, NearestNeighbor, "Nearest Neighbor"),
|
||||
PAIR(ScalingFilter, Bilinear, "Bilinear"),
|
||||
PAIR(ScalingFilter, Bicubic, "Bicubic"),
|
||||
PAIR(ScalingFilter, Gaussian, "Gaussian"),
|
||||
PAIR(ScalingFilter, ScaleForce, "ScaleForce"),
|
||||
PAIR(ScalingFilter, Fsr, "AMD FidelityFX™️ Super Resolution"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AntiAliasing>::Index(),
|
||||
{
|
||||
PAIR(AntiAliasing, None, tr("None")),
|
||||
PAIR(AntiAliasing, Fxaa, tr("FXAA")),
|
||||
PAIR(AntiAliasing, Smaa, tr("SMAA")),
|
||||
PAIR(AntiAliasing, None, "None"),
|
||||
PAIR(AntiAliasing, Fxaa, "FXAA"),
|
||||
PAIR(AntiAliasing, Smaa, "SMAA"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AspectRatio>::Index(),
|
||||
{
|
||||
PAIR(AspectRatio, R16_9, tr("Default (16:9)")),
|
||||
PAIR(AspectRatio, R4_3, tr("Force 4:3")),
|
||||
PAIR(AspectRatio, R21_9, tr("Force 21:9")),
|
||||
PAIR(AspectRatio, R16_10, tr("Force 16:10")),
|
||||
PAIR(AspectRatio, Stretch, tr("Stretch to Window")),
|
||||
PAIR(AspectRatio, R16_9, "Default (16:9)"),
|
||||
PAIR(AspectRatio, R4_3, "Force 4:3"),
|
||||
PAIR(AspectRatio, R21_9, "Force 21:9"),
|
||||
PAIR(AspectRatio, R16_10, "Force 16:10"),
|
||||
PAIR(AspectRatio, Stretch, "Stretch to Window"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AnisotropyMode>::Index(),
|
||||
{
|
||||
PAIR(AnisotropyMode, Automatic, tr("Automatic")),
|
||||
PAIR(AnisotropyMode, Default, tr("Default")),
|
||||
PAIR(AnisotropyMode, X2, tr("2x")),
|
||||
PAIR(AnisotropyMode, X4, tr("4x")),
|
||||
PAIR(AnisotropyMode, X8, tr("8x")),
|
||||
PAIR(AnisotropyMode, X16, tr("16x")),
|
||||
PAIR(AnisotropyMode, Automatic, "Automatic"),
|
||||
PAIR(AnisotropyMode, Default, "Default"),
|
||||
PAIR(AnisotropyMode, X2, "2x"),
|
||||
PAIR(AnisotropyMode, X4, "4x"),
|
||||
PAIR(AnisotropyMode, X8, "8x"),
|
||||
PAIR(AnisotropyMode, X16, "16x"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::Language>::Index(),
|
||||
{
|
||||
PAIR(Language, Japanese, tr("Japanese (日本語)")),
|
||||
PAIR(Language, EnglishAmerican, tr("American English")),
|
||||
PAIR(Language, French, tr("French (français)")),
|
||||
PAIR(Language, German, tr("German (Deutsch)")),
|
||||
PAIR(Language, Italian, tr("Italian (italiano)")),
|
||||
PAIR(Language, Spanish, tr("Spanish (español)")),
|
||||
PAIR(Language, Chinese, tr("Chinese")),
|
||||
PAIR(Language, Korean, tr("Korean (한국어)")),
|
||||
PAIR(Language, Dutch, tr("Dutch (Nederlands)")),
|
||||
PAIR(Language, Portuguese, tr("Portuguese (português)")),
|
||||
PAIR(Language, Russian, tr("Russian (Русский)")),
|
||||
PAIR(Language, Taiwanese, tr("Taiwanese")),
|
||||
PAIR(Language, EnglishBritish, tr("British English")),
|
||||
PAIR(Language, FrenchCanadian, tr("Canadian French")),
|
||||
PAIR(Language, SpanishLatin, tr("Latin American Spanish")),
|
||||
PAIR(Language, ChineseSimplified, tr("Simplified Chinese")),
|
||||
PAIR(Language, ChineseTraditional, tr("Traditional Chinese (正體中文)")),
|
||||
PAIR(Language, PortugueseBrazilian, tr("Brazilian Portuguese (português do Brasil)")),
|
||||
PAIR(Language, Japanese, "Japanese (日本語)"),
|
||||
PAIR(Language, EnglishAmerican, "American English"),
|
||||
PAIR(Language, French, "French (français)"),
|
||||
PAIR(Language, German, "German (Deutsch)"),
|
||||
PAIR(Language, Italian, "Italian (italiano)"),
|
||||
PAIR(Language, Spanish, "Spanish (español)"),
|
||||
PAIR(Language, Chinese, "Chinese"),
|
||||
PAIR(Language, Korean, "Korean (한국어)"),
|
||||
PAIR(Language, Dutch, "Dutch (Nederlands)"),
|
||||
PAIR(Language, Portuguese, "Portuguese (português)"),
|
||||
PAIR(Language, Russian, "Russian (Русский)"),
|
||||
PAIR(Language, Taiwanese, "Taiwanese"),
|
||||
PAIR(Language, EnglishBritish, "British English"),
|
||||
PAIR(Language, FrenchCanadian, "Canadian French"),
|
||||
PAIR(Language, SpanishLatin, "Latin American Spanish"),
|
||||
PAIR(Language, ChineseSimplified, "Simplified Chinese"),
|
||||
PAIR(Language, ChineseTraditional, "Traditional Chinese (正體中文)"),
|
||||
PAIR(Language, PortugueseBrazilian, "Brazilian Portuguese (português do Brasil)"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::Region>::Index(),
|
||||
{
|
||||
PAIR(Region, Japan, tr("Japan")),
|
||||
PAIR(Region, Usa, tr("USA")),
|
||||
PAIR(Region, Europe, tr("Europe")),
|
||||
PAIR(Region, Australia, tr("Australia")),
|
||||
PAIR(Region, China, tr("China")),
|
||||
PAIR(Region, Korea, tr("Korea")),
|
||||
PAIR(Region, Taiwan, tr("Taiwan")),
|
||||
PAIR(Region, Japan, "Japan"),
|
||||
PAIR(Region, Usa, "USA"),
|
||||
PAIR(Region, Europe, "Europe"),
|
||||
PAIR(Region, Australia, "Australia"),
|
||||
PAIR(Region, China, "China"),
|
||||
PAIR(Region, Korea, "Korea"),
|
||||
PAIR(Region, Taiwan, "Taiwan"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::TimeZone>::Index(),
|
||||
@@ -340,74 +323,72 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
||||
{static_cast<u32>(Settings::TimeZone::Default),
|
||||
tr("Default (%1)", "Default time zone")
|
||||
.arg(QString::fromStdString(Common::TimeZone::GetDefaultTimeZone()))},
|
||||
PAIR(TimeZone, Cet, tr("CET")),
|
||||
PAIR(TimeZone, Cst6Cdt, tr("CST6CDT")),
|
||||
PAIR(TimeZone, Cuba, tr("Cuba")),
|
||||
PAIR(TimeZone, Eet, tr("EET")),
|
||||
PAIR(TimeZone, Egypt, tr("Egypt")),
|
||||
PAIR(TimeZone, Eire, tr("Eire")),
|
||||
PAIR(TimeZone, Est, tr("EST")),
|
||||
PAIR(TimeZone, Est5Edt, tr("EST5EDT")),
|
||||
PAIR(TimeZone, Gb, tr("GB")),
|
||||
PAIR(TimeZone, GbEire, tr("GB-Eire")),
|
||||
PAIR(TimeZone, Gmt, tr("GMT")),
|
||||
PAIR(TimeZone, GmtPlusZero, tr("GMT+0")),
|
||||
PAIR(TimeZone, GmtMinusZero, tr("GMT-0")),
|
||||
PAIR(TimeZone, GmtZero, tr("GMT0")),
|
||||
PAIR(TimeZone, Greenwich, tr("Greenwich")),
|
||||
PAIR(TimeZone, Hongkong, tr("Hongkong")),
|
||||
PAIR(TimeZone, Hst, tr("HST")),
|
||||
PAIR(TimeZone, Iceland, tr("Iceland")),
|
||||
PAIR(TimeZone, Iran, tr("Iran")),
|
||||
PAIR(TimeZone, Israel, tr("Israel")),
|
||||
PAIR(TimeZone, Jamaica, tr("Jamaica")),
|
||||
PAIR(TimeZone, Japan, tr("Japan")),
|
||||
PAIR(TimeZone, Kwajalein, tr("Kwajalein")),
|
||||
PAIR(TimeZone, Libya, tr("Libya")),
|
||||
PAIR(TimeZone, Met, tr("MET")),
|
||||
PAIR(TimeZone, Mst, tr("MST")),
|
||||
PAIR(TimeZone, Mst7Mdt, tr("MST7MDT")),
|
||||
PAIR(TimeZone, Navajo, tr("Navajo")),
|
||||
PAIR(TimeZone, Nz, tr("NZ")),
|
||||
PAIR(TimeZone, NzChat, tr("NZ-CHAT")),
|
||||
PAIR(TimeZone, Poland, tr("Poland")),
|
||||
PAIR(TimeZone, Portugal, tr("Portugal")),
|
||||
PAIR(TimeZone, Prc, tr("PRC")),
|
||||
PAIR(TimeZone, Pst8Pdt, tr("PST8PDT")),
|
||||
PAIR(TimeZone, Roc, tr("ROC")),
|
||||
PAIR(TimeZone, Rok, tr("ROK")),
|
||||
PAIR(TimeZone, Singapore, tr("Singapore")),
|
||||
PAIR(TimeZone, Turkey, tr("Turkey")),
|
||||
PAIR(TimeZone, Uct, tr("UCT")),
|
||||
PAIR(TimeZone, Universal, tr("Universal")),
|
||||
PAIR(TimeZone, Utc, tr("UTC")),
|
||||
PAIR(TimeZone, WSu, tr("W-SU")),
|
||||
PAIR(TimeZone, Wet, tr("WET")),
|
||||
PAIR(TimeZone, Zulu, tr("Zulu")),
|
||||
PAIR(TimeZone, Cet, "CET"),
|
||||
PAIR(TimeZone, Cst6Cdt, "CST6CDT"),
|
||||
PAIR(TimeZone, Cuba, "Cuba"),
|
||||
PAIR(TimeZone, Eet, "EET"),
|
||||
PAIR(TimeZone, Egypt, "Egypt"),
|
||||
PAIR(TimeZone, Eire, "Eire"),
|
||||
PAIR(TimeZone, Est, "EST"),
|
||||
PAIR(TimeZone, Est5Edt, "EST5EDT"),
|
||||
PAIR(TimeZone, Gb, "GB"),
|
||||
PAIR(TimeZone, GbEire, "GB-Eire"),
|
||||
PAIR(TimeZone, Gmt, "GMT"),
|
||||
PAIR(TimeZone, GmtPlusZero, "GMT+0"),
|
||||
PAIR(TimeZone, GmtMinusZero, "GMT-0"),
|
||||
PAIR(TimeZone, GmtZero, "GMT0"),
|
||||
PAIR(TimeZone, Greenwich, "Greenwich"),
|
||||
PAIR(TimeZone, Hongkong, "Hongkong"),
|
||||
PAIR(TimeZone, Hst, "HST"),
|
||||
PAIR(TimeZone, Iceland, "Iceland"),
|
||||
PAIR(TimeZone, Iran, "Iran"),
|
||||
PAIR(TimeZone, Israel, "Israel"),
|
||||
PAIR(TimeZone, Jamaica, "Jamaica"),
|
||||
PAIR(TimeZone, Japan, "Japan"),
|
||||
PAIR(TimeZone, Kwajalein, "Kwajalein"),
|
||||
PAIR(TimeZone, Libya, "Libya"),
|
||||
PAIR(TimeZone, Met, "MET"),
|
||||
PAIR(TimeZone, Mst, "MST"),
|
||||
PAIR(TimeZone, Mst7Mdt, "MST7MDT"),
|
||||
PAIR(TimeZone, Navajo, "Navajo"),
|
||||
PAIR(TimeZone, Nz, "NZ"),
|
||||
PAIR(TimeZone, NzChat, "NZ-CHAT"),
|
||||
PAIR(TimeZone, Poland, "Poland"),
|
||||
PAIR(TimeZone, Portugal, "Portugal"),
|
||||
PAIR(TimeZone, Prc, "PRC"),
|
||||
PAIR(TimeZone, Pst8Pdt, "PST8PDT"),
|
||||
PAIR(TimeZone, Roc, "ROC"),
|
||||
PAIR(TimeZone, Rok, "ROK"),
|
||||
PAIR(TimeZone, Singapore, "Singapore"),
|
||||
PAIR(TimeZone, Turkey, "Turkey"),
|
||||
PAIR(TimeZone, Uct, "UCT"),
|
||||
PAIR(TimeZone, Universal, "Universal"),
|
||||
PAIR(TimeZone, Utc, "UTC"),
|
||||
PAIR(TimeZone, WSu, "W-SU"),
|
||||
PAIR(TimeZone, Wet, "WET"),
|
||||
PAIR(TimeZone, Zulu, "Zulu"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AudioMode>::Index(),
|
||||
{
|
||||
PAIR(AudioMode, Mono, tr("Mono")),
|
||||
PAIR(AudioMode, Stereo, tr("Stereo")),
|
||||
PAIR(AudioMode, Surround, tr("Surround")),
|
||||
PAIR(AudioMode, Mono, "Mono"),
|
||||
PAIR(AudioMode, Stereo, "Stereo"),
|
||||
PAIR(AudioMode, Surround, "Surround"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::MemoryLayout>::Index(),
|
||||
{
|
||||
PAIR(MemoryLayout, Memory_4Gb, tr("4GB DRAM (Default)")),
|
||||
PAIR(MemoryLayout, Memory_6Gb, tr("6GB DRAM (Unsafe)")),
|
||||
PAIR(MemoryLayout, Memory_8Gb, tr("8GB DRAM (Unsafe)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ConsoleMode>::Index(),
|
||||
{
|
||||
PAIR(ConsoleMode, Docked, tr("Docked")),
|
||||
PAIR(ConsoleMode, Handheld, tr("Handheld")),
|
||||
PAIR(MemoryLayout, Memory_4Gb, "4GB DRAM (Default)"),
|
||||
PAIR(MemoryLayout, Memory_6Gb, "6GB DRAM (Unsafe)"),
|
||||
PAIR(MemoryLayout, Memory_8Gb, "8GB DRAM (Unsafe)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ConsoleMode>::Index(),
|
||||
{PAIR(ConsoleMode, Docked, "Docked"), PAIR(ConsoleMode, Handheld, "Handheld")}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ConfirmStop>::Index(),
|
||||
{
|
||||
PAIR(ConfirmStop, Ask_Always, tr("Always ask (Default)")),
|
||||
PAIR(ConfirmStop, Ask_Based_On_Game, tr("Only if game specifies not to stop")),
|
||||
PAIR(ConfirmStop, Ask_Never, tr("Never ask")),
|
||||
PAIR(ConfirmStop, Ask_Always, "Always ask (Default)"),
|
||||
PAIR(ConfirmStop, Ask_Based_On_Game, "Only if game specifies not to stop"),
|
||||
PAIR(ConfirmStop, Ask_Never, "Never ask"),
|
||||
}});
|
||||
|
||||
#undef PAIR
|
||||
|
||||
@@ -194,7 +194,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
||||
return group;
|
||||
}
|
||||
|
||||
const auto get_selected = [this]() -> int {
|
||||
const auto get_selected = [=]() -> int {
|
||||
for (const auto& [id, button] : radio_buttons) {
|
||||
if (button->isChecked()) {
|
||||
return id;
|
||||
@@ -203,7 +203,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
||||
return -1;
|
||||
};
|
||||
|
||||
const auto set_index = [this](u32 value) {
|
||||
const auto set_index = [=](u32 value) {
|
||||
for (const auto& [id, button] : radio_buttons) {
|
||||
button->setChecked(id == value);
|
||||
}
|
||||
|
||||
@@ -479,6 +479,6 @@ void GameListWorker::run() {
|
||||
}
|
||||
}
|
||||
|
||||
RecordEvent([this](GameList* game_list) { game_list->DonePopulating(watch_list); });
|
||||
RecordEvent([=](GameList* game_list) { game_list->DonePopulating(watch_list); });
|
||||
processing_completed.Set();
|
||||
}
|
||||
|
||||
@@ -1575,7 +1575,6 @@ void GMainWindow::ConnectMenuEvents() {
|
||||
connect_menu(ui->action_Load_Cabinet_Formatter,
|
||||
[this]() { OnCabinet(Service::NFP::CabinetMode::StartFormatter); });
|
||||
connect_menu(ui->action_Load_Mii_Edit, &GMainWindow::OnMiiEdit);
|
||||
connect_menu(ui->action_Open_Controller_Menu, &GMainWindow::OnOpenControllerMenu);
|
||||
connect_menu(ui->action_Capture_Screenshot, &GMainWindow::OnCaptureScreenshot);
|
||||
|
||||
// TAS
|
||||
@@ -1603,13 +1602,14 @@ void GMainWindow::UpdateMenuState() {
|
||||
ui->action_Pause,
|
||||
};
|
||||
|
||||
const std::array applet_actions{ui->action_Load_Album,
|
||||
ui->action_Load_Cabinet_Nickname_Owner,
|
||||
ui->action_Load_Cabinet_Eraser,
|
||||
ui->action_Load_Cabinet_Restorer,
|
||||
ui->action_Load_Cabinet_Formatter,
|
||||
ui->action_Load_Mii_Edit,
|
||||
ui->action_Open_Controller_Menu};
|
||||
const std::array applet_actions{
|
||||
ui->action_Load_Album,
|
||||
ui->action_Load_Cabinet_Nickname_Owner,
|
||||
ui->action_Load_Cabinet_Eraser,
|
||||
ui->action_Load_Cabinet_Restorer,
|
||||
ui->action_Load_Cabinet_Formatter,
|
||||
ui->action_Load_Mii_Edit,
|
||||
};
|
||||
|
||||
for (QAction* action : running_actions) {
|
||||
action->setEnabled(emulation_running);
|
||||
@@ -4375,31 +4375,6 @@ void GMainWindow::OnMiiEdit() {
|
||||
BootGame(filename, MiiEditId);
|
||||
}
|
||||
|
||||
void GMainWindow::OnOpenControllerMenu() {
|
||||
constexpr u64 ControllerAppletId =
|
||||
static_cast<u64>(Service::AM::Applets::AppletProgramId::Controller);
|
||||
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
||||
if (!bis_system) {
|
||||
QMessageBox::warning(this, tr("No firmware available"),
|
||||
tr("Please install the firmware to use the Controller Menu."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto controller_applet_nca =
|
||||
bis_system->GetEntry(ControllerAppletId, FileSys::ContentRecordType::Program);
|
||||
if (!controller_applet_nca) {
|
||||
QMessageBox::warning(this, tr("Controller Applet"),
|
||||
tr("Controller Menu is not available. Please reinstall firmware."));
|
||||
return;
|
||||
}
|
||||
|
||||
system->GetAppletManager().SetCurrentAppletId(Service::AM::Applets::AppletId::Controller);
|
||||
|
||||
const auto filename = QString::fromStdString((controller_applet_nca->GetFullPath()));
|
||||
UISettings::values.roms_path = QFileInfo(filename).path();
|
||||
BootGame(filename, ControllerAppletId);
|
||||
}
|
||||
|
||||
void GMainWindow::OnCaptureScreenshot() {
|
||||
if (emu_thread == nullptr || !emu_thread->IsRunning()) {
|
||||
return;
|
||||
|
||||
@@ -410,7 +410,6 @@ private slots:
|
||||
void OnAlbum();
|
||||
void OnCabinet(Service::NFP::CabinetMode mode);
|
||||
void OnMiiEdit();
|
||||
void OnOpenControllerMenu();
|
||||
void OnCaptureScreenshot();
|
||||
void OnReinitializeKeys(ReinitializeKeyBehavior behavior);
|
||||
void OnLanguageChanged(const QString& locale);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin" stdset="0">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
@@ -36,7 +36,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1280</width>
|
||||
<height>21</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -162,7 +162,6 @@
|
||||
<addaction name="menu_cabinet_applet"/>
|
||||
<addaction name="action_Load_Album"/>
|
||||
<addaction name="action_Load_Mii_Edit"/>
|
||||
<addaction name="action_Open_Controller_Menu"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_Capture_Screenshot"/>
|
||||
<addaction name="menuTAS"/>
|
||||
@@ -383,9 +382,9 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Load_Album">
|
||||
<property name="text">
|
||||
<string>Open &Album</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open &Album</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Load_Cabinet_Nickname_Owner">
|
||||
<property name="text">
|
||||
@@ -408,9 +407,9 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Load_Mii_Edit">
|
||||
<property name="text">
|
||||
<string>Open &Mii Editor</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open &Mii Editor</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Configure_Tas">
|
||||
<property name="text">
|
||||
@@ -455,11 +454,6 @@
|
||||
<string>R&ecord</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Open_Controller_Menu">
|
||||
<property name="text">
|
||||
<string>Open &Controller Menu</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="yuzu.qrc"/>
|
||||
|
||||
Reference in New Issue
Block a user