Compare commits
132 Commits
android-10
...
android-11
Author | SHA1 | Date | |
---|---|---|---|
d2df38c8c3 | |||
7e284809de | |||
324c93e4aa | |||
133788d0d4 | |||
e8cb8b2668 | |||
361dbdddcc | |||
ab3e3c11af | |||
db5c24eb66 | |||
f7755df2af | |||
c60204e255 | |||
5e69769356 | |||
22cac3a5e3 | |||
e867768316 | |||
07276cf62a | |||
f04bc172ae | |||
585b6e9d46 | |||
a9e29a3972 | |||
1e61c3e1e7 | |||
79d3cef8db | |||
3e0da4f698 | |||
789c16305d | |||
1836e62d33 | |||
0bbbe80f75 | |||
70be45c992 | |||
9b3c64f4a4 | |||
eec3d356b6 | |||
2c1d850b46 | |||
2581590023 | |||
adb0900906 | |||
2d608cd625 | |||
29955de767 | |||
b0f62d8f24 | |||
ed2d77ddbc | |||
6e883a26da | |||
8427b9d49d | |||
0bb1c7c804 | |||
a5aa5876b4 | |||
911d2216be | |||
4da2105a32 | |||
1f9684eaf9 | |||
40c97c0549 | |||
6aee148b17 | |||
b5b93e6741 | |||
18a4529851 | |||
9e4d606c4c | |||
64f60f0acb | |||
21c631b33b | |||
f26dddf3b5 | |||
43be2bfe33 | |||
79ba5d9c26 | |||
008d7e8c5f | |||
19e9bde9e0 | |||
6eb3a583cb | |||
e0834ee50b | |||
79894152a8 | |||
9274eaecd0 | |||
c733620024 | |||
897b411ae7 | |||
94836ba3b1 | |||
b1909b0435 | |||
1cc764988f | |||
da5c49f22d | |||
6b93b0b08c | |||
68f25217b8 | |||
0604b14263 | |||
a065dcdcd9 | |||
3d4a064674 | |||
e4dfd51337 | |||
cfe73af6f2 | |||
d6bd16b2c0 | |||
a49b146ccc | |||
fd9e157184 | |||
6cbd4020e8 | |||
3558b236cd | |||
48e82c4138 | |||
9eb70aea1d | |||
0460fbacc9 | |||
c73297e840 | |||
633d869ff4 | |||
e03f86cc54 | |||
a0a3566977 | |||
77fb9d415b | |||
bbdaa62175 | |||
31bffc7299 | |||
5f8f09d750 | |||
dcfe674ed4 | |||
bb195c2c2b | |||
8c59543ee3 | |||
db37e583ff | |||
d28e826e47 | |||
13beb85514 | |||
4b06bcc82c | |||
12ebc8d9d1 | |||
2b85e9e997 | |||
59b62c6507 | |||
2e760a9833 | |||
bab4a13a41 | |||
b56c7397ad | |||
689f346e97 | |||
249db0a59b | |||
9526ce95dd | |||
687158fe00 | |||
d8507332c1 | |||
67e983a354 | |||
f21058a6c0 | |||
b456af31e6 | |||
0441853d0f | |||
60a1c6b95b | |||
794e6c7a96 | |||
22afa2c7a3 | |||
85a89ca3e3 | |||
26776c0e60 | |||
e02ee8e59d | |||
134ecca9b0 | |||
c5f1ec8040 | |||
765ea9b79d | |||
c5bdc0054c | |||
0b7593d352 | |||
d9dde7e6f3 | |||
c73bb33ff1 | |||
326ebbb2fa | |||
07143ce15c | |||
dbc73c6c6c | |||
90c56f5dc1 | |||
4b0291172e | |||
12e4757cf3 | |||
144c0734f5 | |||
f40f65f5d2 | |||
03c3f936cf | |||
66f41da365 | |||
7a986d731b | |||
d3997bad9b |
@ -19,6 +19,7 @@ cmake .. \
|
|||||||
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
|
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
|
||||||
-DENABLE_QT_TRANSLATION=ON \
|
-DENABLE_QT_TRANSLATION=ON \
|
||||||
-DUSE_DISCORD_PRESENCE=ON \
|
-DUSE_DISCORD_PRESENCE=ON \
|
||||||
|
-DYUZU_CRASH_DUMPS=ON \
|
||||||
-DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
|
-DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
|
||||||
-DYUZU_USE_BUNDLED_FFMPEG=ON \
|
-DYUZU_USE_BUNDLED_FFMPEG=ON \
|
||||||
-GNinja
|
-GNinja
|
||||||
|
@ -23,6 +23,7 @@ cmake .. \
|
|||||||
-DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
|
-DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
|
||||||
-DYUZU_USE_BUNDLED_FFMPEG=ON \
|
-DYUZU_USE_BUNDLED_FFMPEG=ON \
|
||||||
-DYUZU_ENABLE_LTO=ON \
|
-DYUZU_ENABLE_LTO=ON \
|
||||||
|
-DYUZU_CRASH_DUMPS=ON \
|
||||||
-GNinja
|
-GNinja
|
||||||
|
|
||||||
ninja
|
ninja
|
||||||
|
@ -17,7 +17,6 @@ cmake .. \
|
|||||||
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
|
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
|
||||||
-DENABLE_QT_TRANSLATION=ON \
|
-DENABLE_QT_TRANSLATION=ON \
|
||||||
-DUSE_CCACHE=ON \
|
-DUSE_CCACHE=ON \
|
||||||
-DYUZU_CRASH_DUMPS=ON \
|
|
||||||
-DYUZU_USE_BUNDLED_SDL2=OFF \
|
-DYUZU_USE_BUNDLED_SDL2=OFF \
|
||||||
-DYUZU_USE_EXTERNAL_SDL2=OFF \
|
-DYUZU_USE_EXTERNAL_SDL2=OFF \
|
||||||
-DYUZU_TESTS=OFF \
|
-DYUZU_TESTS=OFF \
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
[codespell]
|
[codespell]
|
||||||
skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res
|
skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res
|
||||||
ignore-words-list = aci,allright,ba,canonicalizations,deques,froms,hda,inout,lod,masia,nam,nax,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,zink
|
ignore-words-list = aci,allright,ba,canonicalizations,deques,froms,hda,inout,lod,masia,nam,nax,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,vas,zink
|
||||||
|
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -32,7 +32,7 @@
|
|||||||
path = externals/xbyak
|
path = externals/xbyak
|
||||||
url = https://github.com/herumi/xbyak.git
|
url = https://github.com/herumi/xbyak.git
|
||||||
[submodule "opus"]
|
[submodule "opus"]
|
||||||
path = externals/opus/opus
|
path = externals/opus
|
||||||
url = https://github.com/xiph/opus.git
|
url = https://github.com/xiph/opus.git
|
||||||
[submodule "SDL"]
|
[submodule "SDL"]
|
||||||
path = externals/SDL
|
path = externals/SDL
|
||||||
@ -58,3 +58,6 @@
|
|||||||
[submodule "VulkanMemoryAllocator"]
|
[submodule "VulkanMemoryAllocator"]
|
||||||
path = externals/VulkanMemoryAllocator
|
path = externals/VulkanMemoryAllocator
|
||||||
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
||||||
|
[submodule "breakpad"]
|
||||||
|
path = externals/breakpad
|
||||||
|
url = https://github.com/yuzu-emu/breakpad.git
|
||||||
|
@ -147,3 +147,7 @@ License: GPL-3.0-or-later
|
|||||||
Files: src/android/gradle/wrapper/*
|
Files: src/android/gradle/wrapper/*
|
||||||
Copyright: 2023 yuzu Emulator Project
|
Copyright: 2023 yuzu Emulator Project
|
||||||
License: GPL-3.0-or-later
|
License: GPL-3.0-or-later
|
||||||
|
|
||||||
|
Files: externals/stb/*
|
||||||
|
Copyright: Sean Barrett
|
||||||
|
License: MIT
|
||||||
|
@ -52,7 +52,7 @@ option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android"
|
|||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile crash dump (Minidump) support" OFF "WIN32 OR LINUX" OFF)
|
||||||
|
|
||||||
option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")
|
option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")
|
||||||
|
|
||||||
@ -139,9 +139,6 @@ if (YUZU_USE_BUNDLED_VCPKG)
|
|||||||
if (YUZU_TESTS)
|
if (YUZU_TESTS)
|
||||||
list(APPEND VCPKG_MANIFEST_FEATURES "yuzu-tests")
|
list(APPEND VCPKG_MANIFEST_FEATURES "yuzu-tests")
|
||||||
endif()
|
endif()
|
||||||
if (YUZU_CRASH_DUMPS)
|
|
||||||
list(APPEND VCPKG_MANIFEST_FEATURES "dbghelp")
|
|
||||||
endif()
|
|
||||||
if (ENABLE_WEB_SERVICE)
|
if (ENABLE_WEB_SERVICE)
|
||||||
list(APPEND VCPKG_MANIFEST_FEATURES "web-service")
|
list(APPEND VCPKG_MANIFEST_FEATURES "web-service")
|
||||||
endif()
|
endif()
|
||||||
@ -294,6 +291,7 @@ find_package(lz4 REQUIRED)
|
|||||||
find_package(nlohmann_json 3.8 REQUIRED)
|
find_package(nlohmann_json 3.8 REQUIRED)
|
||||||
find_package(Opus 1.3 MODULE)
|
find_package(Opus 1.3 MODULE)
|
||||||
find_package(RenderDoc MODULE)
|
find_package(RenderDoc MODULE)
|
||||||
|
find_package(stb MODULE)
|
||||||
find_package(VulkanMemoryAllocator CONFIG)
|
find_package(VulkanMemoryAllocator CONFIG)
|
||||||
find_package(ZLIB 1.2 REQUIRED)
|
find_package(ZLIB 1.2 REQUIRED)
|
||||||
find_package(zstd 1.5 REQUIRED)
|
find_package(zstd 1.5 REQUIRED)
|
||||||
@ -550,6 +548,18 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
|
|||||||
find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS})
|
find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIN32 AND YUZU_CRASH_DUMPS)
|
||||||
|
set(BREAKPAD_VER "breakpad-c89f9dd")
|
||||||
|
download_bundled_external("breakpad/" ${BREAKPAD_VER} BREAKPAD_PREFIX)
|
||||||
|
|
||||||
|
set(BREAKPAD_CLIENT_INCLUDE_DIR "${BREAKPAD_PREFIX}/include")
|
||||||
|
set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib")
|
||||||
|
|
||||||
|
add_library(libbreakpad_client INTERFACE IMPORTED)
|
||||||
|
target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}")
|
||||||
|
target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Prefer the -pthread flag on Linux.
|
# Prefer the -pthread flag on Linux.
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
@ -569,13 +579,6 @@ elseif (WIN32)
|
|||||||
# PSAPI is the Process Status API
|
# PSAPI is the Process Status API
|
||||||
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} psapi imm32 version)
|
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} psapi imm32 version)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_CRASH_DUMPS)
|
|
||||||
find_library(DBGHELP_LIBRARY dbghelp)
|
|
||||||
if ("${DBGHELP_LIBRARY}" STREQUAL "DBGHELP_LIBRARY-NOTFOUND")
|
|
||||||
message(FATAL_ERROR "YUZU_CRASH_DUMPS enabled but dbghelp library not found")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$")
|
elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$")
|
||||||
set(PLATFORM_LIBRARIES rt)
|
set(PLATFORM_LIBRARIES rt)
|
||||||
endif()
|
endif()
|
||||||
|
31
CMakeModules/Findstb.cmake
Normal file
31
CMakeModules/Findstb.cmake
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2023 Alexandre Bouvier <contact@amb.tf>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
find_path(stb_image_INCLUDE_DIR stb_image.h PATH_SUFFIXES stb)
|
||||||
|
find_path(stb_image_resize_INCLUDE_DIR stb_image_resize.h PATH_SUFFIXES stb)
|
||||||
|
find_path(stb_image_write_INCLUDE_DIR stb_image_write.h PATH_SUFFIXES stb)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(stb
|
||||||
|
REQUIRED_VARS
|
||||||
|
stb_image_INCLUDE_DIR
|
||||||
|
stb_image_resize_INCLUDE_DIR
|
||||||
|
stb_image_write_INCLUDE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
if (stb_FOUND AND NOT TARGET stb::headers)
|
||||||
|
add_library(stb::headers INTERFACE IMPORTED)
|
||||||
|
set_property(TARGET stb::headers PROPERTY
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${stb_image_INCLUDE_DIR}"
|
||||||
|
"${stb_image_resize_INCLUDE_DIR}"
|
||||||
|
"${stb_image_write_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
stb_image_INCLUDE_DIR
|
||||||
|
stb_image_resize_INCLUDE_DIR
|
||||||
|
stb_image_write_INCLUDE_DIR
|
||||||
|
)
|
@ -1,3 +1,11 @@
|
|||||||
|
| Pull Request | Commit | Title | Author | Merged? |
|
||||||
|
|----|----|----|----|----|
|
||||||
|
|
||||||
|
|
||||||
|
End of merge log. You can find the original README.md below the break.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
SPDX-FileCopyrightText: 2018 yuzu Emulator Project
|
SPDX-FileCopyrightText: 2018 yuzu Emulator Project
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
1
dist/org.yuzu_emu.yuzu.desktop
vendored
1
dist/org.yuzu_emu.yuzu.desktop
vendored
@ -13,3 +13,4 @@ Exec=yuzu %f
|
|||||||
Categories=Game;Emulator;Qt;
|
Categories=Game;Emulator;Qt;
|
||||||
MimeType=application/x-nx-nro;application/x-nx-nso;application/x-nx-nsp;application/x-nx-xci;
|
MimeType=application/x-nx-nro;application/x-nx-nso;application/x-nx-nsp;application/x-nx-xci;
|
||||||
Keywords=Nintendo;Switch;
|
Keywords=Nintendo;Switch;
|
||||||
|
StartupWMClass=yuzu
|
||||||
|
112
externals/CMakeLists.txt
vendored
112
externals/CMakeLists.txt
vendored
@ -134,6 +134,10 @@ endif()
|
|||||||
|
|
||||||
# Opus
|
# Opus
|
||||||
if (NOT TARGET Opus::opus)
|
if (NOT TARGET Opus::opus)
|
||||||
|
set(OPUS_BUILD_TESTING OFF)
|
||||||
|
set(OPUS_BUILD_PROGRAMS OFF)
|
||||||
|
set(OPUS_INSTALL_PKG_CONFIG_MODULE OFF)
|
||||||
|
set(OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF)
|
||||||
add_subdirectory(opus)
|
add_subdirectory(opus)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -168,9 +172,13 @@ if (NOT TARGET LLVM::Demangle)
|
|||||||
add_library(LLVM::Demangle ALIAS demangle)
|
add_library(LLVM::Demangle ALIAS demangle)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(stb stb/stb_dxt.cpp stb/stb_image.cpp stb/stb_image_resize.cpp)
|
add_library(stb stb/stb_dxt.cpp)
|
||||||
target_include_directories(stb PUBLIC ./stb)
|
target_include_directories(stb PUBLIC ./stb)
|
||||||
|
|
||||||
|
if (NOT TARGET stb::headers)
|
||||||
|
add_library(stb::headers ALIAS stb)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(bc_decoder bc_decoder/bc_decoder.cpp)
|
add_library(bc_decoder bc_decoder/bc_decoder.cpp)
|
||||||
target_include_directories(bc_decoder PUBLIC ./bc_decoder)
|
target_include_directories(bc_decoder PUBLIC ./bc_decoder)
|
||||||
|
|
||||||
@ -185,3 +193,105 @@ if (ANDROID)
|
|||||||
add_subdirectory(libadrenotools)
|
add_subdirectory(libadrenotools)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Breakpad
|
||||||
|
# https://github.com/microsoft/vcpkg/blob/master/ports/breakpad/CMakeLists.txt
|
||||||
|
if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
|
||||||
|
set(BREAKPAD_WIN32_DEFINES
|
||||||
|
NOMINMAX
|
||||||
|
UNICODE
|
||||||
|
WIN32_LEAN_AND_MEAN
|
||||||
|
_CRT_SECURE_NO_WARNINGS
|
||||||
|
_CRT_SECURE_NO_DEPRECATE
|
||||||
|
_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
)
|
||||||
|
|
||||||
|
# libbreakpad
|
||||||
|
add_library(libbreakpad STATIC)
|
||||||
|
file(GLOB_RECURSE LIBBREAKPAD_SOURCES breakpad/src/processor/*.cc)
|
||||||
|
file(GLOB_RECURSE LIBDISASM_SOURCES breakpad/src/third_party/libdisasm/*.c)
|
||||||
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX "_unittest|_selftest|synth_minidump|/tests|/testdata|/solaris|microdump_stackwalk|minidump_dump|minidump_stackwalk")
|
||||||
|
if (WIN32)
|
||||||
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX "/linux|/mac|/android")
|
||||||
|
target_compile_definitions(libbreakpad PRIVATE ${BREAKPAD_WIN32_DEFINES})
|
||||||
|
target_include_directories(libbreakpad PRIVATE "${CMAKE_GENERATOR_INSTANCE}/DIA SDK/include")
|
||||||
|
elseif (APPLE)
|
||||||
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX "/linux|/windows|/android")
|
||||||
|
else()
|
||||||
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX "/mac|/windows|/android")
|
||||||
|
endif()
|
||||||
|
target_sources(libbreakpad PRIVATE ${LIBBREAKPAD_SOURCES} ${LIBDISASM_SOURCES})
|
||||||
|
target_include_directories(libbreakpad
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/breakpad/src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/breakpad/src/third_party/libdisasm
|
||||||
|
)
|
||||||
|
|
||||||
|
# libbreakpad_client
|
||||||
|
add_library(libbreakpad_client STATIC)
|
||||||
|
file(GLOB LIBBREAKPAD_COMMON_SOURCES breakpad/src/common/*.cc breakpad/src/common/*.c breakpad/src/client/*.cc)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
file(GLOB_RECURSE LIBBREAKPAD_CLIENT_SOURCES breakpad/src/client/windows/*.cc breakpad/src/common/windows/*.cc)
|
||||||
|
list(FILTER LIBBREAKPAD_COMMON_SOURCES EXCLUDE REGEX "language.cc|path_helper.cc|stabs_to_module.cc|stabs_reader.cc|minidump_file_writer.cc")
|
||||||
|
target_include_directories(libbreakpad_client PRIVATE "${CMAKE_GENERATOR_INSTANCE}/DIA SDK/include")
|
||||||
|
target_compile_definitions(libbreakpad_client PRIVATE ${BREAKPAD_WIN32_DEFINES})
|
||||||
|
elseif (APPLE)
|
||||||
|
target_compile_definitions(libbreakpad_client PRIVATE HAVE_MACH_O_NLIST_H)
|
||||||
|
file(GLOB_RECURSE LIBBREAKPAD_CLIENT_SOURCES breakpad/src/client/mac/*.cc breakpad/src/common/mac/*.cc)
|
||||||
|
list(APPEND LIBBREAKPAD_CLIENT_SOURCES breakpad/src/common/mac/MachIPC.mm)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(libbreakpad_client PUBLIC -DHAVE_A_OUT_H)
|
||||||
|
file(GLOB_RECURSE LIBBREAKPAD_CLIENT_SOURCES breakpad/src/client/linux/*.cc breakpad/src/common/linux/*.cc)
|
||||||
|
endif()
|
||||||
|
list(APPEND LIBBREAKPAD_CLIENT_SOURCES ${LIBBREAKPAD_COMMON_SOURCES})
|
||||||
|
list(FILTER LIBBREAKPAD_CLIENT_SOURCES EXCLUDE REGEX "/sender|/tests|/unittests|/testcases|_unittest|_test")
|
||||||
|
target_sources(libbreakpad_client PRIVATE ${LIBBREAKPAD_CLIENT_SOURCES})
|
||||||
|
target_include_directories(libbreakpad_client PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/breakpad/src)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries(libbreakpad_client PRIVATE wininet.lib)
|
||||||
|
elseif (APPLE)
|
||||||
|
find_library(CoreFoundation_FRAMEWORK CoreFoundation)
|
||||||
|
target_link_libraries(libbreakpad_client PRIVATE ${CoreFoundation_FRAMEWORK})
|
||||||
|
else()
|
||||||
|
find_library(PTHREAD_LIBRARIES pthread)
|
||||||
|
target_compile_definitions(libbreakpad_client PRIVATE HAVE_GETCONTEXT=1)
|
||||||
|
if (PTHREAD_LIBRARIES)
|
||||||
|
target_link_libraries(libbreakpad_client PRIVATE ${PTHREAD_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Host tools for symbol processing
|
||||||
|
if (LINUX)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
|
add_executable(minidump_stackwalk breakpad/src/processor/minidump_stackwalk.cc)
|
||||||
|
target_link_libraries(minidump_stackwalk PRIVATE libbreakpad libbreakpad_client)
|
||||||
|
|
||||||
|
add_executable(dump_syms
|
||||||
|
breakpad/src/common/dwarf_cfi_to_module.cc
|
||||||
|
breakpad/src/common/dwarf_cu_to_module.cc
|
||||||
|
breakpad/src/common/dwarf_line_to_module.cc
|
||||||
|
breakpad/src/common/dwarf_range_list_handler.cc
|
||||||
|
breakpad/src/common/language.cc
|
||||||
|
breakpad/src/common/module.cc
|
||||||
|
breakpad/src/common/path_helper.cc
|
||||||
|
breakpad/src/common/stabs_reader.cc
|
||||||
|
breakpad/src/common/stabs_to_module.cc
|
||||||
|
breakpad/src/common/dwarf/bytereader.cc
|
||||||
|
breakpad/src/common/dwarf/dwarf2diehandler.cc
|
||||||
|
breakpad/src/common/dwarf/dwarf2reader.cc
|
||||||
|
breakpad/src/common/dwarf/elf_reader.cc
|
||||||
|
breakpad/src/common/linux/crc32.cc
|
||||||
|
breakpad/src/common/linux/dump_symbols.cc
|
||||||
|
breakpad/src/common/linux/elf_symbols_to_module.cc
|
||||||
|
breakpad/src/common/linux/elfutils.cc
|
||||||
|
breakpad/src/common/linux/file_id.cc
|
||||||
|
breakpad/src/common/linux/linux_libc_support.cc
|
||||||
|
breakpad/src/common/linux/memory_mapped_file.cc
|
||||||
|
breakpad/src/common/linux/safe_readlink.cc
|
||||||
|
breakpad/src/tools/linux/dump_syms/dump_syms.cc)
|
||||||
|
target_link_libraries(dump_syms PRIVATE libbreakpad_client ZLIB::ZLIB)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
2
externals/SDL
vendored
2
externals/SDL
vendored
Submodule externals/SDL updated: 031912c4b6...cc016b0046
2
externals/Vulkan-Headers
vendored
2
externals/Vulkan-Headers
vendored
Submodule externals/Vulkan-Headers updated: ed857118e2...df60f03168
2
externals/VulkanMemoryAllocator
vendored
2
externals/VulkanMemoryAllocator
vendored
Submodule externals/VulkanMemoryAllocator updated: 9b0fc3e7b0...2f382df218
1
externals/breakpad
vendored
Submodule
1
externals/breakpad
vendored
Submodule
Submodule externals/breakpad added at c89f9dddc7
2
externals/cpp-httplib
vendored
2
externals/cpp-httplib
vendored
Submodule externals/cpp-httplib updated: 6d963fbe8d...a609330e4c
2
externals/cpp-jwt
vendored
2
externals/cpp-jwt
vendored
Submodule externals/cpp-jwt updated: e12ef06218...10ef5735d8
2
externals/dynarmic
vendored
2
externals/dynarmic
vendored
Submodule externals/dynarmic updated: 7da378033a...0df09e2f6b
2
externals/ffmpeg/ffmpeg
vendored
2
externals/ffmpeg/ffmpeg
vendored
Submodule externals/ffmpeg/ffmpeg updated: 6b6b9e593d...9c1294eadd
2
externals/inih/inih
vendored
2
externals/inih/inih
vendored
Submodule externals/inih/inih updated: 1e80a47dff...9cecf0643d
7
externals/libusb/CMakeLists.txt
vendored
7
externals/libusb/CMakeLists.txt
vendored
@ -49,11 +49,6 @@ if (MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") OR APPLE)
|
|||||||
|
|
||||||
set(LIBUSB_INCLUDE_DIRS "${LIBUSB_SRC_DIR}/libusb" CACHE PATH "libusb headers path" FORCE)
|
set(LIBUSB_INCLUDE_DIRS "${LIBUSB_SRC_DIR}/libusb" CACHE PATH "libusb headers path" FORCE)
|
||||||
|
|
||||||
# MINGW: causes "externals/libusb/libusb/libusb/os/windows_winusb.c:1427:2: error: conversion to non-scalar type requested", so cannot statically link it for now.
|
|
||||||
if (NOT MINGW)
|
|
||||||
set(LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
make_directory("${LIBUSB_PREFIX}")
|
make_directory("${LIBUSB_PREFIX}")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
@ -146,8 +141,6 @@ else() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|||||||
target_include_directories(usb BEFORE PRIVATE libusb/msvc)
|
target_include_directories(usb BEFORE PRIVATE libusb/msvc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Works around other libraries providing their own definition of USB GUIDs (e.g. SDL2)
|
|
||||||
target_compile_definitions(usb PRIVATE "-DGUID_DEVINTERFACE_USB_DEVICE=(GUID){ 0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}}")
|
|
||||||
else()
|
else()
|
||||||
target_include_directories(usb
|
target_include_directories(usb
|
||||||
# turns out other projects also have "config.h", so make sure the
|
# turns out other projects also have "config.h", so make sure the
|
||||||
|
2
externals/libusb/libusb
vendored
2
externals/libusb/libusb
vendored
Submodule externals/libusb/libusb updated: c6a35c5601...c060e9ce30
1
externals/opus
vendored
Submodule
1
externals/opus
vendored
Submodule
Submodule externals/opus added at 101a71e03b
259
externals/opus/CMakeLists.txt
vendored
259
externals/opus/CMakeLists.txt
vendored
@ -1,259 +0,0 @@
|
|||||||
# SPDX-FileCopyrightText: 2019 yuzu Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.8)
|
|
||||||
|
|
||||||
project(opus)
|
|
||||||
|
|
||||||
option(OPUS_STACK_PROTECTOR "Use stack protection" OFF)
|
|
||||||
option(OPUS_USE_ALLOCA "Use alloca for stack arrays (on non-C99 compilers)" OFF)
|
|
||||||
option(OPUS_CUSTOM_MODES "Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames" OFF)
|
|
||||||
option(OPUS_FIXED_POINT "Compile as fixed-point (for machines without a fast enough FPU)" OFF)
|
|
||||||
option(OPUS_ENABLE_FLOAT_API "Compile with the floating point API (for machines with float library" ON)
|
|
||||||
|
|
||||||
include(opus/opus_functions.cmake)
|
|
||||||
|
|
||||||
if(OPUS_STACK_PROTECTOR)
|
|
||||||
if(NOT MSVC) # GC on by default on MSVC
|
|
||||||
check_and_set_flag(STACK_PROTECTION_STRONG -fstack-protector-strong)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
if(MSVC)
|
|
||||||
check_and_set_flag(BUFFER_SECURITY_CHECK /GS-)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(opus
|
|
||||||
# CELT sources
|
|
||||||
opus/celt/bands.c
|
|
||||||
opus/celt/celt.c
|
|
||||||
opus/celt/celt_decoder.c
|
|
||||||
opus/celt/celt_encoder.c
|
|
||||||
opus/celt/celt_lpc.c
|
|
||||||
opus/celt/cwrs.c
|
|
||||||
opus/celt/entcode.c
|
|
||||||
opus/celt/entdec.c
|
|
||||||
opus/celt/entenc.c
|
|
||||||
opus/celt/kiss_fft.c
|
|
||||||
opus/celt/laplace.c
|
|
||||||
opus/celt/mathops.c
|
|
||||||
opus/celt/mdct.c
|
|
||||||
opus/celt/modes.c
|
|
||||||
opus/celt/pitch.c
|
|
||||||
opus/celt/quant_bands.c
|
|
||||||
opus/celt/rate.c
|
|
||||||
opus/celt/vq.c
|
|
||||||
|
|
||||||
# SILK sources
|
|
||||||
opus/silk/A2NLSF.c
|
|
||||||
opus/silk/CNG.c
|
|
||||||
opus/silk/HP_variable_cutoff.c
|
|
||||||
opus/silk/LPC_analysis_filter.c
|
|
||||||
opus/silk/LPC_fit.c
|
|
||||||
opus/silk/LPC_inv_pred_gain.c
|
|
||||||
opus/silk/LP_variable_cutoff.c
|
|
||||||
opus/silk/NLSF2A.c
|
|
||||||
opus/silk/NLSF_VQ.c
|
|
||||||
opus/silk/NLSF_VQ_weights_laroia.c
|
|
||||||
opus/silk/NLSF_decode.c
|
|
||||||
opus/silk/NLSF_del_dec_quant.c
|
|
||||||
opus/silk/NLSF_encode.c
|
|
||||||
opus/silk/NLSF_stabilize.c
|
|
||||||
opus/silk/NLSF_unpack.c
|
|
||||||
opus/silk/NSQ.c
|
|
||||||
opus/silk/NSQ_del_dec.c
|
|
||||||
opus/silk/PLC.c
|
|
||||||
opus/silk/VAD.c
|
|
||||||
opus/silk/VQ_WMat_EC.c
|
|
||||||
opus/silk/ana_filt_bank_1.c
|
|
||||||
opus/silk/biquad_alt.c
|
|
||||||
opus/silk/bwexpander.c
|
|
||||||
opus/silk/bwexpander_32.c
|
|
||||||
opus/silk/check_control_input.c
|
|
||||||
opus/silk/code_signs.c
|
|
||||||
opus/silk/control_SNR.c
|
|
||||||
opus/silk/control_audio_bandwidth.c
|
|
||||||
opus/silk/control_codec.c
|
|
||||||
opus/silk/dec_API.c
|
|
||||||
opus/silk/decode_core.c
|
|
||||||
opus/silk/decode_frame.c
|
|
||||||
opus/silk/decode_indices.c
|
|
||||||
opus/silk/decode_parameters.c
|
|
||||||
opus/silk/decode_pitch.c
|
|
||||||
opus/silk/decode_pulses.c
|
|
||||||
opus/silk/decoder_set_fs.c
|
|
||||||
opus/silk/enc_API.c
|
|
||||||
opus/silk/encode_indices.c
|
|
||||||
opus/silk/encode_pulses.c
|
|
||||||
opus/silk/gain_quant.c
|
|
||||||
opus/silk/init_decoder.c
|
|
||||||
opus/silk/init_encoder.c
|
|
||||||
opus/silk/inner_prod_aligned.c
|
|
||||||
opus/silk/interpolate.c
|
|
||||||
opus/silk/lin2log.c
|
|
||||||
opus/silk/log2lin.c
|
|
||||||
opus/silk/pitch_est_tables.c
|
|
||||||
opus/silk/process_NLSFs.c
|
|
||||||
opus/silk/quant_LTP_gains.c
|
|
||||||
opus/silk/resampler.c
|
|
||||||
opus/silk/resampler_down2.c
|
|
||||||
opus/silk/resampler_down2_3.c
|
|
||||||
opus/silk/resampler_private_AR2.c
|
|
||||||
opus/silk/resampler_private_IIR_FIR.c
|
|
||||||
opus/silk/resampler_private_down_FIR.c
|
|
||||||
opus/silk/resampler_private_up2_HQ.c
|
|
||||||
opus/silk/resampler_rom.c
|
|
||||||
opus/silk/shell_coder.c
|
|
||||||
opus/silk/sigm_Q15.c
|
|
||||||
opus/silk/sort.c
|
|
||||||
opus/silk/stereo_LR_to_MS.c
|
|
||||||
opus/silk/stereo_MS_to_LR.c
|
|
||||||
opus/silk/stereo_decode_pred.c
|
|
||||||
opus/silk/stereo_encode_pred.c
|
|
||||||
opus/silk/stereo_find_predictor.c
|
|
||||||
opus/silk/stereo_quant_pred.c
|
|
||||||
opus/silk/sum_sqr_shift.c
|
|
||||||
opus/silk/table_LSF_cos.c
|
|
||||||
opus/silk/tables_LTP.c
|
|
||||||
opus/silk/tables_NLSF_CB_NB_MB.c
|
|
||||||
opus/silk/tables_NLSF_CB_WB.c
|
|
||||||
opus/silk/tables_gain.c
|
|
||||||
opus/silk/tables_other.c
|
|
||||||
opus/silk/tables_pitch_lag.c
|
|
||||||
opus/silk/tables_pulses_per_block.c
|
|
||||||
|
|
||||||
# Opus sources
|
|
||||||
opus/src/analysis.c
|
|
||||||
opus/src/mapping_matrix.c
|
|
||||||
opus/src/mlp.c
|
|
||||||
opus/src/mlp_data.c
|
|
||||||
opus/src/opus.c
|
|
||||||
opus/src/opus_decoder.c
|
|
||||||
opus/src/opus_encoder.c
|
|
||||||
opus/src/opus_multistream.c
|
|
||||||
opus/src/opus_multistream_decoder.c
|
|
||||||
opus/src/opus_multistream_encoder.c
|
|
||||||
opus/src/opus_projection_decoder.c
|
|
||||||
opus/src/opus_projection_encoder.c
|
|
||||||
opus/src/repacketizer.c
|
|
||||||
)
|
|
||||||
|
|
||||||
if (DEBUG)
|
|
||||||
target_sources(opus PRIVATE opus/silk/debug.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (OPUS_FIXED_POINT)
|
|
||||||
target_sources(opus PRIVATE
|
|
||||||
opus/silk/fixed/LTP_analysis_filter_FIX.c
|
|
||||||
opus/silk/fixed/LTP_scale_ctrl_FIX.c
|
|
||||||
opus/silk/fixed/apply_sine_window_FIX.c
|
|
||||||
opus/silk/fixed/autocorr_FIX.c
|
|
||||||
opus/silk/fixed/burg_modified_FIX.c
|
|
||||||
opus/silk/fixed/corrMatrix_FIX.c
|
|
||||||
opus/silk/fixed/encode_frame_FIX.c
|
|
||||||
opus/silk/fixed/find_LPC_FIX.c
|
|
||||||
opus/silk/fixed/find_LTP_FIX.c
|
|
||||||
opus/silk/fixed/find_pitch_lags_FIX.c
|
|
||||||
opus/silk/fixed/find_pred_coefs_FIX.c
|
|
||||||
opus/silk/fixed/k2a_FIX.c
|
|
||||||
opus/silk/fixed/k2a_Q16_FIX.c
|
|
||||||
opus/silk/fixed/noise_shape_analysis_FIX.c
|
|
||||||
opus/silk/fixed/pitch_analysis_core_FIX.c
|
|
||||||
opus/silk/fixed/prefilter_FIX.c
|
|
||||||
opus/silk/fixed/process_gains_FIX.c
|
|
||||||
opus/silk/fixed/regularize_correlations_FIX.c
|
|
||||||
opus/silk/fixed/residual_energy16_FIX.c
|
|
||||||
opus/silk/fixed/residual_energy_FIX.c
|
|
||||||
opus/silk/fixed/schur64_FIX.c
|
|
||||||
opus/silk/fixed/schur_FIX.c
|
|
||||||
opus/silk/fixed/solve_LS_FIX.c
|
|
||||||
opus/silk/fixed/vector_ops_FIX.c
|
|
||||||
opus/silk/fixed/warped_autocorrelation_FIX.c
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
target_sources(opus PRIVATE
|
|
||||||
opus/silk/float/LPC_analysis_filter_FLP.c
|
|
||||||
opus/silk/float/LPC_inv_pred_gain_FLP.c
|
|
||||||
opus/silk/float/LTP_analysis_filter_FLP.c
|
|
||||||
opus/silk/float/LTP_scale_ctrl_FLP.c
|
|
||||||
opus/silk/float/apply_sine_window_FLP.c
|
|
||||||
opus/silk/float/autocorrelation_FLP.c
|
|
||||||
opus/silk/float/burg_modified_FLP.c
|
|
||||||
opus/silk/float/bwexpander_FLP.c
|
|
||||||
opus/silk/float/corrMatrix_FLP.c
|
|
||||||
opus/silk/float/encode_frame_FLP.c
|
|
||||||
opus/silk/float/energy_FLP.c
|
|
||||||
opus/silk/float/find_LPC_FLP.c
|
|
||||||
opus/silk/float/find_LTP_FLP.c
|
|
||||||
opus/silk/float/find_pitch_lags_FLP.c
|
|
||||||
opus/silk/float/find_pred_coefs_FLP.c
|
|
||||||
opus/silk/float/inner_product_FLP.c
|
|
||||||
opus/silk/float/k2a_FLP.c
|
|
||||||
opus/silk/float/noise_shape_analysis_FLP.c
|
|
||||||
opus/silk/float/pitch_analysis_core_FLP.c
|
|
||||||
opus/silk/float/process_gains_FLP.c
|
|
||||||
opus/silk/float/regularize_correlations_FLP.c
|
|
||||||
opus/silk/float/residual_energy_FLP.c
|
|
||||||
opus/silk/float/scale_copy_vector_FLP.c
|
|
||||||
opus/silk/float/scale_vector_FLP.c
|
|
||||||
opus/silk/float/schur_FLP.c
|
|
||||||
opus/silk/float/sort_FLP.c
|
|
||||||
opus/silk/float/warped_autocorrelation_FLP.c
|
|
||||||
opus/silk/float/wrappers_FLP.c
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_definitions(opus PRIVATE OPUS_BUILD ENABLE_HARDENING)
|
|
||||||
|
|
||||||
if(NOT MSVC)
|
|
||||||
if(MINGW)
|
|
||||||
target_compile_definitions(opus PRIVATE _FORTIFY_SOURCE=0)
|
|
||||||
else()
|
|
||||||
target_compile_definitions(opus PRIVATE _FORTIFY_SOURCE=2)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# It is strongly recommended to uncomment one of these VAR_ARRAYS: Use C99
|
|
||||||
# variable-length arrays for stack allocation USE_ALLOCA: Use alloca() for stack
|
|
||||||
# allocation If none is defined, then the fallback is a non-threadsafe global
|
|
||||||
# array
|
|
||||||
if(OPUS_USE_ALLOCA OR MSVC)
|
|
||||||
target_compile_definitions(opus PRIVATE USE_ALLOCA)
|
|
||||||
else()
|
|
||||||
target_compile_definitions(opus PRIVATE VAR_ARRAYS)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(OPUS_CUSTOM_MODES)
|
|
||||||
target_compile_definitions(opus PRIVATE CUSTOM_MODES)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT OPUS_ENABLE_FLOAT_API)
|
|
||||||
target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_definitions(opus
|
|
||||||
PUBLIC
|
|
||||||
-DOPUS_VERSION="\\"1.3.1\\""
|
|
||||||
|
|
||||||
PRIVATE
|
|
||||||
# Use C99 intrinsics to speed up float-to-int conversion
|
|
||||||
HAVE_LRINTF
|
|
||||||
)
|
|
||||||
|
|
||||||
if (FIXED_POINT)
|
|
||||||
target_compile_definitions(opus PRIVATE -DFIXED_POINT=1 -DDISABLE_FLOAT_API)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_include_directories(opus
|
|
||||||
PUBLIC
|
|
||||||
opus/include
|
|
||||||
|
|
||||||
PRIVATE
|
|
||||||
opus/celt
|
|
||||||
opus/silk
|
|
||||||
opus/silk/fixed
|
|
||||||
opus/silk/float
|
|
||||||
opus/src
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(Opus::opus ALIAS opus)
|
|
1
externals/opus/opus
vendored
1
externals/opus/opus
vendored
Submodule externals/opus/opus deleted from ad8fe90db7
7529
externals/stb/stb_image.cpp
vendored
7529
externals/stb/stb_image.cpp
vendored
File diff suppressed because it is too large
Load Diff
7221
externals/stb/stb_image.h
vendored
7221
externals/stb/stb_image.h
vendored
File diff suppressed because it is too large
Load Diff
2282
externals/stb/stb_image_resize.cpp
vendored
2282
externals/stb/stb_image_resize.cpp
vendored
File diff suppressed because it is too large
Load Diff
2214
externals/stb/stb_image_resize.h
vendored
2214
externals/stb/stb_image_resize.h
vendored
File diff suppressed because it is too large
Load Diff
1724
externals/stb/stb_image_write.h
vendored
Normal file
1724
externals/stb/stb_image_write.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
externals/vcpkg
vendored
2
externals/vcpkg
vendored
Submodule externals/vcpkg updated: cbf56573a9...ef2eef1734
@ -5,6 +5,7 @@ package org.yuzu.yuzu_emu
|
|||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
@ -16,7 +17,7 @@ import androidx.fragment.app.DialogFragment
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
||||||
import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath
|
import org.yuzu.yuzu_emu.utils.DocumentsTree
|
||||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||||
import org.yuzu.yuzu_emu.utils.Log
|
import org.yuzu.yuzu_emu.utils.Log
|
||||||
import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable
|
import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable
|
||||||
@ -68,7 +69,7 @@ object NativeLibrary {
|
|||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun openContentUri(path: String?, openmode: String?): Int {
|
fun openContentUri(path: String?, openmode: String?): Int {
|
||||||
return if (isNativePath(path!!)) {
|
return if (DocumentsTree.isNativePath(path!!)) {
|
||||||
YuzuApplication.documentsTree!!.openContentUri(path, openmode)
|
YuzuApplication.documentsTree!!.openContentUri(path, openmode)
|
||||||
} else {
|
} else {
|
||||||
FileUtil.openContentUri(path, openmode)
|
FileUtil.openContentUri(path, openmode)
|
||||||
@ -78,7 +79,7 @@ object NativeLibrary {
|
|||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getSize(path: String?): Long {
|
fun getSize(path: String?): Long {
|
||||||
return if (isNativePath(path!!)) {
|
return if (DocumentsTree.isNativePath(path!!)) {
|
||||||
YuzuApplication.documentsTree!!.getFileSize(path)
|
YuzuApplication.documentsTree!!.getFileSize(path)
|
||||||
} else {
|
} else {
|
||||||
FileUtil.getFileSize(path)
|
FileUtil.getFileSize(path)
|
||||||
@ -88,23 +89,41 @@ object NativeLibrary {
|
|||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun exists(path: String?): Boolean {
|
fun exists(path: String?): Boolean {
|
||||||
return if (isNativePath(path!!)) {
|
return if (DocumentsTree.isNativePath(path!!)) {
|
||||||
YuzuApplication.documentsTree!!.exists(path)
|
YuzuApplication.documentsTree!!.exists(path)
|
||||||
} else {
|
} else {
|
||||||
FileUtil.exists(path)
|
FileUtil.exists(path, suppressLog = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isDirectory(path: String?): Boolean {
|
fun isDirectory(path: String?): Boolean {
|
||||||
return if (isNativePath(path!!)) {
|
return if (DocumentsTree.isNativePath(path!!)) {
|
||||||
YuzuApplication.documentsTree!!.isDirectory(path)
|
YuzuApplication.documentsTree!!.isDirectory(path)
|
||||||
} else {
|
} else {
|
||||||
FileUtil.isDirectory(path)
|
FileUtil.isDirectory(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
@JvmStatic
|
||||||
|
fun getParentDirectory(path: String): String =
|
||||||
|
if (DocumentsTree.isNativePath(path)) {
|
||||||
|
YuzuApplication.documentsTree!!.getParentDirectory(path)
|
||||||
|
} else {
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
@JvmStatic
|
||||||
|
fun getFilename(path: String): String =
|
||||||
|
if (DocumentsTree.isNativePath(path)) {
|
||||||
|
YuzuApplication.documentsTree!!.getFilename(path)
|
||||||
|
} else {
|
||||||
|
FileUtil.getFilename(Uri.parse(path))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if pro controller isn't available and handheld is
|
* Returns true if pro controller isn't available and handheld is
|
||||||
*/
|
*/
|
||||||
@ -215,32 +234,6 @@ object NativeLibrary {
|
|||||||
|
|
||||||
external fun initGameIni(gameID: String?)
|
external fun initGameIni(gameID: String?)
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the embedded icon within the given ROM.
|
|
||||||
*
|
|
||||||
* @param filename the file path to the ROM.
|
|
||||||
* @return a byte array containing the JPEG data for the icon.
|
|
||||||
*/
|
|
||||||
external fun getIcon(filename: String): ByteArray
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the embedded title of the given ISO/ROM.
|
|
||||||
*
|
|
||||||
* @param filename The file path to the ISO/ROM.
|
|
||||||
* @return the embedded title of the ISO/ROM.
|
|
||||||
*/
|
|
||||||
external fun getTitle(filename: String): String
|
|
||||||
|
|
||||||
external fun getDescription(filename: String): String
|
|
||||||
|
|
||||||
external fun getGameId(filename: String): String
|
|
||||||
|
|
||||||
external fun getRegions(filename: String): String
|
|
||||||
|
|
||||||
external fun getCompany(filename: String): String
|
|
||||||
|
|
||||||
external fun isHomebrew(filename: String): Boolean
|
|
||||||
|
|
||||||
external fun setAppDirectory(directory: String)
|
external fun setAppDirectory(directory: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,7 +252,7 @@ object NativeLibrary {
|
|||||||
|
|
||||||
external fun reloadKeys(): Boolean
|
external fun reloadKeys(): Boolean
|
||||||
|
|
||||||
external fun initializeEmulation()
|
external fun initializeSystem()
|
||||||
|
|
||||||
external fun defaultCPUCore(): Int
|
external fun defaultCPUCore(): Int
|
||||||
|
|
||||||
@ -293,11 +286,6 @@ object NativeLibrary {
|
|||||||
*/
|
*/
|
||||||
external fun stopEmulation()
|
external fun stopEmulation()
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the in-memory ROM metadata cache.
|
|
||||||
*/
|
|
||||||
external fun resetRomMetadata()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if emulation is running (or is paused).
|
* Returns true if emulation is running (or is paused).
|
||||||
*/
|
*/
|
||||||
@ -517,6 +505,36 @@ object NativeLibrary {
|
|||||||
*/
|
*/
|
||||||
external fun initializeEmptyUserDirectory()
|
external fun initializeEmptyUserDirectory()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the launch path for a given applet. It is the caller's responsibility to also
|
||||||
|
* set the system's current applet ID before trying to launch the nca given by this function.
|
||||||
|
*
|
||||||
|
* @param id The applet entry ID
|
||||||
|
* @return The applet's launch path
|
||||||
|
*/
|
||||||
|
external fun getAppletLaunchPath(id: Long): String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the system's current applet ID before launching.
|
||||||
|
*
|
||||||
|
* @param appletId One of the ids in the Service::AM::Applets::AppletId enum
|
||||||
|
*/
|
||||||
|
external fun setCurrentAppletId(appletId: Int)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cabinet mode for launching the cabinet applet.
|
||||||
|
*
|
||||||
|
* @param cabinetMode One of the modes that corresponds to the enum in Service::NFP::CabinetMode
|
||||||
|
*/
|
||||||
|
external fun setCabinetMode(cabinetMode: Int)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether NAND contents are available and valid.
|
||||||
|
*
|
||||||
|
* @return 'true' if firmware is available
|
||||||
|
*/
|
||||||
|
external fun isFirmwareAvailable(): Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Button type for use in onTouchEvent
|
* Button type for use in onTouchEvent
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +45,6 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
|||||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||||
import org.yuzu.yuzu_emu.model.EmulationViewModel
|
import org.yuzu.yuzu_emu.model.EmulationViewModel
|
||||||
import org.yuzu.yuzu_emu.model.Game
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
|
|
||||||
import org.yuzu.yuzu_emu.utils.ForegroundService
|
import org.yuzu.yuzu_emu.utils.ForegroundService
|
||||||
import org.yuzu.yuzu_emu.utils.InputHandler
|
import org.yuzu.yuzu_emu.utils.InputHandler
|
||||||
import org.yuzu.yuzu_emu.utils.MemoryUtil
|
import org.yuzu.yuzu_emu.utils.MemoryUtil
|
||||||
@ -57,17 +56,16 @@ import kotlin.math.roundToInt
|
|||||||
class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
private lateinit var binding: ActivityEmulationBinding
|
private lateinit var binding: ActivityEmulationBinding
|
||||||
|
|
||||||
private var controllerMappingHelper: ControllerMappingHelper? = null
|
|
||||||
|
|
||||||
var isActivityRecreated = false
|
var isActivityRecreated = false
|
||||||
private lateinit var nfcReader: NfcReader
|
private lateinit var nfcReader: NfcReader
|
||||||
private lateinit var inputHandler: InputHandler
|
|
||||||
|
|
||||||
private val gyro = FloatArray(3)
|
private val gyro = FloatArray(3)
|
||||||
private val accel = FloatArray(3)
|
private val accel = FloatArray(3)
|
||||||
private var motionTimestamp: Long = 0
|
private var motionTimestamp: Long = 0
|
||||||
private var flipMotionOrientation: Boolean = false
|
private var flipMotionOrientation: Boolean = false
|
||||||
|
|
||||||
|
private var controllerIds = InputHandler.getGameControllerIds()
|
||||||
|
|
||||||
private val actionPause = "ACTION_EMULATOR_PAUSE"
|
private val actionPause = "ACTION_EMULATOR_PAUSE"
|
||||||
private val actionPlay = "ACTION_EMULATOR_PLAY"
|
private val actionPlay = "ACTION_EMULATOR_PLAY"
|
||||||
private val actionMute = "ACTION_EMULATOR_MUTE"
|
private val actionMute = "ACTION_EMULATOR_MUTE"
|
||||||
@ -95,8 +93,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
|
|
||||||
isActivityRecreated = savedInstanceState != null
|
isActivityRecreated = savedInstanceState != null
|
||||||
|
|
||||||
controllerMappingHelper = ControllerMappingHelper()
|
|
||||||
|
|
||||||
// Set these options now so that the SurfaceView the game renders into is the right size.
|
// Set these options now so that the SurfaceView the game renders into is the right size.
|
||||||
enableFullscreenImmersive()
|
enableFullscreenImmersive()
|
||||||
|
|
||||||
@ -105,8 +101,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
nfcReader = NfcReader(this)
|
nfcReader = NfcReader(this)
|
||||||
nfcReader.initialize()
|
nfcReader.initialize()
|
||||||
|
|
||||||
inputHandler = InputHandler()
|
InputHandler.initialize()
|
||||||
inputHandler.initialize()
|
|
||||||
|
|
||||||
val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||||
if (!preferences.getBoolean(Settings.PREF_MEMORY_WARNING_SHOWN, false)) {
|
if (!preferences.getBoolean(Settings.PREF_MEMORY_WARNING_SHOWN, false)) {
|
||||||
@ -162,6 +157,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
nfcReader.startScanning()
|
nfcReader.startScanning()
|
||||||
startMotionSensorListener()
|
startMotionSensorListener()
|
||||||
|
InputHandler.updateControllerIds()
|
||||||
|
|
||||||
buildPictureInPictureParams()
|
buildPictureInPictureParams()
|
||||||
}
|
}
|
||||||
@ -195,7 +191,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
return super.dispatchKeyEvent(event)
|
return super.dispatchKeyEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputHandler.dispatchKeyEvent(event)
|
return InputHandler.dispatchKeyEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
||||||
@ -210,7 +206,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputHandler.dispatchGenericMotionEvent(event)
|
return InputHandler.dispatchGenericMotionEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSensorChanged(event: SensorEvent) {
|
override fun onSensorChanged(event: SensorEvent) {
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.adapters
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.res.ResourcesCompat
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.navigation.findNavController
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||||
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import org.yuzu.yuzu_emu.YuzuApplication
|
||||||
|
import org.yuzu.yuzu_emu.databinding.CardAppletOptionBinding
|
||||||
|
import org.yuzu.yuzu_emu.model.Applet
|
||||||
|
import org.yuzu.yuzu_emu.model.AppletInfo
|
||||||
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
|
|
||||||
|
class AppletAdapter(val activity: FragmentActivity, var applets: List<Applet>) :
|
||||||
|
RecyclerView.Adapter<AppletAdapter.AppletViewHolder>(),
|
||||||
|
View.OnClickListener {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(
|
||||||
|
parent: ViewGroup,
|
||||||
|
viewType: Int
|
||||||
|
): AppletAdapter.AppletViewHolder {
|
||||||
|
CardAppletOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
.apply { root.setOnClickListener(this@AppletAdapter) }
|
||||||
|
.also { return AppletViewHolder(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: AppletViewHolder, position: Int) =
|
||||||
|
holder.bind(applets[position])
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = applets.size
|
||||||
|
|
||||||
|
override fun onClick(view: View) {
|
||||||
|
val applet = (view.tag as AppletViewHolder).applet
|
||||||
|
val appletPath = NativeLibrary.getAppletLaunchPath(applet.appletInfo.entryId)
|
||||||
|
if (appletPath.isEmpty()) {
|
||||||
|
Toast.makeText(
|
||||||
|
YuzuApplication.appContext,
|
||||||
|
R.string.applets_error_applet,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (applet.appletInfo == AppletInfo.Cabinet) {
|
||||||
|
view.findNavController()
|
||||||
|
.navigate(R.id.action_appletLauncherFragment_to_cabinetLauncherDialogFragment)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
NativeLibrary.setCurrentAppletId(applet.appletInfo.appletId)
|
||||||
|
val appletGame = Game(
|
||||||
|
title = YuzuApplication.appContext.getString(applet.titleId),
|
||||||
|
path = appletPath
|
||||||
|
)
|
||||||
|
val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame)
|
||||||
|
view.findNavController().navigate(action)
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class AppletViewHolder(val binding: CardAppletOptionBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
lateinit var applet: Applet
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemView.tag = this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bind(applet: Applet) {
|
||||||
|
this.applet = applet
|
||||||
|
|
||||||
|
binding.title.setText(applet.titleId)
|
||||||
|
binding.description.setText(applet.descriptionId)
|
||||||
|
binding.icon.setImageDrawable(
|
||||||
|
ResourcesCompat.getDrawable(
|
||||||
|
binding.icon.context.resources,
|
||||||
|
applet.iconId,
|
||||||
|
binding.icon.context.theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.adapters
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.res.ResourcesCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||||
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import org.yuzu.yuzu_emu.YuzuApplication
|
||||||
|
import org.yuzu.yuzu_emu.databinding.DialogListItemBinding
|
||||||
|
import org.yuzu.yuzu_emu.model.CabinetMode
|
||||||
|
import org.yuzu.yuzu_emu.adapters.CabinetLauncherDialogAdapter.CabinetModeViewHolder
|
||||||
|
import org.yuzu.yuzu_emu.model.AppletInfo
|
||||||
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
|
|
||||||
|
class CabinetLauncherDialogAdapter(val fragment: Fragment) :
|
||||||
|
RecyclerView.Adapter<CabinetModeViewHolder>(),
|
||||||
|
View.OnClickListener {
|
||||||
|
private val cabinetModes = CabinetMode.values().copyOfRange(1, CabinetMode.values().size)
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CabinetModeViewHolder {
|
||||||
|
DialogListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
.apply { root.setOnClickListener(this@CabinetLauncherDialogAdapter) }
|
||||||
|
.also { return CabinetModeViewHolder(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = cabinetModes.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: CabinetModeViewHolder, position: Int) =
|
||||||
|
holder.bind(cabinetModes[position])
|
||||||
|
|
||||||
|
override fun onClick(view: View) {
|
||||||
|
val mode = (view.tag as CabinetModeViewHolder).cabinetMode
|
||||||
|
val appletPath = NativeLibrary.getAppletLaunchPath(AppletInfo.Cabinet.entryId)
|
||||||
|
NativeLibrary.setCurrentAppletId(AppletInfo.Cabinet.appletId)
|
||||||
|
NativeLibrary.setCabinetMode(mode.id)
|
||||||
|
val appletGame = Game(
|
||||||
|
title = YuzuApplication.appContext.getString(R.string.cabinet_applet),
|
||||||
|
path = appletPath
|
||||||
|
)
|
||||||
|
val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame)
|
||||||
|
fragment.findNavController().navigate(action)
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class CabinetModeViewHolder(val binding: DialogListItemBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
lateinit var cabinetMode: CabinetMode
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemView.tag = this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bind(cabinetMode: CabinetMode) {
|
||||||
|
this.cabinetMode = cabinetMode
|
||||||
|
binding.icon.setImageDrawable(
|
||||||
|
ResourcesCompat.getDrawable(
|
||||||
|
binding.icon.context.resources,
|
||||||
|
cabinetMode.iconId,
|
||||||
|
binding.icon.context.theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
binding.title.setText(cabinetMode.titleId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -147,7 +147,7 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
|||||||
|
|
||||||
private class DiffCallback : DiffUtil.ItemCallback<Game>() {
|
private class DiffCallback : DiffUtil.ItemCallback<Game>() {
|
||||||
override fun areItemsTheSame(oldItem: Game, newItem: Game): Boolean {
|
override fun areItemsTheSame(oldItem: Game, newItem: Game): Boolean {
|
||||||
return oldItem.gameId == newItem.gameId
|
return oldItem.programId == newItem.programId
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItem: Game, newItem: Game): Boolean {
|
override fun areContentsTheSame(oldItem: Game, newItem: Game): Boolean {
|
||||||
|
@ -0,0 +1,113 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.fragments
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.navigation.findNavController
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import org.yuzu.yuzu_emu.adapters.AppletAdapter
|
||||||
|
import org.yuzu.yuzu_emu.databinding.FragmentAppletLauncherBinding
|
||||||
|
import org.yuzu.yuzu_emu.model.Applet
|
||||||
|
import org.yuzu.yuzu_emu.model.AppletInfo
|
||||||
|
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||||
|
|
||||||
|
class AppletLauncherFragment : Fragment() {
|
||||||
|
private var _binding: FragmentAppletLauncherBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||||
|
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||||
|
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
_binding = FragmentAppletLauncherBinding.inflate(inflater)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
homeViewModel.setNavigationVisibility(visible = false, animated = true)
|
||||||
|
homeViewModel.setStatusBarShadeVisibility(visible = false)
|
||||||
|
|
||||||
|
binding.toolbarApplets.setNavigationOnClickListener {
|
||||||
|
binding.root.findNavController().popBackStack()
|
||||||
|
}
|
||||||
|
|
||||||
|
val applets = listOf(
|
||||||
|
Applet(
|
||||||
|
R.string.album_applet,
|
||||||
|
R.string.album_applet_description,
|
||||||
|
R.drawable.ic_album,
|
||||||
|
AppletInfo.PhotoViewer
|
||||||
|
),
|
||||||
|
Applet(
|
||||||
|
R.string.cabinet_applet,
|
||||||
|
R.string.cabinet_applet_description,
|
||||||
|
R.drawable.ic_nfc,
|
||||||
|
AppletInfo.Cabinet
|
||||||
|
),
|
||||||
|
Applet(
|
||||||
|
R.string.mii_edit_applet,
|
||||||
|
R.string.mii_edit_applet_description,
|
||||||
|
R.drawable.ic_mii,
|
||||||
|
AppletInfo.MiiEdit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
binding.listApplets.apply {
|
||||||
|
layoutManager = GridLayoutManager(
|
||||||
|
requireContext(),
|
||||||
|
resources.getInteger(R.integer.grid_columns)
|
||||||
|
)
|
||||||
|
adapter = AppletAdapter(requireActivity(), applets)
|
||||||
|
}
|
||||||
|
|
||||||
|
setInsets()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setInsets() =
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
|
binding.root
|
||||||
|
) { _: View, windowInsets: WindowInsetsCompat ->
|
||||||
|
val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout())
|
||||||
|
|
||||||
|
val leftInsets = barInsets.left + cutoutInsets.left
|
||||||
|
val rightInsets = barInsets.right + cutoutInsets.right
|
||||||
|
|
||||||
|
val mlpAppBar = binding.toolbarApplets.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
mlpAppBar.leftMargin = leftInsets
|
||||||
|
mlpAppBar.rightMargin = rightInsets
|
||||||
|
binding.toolbarApplets.layoutParams = mlpAppBar
|
||||||
|
|
||||||
|
val mlpListApplets =
|
||||||
|
binding.listApplets.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
mlpListApplets.leftMargin = leftInsets
|
||||||
|
mlpListApplets.rightMargin = rightInsets
|
||||||
|
binding.listApplets.layoutParams = mlpListApplets
|
||||||
|
|
||||||
|
binding.listApplets.updatePadding(bottom = barInsets.bottom)
|
||||||
|
|
||||||
|
windowInsets
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.fragments
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import org.yuzu.yuzu_emu.adapters.CabinetLauncherDialogAdapter
|
||||||
|
import org.yuzu.yuzu_emu.databinding.DialogListBinding
|
||||||
|
|
||||||
|
class CabinetLauncherDialogFragment : DialogFragment() {
|
||||||
|
private lateinit var binding: DialogListBinding
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
binding = DialogListBinding.inflate(layoutInflater)
|
||||||
|
binding.dialogList.apply {
|
||||||
|
layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
adapter = CabinetLauncherDialogAdapter(this@CabinetLauncherDialogFragment)
|
||||||
|
}
|
||||||
|
|
||||||
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.cabinet_launcher)
|
||||||
|
.setView(binding.root)
|
||||||
|
.create()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import android.net.Uri
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.os.SystemClock
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -25,6 +26,7 @@ import androidx.core.graphics.Insets
|
|||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
|
import androidx.drawerlayout.widget.DrawerLayout.DrawerListener
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
@ -156,6 +158,32 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||||||
binding.showFpsText.setTextColor(Color.YELLOW)
|
binding.showFpsText.setTextColor(Color.YELLOW)
|
||||||
binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
|
binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
|
||||||
|
|
||||||
|
binding.drawerLayout.addDrawerListener(object : DrawerListener {
|
||||||
|
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
||||||
|
binding.surfaceInputOverlay.dispatchTouchEvent(
|
||||||
|
MotionEvent.obtain(
|
||||||
|
SystemClock.uptimeMillis(),
|
||||||
|
SystemClock.uptimeMillis() + 100,
|
||||||
|
MotionEvent.ACTION_UP,
|
||||||
|
0f,
|
||||||
|
0f,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDrawerOpened(drawerView: View) {
|
||||||
|
// No op
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDrawerClosed(drawerView: View) {
|
||||||
|
// No op
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDrawerStateChanged(newState: Int) {
|
||||||
|
// No op
|
||||||
|
}
|
||||||
|
})
|
||||||
binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
||||||
binding.inGameMenu.getHeaderView(0).findViewById<TextView>(R.id.text_game_title).text =
|
binding.inGameMenu.getHeaderView(0).findViewById<TextView>(R.id.text_game_title).text =
|
||||||
game.title
|
game.title
|
||||||
|
@ -26,10 +26,11 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
import org.yuzu.yuzu_emu.BuildConfig
|
import org.yuzu.yuzu_emu.BuildConfig
|
||||||
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||||
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.adapters.HomeSettingAdapter
|
import org.yuzu.yuzu_emu.adapters.HomeSettingAdapter
|
||||||
import org.yuzu.yuzu_emu.databinding.FragmentHomeSettingsBinding
|
import org.yuzu.yuzu_emu.databinding.FragmentHomeSettingsBinding
|
||||||
@ -131,6 +132,20 @@ class HomeSettingsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
add(
|
||||||
|
HomeSetting(
|
||||||
|
R.string.applets,
|
||||||
|
R.string.applets_description,
|
||||||
|
R.drawable.ic_applet,
|
||||||
|
{
|
||||||
|
binding.root.findNavController()
|
||||||
|
.navigate(R.id.action_homeSettingsFragment_to_appletLauncherFragment)
|
||||||
|
},
|
||||||
|
{ NativeLibrary.isFirmwareAvailable() },
|
||||||
|
R.string.applets_error_firmware,
|
||||||
|
R.string.applets_error_description
|
||||||
|
)
|
||||||
|
)
|
||||||
add(
|
add(
|
||||||
HomeSetting(
|
HomeSetting(
|
||||||
R.string.select_games_folder,
|
R.string.select_games_folder,
|
||||||
@ -186,7 +201,8 @@ class HomeSettingsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.homeSettingsList.apply {
|
binding.homeSettingsList.apply {
|
||||||
layoutManager = LinearLayoutManager(requireContext())
|
layoutManager =
|
||||||
|
GridLayoutManager(requireContext(), resources.getInteger(R.integer.grid_columns))
|
||||||
adapter = HomeSettingAdapter(
|
adapter = HomeSettingAdapter(
|
||||||
requireActivity() as AppCompatActivity,
|
requireActivity() as AppCompatActivity,
|
||||||
viewLifecycleOwner,
|
viewLifecycleOwner,
|
||||||
|
@ -8,6 +8,7 @@ import android.content.DialogInterface
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.Html
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@ -32,7 +33,9 @@ class MessageDialogFragment : DialogFragment() {
|
|||||||
if (titleId != 0) dialog.setTitle(titleId)
|
if (titleId != 0) dialog.setTitle(titleId)
|
||||||
if (titleString.isNotEmpty()) dialog.setTitle(titleString)
|
if (titleString.isNotEmpty()) dialog.setTitle(titleString)
|
||||||
|
|
||||||
if (descriptionId != 0) dialog.setMessage(descriptionId)
|
if (descriptionId != 0) {
|
||||||
|
dialog.setMessage(Html.fromHtml(getString(descriptionId), Html.FROM_HTML_MODE_LEGACY))
|
||||||
|
}
|
||||||
if (descriptionString.isNotEmpty()) dialog.setMessage(descriptionString)
|
if (descriptionString.isNotEmpty()) dialog.setMessage(descriptionString)
|
||||||
|
|
||||||
if (helpLinkId != 0) {
|
if (helpLinkId != 0) {
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.model
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
|
|
||||||
|
data class Applet(
|
||||||
|
@StringRes val titleId: Int,
|
||||||
|
@StringRes val descriptionId: Int,
|
||||||
|
@DrawableRes val iconId: Int,
|
||||||
|
val appletInfo: AppletInfo,
|
||||||
|
val cabinetMode: CabinetMode = CabinetMode.None
|
||||||
|
)
|
||||||
|
|
||||||
|
// Combination of Common::AM::Applets::AppletId enum and the entry id
|
||||||
|
enum class AppletInfo(val appletId: Int, val entryId: Long = 0) {
|
||||||
|
None(0x00),
|
||||||
|
Application(0x01),
|
||||||
|
OverlayDisplay(0x02),
|
||||||
|
QLaunch(0x03),
|
||||||
|
Starter(0x04),
|
||||||
|
Auth(0x0A),
|
||||||
|
Cabinet(0x0B, 0x0100000000001002),
|
||||||
|
Controller(0x0C),
|
||||||
|
DataErase(0x0D),
|
||||||
|
Error(0x0E),
|
||||||
|
NetConnect(0x0F),
|
||||||
|
ProfileSelect(0x10),
|
||||||
|
SoftwareKeyboard(0x11),
|
||||||
|
MiiEdit(0x12, 0x0100000000001009),
|
||||||
|
Web(0x13),
|
||||||
|
Shop(0x14),
|
||||||
|
PhotoViewer(0x015, 0x010000000000100D),
|
||||||
|
Settings(0x16),
|
||||||
|
OfflineWeb(0x17),
|
||||||
|
LoginShare(0x18),
|
||||||
|
WebAuth(0x19),
|
||||||
|
MyPage(0x1A)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Matches enum in Service::NFP::CabinetMode with extra metadata
|
||||||
|
enum class CabinetMode(
|
||||||
|
val id: Int,
|
||||||
|
@StringRes val titleId: Int = 0,
|
||||||
|
@DrawableRes val iconId: Int = 0
|
||||||
|
) {
|
||||||
|
None(-1),
|
||||||
|
StartNicknameAndOwnerSettings(0, R.string.cabinet_nickname_and_owner, R.drawable.ic_edit),
|
||||||
|
StartGameDataEraser(1, R.string.cabinet_game_data_eraser, R.drawable.ic_refresh),
|
||||||
|
StartRestorer(2, R.string.cabinet_restorer, R.drawable.ic_restore),
|
||||||
|
StartFormatter(3, R.string.cabinet_formatter, R.drawable.ic_clear)
|
||||||
|
}
|
@ -11,16 +11,15 @@ import kotlinx.serialization.Serializable
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
@Serializable
|
@Serializable
|
||||||
class Game(
|
class Game(
|
||||||
val title: String,
|
val title: String = "",
|
||||||
val description: String,
|
|
||||||
val regions: String,
|
|
||||||
val path: String,
|
val path: String,
|
||||||
val gameId: String,
|
val programId: String = "",
|
||||||
val company: String,
|
val developer: String = "",
|
||||||
val isHomebrew: Boolean
|
val version: String = "",
|
||||||
|
val isHomebrew: Boolean = false
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
val keyAddedToLibraryTime get() = "${gameId}_AddedToLibraryTime"
|
val keyAddedToLibraryTime get() = "${programId}_AddedToLibraryTime"
|
||||||
val keyLastPlayedTime get() = "${gameId}_LastPlayed"
|
val keyLastPlayedTime get() = "${programId}_LastPlayed"
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other !is Game) {
|
if (other !is Game) {
|
||||||
@ -32,11 +31,9 @@ class Game(
|
|||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
var result = title.hashCode()
|
var result = title.hashCode()
|
||||||
result = 31 * result + description.hashCode()
|
|
||||||
result = 31 * result + regions.hashCode()
|
|
||||||
result = 31 * result + path.hashCode()
|
result = 31 * result + path.hashCode()
|
||||||
result = 31 * result + gameId.hashCode()
|
result = 31 * result + programId.hashCode()
|
||||||
result = 31 * result + company.hashCode()
|
result = 31 * result + developer.hashCode()
|
||||||
result = 31 * result + isHomebrew.hashCode()
|
result = 31 * result + isHomebrew.hashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,13 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
|
||||||
import kotlinx.serialization.MissingFieldException
|
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.YuzuApplication
|
import org.yuzu.yuzu_emu.YuzuApplication
|
||||||
import org.yuzu.yuzu_emu.utils.GameHelper
|
import org.yuzu.yuzu_emu.utils.GameHelper
|
||||||
|
import org.yuzu.yuzu_emu.utils.GameMetadata
|
||||||
|
|
||||||
@OptIn(ExperimentalSerializationApi::class)
|
|
||||||
class GamesViewModel : ViewModel() {
|
class GamesViewModel : ViewModel() {
|
||||||
val games: StateFlow<List<Game>> get() = _games
|
val games: StateFlow<List<Game>> get() = _games
|
||||||
private val _games = MutableStateFlow(emptyList<Game>())
|
private val _games = MutableStateFlow(emptyList<Game>())
|
||||||
@ -49,19 +47,25 @@ class GamesViewModel : ViewModel() {
|
|||||||
// Retrieve list of cached games
|
// Retrieve list of cached games
|
||||||
val storedGames = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
val storedGames = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||||
.getStringSet(GameHelper.KEY_GAMES, emptySet())
|
.getStringSet(GameHelper.KEY_GAMES, emptySet())
|
||||||
|
|
||||||
|
viewModelScope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
if (storedGames!!.isNotEmpty()) {
|
if (storedGames!!.isNotEmpty()) {
|
||||||
val deserializedGames = mutableSetOf<Game>()
|
val deserializedGames = mutableSetOf<Game>()
|
||||||
storedGames.forEach {
|
storedGames.forEach {
|
||||||
val game: Game
|
val game: Game
|
||||||
try {
|
try {
|
||||||
game = Json.decodeFromString(it)
|
game = Json.decodeFromString(it)
|
||||||
} catch (e: MissingFieldException) {
|
} catch (e: Exception) {
|
||||||
|
// We don't care about any errors related to parsing the game cache
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
|
|
||||||
val gameExists =
|
val gameExists =
|
||||||
DocumentFile.fromSingleUri(YuzuApplication.appContext, Uri.parse(game.path))
|
DocumentFile.fromSingleUri(
|
||||||
?.exists()
|
YuzuApplication.appContext,
|
||||||
|
Uri.parse(game.path)
|
||||||
|
)?.exists()
|
||||||
if (gameExists == true) {
|
if (gameExists == true) {
|
||||||
deserializedGames.add(game)
|
deserializedGames.add(game)
|
||||||
}
|
}
|
||||||
@ -70,6 +74,8 @@ class GamesViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
reloadGames(false)
|
reloadGames(false)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setGames(games: List<Game>) {
|
fun setGames(games: List<Game>) {
|
||||||
val sortedList = games.sortedWith(
|
val sortedList = games.sortedWith(
|
||||||
@ -106,7 +112,7 @@ class GamesViewModel : ViewModel() {
|
|||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
NativeLibrary.resetRomMetadata()
|
GameMetadata.resetMetadata()
|
||||||
setGames(GameHelper.getGames())
|
setGames(GameHelper.getGames())
|
||||||
_isReloading.value = false
|
_isReloading.value = false
|
||||||
|
|
||||||
|
@ -403,6 +403,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
|||||||
} else {
|
} else {
|
||||||
firmwarePath.deleteRecursively()
|
firmwarePath.deleteRecursively()
|
||||||
cacheFirmwareDir.copyRecursively(firmwarePath, true)
|
cacheFirmwareDir.copyRecursively(firmwarePath, true)
|
||||||
|
NativeLibrary.initializeSystem()
|
||||||
getString(R.string.save_file_imported_success)
|
getString(R.string.save_file_imported_success)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -648,7 +649,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reinitialize relevant data
|
// Reinitialize relevant data
|
||||||
NativeLibrary.initializeEmulation()
|
NativeLibrary.initializeSystem()
|
||||||
gamesViewModel.reloadGames(false)
|
gamesViewModel.reloadGames(false)
|
||||||
|
|
||||||
return@newInstance getString(R.string.user_data_import_success)
|
return@newInstance getString(R.string.user_data_import_success)
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
package org.yuzu.yuzu_emu.utils
|
|
||||||
|
|
||||||
import android.view.InputDevice
|
|
||||||
import android.view.KeyEvent
|
|
||||||
import android.view.MotionEvent
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Some controllers have incorrect mappings. This class has special-case fixes for them.
|
|
||||||
*/
|
|
||||||
class ControllerMappingHelper {
|
|
||||||
/**
|
|
||||||
* Some controllers report extra button presses that can be ignored.
|
|
||||||
*/
|
|
||||||
fun shouldKeyBeIgnored(inputDevice: InputDevice, keyCode: Int): Boolean {
|
|
||||||
return if (isDualShock4(inputDevice)) {
|
|
||||||
// The two analog triggers generate analog motion events as well as a keycode.
|
|
||||||
// We always prefer to use the analog values, so throw away the button press
|
|
||||||
keyCode == KeyEvent.KEYCODE_BUTTON_L2 || keyCode == KeyEvent.KEYCODE_BUTTON_R2
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scale an axis to be zero-centered with a proper range.
|
|
||||||
*/
|
|
||||||
fun scaleAxis(inputDevice: InputDevice, axis: Int, value: Float): Float {
|
|
||||||
if (isDualShock4(inputDevice)) {
|
|
||||||
// Android doesn't have correct mappings for this controller's triggers. It reports them
|
|
||||||
// as RX & RY, centered at -1.0, and with a range of [-1.0, 1.0]
|
|
||||||
// Scale them to properly zero-centered with a range of [0.0, 1.0].
|
|
||||||
if (axis == MotionEvent.AXIS_RX || axis == MotionEvent.AXIS_RY) {
|
|
||||||
return (value + 1) / 2.0f
|
|
||||||
}
|
|
||||||
} else if (isXboxOneWireless(inputDevice)) {
|
|
||||||
// Same as the DualShock 4, the mappings are missing.
|
|
||||||
if (axis == MotionEvent.AXIS_Z || axis == MotionEvent.AXIS_RZ) {
|
|
||||||
return (value + 1) / 2.0f
|
|
||||||
}
|
|
||||||
if (axis == MotionEvent.AXIS_GENERIC_1) {
|
|
||||||
// This axis is stuck at ~.5. Ignore it.
|
|
||||||
return 0.0f
|
|
||||||
}
|
|
||||||
} else if (isMogaPro2Hid(inputDevice)) {
|
|
||||||
// This controller has a broken axis that reports a constant value. Ignore it.
|
|
||||||
if (axis == MotionEvent.AXIS_GENERIC_1) {
|
|
||||||
return 0.0f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sony DualShock 4 controller
|
|
||||||
private fun isDualShock4(inputDevice: InputDevice): Boolean {
|
|
||||||
return inputDevice.vendorId == 0x54c && inputDevice.productId == 0x9cc
|
|
||||||
}
|
|
||||||
|
|
||||||
// Microsoft Xbox One controller
|
|
||||||
private fun isXboxOneWireless(inputDevice: InputDevice): Boolean {
|
|
||||||
return inputDevice.vendorId == 0x45e && inputDevice.productId == 0x2e0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Moga Pro 2 HID
|
|
||||||
private fun isMogaPro2Hid(inputDevice: InputDevice): Boolean {
|
|
||||||
return inputDevice.vendorId == 0x20d6 && inputDevice.productId == 0x6271
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,7 +15,7 @@ object DirectoryInitialization {
|
|||||||
fun start() {
|
fun start() {
|
||||||
if (!areDirectoriesReady) {
|
if (!areDirectoriesReady) {
|
||||||
initializeInternalStorage()
|
initializeInternalStorage()
|
||||||
NativeLibrary.initializeEmulation()
|
NativeLibrary.initializeSystem()
|
||||||
areDirectoriesReady = true
|
areDirectoriesReady = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,23 @@ class DocumentsTree {
|
|||||||
return node != null && node.isDirectory
|
return node != null && node.isDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getParentDirectory(filepath: String): String {
|
||||||
|
val node = resolvePath(filepath)!!
|
||||||
|
val parentNode = node.parent
|
||||||
|
if (parentNode != null && parentNode.isDirectory) {
|
||||||
|
return parentNode.uri!!.toString()
|
||||||
|
}
|
||||||
|
return node.uri!!.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getFilename(filepath: String): String {
|
||||||
|
val node = resolvePath(filepath)
|
||||||
|
if (node != null) {
|
||||||
|
return node.name!!
|
||||||
|
}
|
||||||
|
return filepath
|
||||||
|
}
|
||||||
|
|
||||||
private fun resolvePath(filepath: String): DocumentsNode? {
|
private fun resolvePath(filepath: String): DocumentsNode? {
|
||||||
val tokens = StringTokenizer(filepath, File.separator, false)
|
val tokens = StringTokenizer(filepath, File.separator, false)
|
||||||
var iterator = root
|
var iterator = root
|
||||||
|
@ -144,7 +144,7 @@ object FileUtil {
|
|||||||
* @param path Native content uri path
|
* @param path Native content uri path
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
fun exists(path: String?): Boolean {
|
fun exists(path: String?, suppressLog: Boolean = false): Boolean {
|
||||||
var c: Cursor? = null
|
var c: Cursor? = null
|
||||||
try {
|
try {
|
||||||
val mUri = Uri.parse(path)
|
val mUri = Uri.parse(path)
|
||||||
@ -152,7 +152,9 @@ object FileUtil {
|
|||||||
c = context.contentResolver.query(mUri, columns, null, null, null)
|
c = context.contentResolver.query(mUri, columns, null, null, null)
|
||||||
return c!!.count > 0
|
return c!!.count > 0
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
if (!suppressLog) {
|
||||||
Log.info("[FileUtil] Cannot find file from given path, error: " + e.message)
|
Log.info("[FileUtil] Cannot find file from given path, error: " + e.message)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
closeQuietly(c)
|
closeQuietly(c)
|
||||||
}
|
}
|
||||||
|
@ -71,27 +71,26 @@ object GameHelper {
|
|||||||
|
|
||||||
fun getGame(uri: Uri, addedToLibrary: Boolean): Game {
|
fun getGame(uri: Uri, addedToLibrary: Boolean): Game {
|
||||||
val filePath = uri.toString()
|
val filePath = uri.toString()
|
||||||
var name = NativeLibrary.getTitle(filePath)
|
var name = GameMetadata.getTitle(filePath)
|
||||||
|
|
||||||
// If the game's title field is empty, use the filename.
|
// If the game's title field is empty, use the filename.
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
name = FileUtil.getFilename(uri)
|
name = FileUtil.getFilename(uri)
|
||||||
}
|
}
|
||||||
var gameId = NativeLibrary.getGameId(filePath)
|
var programId = GameMetadata.getProgramId(filePath)
|
||||||
|
|
||||||
// If the game's ID field is empty, use the filename without extension.
|
// If the game's ID field is empty, use the filename without extension.
|
||||||
if (gameId.isEmpty()) {
|
if (programId.isEmpty()) {
|
||||||
gameId = name.substring(0, name.lastIndexOf("."))
|
programId = name.substring(0, name.lastIndexOf("."))
|
||||||
}
|
}
|
||||||
|
|
||||||
val newGame = Game(
|
val newGame = Game(
|
||||||
name,
|
name,
|
||||||
NativeLibrary.getDescription(filePath).replace("\n", " "),
|
|
||||||
NativeLibrary.getRegions(filePath),
|
|
||||||
filePath,
|
filePath,
|
||||||
gameId,
|
programId,
|
||||||
NativeLibrary.getCompany(filePath),
|
GameMetadata.getDeveloper(filePath),
|
||||||
NativeLibrary.isHomebrew(filePath)
|
GameMetadata.getVersion(filePath),
|
||||||
|
GameMetadata.getIsHomebrew(filePath)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (addedToLibrary) {
|
if (addedToLibrary) {
|
||||||
|
@ -18,7 +18,6 @@ import coil.key.Keyer
|
|||||||
import coil.memory.MemoryCache
|
import coil.memory.MemoryCache
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
import coil.request.Options
|
import coil.request.Options
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.YuzuApplication
|
import org.yuzu.yuzu_emu.YuzuApplication
|
||||||
import org.yuzu.yuzu_emu.model.Game
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
@ -36,7 +35,7 @@ class GameIconFetcher(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun decodeGameIcon(uri: String): Bitmap? {
|
private fun decodeGameIcon(uri: String): Bitmap? {
|
||||||
val data = NativeLibrary.getIcon(uri)
|
val data = GameMetadata.getIcon(uri)
|
||||||
return BitmapFactory.decodeByteArray(
|
return BitmapFactory.decodeByteArray(
|
||||||
data,
|
data,
|
||||||
0,
|
0,
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.utils
|
||||||
|
|
||||||
|
object GameMetadata {
|
||||||
|
external fun getTitle(path: String): String
|
||||||
|
|
||||||
|
external fun getProgramId(path: String): String
|
||||||
|
|
||||||
|
external fun getDeveloper(path: String): String
|
||||||
|
|
||||||
|
external fun getVersion(path: String): String
|
||||||
|
|
||||||
|
external fun getIcon(path: String): ByteArray
|
||||||
|
|
||||||
|
external fun getIsHomebrew(path: String): Boolean
|
||||||
|
|
||||||
|
external fun resetMetadata()
|
||||||
|
}
|
@ -3,17 +3,24 @@
|
|||||||
|
|
||||||
package org.yuzu.yuzu_emu.utils
|
package org.yuzu.yuzu_emu.utils
|
||||||
|
|
||||||
|
import android.view.InputDevice
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
|
|
||||||
class InputHandler {
|
object InputHandler {
|
||||||
|
private var controllerIds = getGameControllerIds()
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
// Connect first controller
|
// Connect first controller
|
||||||
NativeLibrary.onGamePadConnectEvent(getPlayerNumber(NativeLibrary.Player1Device))
|
NativeLibrary.onGamePadConnectEvent(getPlayerNumber(NativeLibrary.Player1Device))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateControllerIds() {
|
||||||
|
controllerIds = getGameControllerIds()
|
||||||
|
}
|
||||||
|
|
||||||
fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||||
val button: Int = when (event.device.vendorId) {
|
val button: Int = when (event.device.vendorId) {
|
||||||
0x045E -> getInputXboxButtonKey(event.keyCode)
|
0x045E -> getInputXboxButtonKey(event.keyCode)
|
||||||
@ -35,7 +42,7 @@ class InputHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NativeLibrary.onGamePadButtonEvent(
|
return NativeLibrary.onGamePadButtonEvent(
|
||||||
getPlayerNumber(event.device.controllerNumber),
|
getPlayerNumber(event.device.controllerNumber, event.deviceId),
|
||||||
button,
|
button,
|
||||||
action
|
action
|
||||||
)
|
)
|
||||||
@ -58,9 +65,14 @@ class InputHandler {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPlayerNumber(index: Int): Int {
|
private fun getPlayerNumber(index: Int, deviceId: Int = -1): Int {
|
||||||
|
var deviceIndex = index
|
||||||
|
if (deviceId != -1) {
|
||||||
|
deviceIndex = controllerIds[deviceId]!!
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Joycons are handled as different controllers. Find a way to merge them.
|
// TODO: Joycons are handled as different controllers. Find a way to merge them.
|
||||||
return when (index) {
|
return when (deviceIndex) {
|
||||||
2 -> NativeLibrary.Player2Device
|
2 -> NativeLibrary.Player2Device
|
||||||
3 -> NativeLibrary.Player3Device
|
3 -> NativeLibrary.Player3Device
|
||||||
4 -> NativeLibrary.Player4Device
|
4 -> NativeLibrary.Player4Device
|
||||||
@ -238,7 +250,7 @@ class InputHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setGenericAxisInput(event: MotionEvent, axis: Int) {
|
private fun setGenericAxisInput(event: MotionEvent, axis: Int) {
|
||||||
val playerNumber = getPlayerNumber(event.device.controllerNumber)
|
val playerNumber = getPlayerNumber(event.device.controllerNumber, event.deviceId)
|
||||||
|
|
||||||
when (axis) {
|
when (axis) {
|
||||||
MotionEvent.AXIS_X, MotionEvent.AXIS_Y ->
|
MotionEvent.AXIS_X, MotionEvent.AXIS_Y ->
|
||||||
@ -297,7 +309,7 @@ class InputHandler {
|
|||||||
|
|
||||||
private fun setJoyconAxisInput(event: MotionEvent, axis: Int) {
|
private fun setJoyconAxisInput(event: MotionEvent, axis: Int) {
|
||||||
// Joycon support is half dead. Right joystick doesn't work
|
// Joycon support is half dead. Right joystick doesn't work
|
||||||
val playerNumber = getPlayerNumber(event.device.controllerNumber)
|
val playerNumber = getPlayerNumber(event.device.controllerNumber, event.deviceId)
|
||||||
|
|
||||||
when (axis) {
|
when (axis) {
|
||||||
MotionEvent.AXIS_X, MotionEvent.AXIS_Y ->
|
MotionEvent.AXIS_X, MotionEvent.AXIS_Y ->
|
||||||
@ -325,7 +337,7 @@ class InputHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setRazerAxisInput(event: MotionEvent, axis: Int) {
|
private fun setRazerAxisInput(event: MotionEvent, axis: Int) {
|
||||||
val playerNumber = getPlayerNumber(event.device.controllerNumber)
|
val playerNumber = getPlayerNumber(event.device.controllerNumber, event.deviceId)
|
||||||
|
|
||||||
when (axis) {
|
when (axis) {
|
||||||
MotionEvent.AXIS_X, MotionEvent.AXIS_Y ->
|
MotionEvent.AXIS_X, MotionEvent.AXIS_Y ->
|
||||||
@ -362,4 +374,33 @@ class InputHandler {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGameControllerIds(): Map<Int, Int> {
|
||||||
|
val gameControllerDeviceIds = mutableMapOf<Int, Int>()
|
||||||
|
val deviceIds = InputDevice.getDeviceIds()
|
||||||
|
var controllerSlot = 1
|
||||||
|
deviceIds.forEach { deviceId ->
|
||||||
|
InputDevice.getDevice(deviceId)?.apply {
|
||||||
|
// Don't over-assign controllers
|
||||||
|
if (controllerSlot >= 8) {
|
||||||
|
return gameControllerDeviceIds
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify that the device has gamepad buttons, control sticks, or both.
|
||||||
|
if (sources and InputDevice.SOURCE_GAMEPAD == InputDevice.SOURCE_GAMEPAD ||
|
||||||
|
sources and InputDevice.SOURCE_JOYSTICK == InputDevice.SOURCE_JOYSTICK
|
||||||
|
) {
|
||||||
|
// This device is a game controller. Store its device ID.
|
||||||
|
if (deviceId and id and vendorId and productId != 0) {
|
||||||
|
// Additionally filter out devices that have no ID
|
||||||
|
gameControllerDeviceIds
|
||||||
|
.takeIf { !it.contains(deviceId) }
|
||||||
|
?.put(deviceId, controllerSlot)
|
||||||
|
controllerSlot++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gameControllerDeviceIds
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,10 @@ add_library(yuzu-android SHARED
|
|||||||
id_cache.cpp
|
id_cache.cpp
|
||||||
id_cache.h
|
id_cache.h
|
||||||
native.cpp
|
native.cpp
|
||||||
|
native.h
|
||||||
native_config.cpp
|
native_config.cpp
|
||||||
uisettings.cpp
|
uisettings.cpp
|
||||||
|
game_metadata.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR})
|
set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR})
|
||||||
|
112
src/android/app/src/main/jni/game_metadata.cpp
Normal file
112
src/android/app/src/main/jni/game_metadata.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <core/core.h>
|
||||||
|
#include <core/file_sys/patch_manager.h>
|
||||||
|
#include <core/loader/nro.h>
|
||||||
|
#include <jni.h>
|
||||||
|
#include "core/loader/loader.h"
|
||||||
|
#include "jni/android_common/android_common.h"
|
||||||
|
#include "native.h"
|
||||||
|
|
||||||
|
struct RomMetadata {
|
||||||
|
std::string title;
|
||||||
|
u64 programId;
|
||||||
|
std::string developer;
|
||||||
|
std::string version;
|
||||||
|
std::vector<u8> icon;
|
||||||
|
bool isHomebrew;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unordered_map<std::string, RomMetadata> m_rom_metadata_cache;
|
||||||
|
|
||||||
|
RomMetadata CacheRomMetadata(const std::string& path) {
|
||||||
|
const auto file =
|
||||||
|
Core::GetGameFileFromPath(EmulationSession::GetInstance().System().GetFilesystem(), path);
|
||||||
|
auto loader = Loader::GetLoader(EmulationSession::GetInstance().System(), file, 0, 0);
|
||||||
|
|
||||||
|
RomMetadata entry;
|
||||||
|
loader->ReadTitle(entry.title);
|
||||||
|
loader->ReadProgramId(entry.programId);
|
||||||
|
loader->ReadIcon(entry.icon);
|
||||||
|
|
||||||
|
const FileSys::PatchManager pm{
|
||||||
|
entry.programId, EmulationSession::GetInstance().System().GetFileSystemController(),
|
||||||
|
EmulationSession::GetInstance().System().GetContentProvider()};
|
||||||
|
const auto control = pm.GetControlMetadata();
|
||||||
|
|
||||||
|
if (control.first != nullptr) {
|
||||||
|
entry.developer = control.first->GetDeveloperName();
|
||||||
|
entry.version = control.first->GetVersionString();
|
||||||
|
} else {
|
||||||
|
FileSys::NACP nacp;
|
||||||
|
if (loader->ReadControlData(nacp) == Loader::ResultStatus::Success) {
|
||||||
|
entry.developer = nacp.GetDeveloperName();
|
||||||
|
} else {
|
||||||
|
entry.developer = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.version = "1.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loader->GetFileType() == Loader::FileType::NRO) {
|
||||||
|
auto loader_nro = reinterpret_cast<Loader::AppLoader_NRO*>(loader.get());
|
||||||
|
entry.isHomebrew = loader_nro->IsHomebrew();
|
||||||
|
} else {
|
||||||
|
entry.isHomebrew = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rom_metadata_cache[path] = entry;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
RomMetadata GetRomMetadata(const std::string& path) {
|
||||||
|
if (auto search = m_rom_metadata_cache.find(path); search != m_rom_metadata_cache.end()) {
|
||||||
|
return search->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CacheRomMetadata(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getTitle(JNIEnv* env, jobject obj,
|
||||||
|
jstring jpath) {
|
||||||
|
return ToJString(env, GetRomMetadata(GetJString(env, jpath)).title);
|
||||||
|
}
|
||||||
|
|
||||||
|
jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getProgramId(JNIEnv* env, jobject obj,
|
||||||
|
jstring jpath) {
|
||||||
|
return ToJString(env, std::to_string(GetRomMetadata(GetJString(env, jpath)).programId));
|
||||||
|
}
|
||||||
|
|
||||||
|
jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getDeveloper(JNIEnv* env, jobject obj,
|
||||||
|
jstring jpath) {
|
||||||
|
return ToJString(env, GetRomMetadata(GetJString(env, jpath)).developer);
|
||||||
|
}
|
||||||
|
|
||||||
|
jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getVersion(JNIEnv* env, jobject obj,
|
||||||
|
jstring jpath) {
|
||||||
|
return ToJString(env, GetRomMetadata(GetJString(env, jpath)).version);
|
||||||
|
}
|
||||||
|
|
||||||
|
jbyteArray Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIcon(JNIEnv* env, jobject obj,
|
||||||
|
jstring jpath) {
|
||||||
|
auto icon_data = GetRomMetadata(GetJString(env, jpath)).icon;
|
||||||
|
jbyteArray icon = env->NewByteArray(static_cast<jsize>(icon_data.size()));
|
||||||
|
env->SetByteArrayRegion(icon, 0, env->GetArrayLength(icon),
|
||||||
|
reinterpret_cast<jbyte*>(icon_data.data()));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsHomebrew(JNIEnv* env, jobject obj,
|
||||||
|
jstring jpath) {
|
||||||
|
return static_cast<jboolean>(GetRomMetadata(GetJString(env, jpath)).isHomebrew);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_org_yuzu_yuzu_1emu_utils_GameMetadata_resetMetadata(JNIEnv* env, jobject obj) {
|
||||||
|
return m_rom_metadata_cache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // extern "C"
|
@ -33,7 +33,6 @@
|
|||||||
#include "core/crypto/key_manager.h"
|
#include "core/crypto/key_manager.h"
|
||||||
#include "core/file_sys/card_image.h"
|
#include "core/file_sys/card_image.h"
|
||||||
#include "core/file_sys/content_archive.h"
|
#include "core/file_sys/content_archive.h"
|
||||||
#include "core/file_sys/registered_cache.h"
|
|
||||||
#include "core/file_sys/submission_package.h"
|
#include "core/file_sys/submission_package.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
#include "core/file_sys/vfs_real.h"
|
#include "core/file_sys/vfs_real.h"
|
||||||
@ -48,63 +47,55 @@
|
|||||||
#include "core/hid/emulated_controller.h"
|
#include "core/hid/emulated_controller.h"
|
||||||
#include "core/hid/hid_core.h"
|
#include "core/hid/hid_core.h"
|
||||||
#include "core/hid/hid_types.h"
|
#include "core/hid/hid_types.h"
|
||||||
#include "core/hle/service/acc/profile_manager.h"
|
|
||||||
#include "core/hle/service/am/applet_ae.h"
|
#include "core/hle/service/am/applet_ae.h"
|
||||||
#include "core/hle/service/am/applet_oe.h"
|
#include "core/hle/service/am/applet_oe.h"
|
||||||
#include "core/hle/service/am/applets/applets.h"
|
#include "core/hle/service/am/applets/applets.h"
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
#include "core/perf_stats.h"
|
|
||||||
#include "jni/android_common/android_common.h"
|
#include "jni/android_common/android_common.h"
|
||||||
#include "jni/applets/software_keyboard.h"
|
|
||||||
#include "jni/config.h"
|
#include "jni/config.h"
|
||||||
#include "jni/emu_window/emu_window.h"
|
|
||||||
#include "jni/id_cache.h"
|
#include "jni/id_cache.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "jni/native.h"
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
|
|
||||||
#define jconst [[maybe_unused]] const auto
|
#define jconst [[maybe_unused]] const auto
|
||||||
#define jauto [[maybe_unused]] auto
|
#define jauto [[maybe_unused]] auto
|
||||||
|
|
||||||
namespace {
|
static EmulationSession s_instance;
|
||||||
|
|
||||||
class EmulationSession final {
|
EmulationSession::EmulationSession() {
|
||||||
public:
|
|
||||||
EmulationSession() {
|
|
||||||
m_vfs = std::make_shared<FileSys::RealVfsFilesystem>();
|
m_vfs = std::make_shared<FileSys::RealVfsFilesystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
~EmulationSession() = default;
|
EmulationSession& EmulationSession::GetInstance() {
|
||||||
|
|
||||||
static EmulationSession& GetInstance() {
|
|
||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Core::System& System() const {
|
const Core::System& EmulationSession::System() const {
|
||||||
return m_system;
|
return m_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::System& System() {
|
Core::System& EmulationSession::System() {
|
||||||
return m_system;
|
return m_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmuWindow_Android& Window() const {
|
const EmuWindow_Android& EmulationSession::Window() const {
|
||||||
return *m_window;
|
return *m_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmuWindow_Android& Window() {
|
EmuWindow_Android& EmulationSession::Window() {
|
||||||
return *m_window;
|
return *m_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
ANativeWindow* NativeWindow() const {
|
ANativeWindow* EmulationSession::NativeWindow() const {
|
||||||
return m_native_window;
|
return m_native_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNativeWindow(ANativeWindow* native_window) {
|
void EmulationSession::SetNativeWindow(ANativeWindow* native_window) {
|
||||||
m_native_window = native_window;
|
m_native_window = native_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstallFileToNand(std::string filename, std::string file_extension) {
|
int EmulationSession::InstallFileToNand(std::string filename, std::string file_extension) {
|
||||||
jconst copy_func = [](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
|
jconst copy_func = [](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
|
||||||
std::size_t block_size) {
|
std::size_t block_size) {
|
||||||
if (src == nullptr || dest == nullptr) {
|
if (src == nullptr || dest == nullptr) {
|
||||||
@ -153,8 +144,8 @@ public:
|
|||||||
return InstallError;
|
return InstallError;
|
||||||
}
|
}
|
||||||
|
|
||||||
jconst res = m_system.GetFileSystemController().GetUserNANDContents()->InstallEntry(
|
jconst res = m_system.GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true,
|
||||||
*nsp, true, copy_func);
|
copy_func);
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case FileSys::InstallResult::Success:
|
case FileSys::InstallResult::Success:
|
||||||
@ -166,9 +157,10 @@ public:
|
|||||||
default:
|
default:
|
||||||
return InstallError;
|
return InstallError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir,
|
void EmulationSession::InitializeGpuDriver(const std::string& hook_lib_dir,
|
||||||
|
const std::string& custom_driver_dir,
|
||||||
const std::string& custom_driver_name,
|
const std::string& custom_driver_name,
|
||||||
const std::string& file_redirect_dir) {
|
const std::string& file_redirect_dir) {
|
||||||
#ifdef ARCHITECTURE_arm64
|
#ifdef ARCHITECTURE_arm64
|
||||||
@ -191,36 +183,35 @@ public:
|
|||||||
|
|
||||||
// Try to load the system driver.
|
// Try to load the system driver.
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
handle =
|
handle = adrenotools_open_libvulkan(RTLD_NOW, featureFlags, nullptr, hook_lib_dir.c_str(),
|
||||||
adrenotools_open_libvulkan(RTLD_NOW, featureFlags, nullptr, hook_lib_dir.c_str(),
|
|
||||||
nullptr, nullptr, file_redirect_dir_, nullptr);
|
nullptr, nullptr, file_redirect_dir_, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vulkan_library = std::make_shared<Common::DynamicLibrary>(handle);
|
m_vulkan_library = std::make_shared<Common::DynamicLibrary>(handle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsRunning() const {
|
bool EmulationSession::IsRunning() const {
|
||||||
return m_is_running;
|
return m_is_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsPaused() const {
|
bool EmulationSession::IsPaused() const {
|
||||||
return m_is_running && m_is_paused;
|
return m_is_running && m_is_paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Core::PerfStatsResults& PerfStats() const {
|
const Core::PerfStatsResults& EmulationSession::PerfStats() const {
|
||||||
std::scoped_lock m_perf_stats_lock(m_perf_stats_mutex);
|
std::scoped_lock m_perf_stats_lock(m_perf_stats_mutex);
|
||||||
return m_perf_stats;
|
return m_perf_stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceChanged() {
|
void EmulationSession::SurfaceChanged() {
|
||||||
if (!IsRunning()) {
|
if (!IsRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_window->OnSurfaceChanged(m_native_window);
|
m_window->OnSurfaceChanged(m_native_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureFilesystemProvider(const std::string& filepath) {
|
void EmulationSession::ConfigureFilesystemProvider(const std::string& filepath) {
|
||||||
const auto file = m_system.GetFilesystem()->OpenFile(filepath, FileSys::Mode::Read);
|
const auto file = m_system.GetFilesystem()->OpenFile(filepath, FileSys::Mode::Read);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return;
|
return;
|
||||||
@ -254,17 +245,25 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::SystemResultStatus InitializeEmulation(const std::string& filepath) {
|
void EmulationSession::InitializeSystem() {
|
||||||
|
// Initialize filesystem.
|
||||||
|
m_system.SetFilesystem(m_vfs);
|
||||||
|
m_system.GetUserChannel().clear();
|
||||||
|
m_manual_provider = std::make_unique<FileSys::ManualContentProvider>();
|
||||||
|
m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
|
||||||
|
m_system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual,
|
||||||
|
m_manual_provider.get());
|
||||||
|
m_system.GetFileSystemController().CreateFactories(*m_vfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath) {
|
||||||
std::scoped_lock lock(m_mutex);
|
std::scoped_lock lock(m_mutex);
|
||||||
|
|
||||||
// Create the render window.
|
// Create the render window.
|
||||||
m_window = std::make_unique<EmuWindow_Android>(&m_input_subsystem, m_native_window,
|
m_window =
|
||||||
m_vulkan_library);
|
std::make_unique<EmuWindow_Android>(&m_input_subsystem, m_native_window, m_vulkan_library);
|
||||||
|
|
||||||
m_system.SetFilesystem(m_vfs);
|
|
||||||
m_system.GetUserChannel().clear();
|
|
||||||
|
|
||||||
// Initialize system.
|
// Initialize system.
|
||||||
jauto android_keyboard = std::make_unique<SoftwareKeyboard::AndroidKeyboard>();
|
jauto android_keyboard = std::make_unique<SoftwareKeyboard::AndroidKeyboard>();
|
||||||
@ -286,11 +285,6 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize filesystem.
|
// Initialize filesystem.
|
||||||
m_manual_provider = std::make_unique<FileSys::ManualContentProvider>();
|
|
||||||
m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
|
|
||||||
m_system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual,
|
|
||||||
m_manual_provider.get());
|
|
||||||
m_system.GetFileSystemController().CreateFactories(*m_vfs);
|
|
||||||
ConfigureFilesystemProvider(filepath);
|
ConfigureFilesystemProvider(filepath);
|
||||||
|
|
||||||
// Initialize account manager
|
// Initialize account manager
|
||||||
@ -308,9 +302,9 @@ public:
|
|||||||
m_system.RegisterExitCallback([&] { HaltEmulation(); });
|
m_system.RegisterExitCallback([&] { HaltEmulation(); });
|
||||||
|
|
||||||
return Core::SystemResultStatus::Success;
|
return Core::SystemResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShutdownEmulation() {
|
void EmulationSession::ShutdownEmulation() {
|
||||||
std::scoped_lock lock(m_mutex);
|
std::scoped_lock lock(m_mutex);
|
||||||
|
|
||||||
m_is_running = false;
|
m_is_running = false;
|
||||||
@ -331,27 +325,27 @@ public:
|
|||||||
|
|
||||||
// Tear down the render window.
|
// Tear down the render window.
|
||||||
m_window.reset();
|
m_window.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PauseEmulation() {
|
void EmulationSession::PauseEmulation() {
|
||||||
std::scoped_lock lock(m_mutex);
|
std::scoped_lock lock(m_mutex);
|
||||||
m_system.Pause();
|
m_system.Pause();
|
||||||
m_is_paused = true;
|
m_is_paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnPauseEmulation() {
|
void EmulationSession::UnPauseEmulation() {
|
||||||
std::scoped_lock lock(m_mutex);
|
std::scoped_lock lock(m_mutex);
|
||||||
m_system.Run();
|
m_system.Run();
|
||||||
m_is_paused = false;
|
m_is_paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HaltEmulation() {
|
void EmulationSession::HaltEmulation() {
|
||||||
std::scoped_lock lock(m_mutex);
|
std::scoped_lock lock(m_mutex);
|
||||||
m_is_running = false;
|
m_is_running = false;
|
||||||
m_cv.notify_one();
|
m_cv.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunEmulation() {
|
void EmulationSession::RunEmulation() {
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(m_mutex);
|
std::scoped_lock lock(m_mutex);
|
||||||
m_is_running = true;
|
m_is_running = true;
|
||||||
@ -361,8 +355,7 @@ public:
|
|||||||
if (Settings::values.use_disk_shader_cache.GetValue()) {
|
if (Settings::values.use_disk_shader_cache.GetValue()) {
|
||||||
LoadDiskCacheProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
|
LoadDiskCacheProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
|
||||||
m_system.Renderer().ReadRasterizer()->LoadDiskResources(
|
m_system.Renderer().ReadRasterizer()->LoadDiskResources(
|
||||||
m_system.GetApplicationProcessProgramID(), std::stop_token{},
|
m_system.GetApplicationProcessProgramID(), std::stop_token{}, LoadDiskCacheProgress);
|
||||||
LoadDiskCacheProgress);
|
|
||||||
LoadDiskCacheProgress(VideoCore::LoadCallbackStage::Complete, 0, 0);
|
LoadDiskCacheProgress(VideoCore::LoadCallbackStage::Complete, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,25 +382,9 @@ public:
|
|||||||
m_perf_stats = m_system.GetAndResetPerfStats();
|
m_perf_stats = m_system.GetAndResetPerfStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetRomTitle(const std::string& path) {
|
bool EmulationSession::IsHandheldOnly() {
|
||||||
return GetRomMetadata(path).title;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<u8> GetRomIcon(const std::string& path) {
|
|
||||||
return GetRomMetadata(path).icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetIsHomebrew(const std::string& path) {
|
|
||||||
return GetRomMetadata(path).isHomebrew;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetRomMetadata() {
|
|
||||||
m_rom_metadata_cache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsHandheldOnly() {
|
|
||||||
jconst npad_style_set = m_system.HIDCore().GetSupportedStyleTag();
|
jconst npad_style_set = m_system.HIDCore().GetSupportedStyleTag();
|
||||||
|
|
||||||
if (npad_style_set.fullkey == 1) {
|
if (npad_style_set.fullkey == 1) {
|
||||||
@ -419,20 +396,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
return !Settings::IsDockedMode();
|
return !Settings::IsDockedMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDeviceType([[maybe_unused]] int index, int type) {
|
void EmulationSession::SetDeviceType([[maybe_unused]] int index, int type) {
|
||||||
jauto controller = m_system.HIDCore().GetEmulatedControllerByIndex(index);
|
jauto controller = m_system.HIDCore().GetEmulatedControllerByIndex(index);
|
||||||
controller->SetNpadStyleIndex(static_cast<Core::HID::NpadStyleIndex>(type));
|
controller->SetNpadStyleIndex(static_cast<Core::HID::NpadStyleIndex>(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGamepadConnectEvent([[maybe_unused]] int index) {
|
void EmulationSession::OnGamepadConnectEvent([[maybe_unused]] int index) {
|
||||||
jauto controller = m_system.HIDCore().GetEmulatedControllerByIndex(index);
|
jauto controller = m_system.HIDCore().GetEmulatedControllerByIndex(index);
|
||||||
|
|
||||||
// Ensure that player1 is configured correctly and handheld disconnected
|
// Ensure that player1 is configured correctly and handheld disconnected
|
||||||
if (controller->GetNpadIdType() == Core::HID::NpadIdType::Player1) {
|
if (controller->GetNpadIdType() == Core::HID::NpadIdType::Player1) {
|
||||||
jauto handheld =
|
jauto handheld = m_system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
m_system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
|
||||||
|
|
||||||
if (controller->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::Handheld) {
|
if (controller->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::Handheld) {
|
||||||
handheld->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
|
handheld->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
|
||||||
@ -443,8 +419,7 @@ public:
|
|||||||
|
|
||||||
// Ensure that handheld is configured correctly and player 1 disconnected
|
// Ensure that handheld is configured correctly and player 1 disconnected
|
||||||
if (controller->GetNpadIdType() == Core::HID::NpadIdType::Handheld) {
|
if (controller->GetNpadIdType() == Core::HID::NpadIdType::Handheld) {
|
||||||
jauto player1 =
|
jauto player1 = m_system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
m_system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
|
||||||
|
|
||||||
if (controller->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::Handheld) {
|
if (controller->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::Handheld) {
|
||||||
player1->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Handheld);
|
player1->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Handheld);
|
||||||
@ -456,106 +431,35 @@ public:
|
|||||||
if (!controller->IsConnected()) {
|
if (!controller->IsConnected()) {
|
||||||
controller->Connect();
|
controller->Connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGamepadDisconnectEvent([[maybe_unused]] int index) {
|
void EmulationSession::OnGamepadDisconnectEvent([[maybe_unused]] int index) {
|
||||||
jauto controller = m_system.HIDCore().GetEmulatedControllerByIndex(index);
|
jauto controller = m_system.HIDCore().GetEmulatedControllerByIndex(index);
|
||||||
controller->Disconnect();
|
controller->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
SoftwareKeyboard::AndroidKeyboard* SoftwareKeyboard() {
|
SoftwareKeyboard::AndroidKeyboard* EmulationSession::SoftwareKeyboard() {
|
||||||
return m_software_keyboard;
|
return m_software_keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
void EmulationSession::LoadDiskCacheProgress(VideoCore::LoadCallbackStage stage, int progress,
|
||||||
struct RomMetadata {
|
int max) {
|
||||||
std::string title;
|
|
||||||
std::vector<u8> icon;
|
|
||||||
bool isHomebrew;
|
|
||||||
};
|
|
||||||
|
|
||||||
RomMetadata GetRomMetadata(const std::string& path) {
|
|
||||||
if (jauto search = m_rom_metadata_cache.find(path); search != m_rom_metadata_cache.end()) {
|
|
||||||
return search->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CacheRomMetadata(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
RomMetadata CacheRomMetadata(const std::string& path) {
|
|
||||||
jconst file = Core::GetGameFileFromPath(m_vfs, path);
|
|
||||||
jauto loader = Loader::GetLoader(EmulationSession::GetInstance().System(), file, 0, 0);
|
|
||||||
|
|
||||||
RomMetadata entry;
|
|
||||||
loader->ReadTitle(entry.title);
|
|
||||||
loader->ReadIcon(entry.icon);
|
|
||||||
if (loader->GetFileType() == Loader::FileType::NRO) {
|
|
||||||
jauto loader_nro = reinterpret_cast<Loader::AppLoader_NRO*>(loader.get());
|
|
||||||
entry.isHomebrew = loader_nro->IsHomebrew();
|
|
||||||
} else {
|
|
||||||
entry.isHomebrew = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rom_metadata_cache[path] = entry;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void LoadDiskCacheProgress(VideoCore::LoadCallbackStage stage, int progress, int max) {
|
|
||||||
JNIEnv* env = IDCache::GetEnvForThread();
|
JNIEnv* env = IDCache::GetEnvForThread();
|
||||||
env->CallStaticVoidMethod(IDCache::GetDiskCacheProgressClass(),
|
env->CallStaticVoidMethod(IDCache::GetDiskCacheProgressClass(),
|
||||||
IDCache::GetDiskCacheLoadProgress(), static_cast<jint>(stage),
|
IDCache::GetDiskCacheLoadProgress(), static_cast<jint>(stage),
|
||||||
static_cast<jint>(progress), static_cast<jint>(max));
|
static_cast<jint>(progress), static_cast<jint>(max));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnEmulationStarted() {
|
void EmulationSession::OnEmulationStarted() {
|
||||||
JNIEnv* env = IDCache::GetEnvForThread();
|
JNIEnv* env = IDCache::GetEnvForThread();
|
||||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnEmulationStarted());
|
||||||
IDCache::GetOnEmulationStarted());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void OnEmulationStopped(Core::SystemResultStatus result) {
|
void EmulationSession::OnEmulationStopped(Core::SystemResultStatus result) {
|
||||||
JNIEnv* env = IDCache::GetEnvForThread();
|
JNIEnv* env = IDCache::GetEnvForThread();
|
||||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnEmulationStopped(),
|
||||||
IDCache::GetOnEmulationStopped(), static_cast<jint>(result));
|
static_cast<jint>(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
static EmulationSession s_instance;
|
|
||||||
|
|
||||||
// Frontend management
|
|
||||||
std::unordered_map<std::string, RomMetadata> m_rom_metadata_cache;
|
|
||||||
|
|
||||||
// Window management
|
|
||||||
std::unique_ptr<EmuWindow_Android> m_window;
|
|
||||||
ANativeWindow* m_native_window{};
|
|
||||||
|
|
||||||
// Core emulation
|
|
||||||
Core::System m_system;
|
|
||||||
InputCommon::InputSubsystem m_input_subsystem;
|
|
||||||
Common::DetachedTasks m_detached_tasks;
|
|
||||||
Core::PerfStatsResults m_perf_stats{};
|
|
||||||
std::shared_ptr<FileSys::VfsFilesystem> m_vfs;
|
|
||||||
Core::SystemResultStatus m_load_result{Core::SystemResultStatus::ErrorNotInitialized};
|
|
||||||
std::atomic<bool> m_is_running = false;
|
|
||||||
std::atomic<bool> m_is_paused = false;
|
|
||||||
SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{};
|
|
||||||
std::unique_ptr<Service::Account::ProfileManager> m_profile_manager;
|
|
||||||
std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider;
|
|
||||||
|
|
||||||
// GPU driver parameters
|
|
||||||
std::shared_ptr<Common::DynamicLibrary> m_vulkan_library;
|
|
||||||
|
|
||||||
// Synchronization
|
|
||||||
std::condition_variable_any m_cv;
|
|
||||||
mutable std::mutex m_perf_stats_mutex;
|
|
||||||
mutable std::mutex m_mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*static*/ EmulationSession EmulationSession::s_instance;
|
|
||||||
|
|
||||||
} // Anonymous namespace
|
|
||||||
|
|
||||||
static Core::SystemResultStatus RunEmulation(const std::string& filepath) {
|
static Core::SystemResultStatus RunEmulation(const std::string& filepath) {
|
||||||
Common::Log::Initialize();
|
Common::Log::Initialize();
|
||||||
@ -657,10 +561,6 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_stopEmulation(JNIEnv* env, jclass cla
|
|||||||
EmulationSession::GetInstance().HaltEmulation();
|
EmulationSession::GetInstance().HaltEmulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_resetRomMetadata(JNIEnv* env, jclass clazz) {
|
|
||||||
EmulationSession::GetInstance().ResetRomMetadata();
|
|
||||||
}
|
|
||||||
|
|
||||||
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_isRunning(JNIEnv* env, jclass clazz) {
|
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_isRunning(JNIEnv* env, jclass clazz) {
|
||||||
return static_cast<jboolean>(EmulationSession::GetInstance().IsRunning());
|
return static_cast<jboolean>(EmulationSession::GetInstance().IsRunning());
|
||||||
}
|
}
|
||||||
@ -766,51 +666,12 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_onTouchReleased(JNIEnv* env, jclass c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jbyteArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getIcon(JNIEnv* env, jclass clazz,
|
void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeSystem(JNIEnv* env, jclass clazz) {
|
||||||
jstring j_filename) {
|
|
||||||
jauto icon_data = EmulationSession::GetInstance().GetRomIcon(GetJString(env, j_filename));
|
|
||||||
jbyteArray icon = env->NewByteArray(static_cast<jsize>(icon_data.size()));
|
|
||||||
env->SetByteArrayRegion(icon, 0, env->GetArrayLength(icon),
|
|
||||||
reinterpret_cast<jbyte*>(icon_data.data()));
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getTitle(JNIEnv* env, jclass clazz,
|
|
||||||
jstring j_filename) {
|
|
||||||
jauto title = EmulationSession::GetInstance().GetRomTitle(GetJString(env, j_filename));
|
|
||||||
return env->NewStringUTF(title.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getDescription(JNIEnv* env, jclass clazz,
|
|
||||||
jstring j_filename) {
|
|
||||||
return j_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getGameId(JNIEnv* env, jclass clazz,
|
|
||||||
jstring j_filename) {
|
|
||||||
return j_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getRegions(JNIEnv* env, jclass clazz,
|
|
||||||
jstring j_filename) {
|
|
||||||
return env->NewStringUTF("");
|
|
||||||
}
|
|
||||||
|
|
||||||
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCompany(JNIEnv* env, jclass clazz,
|
|
||||||
jstring j_filename) {
|
|
||||||
return env->NewStringUTF("");
|
|
||||||
}
|
|
||||||
|
|
||||||
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_isHomebrew(JNIEnv* env, jclass clazz,
|
|
||||||
jstring j_filename) {
|
|
||||||
return EmulationSession::GetInstance().GetIsHomebrew(GetJString(env, j_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmulation(JNIEnv* env, jclass clazz) {
|
|
||||||
// Create the default config.ini.
|
// Create the default config.ini.
|
||||||
Config{};
|
Config{};
|
||||||
// Initialize the emulated system.
|
// Initialize the emulated system.
|
||||||
EmulationSession::GetInstance().System().Initialize();
|
EmulationSession::GetInstance().System().Initialize();
|
||||||
|
EmulationSession::GetInstance().InitializeSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
jint Java_org_yuzu_yuzu_1emu_NativeLibrary_defaultCPUCore(JNIEnv* env, jclass clazz) {
|
jint Java_org_yuzu_yuzu_1emu_NativeLibrary_defaultCPUCore(JNIEnv* env, jclass clazz) {
|
||||||
@ -898,4 +759,49 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getAppletLaunchPath(JNIEnv* env, jclass clazz,
|
||||||
|
jlong jid) {
|
||||||
|
auto bis_system =
|
||||||
|
EmulationSession::GetInstance().System().GetFileSystemController().GetSystemNANDContents();
|
||||||
|
if (!bis_system) {
|
||||||
|
return ToJString(env, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto applet_nca =
|
||||||
|
bis_system->GetEntry(static_cast<u64>(jid), FileSys::ContentRecordType::Program);
|
||||||
|
if (!applet_nca) {
|
||||||
|
return ToJString(env, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ToJString(env, applet_nca->GetFullPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz,
|
||||||
|
jint jappletId) {
|
||||||
|
EmulationSession::GetInstance().System().GetAppletManager().SetCurrentAppletId(
|
||||||
|
static_cast<Service::AM::Applets::AppletId>(jappletId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCabinetMode(JNIEnv* env, jclass clazz,
|
||||||
|
jint jcabinetMode) {
|
||||||
|
EmulationSession::GetInstance().System().GetAppletManager().SetCabinetMode(
|
||||||
|
static_cast<Service::NFP::CabinetMode>(jcabinetMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_isFirmwareAvailable(JNIEnv* env, jclass clazz) {
|
||||||
|
auto bis_system =
|
||||||
|
EmulationSession::GetInstance().System().GetFileSystemController().GetSystemNANDContents();
|
||||||
|
if (!bis_system) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query an applet to see if it's available
|
||||||
|
auto applet_nca =
|
||||||
|
bis_system->GetEntry(0x010000000000100Dull, FileSys::ContentRecordType::Program);
|
||||||
|
if (!applet_nca) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
85
src/android/app/src/main/jni/native.h
Normal file
85
src/android/app/src/main/jni/native.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <android/native_window_jni.h>
|
||||||
|
#include "common/detached_tasks.h"
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/file_sys/registered_cache.h"
|
||||||
|
#include "core/hle/service/acc/profile_manager.h"
|
||||||
|
#include "core/perf_stats.h"
|
||||||
|
#include "jni/applets/software_keyboard.h"
|
||||||
|
#include "jni/emu_window/emu_window.h"
|
||||||
|
#include "video_core/rasterizer_interface.h"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class EmulationSession final {
|
||||||
|
public:
|
||||||
|
explicit EmulationSession();
|
||||||
|
~EmulationSession() = default;
|
||||||
|
|
||||||
|
static EmulationSession& GetInstance();
|
||||||
|
const Core::System& System() const;
|
||||||
|
Core::System& System();
|
||||||
|
|
||||||
|
const EmuWindow_Android& Window() const;
|
||||||
|
EmuWindow_Android& Window();
|
||||||
|
ANativeWindow* NativeWindow() const;
|
||||||
|
void SetNativeWindow(ANativeWindow* native_window);
|
||||||
|
void SurfaceChanged();
|
||||||
|
|
||||||
|
int InstallFileToNand(std::string filename, std::string file_extension);
|
||||||
|
void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir,
|
||||||
|
const std::string& custom_driver_name,
|
||||||
|
const std::string& file_redirect_dir);
|
||||||
|
|
||||||
|
bool IsRunning() const;
|
||||||
|
bool IsPaused() const;
|
||||||
|
void PauseEmulation();
|
||||||
|
void UnPauseEmulation();
|
||||||
|
void HaltEmulation();
|
||||||
|
void RunEmulation();
|
||||||
|
void ShutdownEmulation();
|
||||||
|
|
||||||
|
const Core::PerfStatsResults& PerfStats() const;
|
||||||
|
void ConfigureFilesystemProvider(const std::string& filepath);
|
||||||
|
void InitializeSystem();
|
||||||
|
Core::SystemResultStatus InitializeEmulation(const std::string& filepath);
|
||||||
|
|
||||||
|
bool IsHandheldOnly();
|
||||||
|
void SetDeviceType([[maybe_unused]] int index, int type);
|
||||||
|
void OnGamepadConnectEvent([[maybe_unused]] int index);
|
||||||
|
void OnGamepadDisconnectEvent([[maybe_unused]] int index);
|
||||||
|
SoftwareKeyboard::AndroidKeyboard* SoftwareKeyboard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void LoadDiskCacheProgress(VideoCore::LoadCallbackStage stage, int progress, int max);
|
||||||
|
static void OnEmulationStarted();
|
||||||
|
static void OnEmulationStopped(Core::SystemResultStatus result);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Window management
|
||||||
|
std::unique_ptr<EmuWindow_Android> m_window;
|
||||||
|
ANativeWindow* m_native_window{};
|
||||||
|
|
||||||
|
// Core emulation
|
||||||
|
Core::System m_system;
|
||||||
|
InputCommon::InputSubsystem m_input_subsystem;
|
||||||
|
Common::DetachedTasks m_detached_tasks;
|
||||||
|
Core::PerfStatsResults m_perf_stats{};
|
||||||
|
std::shared_ptr<FileSys::VfsFilesystem> m_vfs;
|
||||||
|
Core::SystemResultStatus m_load_result{Core::SystemResultStatus::ErrorNotInitialized};
|
||||||
|
std::atomic<bool> m_is_running = false;
|
||||||
|
std::atomic<bool> m_is_paused = false;
|
||||||
|
SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{};
|
||||||
|
std::unique_ptr<Service::Account::ProfileManager> m_profile_manager;
|
||||||
|
std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider;
|
||||||
|
|
||||||
|
// GPU driver parameters
|
||||||
|
std::shared_ptr<Common::DynamicLibrary> m_vulkan_library;
|
||||||
|
|
||||||
|
// Synchronization
|
||||||
|
std::condition_variable_any m_cv;
|
||||||
|
mutable std::mutex m_perf_stats_mutex;
|
||||||
|
mutable std::mutex m_mutex;
|
||||||
|
};
|
9
src/android/app/src/main/res/drawable/ic_album.xml
Normal file
9
src/android/app/src/main/res/drawable/ic_album.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
|
||||||
|
</vector>
|
9
src/android/app/src/main/res/drawable/ic_applet.xml
Normal file
9
src/android/app/src/main/res/drawable/ic_applet.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M17,16l-4,-4V8.82C14.16,8.4 15,7.3 15,6c0,-1.66 -1.34,-3 -3,-3S9,4.34 9,6c0,1.3 0.84,2.4 2,2.82V12l-4,4H3v5h5v-3.05l4,-4.2 4,4.2V21h5v-5h-4z" />
|
||||||
|
</vector>
|
9
src/android/app/src/main/res/drawable/ic_edit.xml
Normal file
9
src/android/app/src/main/res/drawable/ic_edit.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
|
||||||
|
</vector>
|
18
src/android/app/src/main/res/drawable/ic_mii.xml
Normal file
18
src/android/app/src/main/res/drawable/ic_mii.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M9,13m-1.25,0a1.25,1.25 0,1 1,2.5 0a1.25,1.25 0,1 1,-2.5 0" />
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M20.77,8.58l-0.92,2.01c0.09,0.46 0.15,0.93 0.15,1.41 0,4.41 -3.59,8 -8,8s-8,-3.59 -8,-8c0,-0.05 0.01,-0.1 0,-0.14 2.6,-0.98 4.69,-2.99 5.74,-5.55C11.58,8.56 14.37,10 17.5,10c0.45,0 0.89,-0.04 1.33,-0.1l-0.6,-1.32 -0.88,-1.93 -1.93,-0.88 -2.79,-1.27 2.79,-1.27 0.71,-0.32C14.87,2.33 13.47,2 12,2 6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10c0,-1.47 -0.33,-2.87 -0.9,-4.13l-0.33,0.71z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M15,13m-1.25,0a1.25,1.25 0,1 1,2.5 0a1.25,1.25 0,1 1,-2.5 0" />
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M20.6,5.6L19.5,8l-1.1,-2.4L16,4.5l2.4,-1.1L19.5,1l1.1,2.4L23,4.5z" />
|
||||||
|
</vector>
|
9
src/android/app/src/main/res/drawable/ic_refresh.xml
Normal file
9
src/android/app/src/main/res/drawable/ic_refresh.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z" />
|
||||||
|
</vector>
|
9
src/android/app/src/main/res/drawable/ic_restore.xml
Normal file
9
src/android/app/src/main/res/drawable/ic_restore.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/colorControlNormal"
|
||||||
|
android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z" />
|
||||||
|
</vector>
|
57
src/android/app/src/main/res/layout/card_applet_option.xml
Normal file
57
src/android/app/src/main/res/layout/card_applet_option.xml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
style="?attr/materialCardViewOutlinedStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginVertical="12dp"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="24dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
app:tint="?attr/colorOnSurface" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_gravity="center_vertical">
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
style="@style/TextAppearance.Material3.TitleMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
tools:text="@string/applets" />
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
style="@style/TextAppearance.Material3.BodyMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
tools:text="@string/applets_description" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
@ -1,63 +1,54 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="?attr/materialCardViewElevatedStyle"
|
|
||||||
android:id="@+id/card_game"
|
android:id="@+id/card_game"
|
||||||
|
style="?attr/materialCardViewElevatedStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:transitionName="card_game"
|
android:transitionName="card_game"
|
||||||
android:layout_gravity="center"
|
app:cardCornerRadius="4dp"
|
||||||
app:cardElevation="0dp"
|
app:cardElevation="0dp">
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="6dp">
|
android:padding="6dp">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
style="?attr/materialCardViewElevatedStyle"
|
android:id="@+id/image_game_screen"
|
||||||
android:id="@+id/card_game_art"
|
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"
|
||||||
app:cardCornerRadius="4dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:shapeAppearance="@style/ShapeAppearance.Material3.Corner.ExtraSmall"
|
||||||
<ImageView
|
|
||||||
android:id="@+id/image_game_screen"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:src="@drawable/default_icon" />
|
tools:src="@drawable/default_icon" />
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
style="@style/TextAppearance.Material3.TitleMedium"
|
|
||||||
android:id="@+id/text_game_title"
|
android:id="@+id/text_game_title"
|
||||||
|
style="@style/TextAppearance.Material3.TitleMedium"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:ellipsize="none"
|
||||||
|
android:marqueeRepeatLimit="marquee_forever"
|
||||||
|
android:requiresFadingEdge="horizontal"
|
||||||
|
android:singleLine="true"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:singleLine="true"
|
app:layout_constraintEnd_toEndOf="@+id/image_game_screen"
|
||||||
android:marqueeRepeatLimit="marquee_forever"
|
app:layout_constraintStart_toStartOf="@+id/image_game_screen"
|
||||||
android:ellipsize="none"
|
app:layout_constraintTop_toBottomOf="@+id/image_game_screen"
|
||||||
android:requiresFadingEdge="horizontal"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/card_game_art"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/card_game_art"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/card_game_art"
|
|
||||||
tools:text="The Legend of Zelda: Skyward Sword" />
|
tools:text="The Legend of Zelda: Skyward Sword" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/option_layout"
|
android:id="@+id/option_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/option_icon"
|
android:id="@+id/option_icon"
|
||||||
|
15
src/android/app/src/main/res/layout/dialog_list.xml
Normal file
15
src/android/app/src/main/res/layout/dialog_list.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/dialog_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:fadeScrollbars="false"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
30
src/android/app/src/main/res/layout/dialog_list_item.xml
Normal file
30
src/android/app/src/main/res/layout/dialog_list_item.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingHorizontal="24dp"
|
||||||
|
android:paddingVertical="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
tools:src="@drawable/ic_nfc" />
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
style="@style/TextAppearance.Material3.BodyMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_gravity="center_vertical|start"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
tools:text="List option" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/coordinator_applets"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorSurface">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar_applets"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/toolbar_applets"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:navigationIcon="@drawable/ic_back"
|
||||||
|
app:title="@string/applets" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/list_applets"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -25,6 +25,9 @@
|
|||||||
<action
|
<action
|
||||||
android:id="@+id/action_homeSettingsFragment_to_driverManagerFragment"
|
android:id="@+id/action_homeSettingsFragment_to_driverManagerFragment"
|
||||||
app:destination="@id/driverManagerFragment" />
|
app:destination="@id/driverManagerFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_homeSettingsFragment_to_appletLauncherFragment"
|
||||||
|
app:destination="@id/appletLauncherFragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
@ -102,5 +105,17 @@
|
|||||||
android:id="@+id/driverManagerFragment"
|
android:id="@+id/driverManagerFragment"
|
||||||
android:name="org.yuzu.yuzu_emu.fragments.DriverManagerFragment"
|
android:name="org.yuzu.yuzu_emu.fragments.DriverManagerFragment"
|
||||||
android:label="DriverManagerFragment" />
|
android:label="DriverManagerFragment" />
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/appletLauncherFragment"
|
||||||
|
android:name="org.yuzu.yuzu_emu.fragments.AppletLauncherFragment"
|
||||||
|
android:label="AppletLauncherFragment" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_appletLauncherFragment_to_cabinetLauncherDialogFragment"
|
||||||
|
app:destination="@id/cabinetLauncherDialogFragment" />
|
||||||
|
</fragment>
|
||||||
|
<dialog
|
||||||
|
android:id="@+id/cabinetLauncherDialogFragment"
|
||||||
|
android:name="org.yuzu.yuzu_emu.fragments.CabinetLauncherDialogFragment"
|
||||||
|
android:label="CabinetLauncherDialogFragment" />
|
||||||
|
|
||||||
</navigation>
|
</navigation>
|
||||||
|
@ -124,6 +124,24 @@
|
|||||||
<string name="share_save_file">Share save file</string>
|
<string name="share_save_file">Share save file</string>
|
||||||
<string name="export_save_failed">Failed to export save</string>
|
<string name="export_save_failed">Failed to export save</string>
|
||||||
|
|
||||||
|
<!-- Applet launcher strings -->
|
||||||
|
<string name="applets">Applet launcher</string>
|
||||||
|
<string name="applets_description">Launch system applets using installed firmware</string>
|
||||||
|
<string name="applets_error_firmware">Firmware not installed</string>
|
||||||
|
<string name="applets_error_applet">Applet not available</string>
|
||||||
|
<string name="applets_error_description"><![CDATA[Please ensure your <a href="https://yuzu-emu.org/help/quickstart/#dumping-prodkeys-and-titlekeys">prod.keys</a> file and <a href="https://yuzu-emu.org/help/quickstart/#dumping-system-firmware">firmware</a> are installed and try again.]]></string>
|
||||||
|
<string name="album_applet">Album</string>
|
||||||
|
<string name="album_applet_description">See images stored in the user screenshots folder with the system photo viewer</string>
|
||||||
|
<string name="mii_edit_applet">Mii edit</string>
|
||||||
|
<string name="mii_edit_applet_description">View and edit Miis with the system editor</string>
|
||||||
|
<string name="cabinet_applet">Cabinet</string>
|
||||||
|
<string name="cabinet_applet_description">Edit and delete data stored on amiibo</string>
|
||||||
|
<string name="cabinet_launcher">Cabinet launcher</string>
|
||||||
|
<string name="cabinet_nickname_and_owner">Nickname and owner settings</string>
|
||||||
|
<string name="cabinet_game_data_eraser">Game data eraser</string>
|
||||||
|
<string name="cabinet_restorer">Restorer</string>
|
||||||
|
<string name="cabinet_formatter">Formatter</string>
|
||||||
|
|
||||||
<!-- About screen strings -->
|
<!-- About screen strings -->
|
||||||
<string name="gaia_is_not_real">Gaia isn\'t real</string>
|
<string name="gaia_is_not_real">Gaia isn\'t real</string>
|
||||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||||
|
@ -120,6 +120,8 @@ add_library(common STATIC
|
|||||||
socket_types.h
|
socket_types.h
|
||||||
spin_lock.cpp
|
spin_lock.cpp
|
||||||
spin_lock.h
|
spin_lock.h
|
||||||
|
stb.cpp
|
||||||
|
stb.h
|
||||||
steady_clock.cpp
|
steady_clock.cpp
|
||||||
steady_clock.h
|
steady_clock.h
|
||||||
stream.cpp
|
stream.cpp
|
||||||
@ -208,6 +210,8 @@ if (MSVC)
|
|||||||
/we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
|
/we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
|
||||||
/we4800 # Implicit conversion from 'type' to bool. Possible information loss
|
/we4800 # Implicit conversion from 'type' to bool. Possible information loss
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
set_source_files_properties(stb.cpp PROPERTIES COMPILE_OPTIONS "-Wno-implicit-fallthrough;-Wno-missing-declarations;-Wno-missing-field-initializers")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
@ -223,7 +227,7 @@ endif()
|
|||||||
|
|
||||||
create_target_directory_groups(common)
|
create_target_directory_groups(common)
|
||||||
|
|
||||||
target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile Threads::Threads)
|
target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
|
||||||
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
|
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "common/fs/fs_android.h"
|
#include "common/fs/fs_android.h"
|
||||||
|
#include "common/string_util.h"
|
||||||
|
|
||||||
namespace Common::FS::Android {
|
namespace Common::FS::Android {
|
||||||
|
|
||||||
@ -28,28 +29,35 @@ void RegisterCallbacks(JNIEnv* env, jclass clazz) {
|
|||||||
env->GetJavaVM(&g_jvm);
|
env->GetJavaVM(&g_jvm);
|
||||||
native_library = clazz;
|
native_library = clazz;
|
||||||
|
|
||||||
|
#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) \
|
||||||
|
F(JMethodID, JMethodName, Signature)
|
||||||
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) \
|
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) \
|
||||||
F(JMethodID, JMethodName, Signature)
|
F(JMethodID, JMethodName, Signature)
|
||||||
#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) \
|
#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) \
|
||||||
F(JMethodID, JMethodName, Signature)
|
F(JMethodID, JMethodName, Signature)
|
||||||
#define F(JMethodID, JMethodName, Signature) \
|
#define F(JMethodID, JMethodName, Signature) \
|
||||||
JMethodID = env->GetStaticMethodID(native_library, JMethodName, Signature);
|
JMethodID = env->GetStaticMethodID(native_library, JMethodName, Signature);
|
||||||
|
ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH)
|
||||||
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
||||||
ANDROID_STORAGE_FUNCTIONS(FS)
|
ANDROID_STORAGE_FUNCTIONS(FS)
|
||||||
#undef F
|
#undef F
|
||||||
#undef FS
|
#undef FS
|
||||||
#undef FR
|
#undef FR
|
||||||
|
#undef FH
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnRegisterCallbacks() {
|
void UnRegisterCallbacks() {
|
||||||
|
#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
||||||
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
||||||
#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID)
|
#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID)
|
||||||
#define F(JMethodID) JMethodID = nullptr;
|
#define F(JMethodID) JMethodID = nullptr;
|
||||||
|
ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH)
|
||||||
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
||||||
ANDROID_STORAGE_FUNCTIONS(FS)
|
ANDROID_STORAGE_FUNCTIONS(FS)
|
||||||
#undef F
|
#undef F
|
||||||
#undef FS
|
#undef FS
|
||||||
#undef FR
|
#undef FR
|
||||||
|
#undef FH
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsContentUri(const std::string& path) {
|
bool IsContentUri(const std::string& path) {
|
||||||
@ -95,4 +103,29 @@ ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
|||||||
#undef F
|
#undef F
|
||||||
#undef FR
|
#undef FR
|
||||||
|
|
||||||
|
#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) \
|
||||||
|
F(FunctionName, JMethodID, Caller)
|
||||||
|
#define F(FunctionName, JMethodID, Caller) \
|
||||||
|
std::string FunctionName(const std::string& filepath) { \
|
||||||
|
if (JMethodID == nullptr) { \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
auto env = GetEnvForThread(); \
|
||||||
|
jstring j_filepath = env->NewStringUTF(filepath.c_str()); \
|
||||||
|
jstring j_return = \
|
||||||
|
static_cast<jstring>(env->Caller(native_library, JMethodID, j_filepath)); \
|
||||||
|
if (!j_return) { \
|
||||||
|
return {}; \
|
||||||
|
} \
|
||||||
|
const jchar* jchars = env->GetStringChars(j_return, nullptr); \
|
||||||
|
const jsize length = env->GetStringLength(j_return); \
|
||||||
|
const std::u16string_view string_view(reinterpret_cast<const char16_t*>(jchars), length); \
|
||||||
|
const std::string converted_string = Common::UTF16ToUTF8(string_view); \
|
||||||
|
env->ReleaseStringChars(j_return, jchars); \
|
||||||
|
return converted_string; \
|
||||||
|
}
|
||||||
|
ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH)
|
||||||
|
#undef F
|
||||||
|
#undef FH
|
||||||
|
|
||||||
} // namespace Common::FS::Android
|
} // namespace Common::FS::Android
|
||||||
|
@ -17,19 +17,28 @@
|
|||||||
"(Ljava/lang/String;)Z") \
|
"(Ljava/lang/String;)Z") \
|
||||||
V(Exists, bool, file_exists, CallStaticBooleanMethod, "exists", "(Ljava/lang/String;)Z")
|
V(Exists, bool, file_exists, CallStaticBooleanMethod, "exists", "(Ljava/lang/String;)Z")
|
||||||
|
|
||||||
|
#define ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(V) \
|
||||||
|
V(GetParentDirectory, get_parent_directory, CallStaticObjectMethod, "getParentDirectory", \
|
||||||
|
"(Ljava/lang/String;)Ljava/lang/String;") \
|
||||||
|
V(GetFilename, get_filename, CallStaticObjectMethod, "getFilename", \
|
||||||
|
"(Ljava/lang/String;)Ljava/lang/String;")
|
||||||
|
|
||||||
namespace Common::FS::Android {
|
namespace Common::FS::Android {
|
||||||
|
|
||||||
static JavaVM* g_jvm = nullptr;
|
static JavaVM* g_jvm = nullptr;
|
||||||
static jclass native_library = nullptr;
|
static jclass native_library = nullptr;
|
||||||
|
|
||||||
|
#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
||||||
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
||||||
#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID)
|
#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID)
|
||||||
#define F(JMethodID) static jmethodID JMethodID = nullptr;
|
#define F(JMethodID) static jmethodID JMethodID = nullptr;
|
||||||
|
ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH)
|
||||||
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
||||||
ANDROID_STORAGE_FUNCTIONS(FS)
|
ANDROID_STORAGE_FUNCTIONS(FS)
|
||||||
#undef F
|
#undef F
|
||||||
#undef FS
|
#undef FS
|
||||||
#undef FR
|
#undef FR
|
||||||
|
#undef FH
|
||||||
|
|
||||||
enum class OpenMode {
|
enum class OpenMode {
|
||||||
Read,
|
Read,
|
||||||
@ -62,4 +71,10 @@ ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
|||||||
#undef F
|
#undef F
|
||||||
#undef FR
|
#undef FR
|
||||||
|
|
||||||
|
#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) F(FunctionName)
|
||||||
|
#define F(FunctionName) std::string FunctionName(const std::string& filepath);
|
||||||
|
ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH)
|
||||||
|
#undef F
|
||||||
|
#undef FH
|
||||||
|
|
||||||
} // namespace Common::FS::Android
|
} // namespace Common::FS::Android
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define AMIIBO_DIR "amiibo"
|
#define AMIIBO_DIR "amiibo"
|
||||||
#define CACHE_DIR "cache"
|
#define CACHE_DIR "cache"
|
||||||
#define CONFIG_DIR "config"
|
#define CONFIG_DIR "config"
|
||||||
|
#define CRASH_DUMPS_DIR "crash_dumps"
|
||||||
#define DUMP_DIR "dump"
|
#define DUMP_DIR "dump"
|
||||||
#define KEYS_DIR "keys"
|
#define KEYS_DIR "keys"
|
||||||
#define LOAD_DIR "load"
|
#define LOAD_DIR "load"
|
||||||
|
@ -119,6 +119,7 @@ public:
|
|||||||
GenerateYuzuPath(YuzuPath::AmiiboDir, yuzu_path / AMIIBO_DIR);
|
GenerateYuzuPath(YuzuPath::AmiiboDir, yuzu_path / AMIIBO_DIR);
|
||||||
GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache);
|
GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache);
|
||||||
GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config);
|
GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config);
|
||||||
|
GenerateYuzuPath(YuzuPath::CrashDumpsDir, yuzu_path / CRASH_DUMPS_DIR);
|
||||||
GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR);
|
GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR);
|
||||||
GenerateYuzuPath(YuzuPath::KeysDir, yuzu_path / KEYS_DIR);
|
GenerateYuzuPath(YuzuPath::KeysDir, yuzu_path / KEYS_DIR);
|
||||||
GenerateYuzuPath(YuzuPath::LoadDir, yuzu_path / LOAD_DIR);
|
GenerateYuzuPath(YuzuPath::LoadDir, yuzu_path / LOAD_DIR);
|
||||||
@ -400,6 +401,16 @@ std::string SanitizePath(std::string_view path_, DirectorySeparator directory_se
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string_view GetParentPath(std::string_view path) {
|
std::string_view GetParentPath(std::string_view path) {
|
||||||
|
if (path.empty()) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
if (path[0] != '/') {
|
||||||
|
std::string path_string{path};
|
||||||
|
return FS::Android::GetParentDirectory(path_string);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
const auto name_bck_index = path.rfind('\\');
|
const auto name_bck_index = path.rfind('\\');
|
||||||
const auto name_fwd_index = path.rfind('/');
|
const auto name_fwd_index = path.rfind('/');
|
||||||
std::size_t name_index;
|
std::size_t name_index;
|
||||||
|
@ -15,6 +15,7 @@ enum class YuzuPath {
|
|||||||
AmiiboDir, // Where Amiibo backups are stored.
|
AmiiboDir, // Where Amiibo backups are stored.
|
||||||
CacheDir, // Where cached filesystem data is stored.
|
CacheDir, // Where cached filesystem data is stored.
|
||||||
ConfigDir, // Where config files are stored.
|
ConfigDir, // Where config files are stored.
|
||||||
|
CrashDumpsDir, // Where crash dumps are stored.
|
||||||
DumpDir, // Where dumped data is stored.
|
DumpDir, // Where dumped data is stored.
|
||||||
KeysDir, // Where key files are stored.
|
KeysDir, // Where key files are stored.
|
||||||
LoadDir, // Where cheat/mod files are stored.
|
LoadDir, // Where cheat/mod files are stored.
|
||||||
|
@ -25,6 +25,7 @@ void ConfigureNvidiaEnvironmentFlags() {
|
|||||||
|
|
||||||
void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", windows_path_string).c_str()));
|
void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", windows_path_string).c_str()));
|
||||||
void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1"));
|
void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1"));
|
||||||
|
void(_putenv("__GL_THREADED_OPTIMIZATIONS=1"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +505,6 @@ struct Values {
|
|||||||
linkage, false, "use_auto_stub", Category::Debugging, Specialization::Default, false};
|
linkage, false, "use_auto_stub", Category::Debugging, Specialization::Default, false};
|
||||||
Setting<bool> enable_all_controllers{linkage, false, "enable_all_controllers",
|
Setting<bool> enable_all_controllers{linkage, false, "enable_all_controllers",
|
||||||
Category::Debugging};
|
Category::Debugging};
|
||||||
Setting<bool> create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging};
|
|
||||||
Setting<bool> perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging};
|
Setting<bool> perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging};
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
|
8
src/common/stb.cpp
Normal file
8
src/common/stb.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
|
||||||
|
#include "common/stb.h"
|
8
src/common/stb.h
Normal file
8
src/common/stb.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stb_image.h>
|
||||||
|
#include <stb_image_resize.h>
|
||||||
|
#include <stb_image_write.h>
|
@ -14,6 +14,10 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include <common/fs/fs_android.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
/// Make a string lowercase
|
/// Make a string lowercase
|
||||||
@ -63,6 +67,14 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
|
|||||||
if (full_path.empty())
|
if (full_path.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
if (full_path[0] != '/') {
|
||||||
|
*_pPath = Common::FS::Android::GetParentDirectory(full_path);
|
||||||
|
*_pFilename = Common::FS::Android::GetFilename(full_path);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::size_t dir_end = full_path.find_last_of("/"
|
std::size_t dir_end = full_path.find_last_of("/"
|
||||||
// windows needs the : included for something like just "C:" to be considered a directory
|
// windows needs the : included for something like just "C:" to be considered a directory
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "common/string_util.h"
|
||||||
#else
|
#else
|
||||||
#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
#include <pthread_np.h>
|
#include <pthread_np.h>
|
||||||
@ -82,29 +83,8 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
// Sets the debugger-visible name of the current thread.
|
// Sets the debugger-visible name of the current thread.
|
||||||
// Uses trick documented in:
|
|
||||||
// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
|
|
||||||
void SetCurrentThreadName(const char* name) {
|
void SetCurrentThreadName(const char* name) {
|
||||||
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
SetThreadDescription(GetCurrentThread(), UTF8ToUTF16W(name).data());
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
|
||||||
struct THREADNAME_INFO {
|
|
||||||
DWORD dwType; // must be 0x1000
|
|
||||||
LPCSTR szName; // pointer to name (in user addr space)
|
|
||||||
DWORD dwThreadID; // thread ID (-1=caller thread)
|
|
||||||
DWORD dwFlags; // reserved for future use, must be zero
|
|
||||||
} info;
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
info.dwType = 0x1000;
|
|
||||||
info.szName = name;
|
|
||||||
info.dwThreadID = std::numeric_limits<DWORD>::max();
|
|
||||||
info.dwFlags = 0;
|
|
||||||
|
|
||||||
__try {
|
|
||||||
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
|
||||||
} __except (EXCEPTION_CONTINUE_EXECUTION) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // !MSVC_VER, so must be POSIX threads
|
#else // !MSVC_VER, so must be POSIX threads
|
||||||
|
@ -86,9 +86,9 @@ void ARM_Interface::SymbolicateBacktrace(Core::System& system, std::vector<Backt
|
|||||||
|
|
||||||
std::map<std::string, Symbols::Symbols> symbols;
|
std::map<std::string, Symbols::Symbols> symbols;
|
||||||
for (const auto& module : modules) {
|
for (const auto& module : modules) {
|
||||||
symbols.insert_or_assign(
|
symbols.insert_or_assign(module.second,
|
||||||
module.second, Symbols::GetSymbols(module.first, system.ApplicationMemory(),
|
Symbols::GetSymbols(module.first, system.ApplicationMemory(),
|
||||||
system.ApplicationProcess()->Is64BitProcess()));
|
system.ApplicationProcess()->Is64Bit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& entry : out) {
|
for (auto& entry : out) {
|
||||||
|
@ -309,17 +309,10 @@ struct System::Impl {
|
|||||||
|
|
||||||
telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider);
|
telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider);
|
||||||
|
|
||||||
// Create a resource limit for the process.
|
|
||||||
const auto physical_memory_size =
|
|
||||||
kernel.MemoryManager().GetSize(Kernel::KMemoryManager::Pool::Application);
|
|
||||||
auto* resource_limit = Kernel::CreateResourceLimitForProcess(system, physical_memory_size);
|
|
||||||
|
|
||||||
// Create the process.
|
// Create the process.
|
||||||
auto main_process = Kernel::KProcess::Create(system.Kernel());
|
auto main_process = Kernel::KProcess::Create(system.Kernel());
|
||||||
ASSERT(Kernel::KProcess::Initialize(main_process, system, "main",
|
|
||||||
Kernel::KProcess::ProcessType::Userland, resource_limit)
|
|
||||||
.IsSuccess());
|
|
||||||
Kernel::KProcess::Register(system.Kernel(), main_process);
|
Kernel::KProcess::Register(system.Kernel(), main_process);
|
||||||
|
kernel.AppendNewProcess(main_process);
|
||||||
kernel.MakeApplicationProcess(main_process);
|
kernel.MakeApplicationProcess(main_process);
|
||||||
const auto [load_result, load_parameters] = app_loader->Load(*main_process, system);
|
const auto [load_result, load_parameters] = app_loader->Load(*main_process, system);
|
||||||
if (load_result != Loader::ResultStatus::Success) {
|
if (load_result != Loader::ResultStatus::Success) {
|
||||||
@ -418,6 +411,7 @@ struct System::Impl {
|
|||||||
services->KillNVNFlinger();
|
services->KillNVNFlinger();
|
||||||
}
|
}
|
||||||
kernel.CloseServices();
|
kernel.CloseServices();
|
||||||
|
kernel.ShutdownCores();
|
||||||
services.reset();
|
services.reset();
|
||||||
service_manager.reset();
|
service_manager.reset();
|
||||||
cheat_engine.reset();
|
cheat_engine.reset();
|
||||||
@ -429,7 +423,6 @@ struct System::Impl {
|
|||||||
gpu_core.reset();
|
gpu_core.reset();
|
||||||
host1x_core.reset();
|
host1x_core.reset();
|
||||||
perf_stats.reset();
|
perf_stats.reset();
|
||||||
kernel.ShutdownCores();
|
|
||||||
cpu_manager.Shutdown();
|
cpu_manager.Shutdown();
|
||||||
debugger.reset();
|
debugger.reset();
|
||||||
kernel.Shutdown();
|
kernel.Shutdown();
|
||||||
|
@ -258,20 +258,20 @@ private:
|
|||||||
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
||||||
|
|
||||||
// Put all threads to sleep on next scheduler round.
|
// Put all threads to sleep on next scheduler round.
|
||||||
for (auto* thread : ThreadList()) {
|
for (auto& thread : ThreadList()) {
|
||||||
thread->RequestSuspend(Kernel::SuspendType::Debug);
|
thread.RequestSuspend(Kernel::SuspendType::Debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResumeEmulation(Kernel::KThread* except = nullptr) {
|
void ResumeEmulation(Kernel::KThread* except = nullptr) {
|
||||||
// Wake up all threads.
|
// Wake up all threads.
|
||||||
for (auto* thread : ThreadList()) {
|
for (auto& thread : ThreadList()) {
|
||||||
if (thread == except) {
|
if (std::addressof(thread) == except) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->SetStepState(Kernel::StepState::NotStepping);
|
thread.SetStepState(Kernel::StepState::NotStepping);
|
||||||
thread->Resume(Kernel::SuspendType::Debug);
|
thread.Resume(Kernel::SuspendType::Debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,13 +283,17 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdateActiveThread() {
|
void UpdateActiveThread() {
|
||||||
const auto& threads{ThreadList()};
|
auto& threads{ThreadList()};
|
||||||
if (std::find(threads.begin(), threads.end(), state->active_thread) == threads.end()) {
|
for (auto& thread : threads) {
|
||||||
state->active_thread = threads.front();
|
if (std::addressof(thread) == state->active_thread) {
|
||||||
|
// Thread is still alive, no need to update.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
state->active_thread = std::addressof(threads.front());
|
||||||
|
}
|
||||||
|
|
||||||
const std::list<Kernel::KThread*>& ThreadList() {
|
Kernel::KProcess::ThreadList& ThreadList() {
|
||||||
return system.ApplicationProcess()->GetThreadList();
|
return system.ApplicationProcess()->GetThreadList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ static std::string EscapeXML(std::string_view data) {
|
|||||||
|
|
||||||
GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_)
|
GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_)
|
||||||
: DebuggerFrontend(backend_), system{system_} {
|
: DebuggerFrontend(backend_), system{system_} {
|
||||||
if (system.ApplicationProcess()->Is64BitProcess()) {
|
if (system.ApplicationProcess()->Is64Bit()) {
|
||||||
arch = std::make_unique<GDBStubA64>();
|
arch = std::make_unique<GDBStubA64>();
|
||||||
} else {
|
} else {
|
||||||
arch = std::make_unique<GDBStubA32>();
|
arch = std::make_unique<GDBStubA32>();
|
||||||
@ -446,10 +446,10 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) {
|
|||||||
// See osdbg_thread_local_region.os.horizon.hpp and osdbg_thread_type.os.horizon.hpp
|
// See osdbg_thread_local_region.os.horizon.hpp and osdbg_thread_type.os.horizon.hpp
|
||||||
|
|
||||||
static std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory& memory,
|
static std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory& memory,
|
||||||
const Kernel::KThread* thread) {
|
const Kernel::KThread& thread) {
|
||||||
// Read thread type from TLS
|
// Read thread type from TLS
|
||||||
const VAddr tls_thread_type{memory.Read32(thread->GetTlsAddress() + 0x1fc)};
|
const VAddr tls_thread_type{memory.Read32(thread.GetTlsAddress() + 0x1fc)};
|
||||||
const VAddr argument_thread_type{thread->GetArgument()};
|
const VAddr argument_thread_type{thread.GetArgument()};
|
||||||
|
|
||||||
if (argument_thread_type && tls_thread_type != argument_thread_type) {
|
if (argument_thread_type && tls_thread_type != argument_thread_type) {
|
||||||
// Probably not created by nnsdk, no name available.
|
// Probably not created by nnsdk, no name available.
|
||||||
@ -477,10 +477,10 @@ static std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory&
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory& memory,
|
static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory& memory,
|
||||||
const Kernel::KThread* thread) {
|
const Kernel::KThread& thread) {
|
||||||
// Read thread type from TLS
|
// Read thread type from TLS
|
||||||
const VAddr tls_thread_type{memory.Read64(thread->GetTlsAddress() + 0x1f8)};
|
const VAddr tls_thread_type{memory.Read64(thread.GetTlsAddress() + 0x1f8)};
|
||||||
const VAddr argument_thread_type{thread->GetArgument()};
|
const VAddr argument_thread_type{thread.GetArgument()};
|
||||||
|
|
||||||
if (argument_thread_type && tls_thread_type != argument_thread_type) {
|
if (argument_thread_type && tls_thread_type != argument_thread_type) {
|
||||||
// Probably not created by nnsdk, no name available.
|
// Probably not created by nnsdk, no name available.
|
||||||
@ -508,16 +508,16 @@ static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory&
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<std::string> GetThreadName(Core::System& system,
|
static std::optional<std::string> GetThreadName(Core::System& system,
|
||||||
const Kernel::KThread* thread) {
|
const Kernel::KThread& thread) {
|
||||||
if (system.ApplicationProcess()->Is64BitProcess()) {
|
if (system.ApplicationProcess()->Is64Bit()) {
|
||||||
return GetNameFromThreadType64(system.ApplicationMemory(), thread);
|
return GetNameFromThreadType64(system.ApplicationMemory(), thread);
|
||||||
} else {
|
} else {
|
||||||
return GetNameFromThreadType32(system.ApplicationMemory(), thread);
|
return GetNameFromThreadType32(system.ApplicationMemory(), thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string_view GetThreadWaitReason(const Kernel::KThread* thread) {
|
static std::string_view GetThreadWaitReason(const Kernel::KThread& thread) {
|
||||||
switch (thread->GetWaitReasonForDebugging()) {
|
switch (thread.GetWaitReasonForDebugging()) {
|
||||||
case Kernel::ThreadWaitReasonForDebugging::Sleep:
|
case Kernel::ThreadWaitReasonForDebugging::Sleep:
|
||||||
return "Sleep";
|
return "Sleep";
|
||||||
case Kernel::ThreadWaitReasonForDebugging::IPC:
|
case Kernel::ThreadWaitReasonForDebugging::IPC:
|
||||||
@ -535,8 +535,8 @@ static std::string_view GetThreadWaitReason(const Kernel::KThread* thread) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetThreadState(const Kernel::KThread* thread) {
|
static std::string GetThreadState(const Kernel::KThread& thread) {
|
||||||
switch (thread->GetState()) {
|
switch (thread.GetState()) {
|
||||||
case Kernel::ThreadState::Initialized:
|
case Kernel::ThreadState::Initialized:
|
||||||
return "Initialized";
|
return "Initialized";
|
||||||
case Kernel::ThreadState::Waiting:
|
case Kernel::ThreadState::Waiting:
|
||||||
@ -604,7 +604,7 @@ void GDBStub::HandleQuery(std::string_view command) {
|
|||||||
const auto& threads = system.ApplicationProcess()->GetThreadList();
|
const auto& threads = system.ApplicationProcess()->GetThreadList();
|
||||||
std::vector<std::string> thread_ids;
|
std::vector<std::string> thread_ids;
|
||||||
for (const auto& thread : threads) {
|
for (const auto& thread : threads) {
|
||||||
thread_ids.push_back(fmt::format("{:x}", thread->GetThreadId()));
|
thread_ids.push_back(fmt::format("{:x}", thread.GetThreadId()));
|
||||||
}
|
}
|
||||||
SendReply(fmt::format("m{}", fmt::join(thread_ids, ",")));
|
SendReply(fmt::format("m{}", fmt::join(thread_ids, ",")));
|
||||||
} else if (command.starts_with("sThreadInfo")) {
|
} else if (command.starts_with("sThreadInfo")) {
|
||||||
@ -616,14 +616,14 @@ void GDBStub::HandleQuery(std::string_view command) {
|
|||||||
buffer += "<threads>";
|
buffer += "<threads>";
|
||||||
|
|
||||||
const auto& threads = system.ApplicationProcess()->GetThreadList();
|
const auto& threads = system.ApplicationProcess()->GetThreadList();
|
||||||
for (const auto* thread : threads) {
|
for (const auto& thread : threads) {
|
||||||
auto thread_name{GetThreadName(system, thread)};
|
auto thread_name{GetThreadName(system, thread)};
|
||||||
if (!thread_name) {
|
if (!thread_name) {
|
||||||
thread_name = fmt::format("Thread {:d}", thread->GetThreadId());
|
thread_name = fmt::format("Thread {:d}", thread.GetThreadId());
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += fmt::format(R"(<thread id="{:x}" core="{:d}" name="{}">{}</thread>)",
|
buffer += fmt::format(R"(<thread id="{:x}" core="{:d}" name="{}">{}</thread>)",
|
||||||
thread->GetThreadId(), thread->GetActiveCore(),
|
thread.GetThreadId(), thread.GetActiveCore(),
|
||||||
EscapeXML(*thread_name), GetThreadState(thread));
|
EscapeXML(*thread_name), GetThreadState(thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,11 +822,13 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
|
|||||||
const char i = True(mem_info.attribute & MemoryAttribute::IpcLocked) ? 'I' : '-';
|
const char i = True(mem_info.attribute & MemoryAttribute::IpcLocked) ? 'I' : '-';
|
||||||
const char d = True(mem_info.attribute & MemoryAttribute::DeviceShared) ? 'D' : '-';
|
const char d = True(mem_info.attribute & MemoryAttribute::DeviceShared) ? 'D' : '-';
|
||||||
const char u = True(mem_info.attribute & MemoryAttribute::Uncached) ? 'U' : '-';
|
const char u = True(mem_info.attribute & MemoryAttribute::Uncached) ? 'U' : '-';
|
||||||
|
const char p =
|
||||||
|
True(mem_info.attribute & MemoryAttribute::PermissionLocked) ? 'P' : '-';
|
||||||
|
|
||||||
reply +=
|
reply += fmt::format(" {:#012x} - {:#012x} {} {} {}{}{}{}{} [{}, {}]\n",
|
||||||
fmt::format(" {:#012x} - {:#012x} {} {} {}{}{}{} [{}, {}]\n",
|
mem_info.base_address,
|
||||||
mem_info.base_address, mem_info.base_address + mem_info.size - 1,
|
mem_info.base_address + mem_info.size - 1, perm, state, l, i,
|
||||||
perm, state, l, i, d, u, mem_info.ipc_count, mem_info.device_count);
|
d, u, p, mem_info.ipc_count, mem_info.device_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uintptr_t next_address = mem_info.base_address + mem_info.size;
|
const uintptr_t next_address = mem_info.base_address + mem_info.size;
|
||||||
@ -848,10 +850,10 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KThread* GDBStub::GetThreadByID(u64 thread_id) {
|
Kernel::KThread* GDBStub::GetThreadByID(u64 thread_id) {
|
||||||
const auto& threads{system.ApplicationProcess()->GetThreadList()};
|
auto& threads{system.ApplicationProcess()->GetThreadList()};
|
||||||
for (auto* thread : threads) {
|
for (auto& thread : threads) {
|
||||||
if (thread->GetThreadId() == thread_id) {
|
if (thread.GetThreadId() == thread_id) {
|
||||||
return thread;
|
return std::addressof(thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,16 +104,16 @@ Loader::ResultStatus ProgramMetadata::Reload(VirtualFile file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ ProgramMetadata ProgramMetadata::GetDefault() {
|
/*static*/ ProgramMetadata ProgramMetadata::GetDefault() {
|
||||||
// Allow use of cores 0~3 and thread priorities 1~63.
|
// Allow use of cores 0~3 and thread priorities 16~63.
|
||||||
constexpr u32 default_thread_info_capability = 0x30007F7;
|
constexpr u32 default_thread_info_capability = 0x30043F7;
|
||||||
|
|
||||||
ProgramMetadata result;
|
ProgramMetadata result;
|
||||||
|
|
||||||
result.LoadManual(
|
result.LoadManual(
|
||||||
true /*is_64_bit*/, FileSys::ProgramAddressSpaceType::Is39Bit /*address_space*/,
|
true /*is_64_bit*/, FileSys::ProgramAddressSpaceType::Is39Bit /*address_space*/,
|
||||||
0x2c /*main_thread_prio*/, 0 /*main_thread_core*/, 0x00100000 /*main_thread_stack_size*/,
|
0x2c /*main_thread_prio*/, 0 /*main_thread_core*/, 0x100000 /*main_thread_stack_size*/,
|
||||||
0 /*title_id*/, 0xFFFFFFFFFFFFFFFF /*filesystem_permissions*/,
|
0 /*title_id*/, 0xFFFFFFFFFFFFFFFF /*filesystem_permissions*/, 0 /*system_resource_size*/,
|
||||||
0x1FE00000 /*system_resource_size*/, {default_thread_info_capability} /*capabilities*/);
|
{default_thread_info_capability} /*capabilities*/);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,9 @@ public:
|
|||||||
u64 GetFilesystemPermissions() const;
|
u64 GetFilesystemPermissions() const;
|
||||||
u32 GetSystemResourceSize() const;
|
u32 GetSystemResourceSize() const;
|
||||||
const KernelCapabilityDescriptors& GetKernelCapabilities() const;
|
const KernelCapabilityDescriptors& GetKernelCapabilities() const;
|
||||||
|
const std::array<u8, 0x10>& GetName() const {
|
||||||
|
return npdm_header.application_name;
|
||||||
|
}
|
||||||
|
|
||||||
void Print() const;
|
void Print() const;
|
||||||
|
|
||||||
@ -164,14 +167,14 @@ private:
|
|||||||
u32_le unk_size_2;
|
u32_le unk_size_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
Header npdm_header;
|
Header npdm_header{};
|
||||||
AciHeader aci_header;
|
AciHeader aci_header{};
|
||||||
AcidHeader acid_header;
|
AcidHeader acid_header{};
|
||||||
|
|
||||||
FileAccessControl acid_file_access;
|
FileAccessControl acid_file_access{};
|
||||||
FileAccessHeader aci_file_access;
|
FileAccessHeader aci_file_access{};
|
||||||
|
|
||||||
KernelCapabilityDescriptors aci_kernel_capabilities;
|
KernelCapabilityDescriptors aci_kernel_capabilities{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "core/file_sys/system_archive/system_version.h"
|
#include "core/file_sys/system_archive/system_version.h"
|
||||||
#include "core/file_sys/vfs_vector.h"
|
#include "core/file_sys/vfs_vector.h"
|
||||||
#include "core/hle/api_version.h"
|
#include "core/hle/api_version.h"
|
||||||
@ -12,6 +13,9 @@ std::string GetLongDisplayVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VirtualDir SystemVersion() {
|
VirtualDir SystemVersion() {
|
||||||
|
LOG_WARNING(Common_Filesystem, "called - Using hardcoded firmware version '{}'",
|
||||||
|
GetLongDisplayVersion());
|
||||||
|
|
||||||
VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file");
|
VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file");
|
||||||
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0);
|
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0);
|
||||||
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1);
|
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1);
|
||||||
|
@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
#include "core/hle/kernel/board/nintendo/nx/k_system_control.h"
|
#include "core/hle/kernel/board/nintendo/nx/k_system_control.h"
|
||||||
#include "core/hle/kernel/board/nintendo/nx/secure_monitor.h"
|
#include "core/hle/kernel/board/nintendo/nx/secure_monitor.h"
|
||||||
|
#include "core/hle/kernel/k_memory_manager.h"
|
||||||
|
#include "core/hle/kernel/k_page_table.h"
|
||||||
#include "core/hle/kernel/k_trace.h"
|
#include "core/hle/kernel/k_trace.h"
|
||||||
|
#include "core/hle/kernel/kernel.h"
|
||||||
|
#include "core/hle/kernel/svc_results.h"
|
||||||
|
|
||||||
namespace Kernel::Board::Nintendo::Nx {
|
namespace Kernel::Board::Nintendo::Nx {
|
||||||
|
|
||||||
@ -30,6 +34,8 @@ constexpr const std::size_t RequiredNonSecureSystemMemorySize =
|
|||||||
constexpr const std::size_t RequiredNonSecureSystemMemorySizeWithFatal =
|
constexpr const std::size_t RequiredNonSecureSystemMemorySizeWithFatal =
|
||||||
RequiredNonSecureSystemMemorySize + impl::RequiredNonSecureSystemMemorySizeViFatal;
|
RequiredNonSecureSystemMemorySize + impl::RequiredNonSecureSystemMemorySizeViFatal;
|
||||||
|
|
||||||
|
constexpr const std::size_t SecureAlignment = 128_KiB;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using namespace Common::Literals;
|
using namespace Common::Literals;
|
||||||
@ -183,4 +189,57 @@ u64 KSystemControl::GenerateRandomRange(u64 min, u64 max) {
|
|||||||
return GenerateUniformRange(min, max, GenerateRandomU64);
|
return GenerateUniformRange(min, max, GenerateRandomU64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t KSystemControl::CalculateRequiredSecureMemorySize(size_t size, u32 pool) {
|
||||||
|
if (pool == static_cast<u32>(KMemoryManager::Pool::Applet)) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// return KSystemControlBase::CalculateRequiredSecureMemorySize(size, pool);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result KSystemControl::AllocateSecureMemory(KernelCore& kernel, KVirtualAddress* out, size_t size,
|
||||||
|
u32 pool) {
|
||||||
|
// Applet secure memory is handled separately.
|
||||||
|
UNIMPLEMENTED_IF(pool == static_cast<u32>(KMemoryManager::Pool::Applet));
|
||||||
|
|
||||||
|
// Ensure the size is aligned.
|
||||||
|
const size_t alignment =
|
||||||
|
(pool == static_cast<u32>(KMemoryManager::Pool::System) ? PageSize : SecureAlignment);
|
||||||
|
R_UNLESS(Common::IsAligned(size, alignment), ResultInvalidSize);
|
||||||
|
|
||||||
|
// Allocate the memory.
|
||||||
|
const size_t num_pages = size / PageSize;
|
||||||
|
const KPhysicalAddress paddr = kernel.MemoryManager().AllocateAndOpenContinuous(
|
||||||
|
num_pages, alignment / PageSize,
|
||||||
|
KMemoryManager::EncodeOption(static_cast<KMemoryManager::Pool>(pool),
|
||||||
|
KMemoryManager::Direction::FromFront));
|
||||||
|
R_UNLESS(paddr != 0, ResultOutOfMemory);
|
||||||
|
|
||||||
|
// Ensure we don't leak references to the memory on error.
|
||||||
|
ON_RESULT_FAILURE {
|
||||||
|
kernel.MemoryManager().Close(paddr, num_pages);
|
||||||
|
};
|
||||||
|
|
||||||
|
// We succeeded.
|
||||||
|
*out = KPageTable::GetHeapVirtualAddress(kernel.MemoryLayout(), paddr);
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KSystemControl::FreeSecureMemory(KernelCore& kernel, KVirtualAddress address, size_t size,
|
||||||
|
u32 pool) {
|
||||||
|
// Applet secure memory is handled separately.
|
||||||
|
UNIMPLEMENTED_IF(pool == static_cast<u32>(KMemoryManager::Pool::Applet));
|
||||||
|
|
||||||
|
// Ensure the size is aligned.
|
||||||
|
const size_t alignment =
|
||||||
|
(pool == static_cast<u32>(KMemoryManager::Pool::System) ? PageSize : SecureAlignment);
|
||||||
|
ASSERT(Common::IsAligned(GetInteger(address), alignment));
|
||||||
|
ASSERT(Common::IsAligned(size, alignment));
|
||||||
|
|
||||||
|
// Close the secure region's pages.
|
||||||
|
kernel.MemoryManager().Close(KPageTable::GetHeapPhysicalAddress(kernel.MemoryLayout(), address),
|
||||||
|
size / PageSize);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Kernel::Board::Nintendo::Nx
|
} // namespace Kernel::Board::Nintendo::Nx
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/hle/kernel/k_typed_address.h"
|
#include "core/hle/kernel/k_typed_address.h"
|
||||||
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class KernelCore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Kernel::Board::Nintendo::Nx {
|
namespace Kernel::Board::Nintendo::Nx {
|
||||||
|
|
||||||
@ -25,8 +30,16 @@ public:
|
|||||||
static std::size_t GetMinimumNonSecureSystemPoolSize();
|
static std::size_t GetMinimumNonSecureSystemPoolSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Randomness.
|
||||||
static u64 GenerateRandomRange(u64 min, u64 max);
|
static u64 GenerateRandomRange(u64 min, u64 max);
|
||||||
static u64 GenerateRandomU64();
|
static u64 GenerateRandomU64();
|
||||||
|
|
||||||
|
// Secure Memory.
|
||||||
|
static size_t CalculateRequiredSecureMemorySize(size_t size, u32 pool);
|
||||||
|
static Result AllocateSecureMemory(KernelCore& kernel, KVirtualAddress* out, size_t size,
|
||||||
|
u32 pool);
|
||||||
|
static void FreeSecureMemory(KernelCore& kernel, KVirtualAddress address, size_t size,
|
||||||
|
u32 pool);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Kernel::Board::Nintendo::Nx
|
} // namespace Kernel::Board::Nintendo::Nx
|
||||||
|
@ -106,7 +106,7 @@ static_assert(KernelPageBufferAdditionalSize ==
|
|||||||
/// memory.
|
/// memory.
|
||||||
static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout,
|
static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout,
|
||||||
KVirtualAddress slab_addr) {
|
KVirtualAddress slab_addr) {
|
||||||
slab_addr -= GetInteger(memory_layout.GetSlabRegionAddress());
|
slab_addr -= memory_layout.GetSlabRegion().GetAddress();
|
||||||
return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase;
|
return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,12 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) {
|
|||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
|
|
||||||
// Get the start of the slab region, since that's where we'll be working.
|
// Get the start of the slab region, since that's where we'll be working.
|
||||||
KVirtualAddress address = memory_layout.GetSlabRegionAddress();
|
const KMemoryRegion& slab_region = memory_layout.GetSlabRegion();
|
||||||
|
KVirtualAddress address = slab_region.GetAddress();
|
||||||
|
|
||||||
|
// Clear the slab region.
|
||||||
|
// TODO: implement access to kernel VAs.
|
||||||
|
// std::memset(device_ptr, 0, slab_region.GetSize());
|
||||||
|
|
||||||
// Initialize slab type array to be in sorted order.
|
// Initialize slab type array to be in sorted order.
|
||||||
std::array<KSlabType, KSlabType_Count> slab_types;
|
std::array<KSlabType, KSlabType_Count> slab_types;
|
||||||
|
@ -19,4 +19,8 @@ static inline KPhysicalAddress GetInitialProcessBinaryPhysicalAddress() {
|
|||||||
MainMemoryAddress);
|
MainMemoryAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline size_t GetInitialProcessBinarySize() {
|
||||||
|
return InitialProcessBinarySizeMax;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
@ -200,8 +200,8 @@ private:
|
|||||||
|
|
||||||
RawCapabilityValue raw;
|
RawCapabilityValue raw;
|
||||||
BitField<0, 15, CapabilityType> id;
|
BitField<0, 15, CapabilityType> id;
|
||||||
BitField<15, 4, u32> major_version;
|
BitField<15, 4, u32> minor_version;
|
||||||
BitField<19, 13, u32> minor_version;
|
BitField<19, 13, u32> major_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
union HandleTable {
|
union HandleTable {
|
||||||
|
@ -107,12 +107,12 @@ KConditionVariable::KConditionVariable(Core::System& system)
|
|||||||
|
|
||||||
KConditionVariable::~KConditionVariable() = default;
|
KConditionVariable::~KConditionVariable() = default;
|
||||||
|
|
||||||
Result KConditionVariable::SignalToAddress(KProcessAddress addr) {
|
Result KConditionVariable::SignalToAddress(KernelCore& kernel, KProcessAddress addr) {
|
||||||
KThread* owner_thread = GetCurrentThreadPointer(m_kernel);
|
KThread* owner_thread = GetCurrentThreadPointer(kernel);
|
||||||
|
|
||||||
// Signal the address.
|
// Signal the address.
|
||||||
{
|
{
|
||||||
KScopedSchedulerLock sl(m_kernel);
|
KScopedSchedulerLock sl(kernel);
|
||||||
|
|
||||||
// Remove waiter thread.
|
// Remove waiter thread.
|
||||||
bool has_waiters{};
|
bool has_waiters{};
|
||||||
@ -133,7 +133,7 @@ Result KConditionVariable::SignalToAddress(KProcessAddress addr) {
|
|||||||
|
|
||||||
// Write the value to userspace.
|
// Write the value to userspace.
|
||||||
Result result{ResultSuccess};
|
Result result{ResultSuccess};
|
||||||
if (WriteToUser(m_kernel, addr, std::addressof(next_value))) [[likely]] {
|
if (WriteToUser(kernel, addr, std::addressof(next_value))) [[likely]] {
|
||||||
result = ResultSuccess;
|
result = ResultSuccess;
|
||||||
} else {
|
} else {
|
||||||
result = ResultInvalidCurrentMemory;
|
result = ResultInvalidCurrentMemory;
|
||||||
@ -148,28 +148,28 @@ Result KConditionVariable::SignalToAddress(KProcessAddress addr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KConditionVariable::WaitForAddress(Handle handle, KProcessAddress addr, u32 value) {
|
Result KConditionVariable::WaitForAddress(KernelCore& kernel, Handle handle, KProcessAddress addr,
|
||||||
KThread* cur_thread = GetCurrentThreadPointer(m_kernel);
|
u32 value) {
|
||||||
ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(m_kernel);
|
KThread* cur_thread = GetCurrentThreadPointer(kernel);
|
||||||
|
ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(kernel);
|
||||||
|
|
||||||
// Wait for the address.
|
// Wait for the address.
|
||||||
KThread* owner_thread{};
|
KThread* owner_thread{};
|
||||||
{
|
{
|
||||||
KScopedSchedulerLock sl(m_kernel);
|
KScopedSchedulerLock sl(kernel);
|
||||||
|
|
||||||
// Check if the thread should terminate.
|
// Check if the thread should terminate.
|
||||||
R_UNLESS(!cur_thread->IsTerminationRequested(), ResultTerminationRequested);
|
R_UNLESS(!cur_thread->IsTerminationRequested(), ResultTerminationRequested);
|
||||||
|
|
||||||
// Read the tag from userspace.
|
// Read the tag from userspace.
|
||||||
u32 test_tag{};
|
u32 test_tag{};
|
||||||
R_UNLESS(ReadFromUser(m_kernel, std::addressof(test_tag), addr),
|
R_UNLESS(ReadFromUser(kernel, std::addressof(test_tag), addr), ResultInvalidCurrentMemory);
|
||||||
ResultInvalidCurrentMemory);
|
|
||||||
|
|
||||||
// If the tag isn't the handle (with wait mask), we're done.
|
// If the tag isn't the handle (with wait mask), we're done.
|
||||||
R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask));
|
R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask));
|
||||||
|
|
||||||
// Get the lock owner thread.
|
// Get the lock owner thread.
|
||||||
owner_thread = GetCurrentProcess(m_kernel)
|
owner_thread = GetCurrentProcess(kernel)
|
||||||
.GetHandleTable()
|
.GetHandleTable()
|
||||||
.GetObjectWithoutPseudoHandle<KThread>(handle)
|
.GetObjectWithoutPseudoHandle<KThread>(handle)
|
||||||
.ReleasePointerUnsafe();
|
.ReleasePointerUnsafe();
|
||||||
|
@ -24,11 +24,12 @@ public:
|
|||||||
explicit KConditionVariable(Core::System& system);
|
explicit KConditionVariable(Core::System& system);
|
||||||
~KConditionVariable();
|
~KConditionVariable();
|
||||||
|
|
||||||
// Arbitration
|
// Arbitration.
|
||||||
Result SignalToAddress(KProcessAddress addr);
|
static Result SignalToAddress(KernelCore& kernel, KProcessAddress addr);
|
||||||
Result WaitForAddress(Handle handle, KProcessAddress addr, u32 value);
|
static Result WaitForAddress(KernelCore& kernel, Handle handle, KProcessAddress addr,
|
||||||
|
u32 value);
|
||||||
|
|
||||||
// Condition variable
|
// Condition variable.
|
||||||
void Signal(u64 cv_key, s32 count);
|
void Signal(u64 cv_key, s32 count);
|
||||||
Result Wait(KProcessAddress addr, u64 key, u32 value, s64 timeout);
|
Result Wait(KProcessAddress addr, u64 key, u32 value, s64 timeout);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ void HandleInterrupt(KernelCore& kernel, s32 core_id) {
|
|||||||
KScopedSchedulerLock sl{kernel};
|
KScopedSchedulerLock sl{kernel};
|
||||||
|
|
||||||
// Pin the current thread.
|
// Pin the current thread.
|
||||||
process->PinCurrentThread(core_id);
|
process->PinCurrentThread();
|
||||||
|
|
||||||
// Set the interrupt flag for the thread.
|
// Set the interrupt flag for the thread.
|
||||||
GetCurrentThread(kernel).SetInterruptFlag();
|
GetCurrentThread(kernel).SetInterruptFlag();
|
||||||
|
@ -36,6 +36,7 @@ enum class KMemoryState : u32 {
|
|||||||
FlagCanChangeAttribute = (1 << 24),
|
FlagCanChangeAttribute = (1 << 24),
|
||||||
FlagCanCodeMemory = (1 << 25),
|
FlagCanCodeMemory = (1 << 25),
|
||||||
FlagLinearMapped = (1 << 26),
|
FlagLinearMapped = (1 << 26),
|
||||||
|
FlagCanPermissionLock = (1 << 27),
|
||||||
|
|
||||||
FlagsData = FlagCanReprotect | FlagCanUseIpc | FlagCanUseNonDeviceIpc | FlagCanUseNonSecureIpc |
|
FlagsData = FlagCanReprotect | FlagCanUseIpc | FlagCanUseNonDeviceIpc | FlagCanUseNonSecureIpc |
|
||||||
FlagMapped | FlagCanAlias | FlagCanTransfer | FlagCanQueryPhysical |
|
FlagMapped | FlagCanAlias | FlagCanTransfer | FlagCanQueryPhysical |
|
||||||
@ -50,12 +51,16 @@ enum class KMemoryState : u32 {
|
|||||||
FlagLinearMapped,
|
FlagLinearMapped,
|
||||||
|
|
||||||
Free = static_cast<u32>(Svc::MemoryState::Free),
|
Free = static_cast<u32>(Svc::MemoryState::Free),
|
||||||
Io = static_cast<u32>(Svc::MemoryState::Io) | FlagMapped | FlagCanDeviceMap |
|
|
||||||
|
IoMemory = static_cast<u32>(Svc::MemoryState::Io) | FlagMapped | FlagCanDeviceMap |
|
||||||
FlagCanAlignedDeviceMap,
|
FlagCanAlignedDeviceMap,
|
||||||
|
IoRegister =
|
||||||
|
static_cast<u32>(Svc::MemoryState::Io) | FlagCanDeviceMap | FlagCanAlignedDeviceMap,
|
||||||
|
|
||||||
Static = static_cast<u32>(Svc::MemoryState::Static) | FlagMapped | FlagCanQueryPhysical,
|
Static = static_cast<u32>(Svc::MemoryState::Static) | FlagMapped | FlagCanQueryPhysical,
|
||||||
Code = static_cast<u32>(Svc::MemoryState::Code) | FlagsCode | FlagCanMapProcess,
|
Code = static_cast<u32>(Svc::MemoryState::Code) | FlagsCode | FlagCanMapProcess,
|
||||||
CodeData = static_cast<u32>(Svc::MemoryState::CodeData) | FlagsData | FlagCanMapProcess |
|
CodeData = static_cast<u32>(Svc::MemoryState::CodeData) | FlagsData | FlagCanMapProcess |
|
||||||
FlagCanCodeMemory,
|
FlagCanCodeMemory | FlagCanPermissionLock,
|
||||||
Normal = static_cast<u32>(Svc::MemoryState::Normal) | FlagsData | FlagCanCodeMemory,
|
Normal = static_cast<u32>(Svc::MemoryState::Normal) | FlagsData | FlagCanCodeMemory,
|
||||||
Shared = static_cast<u32>(Svc::MemoryState::Shared) | FlagMapped | FlagReferenceCounted |
|
Shared = static_cast<u32>(Svc::MemoryState::Shared) | FlagMapped | FlagReferenceCounted |
|
||||||
FlagLinearMapped,
|
FlagLinearMapped,
|
||||||
@ -65,7 +70,8 @@ enum class KMemoryState : u32 {
|
|||||||
AliasCode = static_cast<u32>(Svc::MemoryState::AliasCode) | FlagsCode | FlagCanMapProcess |
|
AliasCode = static_cast<u32>(Svc::MemoryState::AliasCode) | FlagsCode | FlagCanMapProcess |
|
||||||
FlagCanCodeAlias,
|
FlagCanCodeAlias,
|
||||||
AliasCodeData = static_cast<u32>(Svc::MemoryState::AliasCodeData) | FlagsData |
|
AliasCodeData = static_cast<u32>(Svc::MemoryState::AliasCodeData) | FlagsData |
|
||||||
FlagCanMapProcess | FlagCanCodeAlias | FlagCanCodeMemory,
|
FlagCanMapProcess | FlagCanCodeAlias | FlagCanCodeMemory |
|
||||||
|
FlagCanPermissionLock,
|
||||||
|
|
||||||
Ipc = static_cast<u32>(Svc::MemoryState::Ipc) | FlagsMisc | FlagCanAlignedDeviceMap |
|
Ipc = static_cast<u32>(Svc::MemoryState::Ipc) | FlagsMisc | FlagCanAlignedDeviceMap |
|
||||||
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||||
@ -73,7 +79,7 @@ enum class KMemoryState : u32 {
|
|||||||
Stack = static_cast<u32>(Svc::MemoryState::Stack) | FlagsMisc | FlagCanAlignedDeviceMap |
|
Stack = static_cast<u32>(Svc::MemoryState::Stack) | FlagsMisc | FlagCanAlignedDeviceMap |
|
||||||
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||||
|
|
||||||
ThreadLocal = static_cast<u32>(Svc::MemoryState::ThreadLocal) | FlagMapped | FlagLinearMapped,
|
ThreadLocal = static_cast<u32>(Svc::MemoryState::ThreadLocal) | FlagLinearMapped,
|
||||||
|
|
||||||
Transfered = static_cast<u32>(Svc::MemoryState::Transfered) | FlagsMisc |
|
Transfered = static_cast<u32>(Svc::MemoryState::Transfered) | FlagsMisc |
|
||||||
FlagCanAlignedDeviceMap | FlagCanChangeAttribute | FlagCanUseIpc |
|
FlagCanAlignedDeviceMap | FlagCanChangeAttribute | FlagCanUseIpc |
|
||||||
@ -94,7 +100,7 @@ enum class KMemoryState : u32 {
|
|||||||
NonDeviceIpc =
|
NonDeviceIpc =
|
||||||
static_cast<u32>(Svc::MemoryState::NonDeviceIpc) | FlagsMisc | FlagCanUseNonDeviceIpc,
|
static_cast<u32>(Svc::MemoryState::NonDeviceIpc) | FlagsMisc | FlagCanUseNonDeviceIpc,
|
||||||
|
|
||||||
Kernel = static_cast<u32>(Svc::MemoryState::Kernel) | FlagMapped,
|
Kernel = static_cast<u32>(Svc::MemoryState::Kernel),
|
||||||
|
|
||||||
GeneratedCode = static_cast<u32>(Svc::MemoryState::GeneratedCode) | FlagMapped |
|
GeneratedCode = static_cast<u32>(Svc::MemoryState::GeneratedCode) | FlagMapped |
|
||||||
FlagReferenceCounted | FlagCanDebug | FlagLinearMapped,
|
FlagReferenceCounted | FlagCanDebug | FlagLinearMapped,
|
||||||
@ -105,34 +111,36 @@ enum class KMemoryState : u32 {
|
|||||||
|
|
||||||
Insecure = static_cast<u32>(Svc::MemoryState::Insecure) | FlagMapped | FlagReferenceCounted |
|
Insecure = static_cast<u32>(Svc::MemoryState::Insecure) | FlagMapped | FlagReferenceCounted |
|
||||||
FlagLinearMapped | FlagCanChangeAttribute | FlagCanDeviceMap |
|
FlagLinearMapped | FlagCanChangeAttribute | FlagCanDeviceMap |
|
||||||
FlagCanAlignedDeviceMap | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
FlagCanAlignedDeviceMap | FlagCanQueryPhysical | FlagCanUseNonSecureIpc |
|
||||||
|
FlagCanUseNonDeviceIpc,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(KMemoryState);
|
DECLARE_ENUM_FLAG_OPERATORS(KMemoryState);
|
||||||
|
|
||||||
static_assert(static_cast<u32>(KMemoryState::Free) == 0x00000000);
|
static_assert(static_cast<u32>(KMemoryState::Free) == 0x00000000);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Io) == 0x00182001);
|
static_assert(static_cast<u32>(KMemoryState::IoMemory) == 0x00182001);
|
||||||
|
static_assert(static_cast<u32>(KMemoryState::IoRegister) == 0x00180001);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Static) == 0x00042002);
|
static_assert(static_cast<u32>(KMemoryState::Static) == 0x00042002);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Code) == 0x04DC7E03);
|
static_assert(static_cast<u32>(KMemoryState::Code) == 0x04DC7E03);
|
||||||
static_assert(static_cast<u32>(KMemoryState::CodeData) == 0x07FEBD04);
|
static_assert(static_cast<u32>(KMemoryState::CodeData) == 0x0FFEBD04);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Normal) == 0x077EBD05);
|
static_assert(static_cast<u32>(KMemoryState::Normal) == 0x077EBD05);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Shared) == 0x04402006);
|
static_assert(static_cast<u32>(KMemoryState::Shared) == 0x04402006);
|
||||||
|
|
||||||
static_assert(static_cast<u32>(KMemoryState::AliasCode) == 0x04DD7E08);
|
static_assert(static_cast<u32>(KMemoryState::AliasCode) == 0x04DD7E08);
|
||||||
static_assert(static_cast<u32>(KMemoryState::AliasCodeData) == 0x07FFBD09);
|
static_assert(static_cast<u32>(KMemoryState::AliasCodeData) == 0x0FFFBD09);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Ipc) == 0x045C3C0A);
|
static_assert(static_cast<u32>(KMemoryState::Ipc) == 0x045C3C0A);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Stack) == 0x045C3C0B);
|
static_assert(static_cast<u32>(KMemoryState::Stack) == 0x045C3C0B);
|
||||||
static_assert(static_cast<u32>(KMemoryState::ThreadLocal) == 0x0400200C);
|
static_assert(static_cast<u32>(KMemoryState::ThreadLocal) == 0x0400000C);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Transfered) == 0x055C3C0D);
|
static_assert(static_cast<u32>(KMemoryState::Transfered) == 0x055C3C0D);
|
||||||
static_assert(static_cast<u32>(KMemoryState::SharedTransfered) == 0x045C380E);
|
static_assert(static_cast<u32>(KMemoryState::SharedTransfered) == 0x045C380E);
|
||||||
static_assert(static_cast<u32>(KMemoryState::SharedCode) == 0x0440380F);
|
static_assert(static_cast<u32>(KMemoryState::SharedCode) == 0x0440380F);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Inaccessible) == 0x00000010);
|
static_assert(static_cast<u32>(KMemoryState::Inaccessible) == 0x00000010);
|
||||||
static_assert(static_cast<u32>(KMemoryState::NonSecureIpc) == 0x045C3811);
|
static_assert(static_cast<u32>(KMemoryState::NonSecureIpc) == 0x045C3811);
|
||||||
static_assert(static_cast<u32>(KMemoryState::NonDeviceIpc) == 0x044C2812);
|
static_assert(static_cast<u32>(KMemoryState::NonDeviceIpc) == 0x044C2812);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Kernel) == 0x00002013);
|
static_assert(static_cast<u32>(KMemoryState::Kernel) == 0x00000013);
|
||||||
static_assert(static_cast<u32>(KMemoryState::GeneratedCode) == 0x04402214);
|
static_assert(static_cast<u32>(KMemoryState::GeneratedCode) == 0x04402214);
|
||||||
static_assert(static_cast<u32>(KMemoryState::CodeOut) == 0x04402015);
|
static_assert(static_cast<u32>(KMemoryState::CodeOut) == 0x04402015);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Coverage) == 0x00002016);
|
static_assert(static_cast<u32>(KMemoryState::Coverage) == 0x00002016);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Insecure) == 0x05583817);
|
static_assert(static_cast<u32>(KMemoryState::Insecure) == 0x055C3817);
|
||||||
|
|
||||||
enum class KMemoryPermission : u8 {
|
enum class KMemoryPermission : u8 {
|
||||||
None = 0,
|
None = 0,
|
||||||
@ -182,8 +190,9 @@ enum class KMemoryAttribute : u8 {
|
|||||||
IpcLocked = static_cast<u8>(Svc::MemoryAttribute::IpcLocked),
|
IpcLocked = static_cast<u8>(Svc::MemoryAttribute::IpcLocked),
|
||||||
DeviceShared = static_cast<u8>(Svc::MemoryAttribute::DeviceShared),
|
DeviceShared = static_cast<u8>(Svc::MemoryAttribute::DeviceShared),
|
||||||
Uncached = static_cast<u8>(Svc::MemoryAttribute::Uncached),
|
Uncached = static_cast<u8>(Svc::MemoryAttribute::Uncached),
|
||||||
|
PermissionLocked = static_cast<u8>(Svc::MemoryAttribute::PermissionLocked),
|
||||||
|
|
||||||
SetMask = Uncached,
|
SetMask = Uncached | PermissionLocked,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(KMemoryAttribute);
|
DECLARE_ENUM_FLAG_OPERATORS(KMemoryAttribute);
|
||||||
|
|
||||||
@ -261,6 +270,10 @@ struct KMemoryInfo {
|
|||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr Svc::MemoryState GetSvcState() const {
|
||||||
|
return static_cast<Svc::MemoryState>(m_state & KMemoryState::Mask);
|
||||||
|
}
|
||||||
|
|
||||||
constexpr KMemoryPermission GetPermission() const {
|
constexpr KMemoryPermission GetPermission() const {
|
||||||
return m_permission;
|
return m_permission;
|
||||||
}
|
}
|
||||||
@ -326,6 +339,10 @@ public:
|
|||||||
return this->GetEndAddress() - 1;
|
return this->GetEndAddress() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr KMemoryState GetState() const {
|
||||||
|
return m_memory_state;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr u16 GetIpcLockCount() const {
|
constexpr u16 GetIpcLockCount() const {
|
||||||
return m_ipc_lock_count;
|
return m_ipc_lock_count;
|
||||||
}
|
}
|
||||||
@ -443,6 +460,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr void UpdateAttribute(KMemoryAttribute mask, KMemoryAttribute attr) {
|
||||||
|
ASSERT(False(mask & KMemoryAttribute::IpcLocked));
|
||||||
|
ASSERT(False(mask & KMemoryAttribute::DeviceShared));
|
||||||
|
|
||||||
|
m_attribute = (m_attribute & ~mask) | attr;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr void Split(KMemoryBlock* block, KProcessAddress addr) {
|
constexpr void Split(KMemoryBlock* block, KProcessAddress addr) {
|
||||||
ASSERT(this->GetAddress() < addr);
|
ASSERT(this->GetAddress() < addr);
|
||||||
ASSERT(this->Contains(addr));
|
ASSERT(this->Contains(addr));
|
||||||
|
@ -160,8 +160,8 @@ void KMemoryBlockManager::Update(KMemoryBlockManagerUpdateAllocator* allocator,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update block state.
|
// Update block state.
|
||||||
it->Update(state, perm, attr, cur_address == address, static_cast<u8>(set_disable_attr),
|
it->Update(state, perm, attr, it->GetAddress() == address,
|
||||||
static_cast<u8>(clear_disable_attr));
|
static_cast<u8>(set_disable_attr), static_cast<u8>(clear_disable_attr));
|
||||||
cur_address += cur_info.GetSize();
|
cur_address += cur_info.GetSize();
|
||||||
remaining_pages -= cur_info.GetNumPages();
|
remaining_pages -= cur_info.GetNumPages();
|
||||||
}
|
}
|
||||||
@ -175,7 +175,9 @@ void KMemoryBlockManager::UpdateIfMatch(KMemoryBlockManagerUpdateAllocator* allo
|
|||||||
KProcessAddress address, size_t num_pages,
|
KProcessAddress address, size_t num_pages,
|
||||||
KMemoryState test_state, KMemoryPermission test_perm,
|
KMemoryState test_state, KMemoryPermission test_perm,
|
||||||
KMemoryAttribute test_attr, KMemoryState state,
|
KMemoryAttribute test_attr, KMemoryState state,
|
||||||
KMemoryPermission perm, KMemoryAttribute attr) {
|
KMemoryPermission perm, KMemoryAttribute attr,
|
||||||
|
KMemoryBlockDisableMergeAttribute set_disable_attr,
|
||||||
|
KMemoryBlockDisableMergeAttribute clear_disable_attr) {
|
||||||
// Ensure for auditing that we never end up with an invalid tree.
|
// Ensure for auditing that we never end up with an invalid tree.
|
||||||
KScopedMemoryBlockManagerAuditor auditor(this);
|
KScopedMemoryBlockManagerAuditor auditor(this);
|
||||||
ASSERT(Common::IsAligned(GetInteger(address), PageSize));
|
ASSERT(Common::IsAligned(GetInteger(address), PageSize));
|
||||||
@ -214,7 +216,8 @@ void KMemoryBlockManager::UpdateIfMatch(KMemoryBlockManagerUpdateAllocator* allo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update block state.
|
// Update block state.
|
||||||
it->Update(state, perm, attr, false, 0, 0);
|
it->Update(state, perm, attr, false, static_cast<u8>(set_disable_attr),
|
||||||
|
static_cast<u8>(clear_disable_attr));
|
||||||
cur_address += cur_info.GetSize();
|
cur_address += cur_info.GetSize();
|
||||||
remaining_pages -= cur_info.GetNumPages();
|
remaining_pages -= cur_info.GetNumPages();
|
||||||
} else {
|
} else {
|
||||||
@ -284,6 +287,65 @@ void KMemoryBlockManager::UpdateLock(KMemoryBlockManagerUpdateAllocator* allocat
|
|||||||
this->CoalesceForUpdate(allocator, address, num_pages);
|
this->CoalesceForUpdate(allocator, address, num_pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KMemoryBlockManager::UpdateAttribute(KMemoryBlockManagerUpdateAllocator* allocator,
|
||||||
|
KProcessAddress address, size_t num_pages,
|
||||||
|
KMemoryAttribute mask, KMemoryAttribute attr) {
|
||||||
|
// Ensure for auditing that we never end up with an invalid tree.
|
||||||
|
KScopedMemoryBlockManagerAuditor auditor(this);
|
||||||
|
ASSERT(Common::IsAligned(GetInteger(address), PageSize));
|
||||||
|
|
||||||
|
KProcessAddress cur_address = address;
|
||||||
|
size_t remaining_pages = num_pages;
|
||||||
|
iterator it = this->FindIterator(address);
|
||||||
|
|
||||||
|
while (remaining_pages > 0) {
|
||||||
|
const size_t remaining_size = remaining_pages * PageSize;
|
||||||
|
KMemoryInfo cur_info = it->GetMemoryInfo();
|
||||||
|
|
||||||
|
if ((it->GetAttribute() & mask) != attr) {
|
||||||
|
// If we need to, create a new block before and insert it.
|
||||||
|
if (cur_info.GetAddress() != GetInteger(cur_address)) {
|
||||||
|
KMemoryBlock* new_block = allocator->Allocate();
|
||||||
|
|
||||||
|
it->Split(new_block, cur_address);
|
||||||
|
it = m_memory_block_tree.insert(*new_block);
|
||||||
|
it++;
|
||||||
|
|
||||||
|
cur_info = it->GetMemoryInfo();
|
||||||
|
cur_address = cur_info.GetAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we need to, create a new block after and insert it.
|
||||||
|
if (cur_info.GetSize() > remaining_size) {
|
||||||
|
KMemoryBlock* new_block = allocator->Allocate();
|
||||||
|
|
||||||
|
it->Split(new_block, cur_address + remaining_size);
|
||||||
|
it = m_memory_block_tree.insert(*new_block);
|
||||||
|
|
||||||
|
cur_info = it->GetMemoryInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update block state.
|
||||||
|
it->UpdateAttribute(mask, attr);
|
||||||
|
cur_address += cur_info.GetSize();
|
||||||
|
remaining_pages -= cur_info.GetNumPages();
|
||||||
|
} else {
|
||||||
|
// If we already have the right attributes, just advance.
|
||||||
|
if (cur_address + remaining_size < cur_info.GetEndAddress()) {
|
||||||
|
remaining_pages = 0;
|
||||||
|
cur_address += remaining_size;
|
||||||
|
} else {
|
||||||
|
remaining_pages =
|
||||||
|
(cur_address + remaining_size - cur_info.GetEndAddress()) / PageSize;
|
||||||
|
cur_address = cur_info.GetEndAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->CoalesceForUpdate(allocator, address, num_pages);
|
||||||
|
}
|
||||||
|
|
||||||
// Debug.
|
// Debug.
|
||||||
bool KMemoryBlockManager::CheckState() const {
|
bool KMemoryBlockManager::CheckState() const {
|
||||||
// Loop over every block, ensuring that we are sorted and coalesced.
|
// Loop over every block, ensuring that we are sorted and coalesced.
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user