mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Merge branch 'main' into device-abstraction
This commit is contained in:
commit
e47ed6865a
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -92,7 +92,7 @@ jobs:
|
|||||||
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $env:NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
- name: Upload Windows SDL artifact
|
- name: Upload Windows SDL artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@ -146,7 +146,7 @@ jobs:
|
|||||||
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $env:NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
- name: Deploy and Package
|
- name: Deploy and Package
|
||||||
run: |
|
run: |
|
||||||
@ -315,7 +315,7 @@ jobs:
|
|||||||
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc)
|
||||||
|
|
||||||
- name: Package and Upload Linux(ubuntu64) SDL artifact
|
- name: Package and Upload Linux(ubuntu64) SDL artifact
|
||||||
run: |
|
run: |
|
||||||
@ -371,7 +371,7 @@ jobs:
|
|||||||
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel3
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc)
|
||||||
|
|
||||||
- name: Run AppImage packaging script
|
- name: Run AppImage packaging script
|
||||||
run: ./.github/linux-appimage-qt.sh
|
run: ./.github/linux-appimage-qt.sh
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16.3)
|
# Version 3.24 needed for FetchContent OVERRIDE_FIND_PACKAGE
|
||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
@ -110,9 +111,10 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_
|
|||||||
find_package(Boost 1.84.0 CONFIG)
|
find_package(Boost 1.84.0 CONFIG)
|
||||||
find_package(FFmpeg 5.1.2 MODULE)
|
find_package(FFmpeg 5.1.2 MODULE)
|
||||||
find_package(fmt 10.2.0 CONFIG)
|
find_package(fmt 10.2.0 CONFIG)
|
||||||
find_package(glslang 14.2.0 CONFIG)
|
find_package(glslang 15 CONFIG)
|
||||||
find_package(half 1.12.0 MODULE)
|
find_package(half 1.12.0 MODULE)
|
||||||
find_package(magic_enum 0.9.6 CONFIG)
|
find_package(magic_enum 0.9.6 CONFIG)
|
||||||
|
find_package(PNG 1.6 MODULE)
|
||||||
find_package(RenderDoc 1.6.0 MODULE)
|
find_package(RenderDoc 1.6.0 MODULE)
|
||||||
find_package(SDL3 3.1.2 CONFIG)
|
find_package(SDL3 3.1.2 CONFIG)
|
||||||
find_package(toml11 4.2.0 CONFIG)
|
find_package(toml11 4.2.0 CONFIG)
|
||||||
@ -121,7 +123,7 @@ find_package(VulkanHeaders 1.3.289 CONFIG)
|
|||||||
find_package(VulkanMemoryAllocator 3.1.0 CONFIG)
|
find_package(VulkanMemoryAllocator 3.1.0 CONFIG)
|
||||||
find_package(xbyak 7.07 CONFIG)
|
find_package(xbyak 7.07 CONFIG)
|
||||||
find_package(xxHash 0.8.2 MODULE)
|
find_package(xxHash 0.8.2 MODULE)
|
||||||
find_package(zlib-ng 2.1.7 MODULE)
|
find_package(ZLIB 1.3 MODULE)
|
||||||
find_package(Zydis 5.0.0 CONFIG)
|
find_package(Zydis 5.0.0 CONFIG)
|
||||||
find_package(pugixml 1.14 CONFIG)
|
find_package(pugixml 1.14 CONFIG)
|
||||||
|
|
||||||
@ -176,10 +178,6 @@ if(ENABLE_QT_GUI)
|
|||||||
qt_add_resources(TRANSLATIONS ${TRANSLATIONS_QRC})
|
qt_add_resources(TRANSLATIONS ${TRANSLATIONS_QRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(AUDIO_CORE src/audio_core/sdl_audio.cpp
|
|
||||||
src/audio_core/sdl_audio.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(AJM_LIB src/core/libraries/ajm/ajm.cpp
|
set(AJM_LIB src/core/libraries/ajm/ajm.cpp
|
||||||
src/core/libraries/ajm/ajm.h
|
src/core/libraries/ajm/ajm.h
|
||||||
src/core/libraries/ajm/ajm_at9.cpp
|
src/core/libraries/ajm/ajm_at9.cpp
|
||||||
@ -199,6 +197,9 @@ set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
|
|||||||
src/core/libraries/audio/audioin.h
|
src/core/libraries/audio/audioin.h
|
||||||
src/core/libraries/audio/audioout.cpp
|
src/core/libraries/audio/audioout.cpp
|
||||||
src/core/libraries/audio/audioout.h
|
src/core/libraries/audio/audioout.h
|
||||||
|
src/core/libraries/audio/sdl_audio.cpp
|
||||||
|
src/core/libraries/audio/sdl_audio.h
|
||||||
|
src/core/libraries/audio/audioout_error.h
|
||||||
src/core/libraries/ngs2/ngs2.cpp
|
src/core/libraries/ngs2/ngs2.cpp
|
||||||
src/core/libraries/ngs2/ngs2.h
|
src/core/libraries/ngs2/ngs2.h
|
||||||
)
|
)
|
||||||
@ -240,6 +241,8 @@ set(KERNEL_LIB src/core/libraries/kernel/threads/condvar.cpp
|
|||||||
src/core/libraries/kernel/threads.h
|
src/core/libraries/kernel/threads.h
|
||||||
src/core/libraries/kernel/time.cpp
|
src/core/libraries/kernel/time.cpp
|
||||||
src/core/libraries/kernel/time.h
|
src/core/libraries/kernel/time.h
|
||||||
|
src/core/libraries/kernel/orbis_error.h
|
||||||
|
src/core/libraries/kernel/posix_error.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(NETWORK_LIBS src/core/libraries/network/http.cpp
|
set(NETWORK_LIBS src/core/libraries/network/http.cpp
|
||||||
@ -255,6 +258,21 @@ set(NETWORK_LIBS src/core/libraries/network/http.cpp
|
|||||||
src/core/libraries/network/ssl.h
|
src/core/libraries/network/ssl.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(AVPLAYER_LIB src/core/libraries/avplayer/avplayer_common.cpp
|
||||||
|
src/core/libraries/avplayer/avplayer_common.h
|
||||||
|
src/core/libraries/avplayer/avplayer_file_streamer.cpp
|
||||||
|
src/core/libraries/avplayer/avplayer_file_streamer.h
|
||||||
|
src/core/libraries/avplayer/avplayer_impl.cpp
|
||||||
|
src/core/libraries/avplayer/avplayer_impl.h
|
||||||
|
src/core/libraries/avplayer/avplayer_source.cpp
|
||||||
|
src/core/libraries/avplayer/avplayer_source.h
|
||||||
|
src/core/libraries/avplayer/avplayer_state.cpp
|
||||||
|
src/core/libraries/avplayer/avplayer_state.h
|
||||||
|
src/core/libraries/avplayer/avplayer.cpp
|
||||||
|
src/core/libraries/avplayer/avplayer.h
|
||||||
|
src/core/libraries/avplayer/avplayer_error.h
|
||||||
|
)
|
||||||
|
|
||||||
set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
|
set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
|
||||||
src/core/libraries/system/commondialog.h
|
src/core/libraries/system/commondialog.h
|
||||||
src/core/libraries/system/msgdialog.cpp
|
src/core/libraries/system/msgdialog.cpp
|
||||||
@ -276,30 +294,22 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
|
|||||||
src/core/libraries/save_data/dialog/savedatadialog_ui.h
|
src/core/libraries/save_data/dialog/savedatadialog_ui.h
|
||||||
src/core/libraries/system/sysmodule.cpp
|
src/core/libraries/system/sysmodule.cpp
|
||||||
src/core/libraries/system/sysmodule.h
|
src/core/libraries/system/sysmodule.h
|
||||||
|
src/core/libraries/system/system_error.h
|
||||||
src/core/libraries/system/systemservice.cpp
|
src/core/libraries/system/systemservice.cpp
|
||||||
src/core/libraries/system/systemservice.h
|
src/core/libraries/system/systemservice.h
|
||||||
|
src/core/libraries/system/systemservice_error.h
|
||||||
src/core/libraries/system/userservice.cpp
|
src/core/libraries/system/userservice.cpp
|
||||||
src/core/libraries/system/userservice.h
|
src/core/libraries/system/userservice.h
|
||||||
|
src/core/libraries/system/userservice_error.h
|
||||||
src/core/libraries/app_content/app_content.cpp
|
src/core/libraries/app_content/app_content.cpp
|
||||||
src/core/libraries/app_content/app_content.h
|
src/core/libraries/app_content/app_content.h
|
||||||
|
src/core/libraries/app_content/app_content_error.h
|
||||||
src/core/libraries/rtc/rtc.cpp
|
src/core/libraries/rtc/rtc.cpp
|
||||||
src/core/libraries/rtc/rtc.h
|
src/core/libraries/rtc/rtc.h
|
||||||
src/core/libraries/rtc/rtc_error.h
|
src/core/libraries/rtc/rtc_error.h
|
||||||
src/core/libraries/disc_map/disc_map.cpp
|
src/core/libraries/disc_map/disc_map.cpp
|
||||||
src/core/libraries/disc_map/disc_map.h
|
src/core/libraries/disc_map/disc_map.h
|
||||||
src/core/libraries/disc_map/disc_map_codes.h
|
src/core/libraries/disc_map/disc_map_codes.h
|
||||||
src/core/libraries/avplayer/avplayer_common.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_common.h
|
|
||||||
src/core/libraries/avplayer/avplayer_file_streamer.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_file_streamer.h
|
|
||||||
src/core/libraries/avplayer/avplayer_impl.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_impl.h
|
|
||||||
src/core/libraries/avplayer/avplayer_source.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_source.h
|
|
||||||
src/core/libraries/avplayer/avplayer_state.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_state.h
|
|
||||||
src/core/libraries/avplayer/avplayer.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer.h
|
|
||||||
src/core/libraries/ngs2/ngs2.cpp
|
src/core/libraries/ngs2/ngs2.cpp
|
||||||
src/core/libraries/ngs2/ngs2.h
|
src/core/libraries/ngs2/ngs2.h
|
||||||
src/core/libraries/ngs2/ngs2_error.h
|
src/core/libraries/ngs2/ngs2_error.h
|
||||||
@ -317,6 +327,8 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
|
|||||||
src/core/libraries/remote_play/remoteplay.h
|
src/core/libraries/remote_play/remoteplay.h
|
||||||
src/core/libraries/share_play/shareplay.cpp
|
src/core/libraries/share_play/shareplay.cpp
|
||||||
src/core/libraries/share_play/shareplay.h
|
src/core/libraries/share_play/shareplay.h
|
||||||
|
src/core/libraries/razor_cpu/razor_cpu.cpp
|
||||||
|
src/core/libraries/razor_cpu/razor_cpu.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
|
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
|
||||||
@ -324,6 +336,7 @@ set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
|
|||||||
src/core/libraries/videoout/driver.h
|
src/core/libraries/videoout/driver.h
|
||||||
src/core/libraries/videoout/video_out.cpp
|
src/core/libraries/videoout/video_out.cpp
|
||||||
src/core/libraries/videoout/video_out.h
|
src/core/libraries/videoout/video_out.h
|
||||||
|
src/core/libraries/videoout/videoout_error.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LIBC_SOURCES src/core/libraries/libc_internal/libc_internal.cpp
|
set(LIBC_SOURCES src/core/libraries/libc_internal/libc_internal.cpp
|
||||||
@ -341,18 +354,28 @@ set(IME_LIB src/core/libraries/ime/error_dialog.cpp
|
|||||||
src/core/libraries/ime/ime_ui.h
|
src/core/libraries/ime/ime_ui.h
|
||||||
src/core/libraries/ime/ime.cpp
|
src/core/libraries/ime/ime.cpp
|
||||||
src/core/libraries/ime/ime.h
|
src/core/libraries/ime/ime.h
|
||||||
|
src/core/libraries/ime/ime_error.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PAD_LIB src/core/libraries/pad/pad.cpp
|
set(PAD_LIB src/core/libraries/pad/pad.cpp
|
||||||
src/core/libraries/pad/pad.h
|
src/core/libraries/pad/pad.h
|
||||||
|
src/core/libraries/pad/pad_errors.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PNG_LIB src/core/libraries/libpng/pngdec.cpp
|
set(PNG_LIB src/core/libraries/libpng/pngdec.cpp
|
||||||
src/core/libraries/libpng/pngdec.h
|
src/core/libraries/libpng/pngdec.h
|
||||||
|
src/core/libraries/libpng/pngdec_error.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(JPEG_LIB src/core/libraries/jpeg/jpeg_error.h
|
||||||
|
src/core/libraries/jpeg/jpegenc.cpp
|
||||||
|
src/core/libraries/jpeg/jpegenc.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PLAYGO_LIB src/core/libraries/playgo/playgo.cpp
|
set(PLAYGO_LIB src/core/libraries/playgo/playgo.cpp
|
||||||
src/core/libraries/playgo/playgo.h
|
src/core/libraries/playgo/playgo.h
|
||||||
|
src/core/libraries/playgo/playgo_dialog.cpp
|
||||||
|
src/core/libraries/playgo/playgo_dialog.h
|
||||||
src/core/libraries/playgo/playgo_types.h
|
src/core/libraries/playgo/playgo_types.h
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -367,6 +390,7 @@ set(USBD_LIB src/core/libraries/usbd/usbd.cpp
|
|||||||
|
|
||||||
set(FIBER_LIB src/core/libraries/fiber/fiber.cpp
|
set(FIBER_LIB src/core/libraries/fiber/fiber.cpp
|
||||||
src/core/libraries/fiber/fiber.h
|
src/core/libraries/fiber/fiber.h
|
||||||
|
src/core/libraries/fiber/fiber_error.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(VDEC_LIB src/core/libraries/videodec/videodec2_impl.cpp
|
set(VDEC_LIB src/core/libraries/videodec/videodec2_impl.cpp
|
||||||
@ -376,6 +400,7 @@ set(VDEC_LIB src/core/libraries/videodec/videodec2_impl.cpp
|
|||||||
src/core/libraries/videodec/videodec2_avc.h
|
src/core/libraries/videodec/videodec2_avc.h
|
||||||
src/core/libraries/videodec/videodec.cpp
|
src/core/libraries/videodec/videodec.cpp
|
||||||
src/core/libraries/videodec/videodec.h
|
src/core/libraries/videodec/videodec.h
|
||||||
|
src/core/libraries/videodec/videodec_error.h
|
||||||
src/core/libraries/videodec/videodec_impl.cpp
|
src/core/libraries/videodec/videodec_impl.cpp
|
||||||
src/core/libraries/videodec/videodec_impl.h
|
src/core/libraries/videodec/videodec_impl.h
|
||||||
)
|
)
|
||||||
@ -388,6 +413,7 @@ set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp
|
|||||||
src/core/libraries/np_trophy/np_trophy.h
|
src/core/libraries/np_trophy/np_trophy.h
|
||||||
src/core/libraries/np_trophy/trophy_ui.cpp
|
src/core/libraries/np_trophy/trophy_ui.cpp
|
||||||
src/core/libraries/np_trophy/trophy_ui.h
|
src/core/libraries/np_trophy/trophy_ui.h
|
||||||
|
src/core/libraries/np_trophy/np_trophy_error.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp
|
set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp
|
||||||
@ -409,10 +435,14 @@ set(DEV_TOOLS src/core/devtools/layer.cpp
|
|||||||
src/core/devtools/widget/frame_graph.cpp
|
src/core/devtools/widget/frame_graph.cpp
|
||||||
src/core/devtools/widget/frame_graph.h
|
src/core/devtools/widget/frame_graph.h
|
||||||
src/core/devtools/widget/imgui_memory_editor.h
|
src/core/devtools/widget/imgui_memory_editor.h
|
||||||
|
src/core/devtools/widget/memory_map.cpp
|
||||||
|
src/core/devtools/widget/memory_map.h
|
||||||
src/core/devtools/widget/reg_popup.cpp
|
src/core/devtools/widget/reg_popup.cpp
|
||||||
src/core/devtools/widget/reg_popup.h
|
src/core/devtools/widget/reg_popup.h
|
||||||
src/core/devtools/widget/reg_view.cpp
|
src/core/devtools/widget/reg_view.cpp
|
||||||
src/core/devtools/widget/reg_view.h
|
src/core/devtools/widget/reg_view.h
|
||||||
|
src/core/devtools/widget/shader_list.cpp
|
||||||
|
src/core/devtools/widget/shader_list.h
|
||||||
src/core/devtools/widget/text_editor.cpp
|
src/core/devtools/widget/text_editor.cpp
|
||||||
src/core/devtools/widget/text_editor.h
|
src/core/devtools/widget/text_editor.h
|
||||||
)
|
)
|
||||||
@ -526,10 +556,10 @@ set(CORE src/core/aerolib/stubs.cpp
|
|||||||
src/core/loader/elf.h
|
src/core/loader/elf.h
|
||||||
src/core/loader/symbols_resolver.h
|
src/core/loader/symbols_resolver.h
|
||||||
src/core/loader/symbols_resolver.cpp
|
src/core/loader/symbols_resolver.cpp
|
||||||
src/core/libraries/error_codes.h
|
|
||||||
src/core/libraries/libs.h
|
src/core/libraries/libs.h
|
||||||
src/core/libraries/libs.cpp
|
src/core/libraries/libs.cpp
|
||||||
${AJM_LIB}
|
${AJM_LIB}
|
||||||
|
${AVPLAYER_LIB}
|
||||||
${AUDIO_LIB}
|
${AUDIO_LIB}
|
||||||
${GNM_LIB}
|
${GNM_LIB}
|
||||||
${KERNEL_LIB}
|
${KERNEL_LIB}
|
||||||
@ -540,6 +570,7 @@ set(CORE src/core/aerolib/stubs.cpp
|
|||||||
${VIDEOOUT_LIB}
|
${VIDEOOUT_LIB}
|
||||||
${NP_LIBS}
|
${NP_LIBS}
|
||||||
${PNG_LIB}
|
${PNG_LIB}
|
||||||
|
${JPEG_LIB}
|
||||||
${PLAYGO_LIB}
|
${PLAYGO_LIB}
|
||||||
${RANDOM_LIB}
|
${RANDOM_LIB}
|
||||||
${USBD_LIB}
|
${USBD_LIB}
|
||||||
@ -563,8 +594,6 @@ set(CORE src/core/aerolib/stubs.cpp
|
|||||||
src/core/thread.h
|
src/core/thread.h
|
||||||
src/core/tls.cpp
|
src/core/tls.cpp
|
||||||
src/core/tls.h
|
src/core/tls.h
|
||||||
src/core/virtual_memory.cpp
|
|
||||||
src/core/virtual_memory.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ARCHITECTURE STREQUAL "x86_64")
|
if (ARCHITECTURE STREQUAL "x86_64")
|
||||||
@ -837,7 +866,7 @@ endif()
|
|||||||
|
|
||||||
create_target_directory_groups(shadps4)
|
create_target_directory_groups(shadps4)
|
||||||
|
|
||||||
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half zlib-ng::zlib png_static)
|
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half ZLIB::ZLIB PNG::PNG)
|
||||||
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3 pugixml::pugixml)
|
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3 pugixml::pugixml)
|
||||||
|
|
||||||
target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h")
|
target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h")
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_search_module(ZLIB_NG QUIET IMPORTED_TARGET zlib-ng)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(zlib-ng
|
|
||||||
REQUIRED_VARS ZLIB_NG_LINK_LIBRARIES
|
|
||||||
VERSION_VAR ZLIB_NG_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if (zlib-ng_FOUND AND NOT TARGET zlib-ng::zlib)
|
|
||||||
add_library(zlib-ng::zlib ALIAS PkgConfig::ZLIB_NG)
|
|
||||||
endif()
|
|
19
documents/patching-shader.md
Normal file
19
documents/patching-shader.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Install Vulkan SDK and \*ensure `spirv-cross` and `glslc` are in PATH\*.
|
||||||
|
|
||||||
|
1. Enable `dumpShaders` in config.toml
|
||||||
|
|
||||||
|
2. Run `spirv-cross -V fs_0x000000.spv --output fs_0x000000.glsl` to decompile the SPIR-V IR to GLSL.
|
||||||
|
|
||||||
|
3. Edit the GLSL file as you wish
|
||||||
|
|
||||||
|
4. To compile back to SPIR-V, run (change the _**-fshader-stage**_ to correct stage):
|
||||||
|
`glslc --target-env=vulkan1.3 --target-spv=spv1.6 -fshader-stage=frag fs_0x000000.glsl -o fs_0x000000.spv`
|
||||||
|
|
||||||
|
5. Put the updated .spv file to `shader/patch` folder with the same name as the original shader
|
||||||
|
|
||||||
|
6. Enable `patchShaders` in config.toml
|
36
externals/CMakeLists.txt
vendored
36
externals/CMakeLists.txt
vendored
@ -38,7 +38,8 @@ else()
|
|||||||
set(CRYPTOPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/)
|
set(CRYPTOPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/)
|
||||||
add_subdirectory(cryptopp-cmake)
|
add_subdirectory(cryptopp-cmake)
|
||||||
file(COPY cryptopp DESTINATION cryptopp FILES_MATCHING PATTERN "*.h")
|
file(COPY cryptopp DESTINATION cryptopp FILES_MATCHING PATTERN "*.h")
|
||||||
target_include_directories(cryptopp INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/cryptopp")
|
# remove externals/cryptopp from include directories because it contains a conflicting zlib.h file
|
||||||
|
set_target_properties(cryptopp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/cryptopp")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -52,16 +53,23 @@ file(GLOB LIBATRAC9_SOURCES LibAtrac9/C/src/*.c)
|
|||||||
add_library(LibAtrac9 STATIC ${LIBATRAC9_SOURCES})
|
add_library(LibAtrac9 STATIC ${LIBATRAC9_SOURCES})
|
||||||
target_include_directories(LibAtrac9 INTERFACE LibAtrac9/C/src)
|
target_include_directories(LibAtrac9 INTERFACE LibAtrac9/C/src)
|
||||||
|
|
||||||
# Zlib-Ng
|
# zlib
|
||||||
if (NOT TARGET zlib-ng::zlib)
|
if (NOT TARGET ZLIB::ZLIB)
|
||||||
set(ZLIB_ENABLE_TESTS OFF)
|
set(ZLIB_ENABLE_TESTS OFF)
|
||||||
set(WITH_GTEST OFF)
|
set(WITH_GTEST OFF)
|
||||||
set(WITH_NEW_STRATEGIES ON)
|
set(WITH_NEW_STRATEGIES ON)
|
||||||
set(WITH_NATIVE_INSTRUCTIONS ON)
|
set(WITH_NATIVE_INSTRUCTIONS ON)
|
||||||
set(ZLIB_COMPAT ON CACHE BOOL "" FORCE)
|
set(ZLIB_COMPAT ON CACHE BOOL "" FORCE)
|
||||||
add_subdirectory(zlib-ng)
|
include(FetchContent)
|
||||||
add_library(zlib-ng::zlib ALIAS zlib)
|
FetchContent_Declare(
|
||||||
|
ZLIB
|
||||||
|
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng"
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(ZLIB)
|
||||||
add_library(ZLIB::ZLIB ALIAS zlib)
|
add_library(ZLIB::ZLIB ALIAS zlib)
|
||||||
|
# libpng expects this variable to exist after its find_package(ZLIB)
|
||||||
|
set(ZLIB_INCLUDE_DIRS "${FETCHCONTENT_BASE_DIR}/zlib-build")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# SDL3
|
# SDL3
|
||||||
@ -156,15 +164,15 @@ if (NOT TARGET half::half)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libpng
|
# libpng
|
||||||
set(PNG_SHARED OFF CACHE BOOL "" FORCE)
|
if (NOT TARGET PNG::PNG)
|
||||||
set(PNG_STATIC ON CACHE BOOL "" FORCE)
|
set(PNG_SHARED OFF CACHE BOOL "" FORCE)
|
||||||
set(PNG_TESTS OFF CACHE BOOL "" FORCE)
|
set(PNG_STATIC ON CACHE BOOL "" FORCE)
|
||||||
set(PNG_TOOLS OFF CACHE BOOL "" FORCE)
|
set(PNG_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE)
|
set(PNG_TOOLS OFF CACHE BOOL "" FORCE)
|
||||||
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng" CACHE STRING "" FORCE)
|
set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE)
|
||||||
set(ZLIB_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/zlib-ng/zlibstatic-ngd" CACHE STRING "" FORCE)
|
add_subdirectory(libpng)
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libpng/zlib.h" "#include \"../zlib-ng/zlib.h\"")
|
add_library(PNG::PNG ALIAS png_static)
|
||||||
add_subdirectory(libpng)
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
# date
|
# date
|
||||||
|
2
externals/ffmpeg-core
vendored
2
externals/ffmpeg-core
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e30b7d7fe228bfb3f6e41ce1040b44a15eb7d5e0
|
Subproject commit 27de97c826b6b40c255891c37ac046a25836a575
|
@ -1,166 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include "sdl_audio.h"
|
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
|
|
||||||
#include <SDL3/SDL_audio.h>
|
|
||||||
#include <SDL3/SDL_init.h>
|
|
||||||
#include <SDL3/SDL_timer.h>
|
|
||||||
|
|
||||||
#include <mutex> // std::unique_lock
|
|
||||||
|
|
||||||
namespace Audio {
|
|
||||||
|
|
||||||
constexpr int AUDIO_STREAM_BUFFER_THRESHOLD = 65536; // Define constant for buffer threshold
|
|
||||||
|
|
||||||
s32 SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
|
|
||||||
Libraries::AudioOut::OrbisAudioOutParamFormat format) {
|
|
||||||
using Libraries::AudioOut::OrbisAudioOutParamFormat;
|
|
||||||
std::unique_lock lock{m_mutex};
|
|
||||||
for (int id = 0; id < portsOut.size(); id++) {
|
|
||||||
auto& port = portsOut[id];
|
|
||||||
if (!port.isOpen) {
|
|
||||||
port.isOpen = true;
|
|
||||||
port.type = type;
|
|
||||||
port.samples_num = samples_num;
|
|
||||||
port.freq = freq;
|
|
||||||
port.format = format;
|
|
||||||
SDL_AudioFormat sampleFormat;
|
|
||||||
switch (format) {
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
|
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
|
||||||
port.channels_num = 1;
|
|
||||||
port.sample_size = 2;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
|
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
|
||||||
port.channels_num = 1;
|
|
||||||
port.sample_size = 4;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
|
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
|
||||||
port.channels_num = 2;
|
|
||||||
port.sample_size = 2;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
|
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
|
||||||
port.channels_num = 2;
|
|
||||||
port.sample_size = 4;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
|
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
|
||||||
port.channels_num = 8;
|
|
||||||
port.sample_size = 2;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
|
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
|
||||||
port.channels_num = 8;
|
|
||||||
port.sample_size = 4;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
|
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
|
||||||
port.channels_num = 8;
|
|
||||||
port.sample_size = 2;
|
|
||||||
break;
|
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD:
|
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
|
||||||
port.channels_num = 8;
|
|
||||||
port.sample_size = 4;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UNREACHABLE_MSG("Unknown format");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < port.channels_num; i++) {
|
|
||||||
port.volume[i] = Libraries::AudioOut::SCE_AUDIO_OUT_VOLUME_0DB;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_AudioSpec fmt;
|
|
||||||
SDL_zero(fmt);
|
|
||||||
fmt.format = sampleFormat;
|
|
||||||
fmt.channels = port.channels_num;
|
|
||||||
fmt.freq = freq; // Set frequency from the argument
|
|
||||||
port.stream =
|
|
||||||
SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &fmt, NULL, NULL);
|
|
||||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port.stream));
|
|
||||||
return id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
|
|
||||||
return ORBIS_AUDIO_OUT_ERROR_PORT_FULL; // all ports are used
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
|
|
||||||
std::shared_lock lock{m_mutex};
|
|
||||||
auto& port = portsOut[handle - 1];
|
|
||||||
if (!port.isOpen) {
|
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t data_size = port.samples_num * port.sample_size * port.channels_num;
|
|
||||||
|
|
||||||
bool result = SDL_PutAudioStreamData(port.stream, ptr, data_size);
|
|
||||||
|
|
||||||
lock.unlock(); // Unlock only after necessary operations
|
|
||||||
|
|
||||||
while (SDL_GetAudioStreamAvailable(port.stream) > AUDIO_STREAM_BUFFER_THRESHOLD) {
|
|
||||||
SDL_Delay(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result ? ORBIS_OK : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
|
|
||||||
using Libraries::AudioOut::OrbisAudioOutParamFormat;
|
|
||||||
std::shared_lock lock{m_mutex};
|
|
||||||
auto& port = portsOut[handle - 1];
|
|
||||||
if (!port.isOpen) {
|
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < port.channels_num; i++, bitflag >>= 1u) {
|
|
||||||
auto bit = bitflag & 0x1u;
|
|
||||||
|
|
||||||
if (bit == 1) {
|
|
||||||
int src_index = i;
|
|
||||||
if (port.format ==
|
|
||||||
OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD ||
|
|
||||||
port.format == OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD) {
|
|
||||||
switch (i) {
|
|
||||||
case 4:
|
|
||||||
src_index = 6;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
src_index = 7;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
src_index = 4;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
src_index = 5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
port.volume[i] = volume[src_index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) {
|
|
||||||
std::shared_lock lock{m_mutex};
|
|
||||||
auto& port = portsOut[handle - 1];
|
|
||||||
*type = port.type;
|
|
||||||
*channels_num = port.channels_num;
|
|
||||||
|
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Audio
|
|
@ -1,39 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <shared_mutex>
|
|
||||||
#include <SDL3/SDL_audio.h>
|
|
||||||
#include "core/libraries/audio/audioout.h"
|
|
||||||
|
|
||||||
namespace Audio {
|
|
||||||
|
|
||||||
class SDLAudio {
|
|
||||||
public:
|
|
||||||
SDLAudio() = default;
|
|
||||||
virtual ~SDLAudio() = default;
|
|
||||||
|
|
||||||
s32 AudioOutOpen(int type, u32 samples_num, u32 freq,
|
|
||||||
Libraries::AudioOut::OrbisAudioOutParamFormat format);
|
|
||||||
s32 AudioOutOutput(s32 handle, const void* ptr);
|
|
||||||
s32 AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume);
|
|
||||||
s32 AudioOutGetStatus(s32 handle, int* type, int* channels_num);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct PortOut {
|
|
||||||
SDL_AudioStream* stream = nullptr;
|
|
||||||
u32 samples_num = 0;
|
|
||||||
u32 freq = 0;
|
|
||||||
u32 format = -1;
|
|
||||||
int type = 0;
|
|
||||||
int channels_num = 0;
|
|
||||||
int volume[8] = {};
|
|
||||||
u8 sample_size = 0;
|
|
||||||
bool isOpen = false;
|
|
||||||
};
|
|
||||||
std::shared_mutex m_mutex;
|
|
||||||
std::array<PortOut, Libraries::AudioOut::SCE_AUDIO_OUT_NUM_PORTS> portsOut;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Audio
|
|
@ -22,6 +22,12 @@ template <typename T>
|
|||||||
return static_cast<T>(value - value % size);
|
return static_cast<T>(value - value % size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
requires std::is_integral_v<T>
|
||||||
|
[[nodiscard]] constexpr bool IsAligned(T value, std::size_t alignment) {
|
||||||
|
return (value & (alignment - 1)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
requires std::is_integral_v<T>
|
requires std::is_integral_v<T>
|
||||||
[[nodiscard]] constexpr bool Is16KBAligned(T value) {
|
[[nodiscard]] constexpr bool Is16KBAligned(T value) {
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <common/version.h>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <fmt/xchar.h> // for wstring support
|
#include <fmt/xchar.h> // for wstring support
|
||||||
#include <toml.hpp>
|
#include <toml.hpp>
|
||||||
#include "common/logging/formatter.h"
|
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "logging/formatter.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
namespace toml {
|
namespace toml {
|
||||||
template <typename TC, typename K>
|
template <typename TC, typename K>
|
||||||
@ -46,11 +47,13 @@ static std::string backButtonBehavior = "left";
|
|||||||
static bool useSpecialPad = false;
|
static bool useSpecialPad = false;
|
||||||
static int specialPadClass = 1;
|
static int specialPadClass = 1;
|
||||||
static bool isDebugDump = false;
|
static bool isDebugDump = false;
|
||||||
|
static bool isShaderDebug = false;
|
||||||
static bool isShowSplash = false;
|
static bool isShowSplash = false;
|
||||||
static bool isAutoUpdate = false;
|
static bool isAutoUpdate = false;
|
||||||
static bool isNullGpu = false;
|
static bool isNullGpu = false;
|
||||||
static bool shouldCopyGPUBuffers = false;
|
static bool shouldCopyGPUBuffers = false;
|
||||||
static bool shouldDumpShaders = false;
|
static bool shouldDumpShaders = false;
|
||||||
|
static bool shouldPatchShaders = true;
|
||||||
static u32 vblankDivider = 1;
|
static u32 vblankDivider = 1;
|
||||||
static bool vkValidation = false;
|
static bool vkValidation = false;
|
||||||
static bool vkValidationSync = false;
|
static bool vkValidationSync = false;
|
||||||
@ -81,7 +84,8 @@ std::vector<std::string> m_pkg_viewer;
|
|||||||
std::vector<std::string> m_elf_viewer;
|
std::vector<std::string> m_elf_viewer;
|
||||||
std::vector<std::string> m_recent_files;
|
std::vector<std::string> m_recent_files;
|
||||||
std::string emulator_language = "en";
|
std::string emulator_language = "en";
|
||||||
// Settings
|
|
||||||
|
// Language
|
||||||
u32 m_language = 1; // english
|
u32 m_language = 1; // english
|
||||||
|
|
||||||
bool isNeoMode() {
|
bool isNeoMode() {
|
||||||
@ -156,6 +160,10 @@ bool debugDump() {
|
|||||||
return isDebugDump;
|
return isDebugDump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool collectShadersForDebug() {
|
||||||
|
return isShaderDebug;
|
||||||
|
}
|
||||||
|
|
||||||
bool showSplash() {
|
bool showSplash() {
|
||||||
return isShowSplash;
|
return isShowSplash;
|
||||||
}
|
}
|
||||||
@ -176,6 +184,10 @@ bool dumpShaders() {
|
|||||||
return shouldDumpShaders;
|
return shouldDumpShaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool patchShaders() {
|
||||||
|
return shouldPatchShaders;
|
||||||
|
}
|
||||||
|
|
||||||
bool isRdocEnabled() {
|
bool isRdocEnabled() {
|
||||||
return rdocEnable;
|
return rdocEnable;
|
||||||
}
|
}
|
||||||
@ -228,6 +240,10 @@ void setDebugDump(bool enable) {
|
|||||||
isDebugDump = enable;
|
isDebugDump = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCollectShaderForDebug(bool enable) {
|
||||||
|
isShaderDebug = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void setShowSplash(bool enable) {
|
void setShowSplash(bool enable) {
|
||||||
isShowSplash = enable;
|
isShowSplash = enable;
|
||||||
}
|
}
|
||||||
@ -334,6 +350,7 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
|
|||||||
main_window_geometry_w = w;
|
main_window_geometry_w = w;
|
||||||
main_window_geometry_h = h;
|
main_window_geometry_h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addGameInstallDir(const std::filesystem::path& dir) {
|
bool addGameInstallDir(const std::filesystem::path& dir) {
|
||||||
if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
|
if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
|
||||||
settings_install_dirs.end()) {
|
settings_install_dirs.end()) {
|
||||||
@ -342,47 +359,60 @@ bool addGameInstallDir(const std::filesystem::path& dir) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeGameInstallDir(const std::filesystem::path& dir) {
|
void removeGameInstallDir(const std::filesystem::path& dir) {
|
||||||
auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir);
|
auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir);
|
||||||
if (iterator != settings_install_dirs.end()) {
|
if (iterator != settings_install_dirs.end()) {
|
||||||
settings_install_dirs.erase(iterator);
|
settings_install_dirs.erase(iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAddonInstallDir(const std::filesystem::path& dir) {
|
void setAddonInstallDir(const std::filesystem::path& dir) {
|
||||||
settings_addon_install_dir = dir;
|
settings_addon_install_dir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowTheme(u32 theme) {
|
void setMainWindowTheme(u32 theme) {
|
||||||
mw_themes = theme;
|
mw_themes = theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIconSize(u32 size) {
|
void setIconSize(u32 size) {
|
||||||
m_icon_size = size;
|
m_icon_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIconSizeGrid(u32 size) {
|
void setIconSizeGrid(u32 size) {
|
||||||
m_icon_size_grid = size;
|
m_icon_size_grid = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSliderPosition(u32 pos) {
|
void setSliderPosition(u32 pos) {
|
||||||
m_slider_pos = pos;
|
m_slider_pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSliderPositionGrid(u32 pos) {
|
void setSliderPositionGrid(u32 pos) {
|
||||||
m_slider_pos_grid = pos;
|
m_slider_pos_grid = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTableMode(u32 mode) {
|
void setTableMode(u32 mode) {
|
||||||
m_table_mode = mode;
|
m_table_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowWidth(u32 width) {
|
void setMainWindowWidth(u32 width) {
|
||||||
m_window_size_W = width;
|
m_window_size_W = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowHeight(u32 height) {
|
void setMainWindowHeight(u32 height) {
|
||||||
m_window_size_H = height;
|
m_window_size_H = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPkgViewer(const std::vector<std::string>& pkgList) {
|
void setPkgViewer(const std::vector<std::string>& pkgList) {
|
||||||
m_pkg_viewer.resize(pkgList.size());
|
m_pkg_viewer.resize(pkgList.size());
|
||||||
m_pkg_viewer = pkgList;
|
m_pkg_viewer = pkgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setElfViewer(const std::vector<std::string>& elfList) {
|
void setElfViewer(const std::vector<std::string>& elfList) {
|
||||||
m_elf_viewer.resize(elfList.size());
|
m_elf_viewer.resize(elfList.size());
|
||||||
m_elf_viewer = elfList;
|
m_elf_viewer = elfList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRecentFiles(const std::vector<std::string>& recentFiles) {
|
void setRecentFiles(const std::vector<std::string>& recentFiles) {
|
||||||
m_recent_files.resize(recentFiles.size());
|
m_recent_files.resize(recentFiles.size());
|
||||||
m_recent_files = recentFiles;
|
m_recent_files = recentFiles;
|
||||||
@ -395,18 +425,23 @@ void setEmulatorLanguage(std::string language) {
|
|||||||
u32 getMainWindowGeometryX() {
|
u32 getMainWindowGeometryX() {
|
||||||
return main_window_geometry_x;
|
return main_window_geometry_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryY() {
|
u32 getMainWindowGeometryY() {
|
||||||
return main_window_geometry_y;
|
return main_window_geometry_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryW() {
|
u32 getMainWindowGeometryW() {
|
||||||
return main_window_geometry_w;
|
return main_window_geometry_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryH() {
|
u32 getMainWindowGeometryH() {
|
||||||
return main_window_geometry_h;
|
return main_window_geometry_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::filesystem::path>& getGameInstallDirs() {
|
const std::vector<std::filesystem::path>& getGameInstallDirs() {
|
||||||
return settings_install_dirs;
|
return settings_install_dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path getAddonInstallDir() {
|
std::filesystem::path getAddonInstallDir() {
|
||||||
if (settings_addon_install_dir.empty()) {
|
if (settings_addon_install_dir.empty()) {
|
||||||
// Default for users without a config file or a config file from before this option existed
|
// Default for users without a config file or a config file from before this option existed
|
||||||
@ -414,36 +449,47 @@ std::filesystem::path getAddonInstallDir() {
|
|||||||
}
|
}
|
||||||
return settings_addon_install_dir;
|
return settings_addon_install_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowTheme() {
|
u32 getMainWindowTheme() {
|
||||||
return mw_themes;
|
return mw_themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getIconSize() {
|
u32 getIconSize() {
|
||||||
return m_icon_size;
|
return m_icon_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getIconSizeGrid() {
|
u32 getIconSizeGrid() {
|
||||||
return m_icon_size_grid;
|
return m_icon_size_grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getSliderPosition() {
|
u32 getSliderPosition() {
|
||||||
return m_slider_pos;
|
return m_slider_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getSliderPositionGrid() {
|
u32 getSliderPositionGrid() {
|
||||||
return m_slider_pos_grid;
|
return m_slider_pos_grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getTableMode() {
|
u32 getTableMode() {
|
||||||
return m_table_mode;
|
return m_table_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowWidth() {
|
u32 getMainWindowWidth() {
|
||||||
return m_window_size_W;
|
return m_window_size_W;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowHeight() {
|
u32 getMainWindowHeight() {
|
||||||
return m_window_size_H;
|
return m_window_size_H;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getPkgViewer() {
|
std::vector<std::string> getPkgViewer() {
|
||||||
return m_pkg_viewer;
|
return m_pkg_viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getElfViewer() {
|
std::vector<std::string> getElfViewer() {
|
||||||
return m_elf_viewer;
|
return m_elf_viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getRecentFiles() {
|
std::vector<std::string> getRecentFiles() {
|
||||||
return m_recent_files;
|
return m_recent_files;
|
||||||
}
|
}
|
||||||
@ -455,6 +501,7 @@ std::string getEmulatorLanguage() {
|
|||||||
u32 GetLanguage() {
|
u32 GetLanguage() {
|
||||||
return m_language;
|
return m_language;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(const std::filesystem::path& path) {
|
void load(const std::filesystem::path& path) {
|
||||||
// If the configuration file does not exist, create it and return
|
// If the configuration file does not exist, create it and return
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
@ -513,6 +560,7 @@ void load(const std::filesystem::path& path) {
|
|||||||
isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
|
isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
|
||||||
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
|
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
|
||||||
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
|
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
|
||||||
|
shouldPatchShaders = toml::find_or<bool>(gpu, "patchShaders", true);
|
||||||
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
|
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,6 +580,7 @@ void load(const std::filesystem::path& path) {
|
|||||||
const toml::value& debug = data.at("Debug");
|
const toml::value& debug = data.at("Debug");
|
||||||
|
|
||||||
isDebugDump = toml::find_or<bool>(debug, "DebugDump", false);
|
isDebugDump = toml::find_or<bool>(debug, "DebugDump", false);
|
||||||
|
isShaderDebug = toml::find_or<bool>(debug, "CollectShader", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("GUI")) {
|
if (data.contains("GUI")) {
|
||||||
@ -545,16 +594,10 @@ void load(const std::filesystem::path& path) {
|
|||||||
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
|
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
|
||||||
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
|
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
|
||||||
|
|
||||||
// TODO Migration code, after a major release this should be removed.
|
const auto install_dir_array =
|
||||||
auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {});
|
toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
|
||||||
if (!old_game_install_dir.empty()) {
|
for (const auto& dir : install_dir_array) {
|
||||||
addGameInstallDir(std::filesystem::path{old_game_install_dir});
|
addGameInstallDir(std::filesystem::path{dir});
|
||||||
} else {
|
|
||||||
const auto install_dir_array =
|
|
||||||
toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
|
|
||||||
for (const auto& dir : install_dir_array) {
|
|
||||||
addGameInstallDir(std::filesystem::path{dir});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
|
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
|
||||||
@ -575,6 +618,7 @@ void load(const std::filesystem::path& path) {
|
|||||||
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
|
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(const std::filesystem::path& path) {
|
void save(const std::filesystem::path& path) {
|
||||||
toml::value data;
|
toml::value data;
|
||||||
|
|
||||||
@ -618,6 +662,7 @@ void save(const std::filesystem::path& path) {
|
|||||||
data["GPU"]["nullGpu"] = isNullGpu;
|
data["GPU"]["nullGpu"] = isNullGpu;
|
||||||
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
|
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
|
||||||
data["GPU"]["dumpShaders"] = shouldDumpShaders;
|
data["GPU"]["dumpShaders"] = shouldDumpShaders;
|
||||||
|
data["GPU"]["patchShaders"] = shouldPatchShaders;
|
||||||
data["GPU"]["vblankDivider"] = vblankDivider;
|
data["GPU"]["vblankDivider"] = vblankDivider;
|
||||||
data["Vulkan"]["gpuId"] = gpuId;
|
data["Vulkan"]["gpuId"] = gpuId;
|
||||||
data["Vulkan"]["validation"] = vkValidation;
|
data["Vulkan"]["validation"] = vkValidation;
|
||||||
@ -627,6 +672,7 @@ void save(const std::filesystem::path& path) {
|
|||||||
data["Vulkan"]["rdocMarkersEnable"] = vkMarkers;
|
data["Vulkan"]["rdocMarkersEnable"] = vkMarkers;
|
||||||
data["Vulkan"]["crashDiagnostic"] = vkCrashDiagnostic;
|
data["Vulkan"]["crashDiagnostic"] = vkCrashDiagnostic;
|
||||||
data["Debug"]["DebugDump"] = isDebugDump;
|
data["Debug"]["DebugDump"] = isDebugDump;
|
||||||
|
data["Debug"]["CollectShader"] = isShaderDebug;
|
||||||
data["GUI"]["theme"] = mw_themes;
|
data["GUI"]["theme"] = mw_themes;
|
||||||
data["GUI"]["iconSize"] = m_icon_size;
|
data["GUI"]["iconSize"] = m_icon_size;
|
||||||
data["GUI"]["sliderPos"] = m_slider_pos;
|
data["GUI"]["sliderPos"] = m_slider_pos;
|
||||||
@ -655,9 +701,6 @@ void save(const std::filesystem::path& path) {
|
|||||||
|
|
||||||
data["Settings"]["consoleLanguage"] = m_language;
|
data["Settings"]["consoleLanguage"] = m_language;
|
||||||
|
|
||||||
// TODO Migration code, after a major release this should be removed.
|
|
||||||
data.at("GUI").as_table().erase("installDir");
|
|
||||||
|
|
||||||
std::ofstream file(path, std::ios::binary);
|
std::ofstream file(path, std::ios::binary);
|
||||||
file << data;
|
file << data;
|
||||||
file.close();
|
file.close();
|
||||||
@ -685,6 +728,7 @@ void setDefaultValues() {
|
|||||||
useSpecialPad = false;
|
useSpecialPad = false;
|
||||||
specialPadClass = 1;
|
specialPadClass = 1;
|
||||||
isDebugDump = false;
|
isDebugDump = false;
|
||||||
|
isShaderDebug = false;
|
||||||
isShowSplash = false;
|
isShowSplash = false;
|
||||||
isAutoUpdate = false;
|
isAutoUpdate = false;
|
||||||
isNullGpu = false;
|
isNullGpu = false;
|
||||||
|
@ -37,15 +37,18 @@ u32 getScreenHeight();
|
|||||||
s32 getGpuId();
|
s32 getGpuId();
|
||||||
|
|
||||||
bool debugDump();
|
bool debugDump();
|
||||||
|
bool collectShadersForDebug();
|
||||||
bool showSplash();
|
bool showSplash();
|
||||||
bool autoUpdate();
|
bool autoUpdate();
|
||||||
bool nullGpu();
|
bool nullGpu();
|
||||||
bool copyGPUCmdBuffers();
|
bool copyGPUCmdBuffers();
|
||||||
bool dumpShaders();
|
bool dumpShaders();
|
||||||
|
bool patchShaders();
|
||||||
bool isRdocEnabled();
|
bool isRdocEnabled();
|
||||||
u32 vblankDiv();
|
u32 vblankDiv();
|
||||||
|
|
||||||
void setDebugDump(bool enable);
|
void setDebugDump(bool enable);
|
||||||
|
void setCollectShaderForDebug(bool enable);
|
||||||
void setShowSplash(bool enable);
|
void setShowSplash(bool enable);
|
||||||
void setAutoUpdate(bool enable);
|
void setAutoUpdate(bool enable);
|
||||||
void setNullGpu(bool enable);
|
void setNullGpu(bool enable);
|
||||||
|
@ -106,7 +106,9 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
|||||||
SUB(Lib, Rtc) \
|
SUB(Lib, Rtc) \
|
||||||
SUB(Lib, DiscMap) \
|
SUB(Lib, DiscMap) \
|
||||||
SUB(Lib, Png) \
|
SUB(Lib, Png) \
|
||||||
|
SUB(Lib, Jpeg) \
|
||||||
SUB(Lib, PlayGo) \
|
SUB(Lib, PlayGo) \
|
||||||
|
SUB(Lib, PlayGoDialog) \
|
||||||
SUB(Lib, Random) \
|
SUB(Lib, Random) \
|
||||||
SUB(Lib, Usbd) \
|
SUB(Lib, Usbd) \
|
||||||
SUB(Lib, Ajm) \
|
SUB(Lib, Ajm) \
|
||||||
@ -122,6 +124,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
|||||||
SUB(Lib, Fiber) \
|
SUB(Lib, Fiber) \
|
||||||
SUB(Lib, Vdec2) \
|
SUB(Lib, Vdec2) \
|
||||||
SUB(Lib, Videodec) \
|
SUB(Lib, Videodec) \
|
||||||
|
SUB(Lib, RazorCpu) \
|
||||||
CLS(Frontend) \
|
CLS(Frontend) \
|
||||||
CLS(Render) \
|
CLS(Render) \
|
||||||
SUB(Render, Vulkan) \
|
SUB(Render, Vulkan) \
|
||||||
|
@ -73,7 +73,9 @@ enum class Class : u8 {
|
|||||||
Lib_Rtc, ///< The LibSceRtc implementation.
|
Lib_Rtc, ///< The LibSceRtc implementation.
|
||||||
Lib_DiscMap, ///< The LibSceDiscMap implementation.
|
Lib_DiscMap, ///< The LibSceDiscMap implementation.
|
||||||
Lib_Png, ///< The LibScePng implementation.
|
Lib_Png, ///< The LibScePng implementation.
|
||||||
|
Lib_Jpeg, ///< The LibSceJpeg implementation.
|
||||||
Lib_PlayGo, ///< The LibScePlayGo implementation.
|
Lib_PlayGo, ///< The LibScePlayGo implementation.
|
||||||
|
Lib_PlayGoDialog, ///< The LibScePlayGoDialog implementation.
|
||||||
Lib_Random, ///< The libSceRandom implementation.
|
Lib_Random, ///< The libSceRandom implementation.
|
||||||
Lib_Usbd, ///< The LibSceUsbd implementation.
|
Lib_Usbd, ///< The LibSceUsbd implementation.
|
||||||
Lib_Ajm, ///< The LibSceAjm implementation.
|
Lib_Ajm, ///< The LibSceAjm implementation.
|
||||||
@ -89,6 +91,7 @@ enum class Class : u8 {
|
|||||||
Lib_Fiber, ///< The LibSceFiber implementation.
|
Lib_Fiber, ///< The LibSceFiber implementation.
|
||||||
Lib_Vdec2, ///< The LibSceVideodec2 implementation.
|
Lib_Vdec2, ///< The LibSceVideodec2 implementation.
|
||||||
Lib_Videodec, ///< The LibSceVideodec implementation.
|
Lib_Videodec, ///< The LibSceVideodec implementation.
|
||||||
|
Lib_RazorCpu, ///< The LibRazorCpu implementation.
|
||||||
Frontend, ///< Emulator UI
|
Frontend, ///< Emulator UI
|
||||||
Render, ///< Video Core
|
Render, ///< Video Core
|
||||||
Render_Vulkan, ///< Vulkan backend
|
Render_Vulkan, ///< Vulkan backend
|
||||||
|
@ -28,7 +28,7 @@ std::string g_game_serial;
|
|||||||
std::string patchFile;
|
std::string patchFile;
|
||||||
std::vector<patchInfo> pending_patches;
|
std::vector<patchInfo> pending_patches;
|
||||||
|
|
||||||
std::string toHex(unsigned long long value, size_t byteSize) {
|
std::string toHex(u64 value, size_t byteSize) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::hex << std::setfill('0') << std::setw(byteSize * 2) << value;
|
ss << std::hex << std::setfill('0') << std::setw(byteSize * 2) << value;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
@ -38,16 +38,16 @@ std::string convertValueToHex(const std::string type, const std::string valueStr
|
|||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
if (type == "byte") {
|
if (type == "byte") {
|
||||||
unsigned int value = std::stoul(valueStr, nullptr, 16);
|
const u32 value = std::stoul(valueStr, nullptr, 16);
|
||||||
result = toHex(value, 1);
|
result = toHex(value, 1);
|
||||||
} else if (type == "bytes16") {
|
} else if (type == "bytes16") {
|
||||||
unsigned int value = std::stoul(valueStr, nullptr, 16);
|
const u32 value = std::stoul(valueStr, nullptr, 16);
|
||||||
result = toHex(value, 2);
|
result = toHex(value, 2);
|
||||||
} else if (type == "bytes32") {
|
} else if (type == "bytes32") {
|
||||||
unsigned long value = std::stoul(valueStr, nullptr, 16);
|
const u32 value = std::stoul(valueStr, nullptr, 16);
|
||||||
result = toHex(value, 4);
|
result = toHex(value, 4);
|
||||||
} else if (type == "bytes64") {
|
} else if (type == "bytes64") {
|
||||||
unsigned long long value = std::stoull(valueStr, nullptr, 16);
|
const u64 value = std::stoull(valueStr, nullptr, 16);
|
||||||
result = toHex(value, 8);
|
result = toHex(value, 8);
|
||||||
} else if (type == "float32") {
|
} else if (type == "float32") {
|
||||||
union {
|
union {
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
/// Initializes a stack for the current thread for use by patch implementations.
|
/// Initializes a stack for the current thread for use by patch implementations.
|
||||||
|
@ -157,7 +157,7 @@ void DebugStateImpl::PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
|
|||||||
if (is_compute) {
|
if (is_compute) {
|
||||||
dump.is_compute = true;
|
dump.is_compute = true;
|
||||||
const auto& cs = dump.regs.cs_program;
|
const auto& cs = dump.regs.cs_program;
|
||||||
dump.cs_data = ComputerShaderDump{
|
dump.cs_data = PipelineComputerProgramDump{
|
||||||
.cs_program = cs,
|
.cs_program = cs,
|
||||||
.code = std::vector<u32>{cs.Code().begin(), cs.Code().end()},
|
.code = std::vector<u32>{cs.Code().begin(), cs.Code().end()},
|
||||||
};
|
};
|
||||||
@ -167,7 +167,7 @@ void DebugStateImpl::PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
|
|||||||
auto stage = regs.ProgramForStage(i);
|
auto stage = regs.ProgramForStage(i);
|
||||||
if (stage->address_lo != 0) {
|
if (stage->address_lo != 0) {
|
||||||
auto code = stage->Code();
|
auto code = stage->Code();
|
||||||
dump.stages[i] = ShaderDump{
|
dump.stages[i] = PipelineShaderProgramDump{
|
||||||
.user_data = *stage,
|
.user_data = *stage,
|
||||||
.code = std::vector<u32>{code.begin(), code.end()},
|
.code = std::vector<u32>{code.begin(), code.end()},
|
||||||
};
|
};
|
||||||
@ -176,3 +176,10 @@ void DebugStateImpl::PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugStateImpl::CollectShader(const std::string& name, std::span<const u32> spv,
|
||||||
|
std::span<const u32> raw_code) {
|
||||||
|
shader_dump_list.emplace_back(name, std::vector<u32>{spv.begin(), spv.end()},
|
||||||
|
std::vector<u32>{raw_code.begin(), raw_code.end()});
|
||||||
|
std::ranges::sort(shader_dump_list, {}, &ShaderDump::name);
|
||||||
|
}
|
||||||
|
@ -30,7 +30,8 @@ namespace Core::Devtools {
|
|||||||
class Layer;
|
class Layer;
|
||||||
namespace Widget {
|
namespace Widget {
|
||||||
class FrameGraph;
|
class FrameGraph;
|
||||||
}
|
class ShaderList;
|
||||||
|
} // namespace Widget
|
||||||
} // namespace Core::Devtools
|
} // namespace Core::Devtools
|
||||||
|
|
||||||
namespace DebugStateType {
|
namespace DebugStateType {
|
||||||
@ -49,12 +50,12 @@ struct QueueDump {
|
|||||||
uintptr_t base_addr;
|
uintptr_t base_addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShaderDump {
|
struct PipelineShaderProgramDump {
|
||||||
Vulkan::Liverpool::ShaderProgram user_data{};
|
Vulkan::Liverpool::ShaderProgram user_data{};
|
||||||
std::vector<u32> code{};
|
std::vector<u32> code{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ComputerShaderDump {
|
struct PipelineComputerProgramDump {
|
||||||
Vulkan::Liverpool::ComputeProgram cs_program{};
|
Vulkan::Liverpool::ComputeProgram cs_program{};
|
||||||
std::vector<u32> code{};
|
std::vector<u32> code{};
|
||||||
};
|
};
|
||||||
@ -63,8 +64,8 @@ struct RegDump {
|
|||||||
bool is_compute{false};
|
bool is_compute{false};
|
||||||
static constexpr size_t MaxShaderStages = 5;
|
static constexpr size_t MaxShaderStages = 5;
|
||||||
Vulkan::Liverpool::Regs regs{};
|
Vulkan::Liverpool::Regs regs{};
|
||||||
std::array<ShaderDump, MaxShaderStages> stages{};
|
std::array<PipelineShaderProgramDump, MaxShaderStages> stages{};
|
||||||
ComputerShaderDump cs_data{};
|
PipelineComputerProgramDump cs_data{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FrameDump {
|
struct FrameDump {
|
||||||
@ -73,9 +74,41 @@ struct FrameDump {
|
|||||||
std::unordered_map<uintptr_t, RegDump> regs; // address -> reg dump
|
std::unordered_map<uintptr_t, RegDump> regs; // address -> reg dump
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ShaderDump {
|
||||||
|
std::string name;
|
||||||
|
std::vector<u32> spv;
|
||||||
|
std::vector<u32> raw_code;
|
||||||
|
|
||||||
|
std::string cache_spv_disasm{};
|
||||||
|
std::string cache_raw_disasm{};
|
||||||
|
|
||||||
|
ShaderDump(std::string name, std::vector<u32> spv, std::vector<u32> raw_code)
|
||||||
|
: name(std::move(name)), spv(std::move(spv)), raw_code(std::move(raw_code)) {}
|
||||||
|
|
||||||
|
ShaderDump(const ShaderDump& other) = delete;
|
||||||
|
ShaderDump(ShaderDump&& other) noexcept
|
||||||
|
: name{std::move(other.name)}, spv{std::move(other.spv)},
|
||||||
|
raw_code{std::move(other.raw_code)}, cache_spv_disasm{std::move(other.cache_spv_disasm)},
|
||||||
|
cache_raw_disasm{std::move(other.cache_raw_disasm)} {}
|
||||||
|
ShaderDump& operator=(const ShaderDump& other) = delete;
|
||||||
|
ShaderDump& operator=(ShaderDump&& other) noexcept {
|
||||||
|
if (this == &other)
|
||||||
|
return *this;
|
||||||
|
name = std::move(other.name);
|
||||||
|
spv = std::move(other.spv);
|
||||||
|
raw_code = std::move(other.raw_code);
|
||||||
|
cache_spv_disasm = std::move(other.cache_spv_disasm);
|
||||||
|
cache_raw_disasm = std::move(other.cache_raw_disasm);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class DebugStateImpl {
|
class DebugStateImpl {
|
||||||
friend class Core::Devtools::Layer;
|
friend class Core::Devtools::Layer;
|
||||||
friend class Core::Devtools::Widget::FrameGraph;
|
friend class Core::Devtools::Widget::FrameGraph;
|
||||||
|
friend class Core::Devtools::Widget::ShaderList;
|
||||||
|
|
||||||
|
std::queue<std::string> debug_message_popup;
|
||||||
|
|
||||||
std::mutex guest_threads_mutex{};
|
std::mutex guest_threads_mutex{};
|
||||||
std::vector<ThreadID> guest_threads{};
|
std::vector<ThreadID> guest_threads{};
|
||||||
@ -94,7 +127,7 @@ class DebugStateImpl {
|
|||||||
std::shared_mutex frame_dump_list_mutex;
|
std::shared_mutex frame_dump_list_mutex;
|
||||||
std::vector<FrameDump> frame_dump_list{};
|
std::vector<FrameDump> frame_dump_list{};
|
||||||
|
|
||||||
std::queue<std::string> debug_message_popup;
|
std::vector<ShaderDump> shader_dump_list{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void ShowDebugMessage(std::string message) {
|
void ShowDebugMessage(std::string message) {
|
||||||
@ -152,6 +185,9 @@ public:
|
|||||||
|
|
||||||
void PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
|
void PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
|
||||||
const AmdGpu::Liverpool::Regs& regs, bool is_compute = false);
|
const AmdGpu::Liverpool::Regs& regs, bool is_compute = false);
|
||||||
|
|
||||||
|
void CollectShader(const std::string& name, std::span<const u32> spv,
|
||||||
|
std::span<const u32> raw_code);
|
||||||
};
|
};
|
||||||
} // namespace DebugStateType
|
} // namespace DebugStateType
|
||||||
|
|
||||||
|
@ -289,6 +289,16 @@ const char* GetContextRegName(u32 reg_offset) {
|
|||||||
return "mmSPI_PS_INPUT_CNTL_2";
|
return "mmSPI_PS_INPUT_CNTL_2";
|
||||||
case mmSPI_PS_INPUT_CNTL_3:
|
case mmSPI_PS_INPUT_CNTL_3:
|
||||||
return "mmSPI_PS_INPUT_CNTL_3";
|
return "mmSPI_PS_INPUT_CNTL_3";
|
||||||
|
case mmPA_SU_POLY_OFFSET_FRONT_SCALE:
|
||||||
|
return "mmPA_SU_POLY_OFFSET_FRONT_SCALE";
|
||||||
|
case mmPA_SU_POLY_OFFSET_FRONT_OFFSET:
|
||||||
|
return "mmPA_SU_POLY_OFFSET_FRONT_OFFSET";
|
||||||
|
case mmPA_SU_POLY_OFFSET_BACK_SCALE:
|
||||||
|
return "mmPA_SU_POLY_OFFSET_BACK_SCALE";
|
||||||
|
case mmPA_SU_POLY_OFFSET_BACK_OFFSET:
|
||||||
|
return "mmPA_SU_POLY_OFFSET_BACK_OFFSET";
|
||||||
|
case mmPA_SU_POLY_OFFSET_CLAMP:
|
||||||
|
return "mmPA_SU_POLY_OFFSET_CLAMP";
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "layer.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
@ -9,11 +11,12 @@
|
|||||||
#include "core/debug_state.h"
|
#include "core/debug_state.h"
|
||||||
#include "imgui/imgui_std.h"
|
#include "imgui/imgui_std.h"
|
||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
#include "layer.h"
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "video_core/renderer_vulkan/vk_presenter.h"
|
#include "video_core/renderer_vulkan/vk_presenter.h"
|
||||||
#include "widget/frame_dump.h"
|
#include "widget/frame_dump.h"
|
||||||
#include "widget/frame_graph.h"
|
#include "widget/frame_graph.h"
|
||||||
|
#include "widget/memory_map.h"
|
||||||
|
#include "widget/shader_list.h"
|
||||||
|
|
||||||
extern std::unique_ptr<Vulkan::Presenter> presenter;
|
extern std::unique_ptr<Vulkan::Presenter> presenter;
|
||||||
|
|
||||||
@ -35,6 +38,9 @@ static float debug_popup_timing = 3.0f;
|
|||||||
|
|
||||||
static bool just_opened_options = false;
|
static bool just_opened_options = false;
|
||||||
|
|
||||||
|
static Widget::MemoryMapViewer memory_map;
|
||||||
|
static Widget::ShaderList shader_list;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static std::string help_text =
|
static std::string help_text =
|
||||||
#include "help.txt"
|
#include "help.txt"
|
||||||
@ -63,6 +69,7 @@ void L::DrawMenuBar() {
|
|||||||
}
|
}
|
||||||
if (BeginMenu("GPU Tools")) {
|
if (BeginMenu("GPU Tools")) {
|
||||||
MenuItem("Show frame info", nullptr, &frame_graph.is_open);
|
MenuItem("Show frame info", nullptr, &frame_graph.is_open);
|
||||||
|
MenuItem("Show loaded shaders", nullptr, &shader_list.open);
|
||||||
if (BeginMenu("Dump frames")) {
|
if (BeginMenu("Dump frames")) {
|
||||||
SliderInt("Count", &dump_frame_count, 1, 5);
|
SliderInt("Count", &dump_frame_count, 1, 5);
|
||||||
if (MenuItem("Dump", "Ctrl+Alt+F9", nullptr, !DebugState.DumpingCurrentFrame())) {
|
if (MenuItem("Dump", "Ctrl+Alt+F9", nullptr, !DebugState.DumpingCurrentFrame())) {
|
||||||
@ -81,6 +88,12 @@ void L::DrawMenuBar() {
|
|||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
if (BeginMenu("Debug")) {
|
||||||
|
if (MenuItem("Memory map")) {
|
||||||
|
memory_map.open = true;
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
EndMainMenuBar();
|
EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,19 +188,29 @@ void L::DrawAdvanced() {
|
|||||||
bool close_popup_options = true;
|
bool close_popup_options = true;
|
||||||
if (BeginPopupModal("GPU Tools Options", &close_popup_options,
|
if (BeginPopupModal("GPU Tools Options", &close_popup_options,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings)) {
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings)) {
|
||||||
static char disassembly_cli[512];
|
static char disassembler_cli_isa[512];
|
||||||
|
static char disassembler_cli_spv[512];
|
||||||
static bool frame_dump_render_on_collapse;
|
static bool frame_dump_render_on_collapse;
|
||||||
|
|
||||||
if (just_opened_options) {
|
if (just_opened_options) {
|
||||||
just_opened_options = false;
|
just_opened_options = false;
|
||||||
auto s = Options.disassembly_cli.copy(disassembly_cli, sizeof(disassembly_cli) - 1);
|
auto s = Options.disassembler_cli_isa.copy(disassembler_cli_isa,
|
||||||
disassembly_cli[s] = '\0';
|
sizeof(disassembler_cli_isa) - 1);
|
||||||
|
disassembler_cli_isa[s] = '\0';
|
||||||
|
s = Options.disassembler_cli_spv.copy(disassembler_cli_spv,
|
||||||
|
sizeof(disassembler_cli_spv) - 1);
|
||||||
|
disassembler_cli_spv[s] = '\0';
|
||||||
frame_dump_render_on_collapse = Options.frame_dump_render_on_collapse;
|
frame_dump_render_on_collapse = Options.frame_dump_render_on_collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputText("Shader disassembler: ", disassembly_cli, sizeof(disassembly_cli));
|
InputText("Shader isa disassembler: ", disassembler_cli_isa, sizeof(disassembler_cli_isa));
|
||||||
if (IsItemHovered()) {
|
if (IsItemHovered()) {
|
||||||
SetTooltip(R"(Command to disassemble shaders. Example "dis.exe" --raw "{src}")");
|
SetTooltip(R"(Command to disassemble shaders. Example: dis.exe --raw "{src}")");
|
||||||
|
}
|
||||||
|
InputText("Shader SPIRV disassembler: ", disassembler_cli_spv,
|
||||||
|
sizeof(disassembler_cli_spv));
|
||||||
|
if (IsItemHovered()) {
|
||||||
|
SetTooltip(R"(Command to disassemble shaders. Example: spirv-cross -V "{src}")");
|
||||||
}
|
}
|
||||||
Checkbox("Show frame dump popups even when collapsed", &frame_dump_render_on_collapse);
|
Checkbox("Show frame dump popups even when collapsed", &frame_dump_render_on_collapse);
|
||||||
if (IsItemHovered()) {
|
if (IsItemHovered()) {
|
||||||
@ -196,7 +219,8 @@ void L::DrawAdvanced() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Button("Save")) {
|
if (Button("Save")) {
|
||||||
Options.disassembly_cli = disassembly_cli;
|
Options.disassembler_cli_isa = disassembler_cli_isa;
|
||||||
|
Options.disassembler_cli_spv = disassembler_cli_spv;
|
||||||
Options.frame_dump_render_on_collapse = frame_dump_render_on_collapse;
|
Options.frame_dump_render_on_collapse = frame_dump_render_on_collapse;
|
||||||
SaveIniSettingsToDisk(io.IniFilename);
|
SaveIniSettingsToDisk(io.IniFilename);
|
||||||
CloseCurrentPopup();
|
CloseCurrentPopup();
|
||||||
@ -219,6 +243,13 @@ void L::DrawAdvanced() {
|
|||||||
|
|
||||||
EndPopup();
|
EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memory_map.open) {
|
||||||
|
memory_map.Draw();
|
||||||
|
}
|
||||||
|
if (shader_list.open) {
|
||||||
|
shader_list.Draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void L::DrawSimple() {
|
void L::DrawSimple() {
|
||||||
|
@ -12,8 +12,12 @@ TOptions Options;
|
|||||||
void LoadOptionsConfig(const char* line) {
|
void LoadOptionsConfig(const char* line) {
|
||||||
char str[512];
|
char str[512];
|
||||||
int i;
|
int i;
|
||||||
if (sscanf(line, "disassembly_cli=%511[^\n]", str) == 1) {
|
if (sscanf(line, "disassembler_cli_isa=%511[^\n]", str) == 1) {
|
||||||
Options.disassembly_cli = str;
|
Options.disassembler_cli_isa = str;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sscanf(line, "disassembler_cli_spv=%511[^\n]", str) == 1) {
|
||||||
|
Options.disassembler_cli_spv = str;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sscanf(line, "frame_dump_render_on_collapse=%d", &i) == 1) {
|
if (sscanf(line, "frame_dump_render_on_collapse=%d", &i) == 1) {
|
||||||
@ -23,7 +27,8 @@ void LoadOptionsConfig(const char* line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SerializeOptionsConfig(ImGuiTextBuffer* buf) {
|
void SerializeOptionsConfig(ImGuiTextBuffer* buf) {
|
||||||
buf->appendf("disassembly_cli=%s\n", Options.disassembly_cli.c_str());
|
buf->appendf("disassembler_cli_isa=%s\n", Options.disassembler_cli_isa.c_str());
|
||||||
|
buf->appendf("disassembler_cli_spv=%s\n", Options.disassembler_cli_spv.c_str());
|
||||||
buf->appendf("frame_dump_render_on_collapse=%d\n", Options.frame_dump_render_on_collapse);
|
buf->appendf("frame_dump_render_on_collapse=%d\n", Options.frame_dump_render_on_collapse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ struct ImGuiTextBuffer;
|
|||||||
namespace Core::Devtools {
|
namespace Core::Devtools {
|
||||||
|
|
||||||
struct TOptions {
|
struct TOptions {
|
||||||
std::string disassembly_cli{};
|
std::string disassembler_cli_isa{"clrxdisasm --raw \"{src}\""};
|
||||||
|
std::string disassembler_cli_spv{"spirv-cross -V \"{src}\""};
|
||||||
bool frame_dump_render_on_collapse{false};
|
bool frame_dump_render_on_collapse{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1306,7 +1306,7 @@ void CmdListViewer::Draw(bool only_batches_view) {
|
|||||||
if (batch.id == batch_bp) { // highlight batch at breakpoint
|
if (batch.id == batch_bp) { // highlight batch at breakpoint
|
||||||
PushStyleColor(ImGuiCol_Header, ImVec4{1.0f, 0.5f, 0.5f, 0.5f});
|
PushStyleColor(ImGuiCol_Header, ImVec4{1.0f, 0.5f, 0.5f, 0.5f});
|
||||||
}
|
}
|
||||||
if (batch.id == highlight_batch) {
|
if (batch.id == highlight_batch && !group_batches) {
|
||||||
PushStyleColor(ImGuiCol_Text, ImVec4{1.0f, 0.7f, 0.7f, 1.0f});
|
PushStyleColor(ImGuiCol_Text, ImVec4{1.0f, 0.7f, 0.7f, 1.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1459,7 +1459,7 @@ void CmdListViewer::Draw(bool only_batches_view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (batch.id == highlight_batch) {
|
if (batch.id == highlight_batch && !group_batches) {
|
||||||
PopStyleColor();
|
PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
@ -10,9 +11,16 @@
|
|||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
|
#include "common/io_file.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
#include "core/debug_state.h"
|
||||||
#include "video_core/amdgpu/pm4_opcodes.h"
|
#include "video_core/amdgpu/pm4_opcodes.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define popen _popen
|
||||||
|
#define pclose _pclose
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Core::Devtools::Widget {
|
namespace Core::Devtools::Widget {
|
||||||
/*
|
/*
|
||||||
* Generic PM4 header
|
* Generic PM4 header
|
||||||
@ -106,4 +114,53 @@ static bool IsDrawCall(AmdGpu::PM4ItOpcode opcode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::optional<std::string> exec_cli(const char* cli) {
|
||||||
|
std::array<char, 64> buffer{};
|
||||||
|
std::string output;
|
||||||
|
const auto f = popen(cli, "r");
|
||||||
|
if (!f) {
|
||||||
|
pclose(f);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
while (fgets(buffer.data(), buffer.size(), f)) {
|
||||||
|
output += buffer.data();
|
||||||
|
}
|
||||||
|
pclose(f);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string RunDisassembler(const std::string& disassembler_cli,
|
||||||
|
const std::vector<u32>& shader_code) {
|
||||||
|
std::string shader_dis;
|
||||||
|
|
||||||
|
if (disassembler_cli.empty()) {
|
||||||
|
shader_dis = "No disassembler set";
|
||||||
|
} else {
|
||||||
|
auto bin_path = std::filesystem::temp_directory_path() / "shadps4_tmp_shader.bin";
|
||||||
|
|
||||||
|
constexpr std::string_view src_arg = "{src}";
|
||||||
|
std::string cli = disassembler_cli;
|
||||||
|
const auto pos = cli.find(src_arg);
|
||||||
|
if (pos == std::string::npos) {
|
||||||
|
DebugState.ShowDebugMessage("Disassembler CLI does not contain {src} argument\n" +
|
||||||
|
disassembler_cli);
|
||||||
|
} else {
|
||||||
|
cli.replace(pos, src_arg.size(), "\"" + bin_path.string() + "\"");
|
||||||
|
Common::FS::IOFile file(bin_path, Common::FS::FileAccessMode::Write);
|
||||||
|
file.Write(shader_code);
|
||||||
|
file.Close();
|
||||||
|
|
||||||
|
auto result = exec_cli(cli.c_str());
|
||||||
|
shader_dis = result.value_or("Could not disassemble shader");
|
||||||
|
if (shader_dis.empty()) {
|
||||||
|
shader_dis = "Disassembly empty or failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::remove(bin_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return shader_dis;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core::Devtools::Widget
|
} // namespace Core::Devtools::Widget
|
@ -458,7 +458,7 @@ struct MemoryEditor {
|
|||||||
data_write = data_next = true;
|
data_write = data_next = true;
|
||||||
if (data_editing_addr_next != (size_t)-1)
|
if (data_editing_addr_next != (size_t)-1)
|
||||||
data_write = data_next = false;
|
data_write = data_next = false;
|
||||||
unsigned int data_input_value = 0;
|
u32 data_input_value = 0;
|
||||||
if (!ReadOnly && data_write &&
|
if (!ReadOnly && data_write &&
|
||||||
sscanf(DataInputBuf, "%X", &data_input_value) == 1) {
|
sscanf(DataInputBuf, "%X", &data_input_value) == 1) {
|
||||||
if (WriteFn)
|
if (WriteFn)
|
||||||
|
135
src/core/devtools/widget/memory_map.cpp
Normal file
135
src/core/devtools/widget/memory_map.cpp
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
|
#include "core/debug_state.h"
|
||||||
|
#include "core/memory.h"
|
||||||
|
#include "memory_map.h"
|
||||||
|
|
||||||
|
using namespace ImGui;
|
||||||
|
|
||||||
|
namespace Core::Devtools::Widget {
|
||||||
|
|
||||||
|
bool MemoryMapViewer::Iterator::DrawLine() {
|
||||||
|
if (is_vma) {
|
||||||
|
if (vma.it == vma.end) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto m = vma.it->second;
|
||||||
|
if (m.type == VMAType::Free) {
|
||||||
|
++vma.it;
|
||||||
|
return DrawLine();
|
||||||
|
}
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%" PRIXPTR, m.base);
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%zX", m.size);
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%s", magic_enum::enum_name(m.type).data());
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%s", magic_enum::enum_name(m.prot).data());
|
||||||
|
TableNextColumn();
|
||||||
|
if (m.is_exec) {
|
||||||
|
Text("X");
|
||||||
|
}
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%s", m.name.c_str());
|
||||||
|
++vma.it;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (dmem.it == dmem.end) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto m = dmem.it->second;
|
||||||
|
if (m.is_free) {
|
||||||
|
++dmem.it;
|
||||||
|
return DrawLine();
|
||||||
|
}
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%" PRIXPTR, m.base);
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%zX", m.size);
|
||||||
|
TableNextColumn();
|
||||||
|
auto type = static_cast<::Libraries::Kernel::MemoryTypes>(m.memory_type);
|
||||||
|
Text("%s", magic_enum::enum_name(type).data());
|
||||||
|
TableNextColumn();
|
||||||
|
Text("%d", m.is_pooled);
|
||||||
|
++dmem.it;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemoryMapViewer::Draw() {
|
||||||
|
SetNextWindowSize({600.0f, 500.0f}, ImGuiCond_FirstUseEver);
|
||||||
|
if (!Begin("Memory map", &open)) {
|
||||||
|
End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mem = Memory::Instance();
|
||||||
|
std::scoped_lock lck{mem->mutex};
|
||||||
|
|
||||||
|
{
|
||||||
|
bool next_showing_vma = showing_vma;
|
||||||
|
if (showing_vma) {
|
||||||
|
PushStyleColor(ImGuiCol_Button, ImVec4{1.0f, 0.7f, 0.7f, 1.0f});
|
||||||
|
}
|
||||||
|
if (Button("VMem")) {
|
||||||
|
next_showing_vma = true;
|
||||||
|
}
|
||||||
|
if (showing_vma) {
|
||||||
|
PopStyleColor();
|
||||||
|
}
|
||||||
|
SameLine();
|
||||||
|
if (!showing_vma) {
|
||||||
|
PushStyleColor(ImGuiCol_Button, ImVec4{1.0f, 0.7f, 0.7f, 1.0f});
|
||||||
|
}
|
||||||
|
if (Button("DMem")) {
|
||||||
|
next_showing_vma = false;
|
||||||
|
}
|
||||||
|
if (!showing_vma) {
|
||||||
|
PopStyleColor();
|
||||||
|
}
|
||||||
|
showing_vma = next_showing_vma;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator it{};
|
||||||
|
if (showing_vma) {
|
||||||
|
it.is_vma = true;
|
||||||
|
it.vma.it = mem->vma_map.begin();
|
||||||
|
it.vma.end = mem->vma_map.end();
|
||||||
|
} else {
|
||||||
|
it.is_vma = false;
|
||||||
|
it.dmem.it = mem->dmem_map.begin();
|
||||||
|
it.dmem.end = mem->dmem_map.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BeginTable("memory_view_table", showing_vma ? 6 : 4,
|
||||||
|
ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg |
|
||||||
|
ImGuiTableFlags_SizingFixedFit)) {
|
||||||
|
if (showing_vma) {
|
||||||
|
TableSetupColumn("Address");
|
||||||
|
TableSetupColumn("Size");
|
||||||
|
TableSetupColumn("Type");
|
||||||
|
TableSetupColumn("Prot");
|
||||||
|
TableSetupColumn("Is Exec");
|
||||||
|
TableSetupColumn("Name");
|
||||||
|
} else {
|
||||||
|
TableSetupColumn("Address");
|
||||||
|
TableSetupColumn("Size");
|
||||||
|
TableSetupColumn("Type");
|
||||||
|
TableSetupColumn("Pooled");
|
||||||
|
}
|
||||||
|
TableHeadersRow();
|
||||||
|
|
||||||
|
while (it.DrawLine())
|
||||||
|
;
|
||||||
|
EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
End();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core::Devtools::Widget
|
33
src/core/devtools/widget/memory_map.h
Normal file
33
src/core/devtools/widget/memory_map.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/memory.h"
|
||||||
|
|
||||||
|
namespace Core::Devtools::Widget {
|
||||||
|
|
||||||
|
class MemoryMapViewer {
|
||||||
|
struct Iterator {
|
||||||
|
bool is_vma;
|
||||||
|
struct {
|
||||||
|
MemoryManager::DMemMap::iterator it;
|
||||||
|
MemoryManager::DMemMap::iterator end;
|
||||||
|
} dmem;
|
||||||
|
struct {
|
||||||
|
MemoryManager::VMAMap::iterator it;
|
||||||
|
MemoryManager::VMAMap::iterator end;
|
||||||
|
} vma;
|
||||||
|
|
||||||
|
bool DrawLine();
|
||||||
|
};
|
||||||
|
|
||||||
|
bool showing_vma = true;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool open = false;
|
||||||
|
|
||||||
|
void Draw();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core::Devtools::Widget
|
@ -25,21 +25,6 @@ using magic_enum::enum_name;
|
|||||||
|
|
||||||
constexpr auto depth_id = 0xF3;
|
constexpr auto depth_id = 0xF3;
|
||||||
|
|
||||||
static std::optional<std::string> exec_cli(const char* cli) {
|
|
||||||
std::array<char, 64> buffer{};
|
|
||||||
std::string output;
|
|
||||||
const auto f = popen(cli, "r");
|
|
||||||
if (!f) {
|
|
||||||
pclose(f);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
while (fgets(buffer.data(), buffer.size(), f)) {
|
|
||||||
output += buffer.data();
|
|
||||||
}
|
|
||||||
pclose(f);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core::Devtools::Widget {
|
namespace Core::Devtools::Widget {
|
||||||
|
|
||||||
void RegView::ProcessShader(int shader_id) {
|
void RegView::ProcessShader(int shader_id) {
|
||||||
@ -54,38 +39,12 @@ void RegView::ProcessShader(int shader_id) {
|
|||||||
user_data = s.user_data.user_data;
|
user_data = s.user_data.user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string shader_dis;
|
std::string shader_dis = RunDisassembler(Options.disassembler_cli_isa, shader_code);
|
||||||
|
|
||||||
if (Options.disassembly_cli.empty()) {
|
|
||||||
shader_dis = "No disassembler set";
|
|
||||||
} else {
|
|
||||||
auto bin_path = std::filesystem::temp_directory_path() / "shadps4_tmp_shader.bin";
|
|
||||||
|
|
||||||
constexpr std::string_view src_arg = "{src}";
|
|
||||||
std::string cli = Options.disassembly_cli;
|
|
||||||
const auto pos = cli.find(src_arg);
|
|
||||||
if (pos == std::string::npos) {
|
|
||||||
DebugState.ShowDebugMessage("Disassembler CLI does not contain {src} argument");
|
|
||||||
} else {
|
|
||||||
cli.replace(pos, src_arg.size(), "\"" + bin_path.string() + "\"");
|
|
||||||
Common::FS::IOFile file(bin_path, Common::FS::FileAccessMode::Write);
|
|
||||||
file.Write(shader_code);
|
|
||||||
file.Close();
|
|
||||||
|
|
||||||
auto result = exec_cli(cli.c_str());
|
|
||||||
shader_dis = result.value_or("Could not disassemble shader");
|
|
||||||
if (shader_dis.empty()) {
|
|
||||||
shader_dis = "Disassembly empty or failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::filesystem::remove(bin_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryEditor hex_view;
|
MemoryEditor hex_view;
|
||||||
hex_view.Open = true;
|
hex_view.Open = true;
|
||||||
hex_view.ReadOnly = true;
|
hex_view.ReadOnly = true;
|
||||||
hex_view.Cols = 8;
|
hex_view.Cols = 16;
|
||||||
hex_view.OptShowAscii = false;
|
hex_view.OptShowAscii = false;
|
||||||
hex_view.OptShowOptions = false;
|
hex_view.OptShowOptions = false;
|
||||||
|
|
||||||
@ -376,7 +335,9 @@ void RegView::Draw() {
|
|||||||
if (!shader) {
|
if (!shader) {
|
||||||
Text("Stage not selected");
|
Text("Stage not selected");
|
||||||
} else {
|
} else {
|
||||||
shader->hex_view.DrawContents(shader->user_data.data(), shader->user_data.size());
|
shader->hex_view.DrawContents(shader->user_data.data(),
|
||||||
|
shader->user_data.size() *
|
||||||
|
sizeof(Vulkan::Liverpool::UserData::value_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
End();
|
End();
|
||||||
|
95
src/core/devtools/widget/shader_list.cpp
Normal file
95
src/core/devtools/widget/shader_list.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "shader_list.h"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "common/config.h"
|
||||||
|
#include "core/debug_state.h"
|
||||||
|
#include "core/devtools/options.h"
|
||||||
|
#include "imgui/imgui_std.h"
|
||||||
|
|
||||||
|
using namespace ImGui;
|
||||||
|
|
||||||
|
namespace Core::Devtools::Widget {
|
||||||
|
|
||||||
|
void ShaderList::DrawShader(DebugStateType::ShaderDump& value) {
|
||||||
|
if (!loaded_data) {
|
||||||
|
loaded_data = true;
|
||||||
|
if (value.cache_raw_disasm.empty()) {
|
||||||
|
value.cache_raw_disasm = RunDisassembler(Options.disassembler_cli_isa, value.raw_code);
|
||||||
|
}
|
||||||
|
isa_editor.SetText(value.cache_raw_disasm);
|
||||||
|
|
||||||
|
if (value.cache_spv_disasm.empty()) {
|
||||||
|
value.cache_spv_disasm = RunDisassembler(Options.disassembler_cli_spv, value.spv);
|
||||||
|
}
|
||||||
|
spv_editor.SetText(value.cache_spv_disasm);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SmallButton("<-")) {
|
||||||
|
selected_shader = -1;
|
||||||
|
}
|
||||||
|
SameLine();
|
||||||
|
Text("%s", value.name.c_str());
|
||||||
|
SameLine(0.0f, 7.0f);
|
||||||
|
if (BeginCombo("Shader type", showing_isa ? "ISA" : "SPIRV", ImGuiComboFlags_WidthFitPreview)) {
|
||||||
|
if (Selectable("SPIRV")) {
|
||||||
|
showing_isa = false;
|
||||||
|
}
|
||||||
|
if (Selectable("ISA")) {
|
||||||
|
showing_isa = true;
|
||||||
|
}
|
||||||
|
EndCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showing_isa) {
|
||||||
|
isa_editor.Render("ISA", GetContentRegionAvail());
|
||||||
|
} else {
|
||||||
|
spv_editor.Render("SPIRV", GetContentRegionAvail());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderList::ShaderList() {
|
||||||
|
isa_editor.SetPalette(TextEditor::GetDarkPalette());
|
||||||
|
isa_editor.SetReadOnly(true);
|
||||||
|
spv_editor.SetPalette(TextEditor::GetDarkPalette());
|
||||||
|
spv_editor.SetReadOnly(true);
|
||||||
|
spv_editor.SetLanguageDefinition(TextEditor::LanguageDefinition::GLSL());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderList::Draw() {
|
||||||
|
SetNextWindowSize({500.0f, 600.0f}, ImGuiCond_FirstUseEver);
|
||||||
|
if (!Begin("Shader list", &open)) {
|
||||||
|
End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config::collectShadersForDebug()) {
|
||||||
|
DrawCenteredText("Enable 'CollectShader' in config to see shaders");
|
||||||
|
End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected_shader >= 0) {
|
||||||
|
DrawShader(DebugState.shader_dump_list[selected_shader]);
|
||||||
|
End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto width = GetContentRegionAvail().x;
|
||||||
|
int i = 0;
|
||||||
|
for (const auto& shader : DebugState.shader_dump_list) {
|
||||||
|
if (ButtonEx(shader.name.c_str(), {width, 20.0f}, ImGuiButtonFlags_NoHoveredOnFocus)) {
|
||||||
|
selected_shader = i;
|
||||||
|
loaded_data = false;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
End();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core::Devtools::Widget
|
28
src/core/devtools/widget/shader_list.h
Normal file
28
src/core/devtools/widget/shader_list.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/debug_state.h"
|
||||||
|
#include "text_editor.h"
|
||||||
|
|
||||||
|
namespace Core::Devtools::Widget {
|
||||||
|
|
||||||
|
class ShaderList {
|
||||||
|
int selected_shader = -1;
|
||||||
|
TextEditor isa_editor{};
|
||||||
|
TextEditor spv_editor{};
|
||||||
|
bool loaded_data = false;
|
||||||
|
bool showing_isa = false;
|
||||||
|
|
||||||
|
void DrawShader(DebugStateType::ShaderDump& value);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ShaderList();
|
||||||
|
|
||||||
|
bool open = false;
|
||||||
|
|
||||||
|
void Draw();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core::Devtools::Widget
|
@ -131,7 +131,7 @@ static int UTF8CharLength(TextEditor::Char c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "Borrowed" from ImGui source
|
// "Borrowed" from ImGui source
|
||||||
static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c) {
|
static inline int ImTextCharToUtf8(char* buf, int buf_size, u32 c) {
|
||||||
if (c < 0x80) {
|
if (c < 0x80) {
|
||||||
buf[0] = (char)c;
|
buf[0] = (char)c;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -97,24 +97,22 @@ struct PlaygoChunk {
|
|||||||
|
|
||||||
class PlaygoFile {
|
class PlaygoFile {
|
||||||
public:
|
public:
|
||||||
bool initialized;
|
OrbisPlayGoHandle handle = 0;
|
||||||
OrbisPlayGoHandle handle;
|
OrbisPlayGoChunkId id = 0;
|
||||||
OrbisPlayGoChunkId id;
|
OrbisPlayGoLocus locus = OrbisPlayGoLocus::NotDownloaded;
|
||||||
OrbisPlayGoLocus locus;
|
OrbisPlayGoInstallSpeed speed = OrbisPlayGoInstallSpeed::Trickle;
|
||||||
OrbisPlayGoInstallSpeed speed;
|
s64 speed_tick = 0;
|
||||||
s64 speed_tick;
|
OrbisPlayGoEta eta = 0;
|
||||||
OrbisPlayGoEta eta;
|
OrbisPlayGoLanguageMask langMask = 0;
|
||||||
OrbisPlayGoLanguageMask langMask;
|
|
||||||
std::vector<PlaygoChunk> chunks;
|
std::vector<PlaygoChunk> chunks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlaygoFile()
|
explicit PlaygoFile() = default;
|
||||||
: initialized(false), handle(0), id(0), locus(0), speed(ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE),
|
|
||||||
speed_tick(0), eta(0), langMask(0), playgoHeader{0} {}
|
|
||||||
~PlaygoFile() = default;
|
~PlaygoFile() = default;
|
||||||
|
|
||||||
bool Open(const std::filesystem::path& filepath);
|
bool Open(const std::filesystem::path& filepath);
|
||||||
bool LoadChunks(const Common::FS::IOFile& file);
|
bool LoadChunks(const Common::FS::IOFile& file);
|
||||||
|
|
||||||
PlaygoHeader& GetPlaygoHeader() {
|
PlaygoHeader& GetPlaygoHeader() {
|
||||||
return playgoHeader;
|
return playgoHeader;
|
||||||
}
|
}
|
||||||
|
@ -6,34 +6,30 @@
|
|||||||
#include "app_content.h"
|
#include "app_content.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/io_file.h"
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "common/string_util.h"
|
|
||||||
#include "core/file_format/psf.h"
|
#include "core/file_format/psf.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/app_content/app_content_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::AppContent {
|
namespace Libraries::AppContent {
|
||||||
|
|
||||||
int32_t addcont_count = 0;
|
|
||||||
|
|
||||||
struct AddContInfo {
|
struct AddContInfo {
|
||||||
char entitlementLabel[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
|
char entitlement_label[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
|
||||||
OrbisAppContentAddcontDownloadStatus status;
|
OrbisAppContentAddcontDownloadStatus status;
|
||||||
OrbisAppContentGetEntitlementKey key;
|
OrbisAppContentGetEntitlementKey key;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<AddContInfo, ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE> addcont_info = {{
|
static std::array<AddContInfo, ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE> addcont_info = {{
|
||||||
{"0000000000000000",
|
{"0000000000000000",
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED,
|
OrbisAppContentAddcontDownloadStatus::Installed,
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00}},
|
0x00}},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
std::string title_id;
|
static s32 addcont_count = 0;
|
||||||
|
static std::string title_id;
|
||||||
|
|
||||||
int PS4_SYSV_ABI _Z5dummyv() {
|
int PS4_SYSV_ABI _Z5dummyv() {
|
||||||
LOG_ERROR(Lib_AppContent, "(STUBBED) called");
|
LOG_ERROR(Lib_AppContent, "(STUBBED) called");
|
||||||
@ -64,12 +60,11 @@ int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
|
|||||||
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||||
|
|
||||||
for (int i = 0; i < addcont_count; i++) {
|
for (int i = 0; i < addcont_count; i++) {
|
||||||
if (strncmp(entitlement_label->data, addcont_info[i].entitlementLabel,
|
if (strncmp(entitlement_label->data, addcont_info[i].entitlement_label,
|
||||||
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (addcont_info[i].status != OrbisAppContentAddcontDownloadStatus::Installed) {
|
||||||
if (addcont_info[i].status != ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED) {
|
|
||||||
return ORBIS_APP_CONTENT_ERROR_NOT_FOUND;
|
return ORBIS_APP_CONTENT_ERROR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,14 +165,14 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfo(u32 service_label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = 0; i < addcont_count; i++) {
|
for (auto i = 0; i < addcont_count; i++) {
|
||||||
if (strncmp(entitlementLabel->data, addcont_info[i].entitlementLabel,
|
if (strncmp(entitlementLabel->data, addcont_info[i].entitlement_label,
|
||||||
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Lib_AppContent, "found DLC {}", entitlementLabel->data);
|
LOG_INFO(Lib_AppContent, "found DLC {}", entitlementLabel->data);
|
||||||
|
|
||||||
strncpy(info->entitlement_label.data, addcont_info[i].entitlementLabel,
|
strncpy(info->entitlement_label.data, addcont_info[i].entitlement_label,
|
||||||
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
|
||||||
info->status = addcont_info[i].status;
|
info->status = addcont_info[i].status;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -202,7 +197,7 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfoList(u32 service_label,
|
|||||||
|
|
||||||
int dlcs_to_list = addcont_count < list_num ? addcont_count : list_num;
|
int dlcs_to_list = addcont_count < list_num ? addcont_count : list_num;
|
||||||
for (int i = 0; i < dlcs_to_list; i++) {
|
for (int i = 0; i < dlcs_to_list; i++) {
|
||||||
strncpy(list[i].entitlement_label.data, addcont_info[i].entitlementLabel,
|
strncpy(list[i].entitlement_label.data, addcont_info[i].entitlement_label,
|
||||||
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
|
||||||
list[i].status = addcont_info[i].status;
|
list[i].status = addcont_info[i].status;
|
||||||
}
|
}
|
||||||
@ -224,7 +219,7 @@ int PS4_SYSV_ABI sceAppContentGetEntitlementKey(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < addcont_count; i++) {
|
for (int i = 0; i < addcont_count; i++) {
|
||||||
if (strncmp(entitlement_label->data, addcont_info[i].entitlementLabel,
|
if (strncmp(entitlement_label->data, addcont_info[i].entitlement_label,
|
||||||
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -252,21 +247,19 @@ int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initPar
|
|||||||
} else {
|
} else {
|
||||||
UNREACHABLE_MSG("Failed to get TITLE_ID");
|
UNREACHABLE_MSG("Failed to get TITLE_ID");
|
||||||
}
|
}
|
||||||
auto addon_path = addons_dir / title_id;
|
const auto addon_path = addons_dir / title_id;
|
||||||
if (std::filesystem::exists(addon_path)) {
|
if (!std::filesystem::exists(addon_path)) {
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
|
return ORBIS_OK;
|
||||||
if (entry.is_directory()) {
|
|
||||||
auto entitlement_label = entry.path().filename().string();
|
|
||||||
|
|
||||||
AddContInfo info{};
|
|
||||||
info.status = ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED;
|
|
||||||
strcpy(info.entitlementLabel, entitlement_label.c_str());
|
|
||||||
|
|
||||||
addcont_info[addcont_count++] = info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
|
||||||
|
if (entry.is_directory()) {
|
||||||
|
auto entitlement_label = entry.path().filename().string();
|
||||||
|
auto& info = addcont_info[addcont_count++];
|
||||||
|
info.status = OrbisAppContentAddcontDownloadStatus::Installed;
|
||||||
|
entitlement_label.copy(info.entitlement_label, sizeof(info.entitlement_label));
|
||||||
|
}
|
||||||
|
}
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,9 +307,11 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataMount() {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
|
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
|
||||||
OrbisAppContentMountPoint* mountPoint) {
|
OrbisAppContentMountPoint* mountPoint) {
|
||||||
if (mountPoint == nullptr)
|
if (mountPoint == nullptr) {
|
||||||
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
|
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
|
||||||
strncpy(mountPoint->data, "/temp0", 16);
|
}
|
||||||
|
static constexpr std::string_view TmpMount = "/temp0";
|
||||||
|
TmpMount.copy(mountPoint->data, sizeof(mountPoint->data));
|
||||||
LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}",
|
LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}",
|
||||||
option, mountPoint->data);
|
option, mountPoint->data);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
|
@ -30,7 +30,7 @@ struct OrbisAppContentBootParam {
|
|||||||
char reserved2[32];
|
char reserved2[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef u32 OrbisAppContentTemporaryDataOption;
|
using OrbisAppContentTemporaryDataOption = u32;
|
||||||
|
|
||||||
constexpr int ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE = 16;
|
constexpr int ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE = 16;
|
||||||
|
|
||||||
@ -44,12 +44,12 @@ constexpr int ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE = 17;
|
|||||||
constexpr int ORBIS_APP_CONTENT_ENTITLEMENT_KEY_SIZE = 16;
|
constexpr int ORBIS_APP_CONTENT_ENTITLEMENT_KEY_SIZE = 16;
|
||||||
constexpr int ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE = 2500;
|
constexpr int ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE = 2500;
|
||||||
|
|
||||||
enum OrbisAppContentAddcontDownloadStatus : u32 {
|
enum class OrbisAppContentAddcontDownloadStatus : u32 {
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_EXTRA_DATA = 0,
|
NoExtraData = 0,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_IN_QUEUE = 1,
|
NoInQueue = 1,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOADING = 2,
|
Downloading = 2,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOAD_SUSPENDED = 3,
|
DownloadSuspended = 3,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED = 4
|
Installed = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisNpUnifiedEntitlementLabel {
|
struct OrbisNpUnifiedEntitlementLabel {
|
||||||
@ -57,11 +57,11 @@ struct OrbisNpUnifiedEntitlementLabel {
|
|||||||
char padding[3];
|
char padding[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef u32 OrbisAppContentAppParamId;
|
using OrbisAppContentAppParamId = u32;
|
||||||
|
|
||||||
struct OrbisAppContentAddcontInfo {
|
struct OrbisAppContentAddcontInfo {
|
||||||
OrbisNpUnifiedEntitlementLabel entitlement_label;
|
OrbisNpUnifiedEntitlementLabel entitlement_label;
|
||||||
u32 status;
|
OrbisAppContentAddcontDownloadStatus status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAppContentGetEntitlementKey {
|
struct OrbisAppContentGetEntitlementKey {
|
||||||
@ -119,4 +119,4 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfoListByIroTag();
|
|||||||
int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry();
|
int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry();
|
||||||
|
|
||||||
void RegisterlibSceAppContent(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceAppContent(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::AppContent
|
} // namespace Libraries::AppContent
|
||||||
|
11
src/core/libraries/app_content/app_content_error.h
Normal file
11
src/core/libraries/app_content/app_content_error.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// AppContent library
|
||||||
|
constexpr int ORBIS_APP_CONTENT_ERROR_PARAMETER = 0x80D90002;
|
||||||
|
constexpr int ORBIS_APP_CONTENT_ERROR_DRM_NO_ENTITLEMENT = 0x80D90007;
|
||||||
|
constexpr int ORBIS_APP_CONTENT_ERROR_NOT_FOUND = 0x80D90005;
|
@ -4,30 +4,30 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
#include "audio_core/sdl_audio.h"
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/audio/audioout.h"
|
#include "core/libraries/audio/audioout.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/audio/audioout_error.h"
|
||||||
|
#include "core/libraries/audio/sdl_audio.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::AudioOut {
|
namespace Libraries::AudioOut {
|
||||||
|
|
||||||
static std::unique_ptr<Audio::SDLAudio> audio;
|
static std::unique_ptr<SDLAudioOut> audio;
|
||||||
|
|
||||||
static std::string_view GetAudioOutPort(u32 port) {
|
static std::string_view GetAudioOutPort(OrbisAudioOutPort port) {
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
|
case OrbisAudioOutPort::Main:
|
||||||
return "MAIN";
|
return "MAIN";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
|
case OrbisAudioOutPort::Bgm:
|
||||||
return "BGM";
|
return "BGM";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
|
case OrbisAudioOutPort::Voice:
|
||||||
return "VOICE";
|
return "VOICE";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
|
case OrbisAudioOutPort::Personal:
|
||||||
return "PERSONAL";
|
return "PERSONAL";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
|
case OrbisAudioOutPort::Padspk:
|
||||||
return "PADSPK";
|
return "PADSPK";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
|
case OrbisAudioOutPort::Aux:
|
||||||
return "AUX";
|
return "AUX";
|
||||||
default:
|
default:
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
@ -36,21 +36,21 @@ static std::string_view GetAudioOutPort(u32 port) {
|
|||||||
|
|
||||||
static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
|
static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
|
case OrbisAudioOutParamFormat::S16Mono:
|
||||||
return "S16_MONO";
|
return "S16_MONO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
|
case OrbisAudioOutParamFormat::S16Stereo:
|
||||||
return "S16_STEREO";
|
return "S16_STEREO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
|
case OrbisAudioOutParamFormat::S16_8CH:
|
||||||
return "S16_8CH";
|
return "S16_8CH";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
|
case OrbisAudioOutParamFormat::FloatMono:
|
||||||
return "FLOAT_MONO";
|
return "FLOAT_MONO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
|
case OrbisAudioOutParamFormat::FloatStereo:
|
||||||
return "FLOAT_STEREO";
|
return "FLOAT_STEREO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
|
case OrbisAudioOutParamFormat::Float_8CH:
|
||||||
return "FLOAT_8CH";
|
return "FLOAT_8CH";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
|
case OrbisAudioOutParamFormat::S16_8CH_Std:
|
||||||
return "S16_8CH_STD";
|
return "S16_8CH_STD";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD:
|
case OrbisAudioOutParamFormat::Float_8CH_Std:
|
||||||
return "FLOAT_8CH_STD";
|
return "FLOAT_8CH_STD";
|
||||||
default:
|
default:
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
@ -59,11 +59,11 @@ static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
|
|||||||
|
|
||||||
static std::string_view GetAudioOutParamAttr(OrbisAudioOutParamAttr attr) {
|
static std::string_view GetAudioOutParamAttr(OrbisAudioOutParamAttr attr) {
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case ORBIS_AUDIO_OUT_PARAM_ATTR_NONE:
|
case OrbisAudioOutParamAttr::None:
|
||||||
return "NONE";
|
return "NONE";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_ATTR_RESTRICTED:
|
case OrbisAudioOutParamAttr::Restricted:
|
||||||
return "RESTRICTED";
|
return "RESTRICTED";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_ATTR_MIX_TO_MAIN:
|
case OrbisAudioOutParamAttr::MixToMain:
|
||||||
return "MIX_TO_MAIN";
|
return "MIX_TO_MAIN";
|
||||||
default:
|
default:
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
@ -180,29 +180,23 @@ int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* sta
|
|||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int type = 0;
|
const auto [type, channels_num] = audio->GetStatus(handle);
|
||||||
int channels_num = 0;
|
|
||||||
|
|
||||||
if (const auto err = audio->AudioOutGetStatus(handle, &type, &channels_num); err != ORBIS_OK) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
state->rerouteCounter = 0;
|
state->rerouteCounter = 0;
|
||||||
state->volume = 127; // max volume
|
state->volume = 127;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
|
case OrbisAudioOutPort::Main:
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
|
case OrbisAudioOutPort::Bgm:
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
|
case OrbisAudioOutPort::Voice:
|
||||||
state->output = 1;
|
state->output = 1;
|
||||||
state->channel = (channels_num > 2 ? 2 : channels_num);
|
state->channel = (channels_num > 2 ? 2 : channels_num);
|
||||||
break;
|
break;
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
|
case OrbisAudioOutPort::Personal:
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
|
case OrbisAudioOutPort::Padspk:
|
||||||
state->output = 4;
|
state->output = 4;
|
||||||
state->channel = 1;
|
state->channel = 1;
|
||||||
break;
|
break;
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
|
case OrbisAudioOutPort::Aux:
|
||||||
state->output = 0;
|
state->output = 0;
|
||||||
state->channel = 0;
|
state->channel = 0;
|
||||||
break;
|
break;
|
||||||
@ -243,7 +237,7 @@ int PS4_SYSV_ABI sceAudioOutInit() {
|
|||||||
if (audio != nullptr) {
|
if (audio != nullptr) {
|
||||||
return ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT;
|
return ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT;
|
||||||
}
|
}
|
||||||
audio = std::make_unique<Audio::SDLAudio>();
|
audio = std::make_unique<SDLAudioOut>();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +281,8 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
|
|||||||
user_id, GetAudioOutPort(port_type), index, length, sample_rate,
|
user_id, GetAudioOutPort(port_type), index, length, sample_rate,
|
||||||
GetAudioOutParamFormat(param_type.data_format),
|
GetAudioOutParamFormat(param_type.data_format),
|
||||||
GetAudioOutParamAttr(param_type.attributes));
|
GetAudioOutParamAttr(param_type.attributes));
|
||||||
if ((port_type < 0 || port_type > 4) && (port_type != 127)) {
|
if ((port_type < OrbisAudioOutPort::Main || port_type > OrbisAudioOutPort::Padspk) &&
|
||||||
|
(port_type != OrbisAudioOutPort::Aux)) {
|
||||||
LOG_ERROR(Lib_AudioOut, "Invalid port type");
|
LOG_ERROR(Lib_AudioOut, "Invalid port type");
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT_TYPE;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT_TYPE;
|
||||||
}
|
}
|
||||||
@ -303,18 +298,19 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
|
|||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
LOG_ERROR(Lib_AudioOut, "index is not valid !=0 {}", index);
|
LOG_ERROR(Lib_AudioOut, "index is not valid !=0 {}", index);
|
||||||
}
|
}
|
||||||
OrbisAudioOutParamFormat format = param_type.data_format;
|
const auto format = param_type.data_format.Value();
|
||||||
if (format < 0 || format > 7) {
|
if (format < OrbisAudioOutParamFormat::S16Mono ||
|
||||||
|
format > OrbisAudioOutParamFormat::Float_8CH_Std) {
|
||||||
LOG_ERROR(Lib_AudioOut, "Invalid format");
|
LOG_ERROR(Lib_AudioOut, "Invalid format");
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
||||||
}
|
}
|
||||||
OrbisAudioOutParamAttr attr = param_type.attributes;
|
const auto attr = param_type.attributes;
|
||||||
if (attr < 0 || attr > 2) {
|
if (attr < OrbisAudioOutParamAttr::None || attr > OrbisAudioOutParamAttr::MixToMain) {
|
||||||
// TODO Handle attributes in output audio device
|
// TODO Handle attributes in output audio device
|
||||||
LOG_ERROR(Lib_AudioOut, "Invalid format attribute");
|
LOG_ERROR(Lib_AudioOut, "Invalid format attribute");
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
||||||
}
|
}
|
||||||
return audio->AudioOutOpen(port_type, length, sample_rate, format);
|
return audio->Open(port_type, length, sample_rate, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutOpenEx() {
|
int PS4_SYSV_ABI sceAudioOutOpenEx() {
|
||||||
@ -330,7 +326,7 @@ s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr) {
|
|||||||
// Nothing to output
|
// Nothing to output
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
return audio->AudioOutOutput(handle, ptr);
|
return audio->Output(handle, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num) {
|
int PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num) {
|
||||||
@ -435,7 +431,7 @@ s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
|
|||||||
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
|
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
}
|
}
|
||||||
return audio->AudioOutSetVolume(handle, flag, vol);
|
return audio->SetVolume(handle, flag, vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
||||||
|
@ -9,46 +9,36 @@
|
|||||||
|
|
||||||
namespace Libraries::AudioOut {
|
namespace Libraries::AudioOut {
|
||||||
|
|
||||||
constexpr int SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value
|
// Main up to 8 ports, BGM 1 port, voice up to 4 ports,
|
||||||
|
|
||||||
// main up to 8 ports, BGM 1 port, voice up to 4 ports,
|
|
||||||
// personal up to 4 ports, padspk up to 5 ports, aux 1 port
|
// personal up to 4 ports, padspk up to 5 ports, aux 1 port
|
||||||
constexpr int SCE_AUDIO_OUT_NUM_PORTS = 22;
|
constexpr int SCE_AUDIO_OUT_NUM_PORTS = 22;
|
||||||
|
constexpr int SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value
|
||||||
|
|
||||||
enum OrbisAudioOutPort {
|
enum class OrbisAudioOutPort { Main = 0, Bgm = 1, Voice = 2, Personal = 3, Padspk = 4, Aux = 127 };
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_MAIN = 0,
|
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_BGM = 1,
|
enum class OrbisAudioOutParamFormat {
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_VOICE = 2,
|
S16Mono = 0,
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL = 3,
|
S16Stereo = 1,
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK = 4,
|
S16_8CH = 2,
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_AUX = 127
|
FloatMono = 3,
|
||||||
|
FloatStereo = 4,
|
||||||
|
Float_8CH = 5,
|
||||||
|
S16_8CH_Std = 6,
|
||||||
|
Float_8CH_Std = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudioOutParamFormat {
|
enum class OrbisAudioOutParamAttr {
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO = 0,
|
None = 0,
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO = 1,
|
Restricted = 1,
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH = 2,
|
MixToMain = 2,
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO = 3,
|
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO = 4,
|
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH = 5,
|
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD = 6,
|
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD = 7
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudioOutParamAttr {
|
union OrbisAudioOutParamExtendedInformation {
|
||||||
ORBIS_AUDIO_OUT_PARAM_ATTR_NONE = 0,
|
BitField<0, 8, OrbisAudioOutParamFormat> data_format;
|
||||||
ORBIS_AUDIO_OUT_PARAM_ATTR_RESTRICTED = 1,
|
BitField<8, 8, u32> reserve0;
|
||||||
ORBIS_AUDIO_OUT_PARAM_ATTR_MIX_TO_MAIN = 2,
|
BitField<16, 4, OrbisAudioOutParamAttr> attributes;
|
||||||
};
|
BitField<20, 10, u32> reserve1;
|
||||||
|
BitField<31, 1, u32> unused;
|
||||||
struct OrbisAudioOutParamExtendedInformation {
|
|
||||||
union {
|
|
||||||
BitField<0, 8, OrbisAudioOutParamFormat> data_format;
|
|
||||||
BitField<8, 8, u32> reserve0;
|
|
||||||
BitField<16, 4, OrbisAudioOutParamAttr> attributes;
|
|
||||||
BitField<20, 10, u32> reserve1;
|
|
||||||
BitField<31, 1, u32> unused;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAudioOutOutputParam {
|
struct OrbisAudioOutOutputParam {
|
||||||
|
34
src/core/libraries/audio/audioout_error.h
Normal file
34
src/core/libraries/audio/audioout_error.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// AudioOut library
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_NOT_OPENED = 0x80260001;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_BUSY = 0x80260002;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_PORT = 0x80260003;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_POINTER = 0x80260004;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_PORT_FULL = 0x80260005;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_SIZE = 0x80260006;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT = 0x80260007;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_SAMPLE_FREQ = 0x80260008;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_VOLUME = 0x80260009;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_PORT_TYPE = 0x8026000A;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_CONF_TYPE = 0x8026000C;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_OUT_OF_MEMORY = 0x8026000D;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT = 0x8026000E;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_NOT_INIT = 0x8026000F;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_MEMORY = 0x80260010;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_SYSTEM_RESOURCE = 0x80260011;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_TRANS_EVENT = 0x80260012;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_FLAG = 0x80260013;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_MIXLEVEL = 0x80260014;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_ARG = 0x80260015;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_PARAM = 0x80260016;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_FATAL = 0x80260200;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_API_PARAM = 0x80260201;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_CONFIG = 0x80260202;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_NOT_INITIALIZED = 0x80260203;
|
||||||
|
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_STATES_ID = 0x80260204;
|
141
src/core/libraries/audio/sdl_audio.cpp
Normal file
141
src/core/libraries/audio/sdl_audio.cpp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <SDL3/SDL_audio.h>
|
||||||
|
#include <SDL3/SDL_init.h>
|
||||||
|
#include <SDL3/SDL_timer.h>
|
||||||
|
|
||||||
|
#include "common/assert.h"
|
||||||
|
#include "core/libraries/audio/audioout_error.h"
|
||||||
|
#include "core/libraries/audio/sdl_audio.h"
|
||||||
|
|
||||||
|
namespace Libraries::AudioOut {
|
||||||
|
|
||||||
|
constexpr int AUDIO_STREAM_BUFFER_THRESHOLD = 65536; // Define constant for buffer threshold
|
||||||
|
|
||||||
|
s32 SDLAudioOut::Open(OrbisAudioOutPort type, u32 samples_num, u32 freq,
|
||||||
|
OrbisAudioOutParamFormat format) {
|
||||||
|
std::scoped_lock lock{m_mutex};
|
||||||
|
const auto port = std::ranges::find(ports_out, false, &PortOut::is_open);
|
||||||
|
if (port == ports_out.end()) {
|
||||||
|
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
|
||||||
|
return ORBIS_AUDIO_OUT_ERROR_PORT_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
port->is_open = true;
|
||||||
|
port->type = type;
|
||||||
|
port->samples_num = samples_num;
|
||||||
|
port->freq = freq;
|
||||||
|
port->format = format;
|
||||||
|
SDL_AudioFormat sampleFormat;
|
||||||
|
switch (format) {
|
||||||
|
case OrbisAudioOutParamFormat::S16Mono:
|
||||||
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
|
port->channels_num = 1;
|
||||||
|
port->sample_size = 2;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::FloatMono:
|
||||||
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
|
port->channels_num = 1;
|
||||||
|
port->sample_size = 4;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::S16Stereo:
|
||||||
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
|
port->channels_num = 2;
|
||||||
|
port->sample_size = 2;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::FloatStereo:
|
||||||
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
|
port->channels_num = 2;
|
||||||
|
port->sample_size = 4;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::S16_8CH:
|
||||||
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
|
port->channels_num = 8;
|
||||||
|
port->sample_size = 2;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::Float_8CH:
|
||||||
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
|
port->channels_num = 8;
|
||||||
|
port->sample_size = 4;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::S16_8CH_Std:
|
||||||
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
|
port->channels_num = 8;
|
||||||
|
port->sample_size = 2;
|
||||||
|
break;
|
||||||
|
case OrbisAudioOutParamFormat::Float_8CH_Std:
|
||||||
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
|
port->channels_num = 8;
|
||||||
|
port->sample_size = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE_MSG("Unknown format");
|
||||||
|
}
|
||||||
|
|
||||||
|
port->volume.fill(Libraries::AudioOut::SCE_AUDIO_OUT_VOLUME_0DB);
|
||||||
|
|
||||||
|
SDL_AudioSpec fmt;
|
||||||
|
SDL_zero(fmt);
|
||||||
|
fmt.format = sampleFormat;
|
||||||
|
fmt.channels = port->channels_num;
|
||||||
|
fmt.freq = freq;
|
||||||
|
port->stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &fmt, NULL, NULL);
|
||||||
|
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port->stream));
|
||||||
|
return std::distance(ports_out.begin(), port) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 SDLAudioOut::Output(s32 handle, const void* ptr) {
|
||||||
|
auto& port = ports_out.at(handle - 1);
|
||||||
|
if (!port.is_open) {
|
||||||
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t data_size = port.samples_num * port.sample_size * port.channels_num;
|
||||||
|
bool result = SDL_PutAudioStreamData(port.stream, ptr, data_size);
|
||||||
|
while (SDL_GetAudioStreamAvailable(port.stream) > AUDIO_STREAM_BUFFER_THRESHOLD) {
|
||||||
|
SDL_Delay(0);
|
||||||
|
}
|
||||||
|
return result ? ORBIS_OK : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 SDLAudioOut::SetVolume(s32 handle, s32 bitflag, s32* volume) {
|
||||||
|
using Libraries::AudioOut::OrbisAudioOutParamFormat;
|
||||||
|
auto& port = ports_out.at(handle - 1);
|
||||||
|
if (!port.is_open) {
|
||||||
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < port.channels_num; i++, bitflag >>= 1u) {
|
||||||
|
auto bit = bitflag & 0x1u;
|
||||||
|
|
||||||
|
if (bit == 1) {
|
||||||
|
int src_index = i;
|
||||||
|
if (port.format == OrbisAudioOutParamFormat::Float_8CH_Std ||
|
||||||
|
port.format == OrbisAudioOutParamFormat::S16_8CH_Std) {
|
||||||
|
switch (i) {
|
||||||
|
case 4:
|
||||||
|
src_index = 6;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
src_index = 7;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
src_index = 4;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
src_index = 5;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
port.volume[i] = volume[src_index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Libraries::AudioOut
|
42
src/core/libraries/audio/sdl_audio.h
Normal file
42
src/core/libraries/audio/sdl_audio.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <shared_mutex>
|
||||||
|
#include <SDL3/SDL_audio.h>
|
||||||
|
#include "core/libraries/audio/audioout.h"
|
||||||
|
|
||||||
|
namespace Libraries::AudioOut {
|
||||||
|
|
||||||
|
class SDLAudioOut {
|
||||||
|
public:
|
||||||
|
explicit SDLAudioOut() = default;
|
||||||
|
~SDLAudioOut() = default;
|
||||||
|
|
||||||
|
s32 Open(OrbisAudioOutPort type, u32 samples_num, u32 freq, OrbisAudioOutParamFormat format);
|
||||||
|
s32 Output(s32 handle, const void* ptr);
|
||||||
|
s32 SetVolume(s32 handle, s32 bitflag, s32* volume);
|
||||||
|
|
||||||
|
constexpr std::pair<OrbisAudioOutPort, int> GetStatus(s32 handle) const {
|
||||||
|
const auto& port = ports_out.at(handle - 1);
|
||||||
|
return std::make_pair(port.type, port.channels_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PortOut {
|
||||||
|
SDL_AudioStream* stream;
|
||||||
|
u32 samples_num;
|
||||||
|
u32 freq;
|
||||||
|
OrbisAudioOutParamFormat format;
|
||||||
|
OrbisAudioOutPort type;
|
||||||
|
int channels_num;
|
||||||
|
std::array<int, 8> volume;
|
||||||
|
u8 sample_size;
|
||||||
|
bool is_open;
|
||||||
|
};
|
||||||
|
std::shared_mutex m_mutex;
|
||||||
|
std::array<PortOut, Libraries::AudioOut::SCE_AUDIO_OUT_NUM_PORTS> ports_out{};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Libraries::AudioOut
|
@ -1,19 +1,15 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "audio3d.h"
|
|
||||||
#include "audio3d_error.h"
|
|
||||||
#include "audio3d_impl.h"
|
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/audio/audioout.h"
|
#include "core/libraries/audio/audioout.h"
|
||||||
|
#include "core/libraries/audio3d/audio3d.h"
|
||||||
|
#include "core/libraries/audio3d/audio3d_error.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::Audio3d {
|
namespace Libraries::Audio3d {
|
||||||
|
|
||||||
// Audio3d
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dInitialize(s64 iReserved) {
|
int PS4_SYSV_ABI sceAudio3dInitialize(s64 iReserved) {
|
||||||
LOG_INFO(Lib_Audio3d, "iReserved = {}", iReserved);
|
LOG_INFO(Lib_Audio3d, "iReserved = {}", iReserved);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -25,18 +21,19 @@ int PS4_SYSV_ABI sceAudio3dTerminate() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters) {
|
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* parameters) {
|
||||||
if (sParameters != NULL) {
|
if (parameters == nullptr) {
|
||||||
sParameters->szSizeThis = sizeof(OrbisAudio3dOpenParameters);
|
|
||||||
sParameters->uiGranularity = 256;
|
|
||||||
sParameters->eRate = ORBIS_AUDIO3D_RATE_48000;
|
|
||||||
sParameters->uiMaxObjects = 512;
|
|
||||||
sParameters->uiQueueDepth = 2;
|
|
||||||
sParameters->eBufferMode = ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH;
|
|
||||||
sParameters->uiNumBeds = 2;
|
|
||||||
} else {
|
|
||||||
LOG_ERROR(Lib_Audio3d, "Invalid OpenParameters ptr");
|
LOG_ERROR(Lib_Audio3d, "Invalid OpenParameters ptr");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameters->size_this = sizeof(OrbisAudio3dOpenParameters);
|
||||||
|
parameters->granularity = 256;
|
||||||
|
parameters->rate = OrbisAudio3dRate::Rate48000;
|
||||||
|
parameters->max_objects = 512;
|
||||||
|
parameters->queue_depth = 2;
|
||||||
|
parameters->buffer_mode = OrbisAudio3dBufferMode::AdvanceAndPush;
|
||||||
|
parameters->num_beds = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dPortOpen(OrbisUserServiceUserId iUserId,
|
int PS4_SYSV_ABI sceAudio3dPortOpen(OrbisUserServiceUserId iUserId,
|
||||||
@ -76,13 +73,13 @@ int PS4_SYSV_ABI sceAudio3dPortPush(OrbisAudio3dPortId uiPortId, OrbisAudio3dBlo
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported(OrbisAudio3dPortId uiPortId,
|
int PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported(OrbisAudio3dPortId uiPortId,
|
||||||
OrbisAudio3dAttributeId* pCapabilities,
|
OrbisAudio3dAttributeId* pCapabilities,
|
||||||
unsigned int* pNumCapabilities) {
|
u32* pNumCapabilities) {
|
||||||
LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId);
|
LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId uiPortId, unsigned int* pQueueLevel,
|
int PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId uiPortId, u32* pQueueLevel,
|
||||||
unsigned int* pQueueAvailable) {
|
u32* pQueueAvailable) {
|
||||||
LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId);
|
LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -107,24 +104,24 @@ int PS4_SYSV_ABI sceAudio3dObjectSetAttributes(OrbisAudio3dPortId uiPortId,
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId uiPortId, unsigned int uiNumChannels,
|
int PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId uiPortId, u32 uiNumChannels,
|
||||||
OrbisAudio3dFormat eFormat, const void* pBuffer,
|
OrbisAudio3dFormat eFormat, const void* pBuffer,
|
||||||
unsigned int uiNumSamples) {
|
u32 uiNumSamples) {
|
||||||
LOG_TRACE(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}", uiPortId,
|
LOG_TRACE(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}", uiPortId,
|
||||||
uiNumChannels, uiNumSamples);
|
uiNumChannels, uiNumSamples);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId uiPortId, unsigned int uiNumChannels,
|
int PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId uiPortId, u32 uiNumChannels,
|
||||||
OrbisAudio3dFormat eFormat, const void* pBuffer,
|
OrbisAudio3dFormat eFormat, const void* pBuffer,
|
||||||
unsigned int uiNumSamples,
|
u32 uiNumSamples, OrbisAudio3dOutputRoute eOutputRoute,
|
||||||
OrbisAudio3dOutputRoute eOutputRoute, bool bRestricted) {
|
bool bRestricted) {
|
||||||
LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}, bRestricted = {}",
|
LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}, bRestricted = {}",
|
||||||
uiPortId, uiNumChannels, uiNumSamples, bRestricted);
|
uiPortId, uiNumChannels, uiNumSamples, bRestricted);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(unsigned int uiNumSpeakers, bool bIs3d) {
|
size_t PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(u32 uiNumSpeakers, bool bIs3d) {
|
||||||
LOG_INFO(Lib_Audio3d, "uiNumSpeakers = {}, bIs3d = {}", uiNumSpeakers, bIs3d);
|
LOG_INFO(Lib_Audio3d, "uiNumSpeakers = {}, bIs3d = {}", uiNumSpeakers, bIs3d);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -152,7 +149,7 @@ int PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray(OrbisAudio3dSpeakerArrayHandle han
|
|||||||
int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArrayHandle handle,
|
int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArrayHandle handle,
|
||||||
OrbisAudio3dPosition pos, float fSpread,
|
OrbisAudio3dPosition pos, float fSpread,
|
||||||
float* pCoefficients,
|
float* pCoefficients,
|
||||||
unsigned int uiNumCoefficients) {
|
u32 uiNumCoefficients) {
|
||||||
LOG_INFO(Lib_Audio3d, "fSpread = {}, uiNumCoefficients = {}", fSpread, uiNumCoefficients);
|
LOG_INFO(Lib_Audio3d, "fSpread = {}, uiNumCoefficients = {}", fSpread, uiNumCoefficients);
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle");
|
LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle");
|
||||||
@ -164,8 +161,7 @@ int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArr
|
|||||||
int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2(OrbisAudio3dSpeakerArrayHandle handle,
|
int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2(OrbisAudio3dSpeakerArrayHandle handle,
|
||||||
OrbisAudio3dPosition pos, float fSpread,
|
OrbisAudio3dPosition pos, float fSpread,
|
||||||
float* pCoefficients,
|
float* pCoefficients,
|
||||||
unsigned int uiNumCoefficients,
|
u32 uiNumCoefficients, bool bHeightAware,
|
||||||
bool bHeightAware,
|
|
||||||
float fDownmixSpreadRadius) {
|
float fDownmixSpreadRadius) {
|
||||||
LOG_INFO(Lib_Audio3d,
|
LOG_INFO(Lib_Audio3d,
|
||||||
"fSpread = {}, uiNumCoefficients = {}, bHeightAware = {}, fDownmixSpreadRadius = {}",
|
"fSpread = {}, uiNumCoefficients = {}, bHeightAware = {}, fDownmixSpreadRadius = {}",
|
||||||
@ -209,8 +205,8 @@ s32 PS4_SYSV_ABI sceAudio3dAudioOutOutputs(::Libraries::AudioOut::OrbisAudioOutO
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudio3dPortCreate(unsigned int uiGranularity, OrbisAudio3dRate eRate,
|
int PS4_SYSV_ABI sceAudio3dPortCreate(u32 uiGranularity, OrbisAudio3dRate eRate, s64 iReserved,
|
||||||
s64 iReserved, OrbisAudio3dPortId* pId) {
|
OrbisAudio3dPortId* pId) {
|
||||||
LOG_INFO(Lib_Audio3d, "uiGranularity = {}, iReserved = {}", uiGranularity, iReserved);
|
LOG_INFO(Lib_Audio3d, "uiGranularity = {}, iReserved = {}", uiGranularity, iReserved);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -341,4 +337,4 @@ void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym) {
|
|||||||
sceAudio3dSetGpuRenderer);
|
sceAudio3dSetGpuRenderer);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Libraries::Audio3d
|
} // namespace Libraries::Audio3d
|
||||||
|
@ -15,56 +15,57 @@ namespace Libraries::Audio3d {
|
|||||||
|
|
||||||
class Audio3d;
|
class Audio3d;
|
||||||
|
|
||||||
typedef int OrbisUserServiceUserId;
|
using OrbisUserServiceUserId = s32;
|
||||||
typedef unsigned int OrbisAudio3dPortId;
|
using OrbisAudio3dPortId = u32;
|
||||||
typedef unsigned int OrbisAudio3dObjectId;
|
using OrbisAudio3dObjectId = u32;
|
||||||
typedef unsigned int OrbisAudio3dAttributeId;
|
using OrbisAudio3dAttributeId = u32;
|
||||||
|
|
||||||
enum OrbisAudio3dFormat {
|
enum class OrbisAudio3dFormat {
|
||||||
ORBIS_AUDIO3D_FORMAT_S16 = 0, // s16
|
S16 = 0,
|
||||||
ORBIS_AUDIO3D_FORMAT_FLOAT = 1 // f32
|
Float = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudio3dRate { ORBIS_AUDIO3D_RATE_48000 = 0 };
|
enum class OrbisAudio3dRate {
|
||||||
|
Rate48000 = 0,
|
||||||
enum OrbisAudio3dBufferMode {
|
|
||||||
ORBIS_AUDIO3D_BUFFER_NO_ADVANCE = 0,
|
|
||||||
ORBIS_AUDIO3D_BUFFER_ADVANCE_NO_PUSH = 1,
|
|
||||||
ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH = 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudio3dBlocking { ORBIS_AUDIO3D_BLOCKING_ASYNC = 0, ORBIS_AUDIO3D_BLOCKING_SYNC = 1 };
|
enum class OrbisAudio3dBufferMode { NoAdvance = 0, AdvanceNoPush = 1, AdvanceAndPush = 2 };
|
||||||
|
|
||||||
enum OrbisAudio3dPassthrough {
|
enum class OrbisAudio3dBlocking {
|
||||||
ORBIS_AUDIO3D_PASSTHROUGH_NONE = 0,
|
Async = 0,
|
||||||
ORBIS_AUDIO3D_PASSTHROUGH_LEFT = 1,
|
Sync = 1,
|
||||||
ORBIS_AUDIO3D_PASSTHROUGH_RIGHT = 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudio3dOutputRoute {
|
enum class OrbisAudio3dPassthrough {
|
||||||
ORBIS_AUDIO3D_OUTPUT_BOTH = 0,
|
None = 0,
|
||||||
ORBIS_AUDIO3D_OUTPUT_HMU_ONLY = 1,
|
Left = 1,
|
||||||
ORBIS_AUDIO3D_OUTPUT_TV_ONLY = 2
|
Right = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudio3dAmbisonics {
|
enum class OrbisAudio3dOutputRoute {
|
||||||
ORBIS_AUDIO3D_AMBISONICS_NONE = ~0,
|
Both = 0,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_W = 0,
|
HmuOnly = 1,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_X = 1,
|
TvOnly = 2,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_Y = 2,
|
};
|
||||||
ORBIS_AUDIO3D_AMBISONICS_Z = 3,
|
|
||||||
ORBIS_AUDIO3D_AMBISONICS_R = 4,
|
enum class OrbisAudio3dAmbisonics : u32 {
|
||||||
ORBIS_AUDIO3D_AMBISONICS_S = 5,
|
None = ~0U,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_T = 6,
|
W = 0,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_U = 7,
|
X = 1,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_V = 8,
|
Y = 2,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_K = 9,
|
Z = 3,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_L = 10,
|
R = 4,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_M = 11,
|
S = 5,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_N = 12,
|
T = 6,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_O = 13,
|
U = 7,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_P = 14,
|
V = 8,
|
||||||
ORBIS_AUDIO3D_AMBISONICS_Q = 15
|
K = 9,
|
||||||
|
L = 10,
|
||||||
|
M = 11,
|
||||||
|
N = 12,
|
||||||
|
O = 13,
|
||||||
|
P = 14,
|
||||||
|
Q = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
static const OrbisAudio3dAttributeId s_sceAudio3dAttributePcm = 0x00000001;
|
static const OrbisAudio3dAttributeId s_sceAudio3dAttributePcm = 0x00000001;
|
||||||
@ -86,21 +87,21 @@ struct OrbisAudio3dSpeakerArray;
|
|||||||
using OrbisAudio3dSpeakerArrayHandle = OrbisAudio3dSpeakerArray*; // head
|
using OrbisAudio3dSpeakerArrayHandle = OrbisAudio3dSpeakerArray*; // head
|
||||||
|
|
||||||
struct OrbisAudio3dOpenParameters {
|
struct OrbisAudio3dOpenParameters {
|
||||||
size_t szSizeThis;
|
size_t size_this;
|
||||||
unsigned int uiGranularity;
|
u32 granularity;
|
||||||
OrbisAudio3dRate eRate;
|
OrbisAudio3dRate rate;
|
||||||
unsigned int uiMaxObjects;
|
u32 max_objects;
|
||||||
unsigned int uiQueueDepth;
|
u32 queue_depth;
|
||||||
OrbisAudio3dBufferMode eBufferMode;
|
OrbisAudio3dBufferMode buffer_mode;
|
||||||
char padding[32];
|
char padding[32];
|
||||||
unsigned int uiNumBeds;
|
u32 num_beds;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAudio3dAttribute {
|
struct OrbisAudio3dAttribute {
|
||||||
OrbisAudio3dAttributeId uiAttributeId;
|
OrbisAudio3dAttributeId attribute_id;
|
||||||
char padding[32];
|
char padding[32];
|
||||||
const void* pValue;
|
const void* p_value;
|
||||||
size_t szValue;
|
size_t value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAudio3dPosition {
|
struct OrbisAudio3dPosition {
|
||||||
@ -110,25 +111,25 @@ struct OrbisAudio3dPosition {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAudio3dPcm {
|
struct OrbisAudio3dPcm {
|
||||||
OrbisAudio3dFormat eFormat;
|
OrbisAudio3dFormat format;
|
||||||
const void* pSampleBuffer;
|
const void* sample_buffer;
|
||||||
unsigned int uiNumSamples;
|
u32 num_samples;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAudio3dSpeakerArrayParameters {
|
struct OrbisAudio3dSpeakerArrayParameters {
|
||||||
OrbisAudio3dPosition* pSpeakerPosition;
|
OrbisAudio3dPosition* speaker_position;
|
||||||
unsigned int uiNumSpeakers;
|
u32 num_speakers;
|
||||||
bool bIs3d;
|
bool is_3d;
|
||||||
void* pBuffer;
|
void* buffer;
|
||||||
size_t szSize;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAudio3dApplicationSpecific {
|
struct OrbisAudio3dApplicationSpecific {
|
||||||
size_t szSizeThis;
|
size_t size_this;
|
||||||
u8 cApplicationSpecific[32];
|
u8 application_specific[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters);
|
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters);
|
||||||
|
|
||||||
void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Audio3d
|
} // namespace Libraries::Audio3d
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
constexpr int ORBIS_AUDIO3D_ERROR_UNKNOWN = 0x80EA0001;
|
constexpr int ORBIS_AUDIO3D_ERROR_UNKNOWN = 0x80EA0001;
|
||||||
constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PORT = 0x80EA0002;
|
constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PORT = 0x80EA0002;
|
||||||
constexpr int ORBIS_AUDIO3D_ERROR_INVALID_OBJECT = 0x80EA0003;
|
constexpr int ORBIS_AUDIO3D_ERROR_INVALID_OBJECT = 0x80EA0003;
|
||||||
|
@ -10,7 +10,7 @@ namespace Libraries::Audio3d {
|
|||||||
class Audio3d {
|
class Audio3d {
|
||||||
public:
|
public:
|
||||||
private:
|
private:
|
||||||
typedef unsigned int OrbisAudio3dPluginId;
|
using OrbisAudio3dPluginId = u32;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Libraries::Audio3d
|
} // namespace Libraries::Audio3d
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/avplayer/avplayer.h"
|
#include "core/libraries/avplayer/avplayer.h"
|
||||||
|
#include "core/libraries/avplayer/avplayer_error.h"
|
||||||
#include "core/libraries/avplayer/avplayer_impl.h"
|
#include "core/libraries/avplayer/avplayer_impl.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::AvPlayer {
|
namespace Libraries::AvPlayer {
|
||||||
|
@ -18,17 +18,26 @@ class AvPlayer;
|
|||||||
|
|
||||||
using SceAvPlayerHandle = AvPlayer*;
|
using SceAvPlayerHandle = AvPlayer*;
|
||||||
|
|
||||||
enum SceAvPlayerUriType { SCE_AVPLAYER_URI_TYPE_SOURCE = 0 };
|
enum class SceAvPlayerUriType : u32 {
|
||||||
|
Source = 0,
|
||||||
|
};
|
||||||
|
|
||||||
struct SceAvPlayerUri {
|
struct SceAvPlayerUri {
|
||||||
const char* name;
|
const char* name;
|
||||||
u32 length;
|
u32 length;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SceAvPlayerSourceType {
|
enum class SceAvPlayerSourceType {
|
||||||
SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN = 0,
|
Unknown = 0,
|
||||||
SCE_AVPLAYER_SOURCE_TYPE_FILE_MP4 = 1,
|
FileMp4 = 1,
|
||||||
SCE_AVPLAYER_SOURCE_TYPE_HLS = 8
|
Hls = 8,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class SceAvPlayerStreamType : u32 {
|
||||||
|
Video,
|
||||||
|
Audio,
|
||||||
|
TimedText,
|
||||||
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceAvPlayerSourceDetails {
|
struct SceAvPlayerSourceDetails {
|
||||||
@ -50,7 +59,7 @@ struct SceAvPlayerVideo {
|
|||||||
u32 width;
|
u32 width;
|
||||||
u32 height;
|
u32 height;
|
||||||
f32 aspect_ratio;
|
f32 aspect_ratio;
|
||||||
u8 language_code[4];
|
char language_code[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceAvPlayerTextPosition {
|
struct SceAvPlayerTextPosition {
|
||||||
@ -82,7 +91,7 @@ struct SceAvPlayerFrameInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct SceAvPlayerStreamInfo {
|
struct SceAvPlayerStreamInfo {
|
||||||
u32 type;
|
SceAvPlayerStreamType type;
|
||||||
u8 reserved[4];
|
u8 reserved[4];
|
||||||
SceAvPlayerStreamDetails details;
|
SceAvPlayerStreamDetails details;
|
||||||
u64 duration;
|
u64 duration;
|
||||||
@ -135,10 +144,10 @@ struct SceAvPlayerFrameInfoEx {
|
|||||||
SceAvPlayerStreamDetailsEx details;
|
SceAvPlayerStreamDetailsEx details;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void* PS4_SYSV_ABI (*SceAvPlayerAllocate)(void* p, u32 align, u32 size);
|
using SceAvPlayerAllocate = void* PS4_SYSV_ABI (*)(void* p, u32 align, u32 size);
|
||||||
typedef void PS4_SYSV_ABI (*SceAvPlayerDeallocate)(void* p, void* mem);
|
using SceAvPlayerDeallocate = void PS4_SYSV_ABI (*)(void* p, void* mem);
|
||||||
typedef void* PS4_SYSV_ABI (*SceAvPlayerAllocateTexture)(void* p, u32 align, u32 size);
|
using SceAvPlayerAllocateTexture = void* PS4_SYSV_ABI (*)(void* p, u32 align, u32 size);
|
||||||
typedef void PS4_SYSV_ABI (*SceAvPlayerDeallocateTexture)(void* p, void* mem);
|
using SceAvPlayerDeallocateTexture = void PS4_SYSV_ABI (*)(void* p, void* mem);
|
||||||
|
|
||||||
struct SceAvPlayerMemAllocator {
|
struct SceAvPlayerMemAllocator {
|
||||||
void* object_ptr;
|
void* object_ptr;
|
||||||
@ -148,10 +157,10 @@ struct SceAvPlayerMemAllocator {
|
|||||||
SceAvPlayerDeallocateTexture deallocate_texture;
|
SceAvPlayerDeallocateTexture deallocate_texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef s32 PS4_SYSV_ABI (*SceAvPlayerOpenFile)(void* p, const char* name);
|
using SceAvPlayerOpenFile = s32 PS4_SYSV_ABI (*)(void* p, const char* name);
|
||||||
typedef s32 PS4_SYSV_ABI (*SceAvPlayerCloseFile)(void* p);
|
using SceAvPlayerCloseFile = s32 PS4_SYSV_ABI (*)(void* p);
|
||||||
typedef s32 PS4_SYSV_ABI (*SceAvPlayerReadOffsetFile)(void* p, u8* buf, u64 pos, u32 len);
|
using SceAvPlayerReadOffsetFile = s32 PS4_SYSV_ABI (*)(void* p, u8* buf, u64 pos, u32 len);
|
||||||
typedef u64 PS4_SYSV_ABI (*SceAvPlayerSizeFile)(void* p);
|
using SceAvPlayerSizeFile = u64 PS4_SYSV_ABI (*)(void* p);
|
||||||
|
|
||||||
struct SceAvPlayerFileReplacement {
|
struct SceAvPlayerFileReplacement {
|
||||||
void* object_ptr;
|
void* object_ptr;
|
||||||
@ -161,31 +170,31 @@ struct SceAvPlayerFileReplacement {
|
|||||||
SceAvPlayerSizeFile size;
|
SceAvPlayerSizeFile size;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SceAvPlayerEvents {
|
enum class SceAvPlayerEvents {
|
||||||
SCE_AVPLAYER_STATE_STOP = 0x01,
|
StateStop = 0x01,
|
||||||
SCE_AVPLAYER_STATE_READY = 0x02,
|
StateReady = 0x02,
|
||||||
SCE_AVPLAYER_STATE_PLAY = 0x03,
|
StatePlay = 0x03,
|
||||||
SCE_AVPLAYER_STATE_PAUSE = 0x04,
|
StatePause = 0x04,
|
||||||
SCE_AVPLAYER_STATE_BUFFERING = 0x05,
|
StateBuffering = 0x05,
|
||||||
SCE_AVPLAYER_TIMED_TEXT_DELIVERY = 0x10,
|
TimedTextDelivery = 0x10,
|
||||||
SCE_AVPLAYER_WARNING_ID = 0x20,
|
WarningId = 0x20,
|
||||||
SCE_AVPLAYER_ENCRYPTION = 0x30,
|
Encryption = 0x30,
|
||||||
SCE_AVPLAYER_DRM_ERROR = 0x40
|
DrmError = 0x40,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void PS4_SYSV_ABI (*SceAvPlayerEventCallback)(void* p, SceAvPlayerEvents event, s32 src_id,
|
using SceAvPlayerEventCallback = void PS4_SYSV_ABI (*)(void* p, SceAvPlayerEvents event, s32 src_id,
|
||||||
void* data);
|
void* data);
|
||||||
|
|
||||||
struct SceAvPlayerEventReplacement {
|
struct SceAvPlayerEventReplacement {
|
||||||
void* object_ptr;
|
void* object_ptr;
|
||||||
SceAvPlayerEventCallback event_callback;
|
SceAvPlayerEventCallback event_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SceAvPlayerDebuglevels {
|
enum class SceAvPlayerDebuglevels {
|
||||||
SCE_AVPLAYER_DBG_NONE,
|
None,
|
||||||
SCE_AVPLAYER_DBG_INFO,
|
Info,
|
||||||
SCE_AVPLAYER_DBG_WARNINGS,
|
Warnings,
|
||||||
SCE_AVPLAYER_DBG_ALL
|
All,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceAvPlayerInitData {
|
struct SceAvPlayerInitData {
|
||||||
@ -224,24 +233,17 @@ struct SceAvPlayerInitDataEx {
|
|||||||
u8 reserved[3];
|
u8 reserved[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SceAvPlayerStreamType {
|
enum class SceAvPlayerVideoDecoderType {
|
||||||
SCE_AVPLAYER_VIDEO,
|
Default = 0,
|
||||||
SCE_AVPLAYER_AUDIO,
|
Reserved1,
|
||||||
SCE_AVPLAYER_TIMEDTEXT,
|
Software,
|
||||||
SCE_AVPLAYER_UNKNOWN
|
Software2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SceAvPlayerVideoDecoderType {
|
enum class SceAvPlayerAudioDecoderType {
|
||||||
SCE_AVPLAYER_VIDEO_DECODER_TYPE_DEFAULT = 0,
|
Default = 0,
|
||||||
SCE_AVPLAYER_VIDEO_DECODER_TYPE_RESERVED1,
|
Reserved1,
|
||||||
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE,
|
Reserved2,
|
||||||
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SceAvPlayerAudioDecoderType {
|
|
||||||
SCE_AVPLAYER_AUDIO_DECODER_TYPE_DEFAULT = 0,
|
|
||||||
SCE_AVPLAYER_AUDIO_DECODER_TYPE_RESERVED1,
|
|
||||||
SCE_AVPLAYER_AUDIO_DECODER_TYPE_RESERVED2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceAvPlayerDecoderInit {
|
struct SceAvPlayerDecoderInit {
|
||||||
@ -281,12 +283,12 @@ struct SceAvPlayerPostInitData {
|
|||||||
u8 reserved[56];
|
u8 reserved[56];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SceAvPlayerAvSyncMode {
|
enum class SceAvPlayerAvSyncMode {
|
||||||
SCE_AVPLAYER_AV_SYNC_MODE_DEFAULT = 0,
|
Default = 0,
|
||||||
SCE_AVPLAYER_AV_SYNC_MODE_NONE
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int PS4_SYSV_ABI (*SceAvPlayerLogCallback)(void* p, const char* format, va_list args);
|
using SceAvPlayerLogCallback = int PS4_SYSV_ABI (*)(void* p, const char* format, va_list args);
|
||||||
|
|
||||||
void RegisterlibSceAvPlayer(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceAvPlayer(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ static bool iequals(std::string_view l, std::string_view r) {
|
|||||||
|
|
||||||
SceAvPlayerSourceType GetSourceType(std::string_view path) {
|
SceAvPlayerSourceType GetSourceType(std::string_view path) {
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
|
return SceAvPlayerSourceType::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view name = path;
|
std::string_view name = path;
|
||||||
@ -25,14 +25,14 @@ SceAvPlayerSourceType GetSourceType(std::string_view path) {
|
|||||||
// -> schema://server.domain/path/to/file.ext/and/beyond
|
// -> schema://server.domain/path/to/file.ext/and/beyond
|
||||||
name = path.substr(0, path.find_first_of("?#"));
|
name = path.substr(0, path.find_first_of("?#"));
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
|
return SceAvPlayerSourceType::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// schema://server.domain/path/to/file.ext/and/beyond -> .ext/and/beyond
|
// schema://server.domain/path/to/file.ext/and/beyond -> .ext/and/beyond
|
||||||
auto ext = name.substr(name.rfind('.'));
|
auto ext = name.substr(name.rfind('.'));
|
||||||
if (ext.empty()) {
|
if (ext.empty()) {
|
||||||
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
|
return SceAvPlayerSourceType::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
// .ext/and/beyond -> .ext
|
// .ext/and/beyond -> .ext
|
||||||
@ -40,14 +40,14 @@ SceAvPlayerSourceType GetSourceType(std::string_view path) {
|
|||||||
|
|
||||||
if (iequals(ext, ".mp4") || iequals(ext, ".m4v") || iequals(ext, ".m3d") ||
|
if (iequals(ext, ".mp4") || iequals(ext, ".m4v") || iequals(ext, ".m3d") ||
|
||||||
iequals(ext, ".m4a") || iequals(ext, ".mov")) {
|
iequals(ext, ".m4a") || iequals(ext, ".mov")) {
|
||||||
return SCE_AVPLAYER_SOURCE_TYPE_FILE_MP4;
|
return SceAvPlayerSourceType::FileMp4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iequals(ext, ".m3u8")) {
|
if (iequals(ext, ".m3u8")) {
|
||||||
return SCE_AVPLAYER_SOURCE_TYPE_HLS;
|
return SceAvPlayerSourceType::Hls;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
|
return SceAvPlayerSourceType::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries::AvPlayer
|
} // namespace Libraries::AvPlayer
|
||||||
|
19
src/core/libraries/avplayer/avplayer_error.h
Normal file
19
src/core/libraries/avplayer/avplayer_error.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// AvPlayer library
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_INVALID_PARAMS = 0x806A0001;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_OPERATION_FAILED = 0x806A0002;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_NO_MEMORY = 0x806A0003;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_NOT_SUPPORTED = 0x806A0004;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_WAR_FILE_NONINTERLEAVED = 0x806A00A0;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_WAR_LOOPING_BACK = 0x806A00A1;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_WAR_JUMP_COMPLETE = 0x806A00A3;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_INFO_MARLIN_ENCRY = 0x806A00B0;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_INFO_PLAYREADY_ENCRY = 0x806A00B4;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_INFO_AES_ENCRY = 0x806A00B5;
|
||||||
|
constexpr int ORBIS_AVPLAYER_ERROR_INFO_OTHER_ENCRY = 0x806A00BF;
|
@ -2,8 +2,8 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/libraries/avplayer/avplayer_common.h"
|
#include "core/libraries/avplayer/avplayer_common.h"
|
||||||
|
#include "core/libraries/avplayer/avplayer_error.h"
|
||||||
#include "core/libraries/avplayer/avplayer_impl.h"
|
#include "core/libraries/avplayer/avplayer_impl.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/tls.h"
|
#include "core/tls.h"
|
||||||
|
|
||||||
namespace Libraries::AvPlayer {
|
namespace Libraries::AvPlayer {
|
||||||
|
@ -85,17 +85,17 @@ s32 AvPlayerSource::GetStreamCount() {
|
|||||||
return m_avformat_context->nb_streams;
|
return m_avformat_context->nb_streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32 CodecTypeToStreamType(AVMediaType codec_type) {
|
static SceAvPlayerStreamType CodecTypeToStreamType(AVMediaType codec_type) {
|
||||||
switch (codec_type) {
|
switch (codec_type) {
|
||||||
case AVMediaType::AVMEDIA_TYPE_VIDEO:
|
case AVMediaType::AVMEDIA_TYPE_VIDEO:
|
||||||
return SCE_AVPLAYER_VIDEO;
|
return SceAvPlayerStreamType::Video;
|
||||||
case AVMediaType::AVMEDIA_TYPE_AUDIO:
|
case AVMediaType::AVMEDIA_TYPE_AUDIO:
|
||||||
return SCE_AVPLAYER_AUDIO;
|
return SceAvPlayerStreamType::Audio;
|
||||||
case AVMediaType::AVMEDIA_TYPE_SUBTITLE:
|
case AVMediaType::AVMEDIA_TYPE_SUBTITLE:
|
||||||
return SCE_AVPLAYER_TIMEDTEXT;
|
return SceAvPlayerStreamType::TimedText;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Lib_AvPlayer, "Unexpected AVMediaType {}", magic_enum::enum_name(codec_type));
|
LOG_ERROR(Lib_AvPlayer, "Unexpected AVMediaType {}", magic_enum::enum_name(codec_type));
|
||||||
return -1;
|
return SceAvPlayerStreamType::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
|
|||||||
LOG_WARNING(Lib_AvPlayer, "Stream {} language is unknown", stream_index);
|
LOG_WARNING(Lib_AvPlayer, "Stream {} language is unknown", stream_index);
|
||||||
}
|
}
|
||||||
switch (info.type) {
|
switch (info.type) {
|
||||||
case SCE_AVPLAYER_VIDEO: {
|
case SceAvPlayerStreamType::Video: {
|
||||||
LOG_INFO(Lib_AvPlayer, "Stream {} is a video stream.", stream_index);
|
LOG_INFO(Lib_AvPlayer, "Stream {} is a video stream.", stream_index);
|
||||||
info.details.video.aspect_ratio =
|
info.details.video.aspect_ratio =
|
||||||
f32(p_stream->codecpar->width) / p_stream->codecpar->height;
|
f32(p_stream->codecpar->width) / p_stream->codecpar->height;
|
||||||
@ -142,7 +142,7 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCE_AVPLAYER_AUDIO: {
|
case SceAvPlayerStreamType::Audio: {
|
||||||
LOG_INFO(Lib_AvPlayer, "Stream {} is an audio stream.", stream_index);
|
LOG_INFO(Lib_AvPlayer, "Stream {} is an audio stream.", stream_index);
|
||||||
info.details.audio.channel_count = p_stream->codecpar->ch_layout.nb_channels;
|
info.details.audio.channel_count = p_stream->codecpar->ch_layout.nb_channels;
|
||||||
info.details.audio.sample_rate = p_stream->codecpar->sample_rate;
|
info.details.audio.sample_rate = p_stream->codecpar->sample_rate;
|
||||||
@ -153,7 +153,7 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCE_AVPLAYER_TIMEDTEXT: {
|
case SceAvPlayerStreamType::TimedText: {
|
||||||
LOG_WARNING(Lib_AvPlayer, "Stream {} is a timedtext stream.", stream_index);
|
LOG_WARNING(Lib_AvPlayer, "Stream {} is a timedtext stream.", stream_index);
|
||||||
info.details.subs.font_size = 12;
|
info.details.subs.font_size = 12;
|
||||||
info.details.subs.text_size = 12;
|
info.details.subs.text_size = 12;
|
||||||
@ -164,7 +164,8 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
LOG_ERROR(Lib_AvPlayer, "Stream {} type is unknown: {}.", stream_index, info.type);
|
LOG_ERROR(Lib_AvPlayer, "Stream {} type is unknown: {}.", stream_index,
|
||||||
|
magic_enum::enum_name(info.type));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
|
#include "core/libraries/avplayer/avplayer_error.h"
|
||||||
#include "core/libraries/avplayer/avplayer_source.h"
|
#include "core/libraries/avplayer/avplayer_source.h"
|
||||||
#include "core/libraries/avplayer/avplayer_state.h"
|
#include "core/libraries/avplayer/avplayer_state.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/tls.h"
|
#include "core/tls.h"
|
||||||
|
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
@ -16,7 +16,7 @@ void PS4_SYSV_ABI AvPlayerState::AutoPlayEventCallback(void* opaque, SceAvPlayer
|
|||||||
s32 source_id, void* event_data) {
|
s32 source_id, void* event_data) {
|
||||||
auto const self = reinterpret_cast<AvPlayerState*>(opaque);
|
auto const self = reinterpret_cast<AvPlayerState*>(opaque);
|
||||||
|
|
||||||
if (event_id == SCE_AVPLAYER_STATE_READY) {
|
if (event_id == SceAvPlayerEvents::StateReady) {
|
||||||
s32 video_stream_index = -1;
|
s32 video_stream_index = -1;
|
||||||
s32 audio_stream_index = -1;
|
s32 audio_stream_index = -1;
|
||||||
s32 timedtext_stream_index = -1;
|
s32 timedtext_stream_index = -1;
|
||||||
@ -36,36 +36,37 @@ void PS4_SYSV_ABI AvPlayerState::AutoPlayEventCallback(void* opaque, SceAvPlayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string_view default_language(
|
const std::string_view default_language{self->m_default_language};
|
||||||
reinterpret_cast<char*>(self->m_default_language));
|
|
||||||
switch (info.type) {
|
switch (info.type) {
|
||||||
case SCE_AVPLAYER_VIDEO:
|
case SceAvPlayerStreamType::Video:
|
||||||
if (video_stream_index == -1) {
|
if (video_stream_index == -1) {
|
||||||
video_stream_index = stream_index;
|
video_stream_index = stream_index;
|
||||||
}
|
}
|
||||||
if (!default_language.empty() &&
|
if (!default_language.empty() &&
|
||||||
default_language == reinterpret_cast<char*>(info.details.video.language_code)) {
|
default_language == info.details.video.language_code) {
|
||||||
video_stream_index = stream_index;
|
video_stream_index = stream_index;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCE_AVPLAYER_AUDIO:
|
case SceAvPlayerStreamType::Audio:
|
||||||
if (audio_stream_index == -1) {
|
if (audio_stream_index == -1) {
|
||||||
audio_stream_index = stream_index;
|
audio_stream_index = stream_index;
|
||||||
}
|
}
|
||||||
if (!default_language.empty() &&
|
if (!default_language.empty() &&
|
||||||
default_language == reinterpret_cast<char*>(info.details.video.language_code)) {
|
default_language == info.details.video.language_code) {
|
||||||
audio_stream_index = stream_index;
|
audio_stream_index = stream_index;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCE_AVPLAYER_TIMEDTEXT:
|
case SceAvPlayerStreamType::TimedText:
|
||||||
if (default_language.empty()) {
|
if (default_language.empty()) {
|
||||||
timedtext_stream_index = stream_index;
|
timedtext_stream_index = stream_index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (default_language == reinterpret_cast<char*>(info.details.video.language_code)) {
|
if (default_language == info.details.video.language_code) {
|
||||||
timedtext_stream_index = stream_index;
|
timedtext_stream_index = stream_index;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ bool AvPlayerState::AddSource(std::string_view path, SceAvPlayerSourceType sourc
|
|||||||
|
|
||||||
m_up_source = std::make_unique<AvPlayerSource>(
|
m_up_source = std::make_unique<AvPlayerSource>(
|
||||||
*this, m_post_init_data.video_decoder_init.decoderType.video_type ==
|
*this, m_post_init_data.video_decoder_init.decoderType.video_type ==
|
||||||
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE2);
|
SceAvPlayerVideoDecoderType::Software2);
|
||||||
if (!m_up_source->Init(m_init_data, path)) {
|
if (!m_up_source->Init(m_init_data, path)) {
|
||||||
SetState(AvState::Error);
|
SetState(AvState::Error);
|
||||||
m_up_source.reset();
|
m_up_source.reset();
|
||||||
@ -317,23 +318,23 @@ void AvPlayerState::OnEOF() {
|
|||||||
void AvPlayerState::OnPlaybackStateChanged(AvState state) {
|
void AvPlayerState::OnPlaybackStateChanged(AvState state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AvState::Ready: {
|
case AvState::Ready: {
|
||||||
EmitEvent(SCE_AVPLAYER_STATE_READY);
|
EmitEvent(SceAvPlayerEvents::StateReady);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AvState::Play: {
|
case AvState::Play: {
|
||||||
EmitEvent(SCE_AVPLAYER_STATE_PLAY);
|
EmitEvent(SceAvPlayerEvents::StatePlay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AvState::Stop: {
|
case AvState::Stop: {
|
||||||
EmitEvent(SCE_AVPLAYER_STATE_STOP);
|
EmitEvent(SceAvPlayerEvents::StateStop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AvState::Pause: {
|
case AvState::Pause: {
|
||||||
EmitEvent(SCE_AVPLAYER_STATE_PAUSE);
|
EmitEvent(SceAvPlayerEvents::StatePause);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AvState::Buffering: {
|
case AvState::Buffering: {
|
||||||
EmitEvent(SCE_AVPLAYER_STATE_BUFFERING);
|
EmitEvent(SceAvPlayerEvents::StateBuffering);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
SceAvPlayerPostInitData m_post_init_data{};
|
SceAvPlayerPostInitData m_post_init_data{};
|
||||||
SceAvPlayerEventReplacement m_event_replacement{};
|
SceAvPlayerEventReplacement m_event_replacement{};
|
||||||
bool m_auto_start{};
|
bool m_auto_start{};
|
||||||
u8 m_default_language[4]{};
|
char m_default_language[4]{};
|
||||||
|
|
||||||
std::atomic<AvState> m_current_state;
|
std::atomic<AvState> m_current_state;
|
||||||
std::atomic<AvState> m_previous_state;
|
std::atomic<AvState> m_previous_state;
|
||||||
|
@ -3,626 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// posix error codes
|
|
||||||
constexpr int POSIX_EPERM = 1;
|
|
||||||
constexpr int POSIX_ENOENT = 2;
|
|
||||||
constexpr int POSIX_ESRCH = 3;
|
|
||||||
constexpr int POSIX_EINTR = 4;
|
|
||||||
constexpr int POSIX_EIO = 5;
|
|
||||||
constexpr int POSIX_ENXIO = 6;
|
|
||||||
constexpr int POSIX_E2BIG = 7;
|
|
||||||
constexpr int POSIX_ENOEXEC = 8;
|
|
||||||
constexpr int POSIX_EBADF = 9;
|
|
||||||
constexpr int POSIX_ECHILD = 10;
|
|
||||||
constexpr int POSIX_EDEADLK = 11;
|
|
||||||
constexpr int POSIX_ENOMEM = 12;
|
|
||||||
constexpr int POSIX_EACCES = 13;
|
|
||||||
constexpr int POSIX_EFAULT = 14;
|
|
||||||
constexpr int POSIX_ENOTBLK = 15;
|
|
||||||
constexpr int POSIX_EBUSY = 16;
|
|
||||||
constexpr int POSIX_EEXIST = 17;
|
|
||||||
constexpr int POSIX_EXDEV = 18;
|
|
||||||
constexpr int POSIX_ENODEV = 19;
|
|
||||||
constexpr int POSIX_ENOTDIR = 20;
|
|
||||||
constexpr int POSIX_EISDIR = 21;
|
|
||||||
constexpr int POSIX_EINVAL = 22;
|
|
||||||
constexpr int POSIX_ENFILE = 23;
|
|
||||||
constexpr int POSIX_EMFILE = 24;
|
|
||||||
constexpr int POSIX_ENOTTY = 25;
|
|
||||||
constexpr int POSIX_ETXTBSY = 26;
|
|
||||||
constexpr int POSIX_EFBIG = 27;
|
|
||||||
constexpr int POSIX_ENOSPC = 28;
|
|
||||||
constexpr int POSIX_ESPIPE = 29;
|
|
||||||
constexpr int POSIX_EROFS = 30;
|
|
||||||
constexpr int POSIX_EMLINK = 31;
|
|
||||||
constexpr int POSIX_EPIPE = 32;
|
|
||||||
constexpr int POSIX_EDOM = 33;
|
|
||||||
constexpr int POSIX_ERANGE = 34;
|
|
||||||
constexpr int POSIX_EAGAIN = 35;
|
|
||||||
constexpr int POSIX_EWOULDBLOCK = 35;
|
|
||||||
constexpr int POSIX_EINPROGRESS = 36;
|
|
||||||
constexpr int POSIX_EALREADY = 37;
|
|
||||||
constexpr int POSIX_ENOTSOCK = 38;
|
|
||||||
constexpr int POSIX_EDESTADDRREQ = 39;
|
|
||||||
constexpr int POSIX_EMSGSIZE = 40;
|
|
||||||
constexpr int POSIX_EPROTOTYPE = 41;
|
|
||||||
constexpr int POSIX_ENOPROTOOPT = 42;
|
|
||||||
constexpr int POSIX_EPROTONOSUPPORT = 43;
|
|
||||||
constexpr int POSIX_ESOCKTNOSUPPORT = 44;
|
|
||||||
constexpr int POSIX_EOPNOTSUPP = 45;
|
|
||||||
constexpr int POSIX_ENOTSUP = 45;
|
|
||||||
constexpr int POSIX_EPFNOSUPPORT = 46;
|
|
||||||
constexpr int POSIX_EAFNOSUPPORT = 47;
|
|
||||||
constexpr int POSIX_EADDRINUSE = 48;
|
|
||||||
constexpr int POSIX_EADDRNOTAVAIL = 49;
|
|
||||||
constexpr int POSIX_ENETDOWN = 50;
|
|
||||||
constexpr int POSIX_ENETUNREACH = 51;
|
|
||||||
constexpr int POSIX_ENETRESET = 52;
|
|
||||||
constexpr int POSIX_ECONNABORTED = 53;
|
|
||||||
constexpr int POSIX_ECONNRESET = 54;
|
|
||||||
constexpr int POSIX_ENOBUFS = 55;
|
|
||||||
constexpr int POSIX_EISCONN = 56;
|
|
||||||
constexpr int POSIX_ENOTCONN = 57;
|
|
||||||
constexpr int POSIX_ESHUTDOWN = 58;
|
|
||||||
constexpr int POSIX_ETOOMANYREFS = 59;
|
|
||||||
constexpr int POSIX_ETIMEDOUT = 60;
|
|
||||||
constexpr int POSIX_ECONNREFUSED = 61;
|
|
||||||
constexpr int POSIX_ELOOP = 62;
|
|
||||||
constexpr int POSIX_ENAMETOOLONG = 63;
|
|
||||||
constexpr int POSIX_EHOSTDOWN = 64;
|
|
||||||
constexpr int POSIX_EHOSTUNREACH = 65;
|
|
||||||
constexpr int POSIX_ENOTEMPTY = 66;
|
|
||||||
constexpr int POSIX_EPROCLIM = 67;
|
|
||||||
constexpr int POSIX_EUSERS = 68;
|
|
||||||
constexpr int POSIX_EDQUOT = 69;
|
|
||||||
constexpr int POSIX_ESTALE = 70;
|
|
||||||
constexpr int POSIX_EREMOTE = 71;
|
|
||||||
constexpr int POSIX_EBADRPC = 72;
|
|
||||||
constexpr int POSIX_ERPCMISMATCH = 73;
|
|
||||||
constexpr int POSIX_EPROGUNAVAIL = 74;
|
|
||||||
constexpr int POSIX_EPROGMISMATCH = 75;
|
|
||||||
constexpr int POSIX_EPROCUNAVAIL = 76;
|
|
||||||
constexpr int POSIX_ENOLCK = 77;
|
|
||||||
constexpr int POSIX_ENOSYS = 78;
|
|
||||||
constexpr int POSIX_EFTYPE = 79;
|
|
||||||
constexpr int POSIX_EAUTH = 80;
|
|
||||||
constexpr int POSIX_ENEEDAUTH = 81;
|
|
||||||
constexpr int POSIX_EIDRM = 82;
|
|
||||||
constexpr int POSIX_ENOMSG = 83;
|
|
||||||
constexpr int POSIX_EOVERFLOW = 84;
|
|
||||||
constexpr int POSIX_ECANCELED = 85;
|
|
||||||
constexpr int POSIX_EILSEQ = 86;
|
|
||||||
constexpr int POSIX_ENOATTR = 87;
|
|
||||||
constexpr int POSIX_EDOOFUS = 88;
|
|
||||||
constexpr int POSIX_EBADMSG = 89;
|
|
||||||
constexpr int POSIX_EMULTIHOP = 90;
|
|
||||||
constexpr int POSIX_ENOLINK = 91;
|
|
||||||
constexpr int POSIX_EPROTO = 92;
|
|
||||||
constexpr int POSIX_ENOTCAPABLE = 93;
|
|
||||||
constexpr int POSIX_ECAPMODE = 94;
|
|
||||||
constexpr int POSIX_ENOBLK = 95;
|
|
||||||
constexpr int POSIX_EICV = 96;
|
|
||||||
constexpr int POSIX_ENOPLAYGOENT = 97;
|
|
||||||
constexpr int POSIX_EREVOKE = 98;
|
|
||||||
constexpr int POSIX_ESDKVERSION = 99;
|
|
||||||
constexpr int POSIX_ESTART = 100;
|
|
||||||
constexpr int POSIX_ESTOP = 101;
|
|
||||||
constexpr int POSIX_EINVALID2MB = 102;
|
|
||||||
constexpr int POSIX_ELAST = 102;
|
|
||||||
constexpr int POSIX_EADHOC = 160;
|
|
||||||
constexpr int POSIX_EINACTIVEDISABLED = 163;
|
|
||||||
constexpr int POSIX_ENETNODATA = 164;
|
|
||||||
constexpr int POSIX_ENETDESC = 165;
|
|
||||||
constexpr int POSIX_ENETDESCTIMEDOUT = 166;
|
|
||||||
constexpr int POSIX_ENETINTR = 167;
|
|
||||||
constexpr int POSIX_ERETURN = 205;
|
|
||||||
constexpr int POSIX_EFPOS = 152;
|
|
||||||
constexpr int POSIX_ENODATA = 1040;
|
|
||||||
constexpr int POSIX_ENOSR = 1050;
|
|
||||||
constexpr int POSIX_ENOSTR = 1051;
|
|
||||||
constexpr int POSIX_ENOTRECOVERABLE = 1056;
|
|
||||||
constexpr int POSIX_EOTHER = 1062;
|
|
||||||
constexpr int POSIX_EOWNERDEAD = 1064;
|
|
||||||
constexpr int POSIX_ETIME = 1074;
|
|
||||||
|
|
||||||
constexpr int SCE_OK = 0;
|
|
||||||
|
|
||||||
// kernel error codes
|
|
||||||
constexpr int SCE_KERNEL_ERROR_UNKNOWN = 0x80020000;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPERM = 0x80020001;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOENT = 0x80020002;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESRCH = 0x80020003;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EINTR = 0x80020004;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EIO = 0x80020005;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENXIO = 0x80020006;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_E2BIG = 0x80020007;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOEXEC = 0x80020008;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EBADF = 0x80020009;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ECHILD = 0x8002000A;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EDEADLK = 0x8002000B;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000C;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EACCES = 0x8002000D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EFAULT = 0x8002000E;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTBLK = 0x8002000F;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EBUSY = 0x80020010;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EEXIST = 0x80020011;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EXDEV = 0x80020012;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENODEV = 0x80020013;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTDIR = 0x80020014;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EISDIR = 0x80020015;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENFILE = 0x80020017;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EMFILE = 0x80020018;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTTY = 0x80020019;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ETXTBSY = 0x8002001A;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EFBIG = 0x8002001B;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOSPC = 0x8002001C;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESPIPE = 0x8002001D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EROFS = 0x8002001E;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EMLINK = 0x8002001F;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPIPE = 0x80020020;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EDOM = 0x80020021;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ERANGE = 0x80020022;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EAGAIN = 0x80020023;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EWOULDBLOCK = 0x80020023;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EINPROGRESS = 0x80020024;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EALREADY = 0x80020025;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTSOCK = 0x80020026;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EDESTADDRREQ = 0x80020027;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EMSGSIZE = 0x80020028;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROTOTYPE = 0x80020029;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOPROTOOPT = 0x8002002A;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROTONOSUPPORT = 0x8002002B;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESOCKTNOSUPPORT = 0x8002002C;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EOPNOTSUPP = 0x8002002D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTSUP = 0x8002002D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPFNOSUPPORT = 0x8002002E;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EAFNOSUPPORT = 0x8002002F;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EADDRINUSE = 0x80020030;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EADDRNOTAVAIL = 0x80020031;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENETDOWN = 0x80020032;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENETUNREACH = 0x80020033;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENETRESET = 0x80020034;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ECONNABORTED = 0x80020035;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ECONNRESET = 0x80020036;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOBUFS = 0x80020037;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EISCONN = 0x80020038;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTCONN = 0x80020039;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESHUTDOWN = 0x8002003A;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ETOOMANYREFS = 0x8002003B;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ETIMEDOUT = 0x8002003C;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ECONNREFUSED = 0x8002003D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ELOOP = 0x8002003E;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENAMETOOLONG = 0x8002003F;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EHOSTDOWN = 0x80020040;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EHOSTUNREACH = 0x80020041;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTEMPTY = 0x80020042;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROCLIM = 0x80020043;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EUSERS = 0x80020044;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EDQUOT = 0x80020045;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESTALE = 0x80020046;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EREMOTE = 0x80020047;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EBADRPC = 0x80020048;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ERPCMISMATCH = 0x80020049;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROGUNAVAIL = 0x8002004A;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROGMISMATCH = 0x8002004B;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROCUNAVAIL = 0x8002004C;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOLCK = 0x8002004D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOSYS = 0x8002004E;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EFTYPE = 0x8002004F;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EAUTH = 0x80020050;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENEEDAUTH = 0x80020051;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EIDRM = 0x80020052;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOMSG = 0x80020053;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EOVERFLOW = 0x80020054;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ECANCELED = 0x80020055;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EILSEQ = 0x80020056;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOATTR = 0x80020057;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EDOOFUS = 0x80020058;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EBADMSG = 0x80020059;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EMULTIHOP = 0x8002005A;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOLINK = 0x8002005B;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EPROTO = 0x8002005C;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOTCAPABLE = 0x8002005D;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ECAPMODE = 0x8002005E;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOBLK = 0x8002005F;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EICV = 0x80020060;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ENOPLAYGOENT = 0x80020061;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_EREVOKE = 0x80020062;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESDKVERSION = 0x80020063;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESTART = 0x80020064;
|
|
||||||
constexpr int SCE_KERNEL_ERROR_ESTOP = 0x80020065;
|
|
||||||
|
|
||||||
// videoOut
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_VALUE = 0x80290001; // invalid argument
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_ADDRESS = 0x80290002; // invalid addresses
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_TILING_MODE = 0x80290007; // invalid tiling mode
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_ASPECT_RATIO = 0x80290008; // invalid aspect ration
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_RESOURCE_BUSY = 0x80290009; // already opened
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_INDEX = 0x8029000A; // invalid buffer index
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_HANDLE = 0x8029000B; // invalid handle
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE = 0x8029000C; // Invalid event queue
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_SLOT_OCCUPIED = 0x80290010; // slot already used
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_FLIP_QUEUE_FULL = 0x80290012; // flip queue is full
|
|
||||||
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_OPTION = 0x8029001A; // Invalid buffer attribute option
|
|
||||||
|
|
||||||
// Generic
|
// Generic
|
||||||
constexpr int ORBIS_OK = 0x00000000;
|
constexpr int ORBIS_OK = 0x00000000;
|
||||||
constexpr int ORBIS_FAIL = 0xFFFFFFFF;
|
constexpr int ORBIS_FAIL = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Libkernel library
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_UNKNOWN = 0x80020000;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPERM = 0x80020001;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOENT = 0x80020002;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ESRCH = 0x80020003;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EINTR = 0x80020004;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EIO = 0x80020005;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENXIO = 0x80020006;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_E2BIG = 0x80020007;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOEXEC = 0x80020008;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EBADF = 0x80020009;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ECHILD = 0x8002000A;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EDEADLK = 0x8002000B;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOMEM = 0x8002000C;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EACCES = 0x8002000D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EFAULT = 0x8002000E;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTBLK = 0x8002000F;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EBUSY = 0x80020010;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EEXIST = 0x80020011;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EXDEV = 0x80020012;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENODEV = 0x80020013;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTDIR = 0x80020014;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EISDIR = 0x80020015;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EINVAL = 0x80020016;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENFILE = 0x80020017;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EMFILE = 0x80020018;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTTY = 0x80020019;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ETXTBSY = 0x8002001A;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EFBIG = 0x8002001B;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOSPC = 0x8002001C;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ESPIPE = 0x8002001D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EROFS = 0x8002001E;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EMLINK = 0x8002001F;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPIPE = 0x80020020;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EDOM = 0x80020021;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ERANGE = 0x80020022;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EAGAIN = 0x80020023;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EWOULDBLOCK = 0x80020023;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EINPROGRESS = 0x80020024;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EALREADY = 0x80020025;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTSOCK = 0x80020026;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EDESTADDRREQ = 0x80020027;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EMSGSIZE = 0x80020028;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROTOTYPE = 0x80020029;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOPROTOOPT = 0x8002002A;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROTONOSUPPORT = 0x8002002B;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ESOCKTNOSUPPORT = 0x8002002C;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTSUP = 0x8002002D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EOPNOTSUPP = 0x8002002D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPFNOSUPPORT = 0x8002002E;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EAFNOSUPPORT = 0x8002002F;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EADDRINUSE = 0x80020030;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EADDRNOTAVAIL = 0x80020031;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENETDOWN = 0x80020032;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENETUNREACH = 0x80020033;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENETRESET = 0x80020034;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ECONNABORTED = 0x80020035;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ECONNRESET = 0x80020036;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOBUFS = 0x80020037;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EISCONN = 0x80020038;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTCONN = 0x80020039;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ESHUTDOWN = 0x8002003A;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ETOOMANYREFS = 0x8002003B;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ETIMEDOUT = 0x8002003C;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ECONNREFUSED = 0x8002003D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ELOOP = 0x8002003E;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENAMETOOLONG = 0x8002003F;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EHOSTDOWN = 0x80020040;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EHOSTUNREACH = 0x80020041;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTEMPTY = 0x80020042;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROCLIM = 0x80020043;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EUSERS = 0x80020044;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EDQUOT = 0x80020045;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ESTALE = 0x80020046;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EREMOTE = 0x80020047;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EBADRPC = 0x80020048;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ERPCMISMATCH = 0x80020049;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROGUNAVAIL = 0x8002004A;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROGMISMATCH = 0x8002004B;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROCUNAVAIL = 0x8002004C;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOLCK = 0x8002004D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOSYS = 0x8002004E;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EFTYPE = 0x8002004F;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EAUTH = 0x80020050;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENEEDAUTH = 0x80020051;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EIDRM = 0x80020052;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOMSG = 0x80020053;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EOVERFLOW = 0x80020054;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ECANCELED = 0x80020055;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EILSEQ = 0x80020056;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOATTR = 0x80020057;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EDOOFUS = 0x80020058;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EBADMSG = 0x80020059;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EMULTIHOP = 0x8002005A;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOLINK = 0x8002005B;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EPROTO = 0x8002005C;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOTCAPABLE = 0x8002005D;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ECAPMODE = 0x8002005E;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOBLK = 0x8002005F;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_EICV = 0x80020060;
|
|
||||||
constexpr int ORBIS_KERNEL_ERROR_ENOPLAYGOENT = 0x80020061;
|
|
||||||
|
|
||||||
// AudioOut library
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_NOT_OPENED = 0x80260001;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_BUSY = 0x80260002;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_PORT = 0x80260003;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_POINTER = 0x80260004;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_PORT_FULL = 0x80260005;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_SIZE = 0x80260006;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT = 0x80260007;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_SAMPLE_FREQ = 0x80260008;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_VOLUME = 0x80260009;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_PORT_TYPE = 0x8026000A;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_CONF_TYPE = 0x8026000C;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_OUT_OF_MEMORY = 0x8026000D;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT = 0x8026000E;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_NOT_INIT = 0x8026000F;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_MEMORY = 0x80260010;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_SYSTEM_RESOURCE = 0x80260011;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_TRANS_EVENT = 0x80260012;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_FLAG = 0x80260013;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_MIXLEVEL = 0x80260014;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_ARG = 0x80260015;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_INVALID_PARAM = 0x80260016;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_FATAL = 0x80260200;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_API_PARAM = 0x80260201;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_CONFIG = 0x80260202;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_NOT_INITIALIZED = 0x80260203;
|
|
||||||
constexpr int ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_STATES_ID = 0x80260204;
|
|
||||||
|
|
||||||
// VideoOut library
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_VALUE = 0x80290001;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS = 0x80290002;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_PIXEL_FORMAT = 0x80290003;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_PITCH = 0x80290004;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_RESOLUTION = 0x80290005;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_FLIP_MODE = 0x80290006;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_TILING_MODE = 0x80290007;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_ASPECT_RATIO = 0x80290008;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_RESOURCE_BUSY = 0x80290009;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_INDEX = 0x8029000A;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE = 0x8029000B;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE = 0x8029000C;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT = 0x8029000D;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_NO_EMPTY_SLOT = 0x8029000F;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_SLOT_OCCUPIED = 0x80290010;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_FLIP_QUEUE_FULL = 0x80290012;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_MEMORY = 0x80290013;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_MEMORY_NOT_PHYSICALLY_CONTIGUOUS = 0x80290014;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_MEMORY_INVALID_ALIGNMENT = 0x80290015;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_UNSUPPORTED_OUTPUT_MODE = 0x80290016;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_OVERFLOW = 0x80290017;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_NO_DEVICE = 0x80290018;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_UNAVAILABLE_OUTPUT_MODE = 0x80290019;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_INVALID_OPTION = 0x8029001A;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_UNKNOWN = 0x802900FE;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_FATAL = 0x802900FF;
|
|
||||||
constexpr int ORBIS_VIDEO_OUT_ERROR_ENOMEM = 0x8029100C;
|
|
||||||
|
|
||||||
// Pad library
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_ARG = 0x80920001;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_PORT = 0x80920002;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_HANDLE = 0x80920003;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_ALREADY_OPENED = 0x80920004;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_NOT_INITIALIZED = 0x80920005;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_LIGHTBAR_SETTING = 0x80920006;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED = 0x80920007;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_DEVICE_NO_HANDLE = 0x80920008;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_FATAL = 0x809200FF;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_NOT_PERMITTED = 0x80920101;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_BUFFER_LENGTH = 0x80920102;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_REPORT_LENGTH = 0x80920103;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_INVALID_REPORT_ID = 0x80920104;
|
|
||||||
constexpr int ORBIS_PAD_ERROR_SEND_AGAIN = 0x80920105;
|
|
||||||
|
|
||||||
// UserService library
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_INTERNAL = 0x80960001;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_NOT_INITIALIZED = 0x80960002;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_ALREADY_INITIALIZED = 0x80960003;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_NO_MEMORY = 0x80960004;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT = 0x80960005;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_OPERATION_NOT_SUPPORTED = 0x80960006;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_NO_EVENT = 0x80960007;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_NOT_LOGGED_IN = 0x80960009;
|
|
||||||
constexpr int ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT = 0x8096000A;
|
|
||||||
|
|
||||||
// SystemService library
|
|
||||||
constexpr int ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER = 0x80A10003;
|
|
||||||
constexpr int ORBIS_SYSTEM_SERVICE_ERROR_NO_EVENT = 0x80A10004;
|
|
||||||
|
|
||||||
// NpTrophy library
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_UNKNOWN = 0x80551600;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_NOT_INITIALIZED = 0x80551601;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_ALREADY_INITIALIZED = 0x80551602;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_OUT_OF_MEMORY = 0x80551603;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT = 0x80551604;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INSUFFICIENT_BUFFER = 0x80551605;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_EXCEEDS_MAX = 0x80551606;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_ABORT = 0x80551607;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE = 0x80551608;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT = 0x80551609;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_ID = 0x8055160A;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_GROUP_ID = 0x8055160B;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_TROPHY_ALREADY_UNLOCKED = 0x8055160C;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_PLATINUM_CANNOT_UNLOCK = 0x8055160D;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_ACCOUNTID_NOT_MATCH = 0x8055160E;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_NOT_REGISTERED = 0x8055160F;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_ALREADY_REGISTERED = 0x80551610;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_BROKEN_DATA = 0x80551611;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INSUFFICIENT_SPACE = 0x80551612;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_ALREADY_EXISTS = 0x80551613;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_ICON_FILE_NOT_FOUND = 0x80551614;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TRP_FILE_FORMAT = 0x80551616;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_UNSUPPORTED_TRP_FILE = 0x80551617;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_CONF_FORMAT = 0x80551618;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_UNSUPPORTED_TROPHY_CONF = 0x80551619;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_TROPHY_NOT_UNLOCKED = 0x8055161A;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_USER_NOT_FOUND = 0x8055161C;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_USER_NOT_LOGGED_IN = 0x8055161D;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_USER_LOGOUT = 0x8055161E;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_USE_TRP_FOR_DEVELOPMENT = 0x8055161F;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_NP_SERVICE_LABEL = 0x80551621;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_NOT_SUPPORTED = 0x80551622;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_EXCEEDS_MAX = 0x80551623;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_HANDLE_EXCEEDS_MAX = 0x80551624;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_USER_ID = 0x80551625;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_TITLE_CONF_NOT_INSTALLED = 0x80551626;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_BROKEN_TITLE_CONF = 0x80551627;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_INCONSISTENT_TITLE_CONF = 0x80551628;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_TITLE_BACKGROUND = 0x80551629;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_SCREENSHOT_DISABLED = 0x8055162B;
|
|
||||||
constexpr int ORBIS_NP_TROPHY_ERROR_SCREENSHOT_DISPLAY_BUFFER_NOT_IN_USE = 0x8055162D;
|
|
||||||
|
|
||||||
// AvPlayer library
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_INVALID_PARAMS = 0x806A0001;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_OPERATION_FAILED = 0x806A0002;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_NO_MEMORY = 0x806A0003;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_NOT_SUPPORTED = 0x806A0004;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_WAR_FILE_NONINTERLEAVED = 0x806A00A0;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_WAR_LOOPING_BACK = 0x806A00A1;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_WAR_JUMP_COMPLETE = 0x806A00A3;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_INFO_MARLIN_ENCRY = 0x806A00B0;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_INFO_PLAYREADY_ENCRY = 0x806A00B4;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_INFO_AES_ENCRY = 0x806A00B5;
|
|
||||||
constexpr int ORBIS_AVPLAYER_ERROR_INFO_OTHER_ENCRY = 0x806A00BF;
|
|
||||||
|
|
||||||
// AppContent library
|
|
||||||
constexpr int ORBIS_APP_CONTENT_ERROR_PARAMETER = 0x80D90002;
|
|
||||||
constexpr int ORBIS_APP_CONTENT_ERROR_DRM_NO_ENTITLEMENT = 0x80D90007;
|
|
||||||
constexpr int ORBIS_APP_CONTENT_ERROR_NOT_FOUND = 0x80D90005;
|
|
||||||
|
|
||||||
// Fiber library
|
|
||||||
constexpr int ORBIS_FIBER_ERROR_NULL = 0x80590001;
|
|
||||||
constexpr int ORBIS_FIBER_ERROR_ALIGNMENT = 0x80590002;
|
|
||||||
constexpr int ORBIS_FIBER_ERROR_RANGE = 0x80590003;
|
|
||||||
constexpr int ORBIS_FIBER_ERROR_INVALID = 0x80590004;
|
|
||||||
constexpr int ORBIS_FIBER_ERROR_PERMISSION = 0x80590005;
|
|
||||||
constexpr int ORBIS_FIBER_ERROR_STATE = 0x80590006;
|
|
||||||
|
|
||||||
// ImeDialog library
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_NOT_INITIALIZED = 0x80ED0001;
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_ALREADY_INITIALIZED = 0x80ED0002;
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_PARAM_INVALID = 0x80ED0003;
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_UNEXPECTED_FATAL = 0x80ED0004;
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_INVALID_STATE = 0x80ED0005;
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_SERVICE_BUSY = 0x80ED0006;
|
|
||||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_INVALID_USER_ID = 0x80ED0007;
|
|
||||||
|
|
||||||
// Ime library
|
|
||||||
constexpr int ORBIS_IME_ERROR_BUSY = 0x80BC0001;
|
|
||||||
constexpr int ORBIS_IME_ERROR_NOT_OPENED = 0x80BC0002;
|
|
||||||
constexpr int ORBIS_IME_ERROR_NO_MEMORY = 0x80BC0003;
|
|
||||||
constexpr int ORBIS_IME_ERROR_CONNECTION_FAILED = 0x80BC0004;
|
|
||||||
constexpr int ORBIS_IME_ERROR_TOO_MANY_REQUESTS = 0x80BC0005;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_TEXT = 0x80BC0006;
|
|
||||||
constexpr int ORBIS_IME_ERROR_EVENT_OVERFLOW = 0x80BC0007;
|
|
||||||
constexpr int ORBIS_IME_ERROR_NOT_ACTIVE = 0x80BC0008;
|
|
||||||
constexpr int ORBIS_IME_ERROR_IME_SUSPENDING = 0x80BC0009;
|
|
||||||
constexpr int ORBIS_IME_ERROR_DEVICE_IN_USE = 0x80BC000A;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_USER_ID = 0x80BC0010;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_TYPE = 0x80BC0011;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_SUPPORTED_LANGUAGES = 0x80BC0012;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_ENTER_LABEL = 0x80BC0013;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_INPUT_METHOD = 0x80BC0014;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_OPTION = 0x80BC0015;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_MAX_TEXT_LENGTH = 0x80BC0016;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_INPUT_TEXT_BUFFER = 0x80BC0017;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_POSX = 0x80BC0018;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_POSY = 0x80BC0019;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_HORIZONTAL_ALIGNMENT = 0x80BC001A;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_VERTICAL_ALIGNMENT = 0x80BC001B;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_EXTENDED = 0x80BC001C;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_KEYBOARD_TYPE = 0x80BC001D;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_WORK = 0x80BC0020;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_ARG = 0x80BC0021;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_HANDLER = 0x80BC0022;
|
|
||||||
constexpr int ORBIS_IME_ERROR_NO_RESOURCE_ID = 0x80BC0023;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_MODE = 0x80BC0024;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_PARAM = 0x80BC0030;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_ADDRESS = 0x80BC0031;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_RESERVED = 0x80BC0032;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INVALID_TIMING = 0x80BC0033;
|
|
||||||
constexpr int ORBIS_IME_ERROR_INTERNAL = 0x80BC00FF;
|
|
||||||
|
|
||||||
// Videodec2 library
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_API_FAIL = 0x811D0100;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_STRUCT_SIZE = 0x811D0101;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_ARGUMENT_POINTER = 0x811D0102;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_DECODER_INSTANCE = 0x811D0103;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_MEMORY_SIZE = 0x811D0104;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_MEMORY_POINTER = 0x811D0105;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_FRAME_BUFFER_SIZE = 0x811D0106;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_FRAME_BUFFER_POINTER = 0x811D0107;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_FRAME_BUFFER_ALIGNMENT = 0x811D0108;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_NOT_ONION_MEMORY = 0x811D0109;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_NOT_GARLIC_MEMORY = 0x811D010A;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_NOT_DIRECT_MEMORY = 0x811D010B;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_MEMORY_INFO = 0x811D010C;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_ACCESS_UNIT_SIZE = 0x811D010D;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_ACCESS_UNIT_POINTER = 0x811D010E;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_OUTPUT_INFO = 0x811D010F;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_COMPUTE_QUEUE = 0x811D0110;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_FATAL_STATE = 0x811D0111;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_PRESET_VALUE = 0x811D0112;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_CONFIG_INFO = 0x811D0200;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_COMPUTE_PIPE_ID = 0x811D0201;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_COMPUTE_QUEUE_ID = 0x811D0202;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_RESOURCE_TYPE = 0x811D0203;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_CODEC_TYPE = 0x811D0204;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_PROFILE_LEVEL = 0x811D0205;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_PIPELINE_DEPTH = 0x811D0206;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_AFFINITY_MASK = 0x811D0207;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_THREAD_PRIORITY = 0x811D0208;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_DPB_FRAME_COUNT = 0x811D0209;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_FRAME_WIDTH_HEIGHT = 0x811D020A;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_EXTRA_CONFIG_INFO = 0x811D020B;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_NEW_SEQUENCE = 0x811D0300;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_ACCESS_UNIT = 0x811D0301;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_OVERSIZE_DECODE = 0x811D0302;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_INVALID_SEQUENCE = 0x811D0303;
|
|
||||||
constexpr int ORBIS_VIDEODEC2_ERROR_FATAL_STREAM = 0x811D0304;
|
|
||||||
|
|
||||||
// Videodec library
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_API_FAIL = 0x80C10000;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_CODEC_TYPE = 0x80C10001;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_STRUCT_SIZE = 0x80C10002;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_HANDLE = 0x80C10003;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_CPU_MEMORY_SIZE = 0x80C10004;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_CPU_MEMORY_POINTER = 0x80C10005;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_CPU_GPU_MEMORY_SIZE = 0x80C10006;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_CPU_GPU_MEMORY_POINTER = 0x80C10007;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_SHADER_CONTEXT_POINTER = 0x80C10008;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_AU_SIZE = 0x80C10009;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_AU_POINTER = 0x80C1000A;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_FRAME_BUFFER_SIZE = 0x80C1000B;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_FRAME_BUFFER_POINTER = 0x80C1000C;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_FRAME_BUFFER_ALIGNMENT = 0x80C1000D;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_CONFIG_INFO = 0x80C1000E;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_ARGUMENT_POINTER = 0x80C1000F;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_NEW_SEQUENCE = 0x80C10010;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_DECODE_AU = 0x80C10011;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_MISMATCH_SPEC = 0x80C10012;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_INVALID_SEQUENCE = 0x80C10013;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_FATAL_STREAM = 0x80C10014;
|
|
||||||
constexpr int ORBIS_VIDEODEC_ERROR_FATAL_STATE = 0x80C10015;
|
|
||||||
|
|
||||||
// PngDec library
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_ADDR = 0x80690001;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_SIZE = 0x80690002;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_PARAM = 0x80690003;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_HANDLE = 0x80690004;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_WORK_MEMORY = 0x80690005;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_DATA = 0x80690010;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_UNSUPPORT_DATA = 0x80690011;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_DECODE_ERROR = 0x80690012;
|
|
||||||
constexpr int ORBIS_PNG_DEC_ERROR_FATAL = 0x80690020;
|
|
@ -4,7 +4,7 @@
|
|||||||
#include "fiber.h"
|
#include "fiber.h"
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/fiber/fiber_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/tls.h"
|
#include "core/tls.h"
|
||||||
|
|
||||||
|
@ -26,17 +26,12 @@ struct SceFiber {
|
|||||||
u64 signature;
|
u64 signature;
|
||||||
FiberState state;
|
FiberState state;
|
||||||
SceFiberEntry entry;
|
SceFiberEntry entry;
|
||||||
|
|
||||||
u64 argOnInitialize;
|
u64 argOnInitialize;
|
||||||
|
|
||||||
u64 argRun;
|
u64 argRun;
|
||||||
u64* pArgRun;
|
u64* pArgRun;
|
||||||
|
|
||||||
u64 argReturn;
|
u64 argReturn;
|
||||||
u64* pArgReturn;
|
u64* pArgReturn;
|
||||||
|
|
||||||
u64 sizeContext;
|
u64 sizeContext;
|
||||||
|
|
||||||
char name[ORBIS_FIBER_MAX_NAME_LENGTH];
|
char name[ORBIS_FIBER_MAX_NAME_LENGTH];
|
||||||
void* handle;
|
void* handle;
|
||||||
};
|
};
|
||||||
@ -53,7 +48,7 @@ struct SceFiberInfo {
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(SceFiberInfo) <= 128);
|
static_assert(sizeof(SceFiberInfo) <= 128);
|
||||||
|
|
||||||
typedef void* SceFiberOptParam;
|
using SceFiberOptParam = void*;
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceFiberInitialize(SceFiber* fiber, const char* name, SceFiberEntry entry,
|
s32 PS4_SYSV_ABI sceFiberInitialize(SceFiber* fiber, const char* name, SceFiberEntry entry,
|
||||||
u64 argOnInitialize, void* addrContext, u64 sizeContext,
|
u64 argOnInitialize, void* addrContext, u64 sizeContext,
|
||||||
|
14
src/core/libraries/fiber/fiber_error.h
Normal file
14
src/core/libraries/fiber/fiber_error.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// Fiber library
|
||||||
|
constexpr int ORBIS_FIBER_ERROR_NULL = 0x80590001;
|
||||||
|
constexpr int ORBIS_FIBER_ERROR_ALIGNMENT = 0x80590002;
|
||||||
|
constexpr int ORBIS_FIBER_ERROR_RANGE = 0x80590003;
|
||||||
|
constexpr int ORBIS_FIBER_ERROR_INVALID = 0x80590004;
|
||||||
|
constexpr int ORBIS_FIBER_ERROR_PERMISSION = 0x80590005;
|
||||||
|
constexpr int ORBIS_FIBER_ERROR_STATE = 0x80590006;
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
constexpr int ORBIS_GNM_ERROR_SUBMISSION_FAILED_INVALID_ARGUMENT = 0x80D11000;
|
constexpr int ORBIS_GNM_ERROR_SUBMISSION_FAILED_INVALID_ARGUMENT = 0x80D11000;
|
||||||
constexpr int ORBIS_GNM_ERROR_SUBMISSION_NOT_ENOUGH_RESOURCES = 0x80D11001;
|
constexpr int ORBIS_GNM_ERROR_SUBMISSION_NOT_ENOUGH_RESOURCES = 0x80D11001;
|
||||||
constexpr int ORBIS_GNM_ERROR_SUBMISSION_AND_FLIP_FAILED_INVALID_COMMAND_BUFFER = 0x80D11080;
|
constexpr int ORBIS_GNM_ERROR_SUBMISSION_AND_FLIP_FAILED_INVALID_COMMAND_BUFFER = 0x80D11080;
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
#include "common/slot_vector.h"
|
#include "common/slot_vector.h"
|
||||||
#include "core/address_space.h"
|
#include "core/address_space.h"
|
||||||
#include "core/debug_state.h"
|
#include "core/debug_state.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/gnmdriver/gnm_error.h"
|
||||||
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/kernel/process.h"
|
#include "core/libraries/kernel/process.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/libraries/videoout/video_out.h"
|
#include "core/libraries/videoout/video_out.h"
|
||||||
|
@ -2,14 +2,12 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "ime.h"
|
|
||||||
#include "ime_ui.h"
|
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/singleton.h"
|
#include "core/libraries/ime/ime.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/ime/ime_error.h"
|
||||||
|
#include "core/libraries/ime/ime_ui.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/linker.h"
|
#include "core/tls.h"
|
||||||
|
|
||||||
namespace Libraries::Ime {
|
namespace Libraries::Ime {
|
||||||
|
|
||||||
@ -37,7 +35,7 @@ public:
|
|||||||
|
|
||||||
// Open an event to let the game know the IME has started
|
// Open an event to let the game know the IME has started
|
||||||
OrbisImeEvent openEvent{};
|
OrbisImeEvent openEvent{};
|
||||||
openEvent.id = (ime_mode ? OrbisImeEventId::OPEN : OrbisImeEventId::KEYBOARD_OPEN);
|
openEvent.id = (ime_mode ? OrbisImeEventId::Open : OrbisImeEventId::KeyboardOpen);
|
||||||
|
|
||||||
if (ime_mode) {
|
if (ime_mode) {
|
||||||
sceImeGetPanelSize(&m_param.ime, &openEvent.param.rect.width,
|
sceImeGetPanelSize(&m_param.ime, &openEvent.param.rect.width,
|
||||||
@ -45,11 +43,15 @@ public:
|
|||||||
openEvent.param.rect.x = m_param.ime.posx;
|
openEvent.param.rect.x = m_param.ime.posx;
|
||||||
openEvent.param.rect.y = m_param.ime.posy;
|
openEvent.param.rect.y = m_param.ime.posy;
|
||||||
} else {
|
} else {
|
||||||
openEvent.param.resourceIdArray.userId = 1;
|
openEvent.param.resource_id_array.userId = 1;
|
||||||
openEvent.param.resourceIdArray.resourceId[0] = 1;
|
openEvent.param.resource_id_array.resourceId[0] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Execute(nullptr, &openEvent, true);
|
// Are we supposed to call the event handler on init with
|
||||||
|
// ADD_OSK?
|
||||||
|
if (!ime_mode && False(m_param.key.option & OrbisImeKeyboardOption::AddOsk)) {
|
||||||
|
Execute(nullptr, &openEvent, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (ime_mode) {
|
if (ime_mode) {
|
||||||
g_ime_state = ImeState(&m_param.ime);
|
g_ime_state = ImeState(&m_param.ime);
|
||||||
@ -58,6 +60,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 Update(OrbisImeEventHandler handler) {
|
s32 Update(OrbisImeEventHandler handler) {
|
||||||
|
if (!m_ime_mode) {
|
||||||
|
/* We don't handle any events for ImeKeyboard */
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_lock lock{g_ime_state.queue_mutex};
|
std::unique_lock lock{g_ime_state.queue_mutex};
|
||||||
|
|
||||||
while (!g_ime_state.event_queue.empty()) {
|
while (!g_ime_state.event_queue.empty()) {
|
||||||
@ -87,6 +94,16 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 SetText(const char16_t* text, u32 length) {
|
||||||
|
g_ime_state.SetText(text, length);
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 SetCaret(const OrbisImeCaret* caret) {
|
||||||
|
g_ime_state.SetCaret(caret->index);
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsIme() {
|
bool IsIme() {
|
||||||
return m_ime_mode;
|
return m_ime_mode;
|
||||||
}
|
}
|
||||||
@ -100,6 +117,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<ImeHandler> g_ime_handler;
|
static std::unique_ptr<ImeHandler> g_ime_handler;
|
||||||
|
static std::unique_ptr<ImeHandler> g_keyboard_handler;
|
||||||
|
|
||||||
int PS4_SYSV_ABI FinalizeImeModule() {
|
int PS4_SYSV_ABI FinalizeImeModule() {
|
||||||
LOG_ERROR(Lib_Ime, "(STUBBED) called");
|
LOG_ERROR(Lib_Ime, "(STUBBED) called");
|
||||||
@ -132,9 +150,6 @@ s32 PS4_SYSV_ABI sceImeClose() {
|
|||||||
if (!g_ime_handler) {
|
if (!g_ime_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return ORBIS_IME_ERROR_NOT_OPENED;
|
||||||
}
|
}
|
||||||
if (!g_ime_handler->IsIme()) {
|
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_ime_handler.release();
|
g_ime_handler.release();
|
||||||
g_ime_ui = ImeUi();
|
g_ime_ui = ImeUi();
|
||||||
@ -215,15 +230,15 @@ s32 PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32*
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (param->type) {
|
switch (param->type) {
|
||||||
case OrbisImeType::DEFAULT:
|
case OrbisImeType::Default:
|
||||||
case OrbisImeType::BASIC_LATIN:
|
case OrbisImeType::BasicLatin:
|
||||||
case OrbisImeType::URL:
|
case OrbisImeType::Url:
|
||||||
case OrbisImeType::MAIL:
|
case OrbisImeType::Mail:
|
||||||
// We set our custom sizes, commented sizes are the original ones
|
// We set our custom sizes, commented sizes are the original ones
|
||||||
*width = 500; // 793
|
*width = 500; // 793
|
||||||
*height = 100; // 408
|
*height = 100; // 408
|
||||||
break;
|
break;
|
||||||
case OrbisImeType::NUMBER:
|
case OrbisImeType::Number:
|
||||||
*width = 370;
|
*width = 370;
|
||||||
*height = 402;
|
*height = 402;
|
||||||
break;
|
break;
|
||||||
@ -235,14 +250,11 @@ s32 PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32*
|
|||||||
s32 PS4_SYSV_ABI sceImeKeyboardClose(s32 userId) {
|
s32 PS4_SYSV_ABI sceImeKeyboardClose(s32 userId) {
|
||||||
LOG_INFO(Lib_Ime, "(STUBBED) called");
|
LOG_INFO(Lib_Ime, "(STUBBED) called");
|
||||||
|
|
||||||
if (!g_ime_handler) {
|
if (!g_keyboard_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
|
||||||
}
|
|
||||||
if (g_ime_handler->IsIme()) {
|
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return ORBIS_IME_ERROR_NOT_OPENED;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_handler.release();
|
g_keyboard_handler.release();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,18 +269,17 @@ int PS4_SYSV_ABI sceImeKeyboardGetResourceId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeKeyboardOpen(s32 userId, const OrbisImeKeyboardParam* param) {
|
s32 PS4_SYSV_ABI sceImeKeyboardOpen(s32 userId, const OrbisImeKeyboardParam* param) {
|
||||||
LOG_ERROR(Lib_Ime, "(STUBBED) called");
|
LOG_INFO(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!param) {
|
if (!param) {
|
||||||
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
||||||
}
|
}
|
||||||
if (g_ime_handler) {
|
if (g_keyboard_handler) {
|
||||||
return ORBIS_IME_ERROR_BUSY;
|
return ORBIS_IME_ERROR_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// g_ime_handler = std::make_unique<ImeHandler>(param);
|
g_keyboard_handler = std::make_unique<ImeHandler>(param);
|
||||||
// return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
return ORBIS_IME_ERROR_CONNECTION_FAILED; // Fixup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeKeyboardOpenInternal() {
|
int PS4_SYSV_ABI sceImeKeyboardOpenInternal() {
|
||||||
@ -289,16 +300,14 @@ int PS4_SYSV_ABI sceImeKeyboardUpdate() {
|
|||||||
s32 PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const void* extended) {
|
s32 PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const void* extended) {
|
||||||
LOG_INFO(Lib_Ime, "called");
|
LOG_INFO(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!g_ime_handler) {
|
if (!param) {
|
||||||
g_ime_handler = std::make_unique<ImeHandler>(param);
|
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
||||||
} else {
|
}
|
||||||
if (g_ime_handler->IsIme()) {
|
if (g_ime_handler) {
|
||||||
return ORBIS_IME_ERROR_BUSY;
|
return ORBIS_IME_ERROR_BUSY;
|
||||||
}
|
|
||||||
|
|
||||||
g_ime_handler->Init((void*)param, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_ime_handler = std::make_unique<ImeHandler>(param);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +324,7 @@ void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(param, 0, sizeof(OrbisImeParam));
|
memset(param, 0, sizeof(OrbisImeParam));
|
||||||
param->userId = -1;
|
param->user_id = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeSetCandidateIndex() {
|
int PS4_SYSV_ABI sceImeSetCandidateIndex() {
|
||||||
@ -324,13 +333,29 @@ int PS4_SYSV_ABI sceImeSetCandidateIndex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret) {
|
int PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret) {
|
||||||
LOG_ERROR(Lib_Ime, "(STUBBED) called");
|
LOG_TRACE(Lib_Ime, "called");
|
||||||
return ORBIS_OK;
|
|
||||||
|
if (!g_ime_handler) {
|
||||||
|
return ORBIS_IME_ERROR_NOT_OPENED;
|
||||||
|
}
|
||||||
|
if (!caret) {
|
||||||
|
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_ime_handler->SetCaret(caret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeSetText() {
|
s32 PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length) {
|
||||||
LOG_ERROR(Lib_Ime, "(STUBBED) called");
|
LOG_TRACE(Lib_Ime, "called");
|
||||||
return ORBIS_OK;
|
|
||||||
|
if (!g_ime_handler) {
|
||||||
|
return ORBIS_IME_ERROR_NOT_OPENED;
|
||||||
|
}
|
||||||
|
if (!text) {
|
||||||
|
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_ime_handler->SetText(text, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeSetTextGeometry() {
|
int PS4_SYSV_ABI sceImeSetTextGeometry() {
|
||||||
@ -339,13 +364,19 @@ int PS4_SYSV_ABI sceImeSetTextGeometry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler) {
|
s32 PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler) {
|
||||||
LOG_TRACE(Lib_Ime, "called");
|
if (g_ime_handler) {
|
||||||
|
g_ime_handler->Update(handler);
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_ime_handler) {
|
if (g_keyboard_handler) {
|
||||||
|
g_keyboard_handler->Update(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_ime_handler || !g_keyboard_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return ORBIS_IME_ERROR_NOT_OPENED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_ime_handler->Update(handler);
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeVshClearPreedit() {
|
int PS4_SYSV_ABI sceImeVshClearPreedit() {
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/enum.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
#include "core/libraries/ime/ime_common.h"
|
||||||
#include "ime_common.h"
|
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
class SymbolsResolver;
|
class SymbolsResolver;
|
||||||
@ -16,16 +16,34 @@ namespace Libraries::Ime {
|
|||||||
constexpr u32 ORBIS_IME_MAX_TEXT_LENGTH = 2048;
|
constexpr u32 ORBIS_IME_MAX_TEXT_LENGTH = 2048;
|
||||||
|
|
||||||
enum class OrbisImeKeyboardOption : u32 {
|
enum class OrbisImeKeyboardOption : u32 {
|
||||||
DEFAULT = 0,
|
Default = 0,
|
||||||
REPEAT = 1,
|
Repeat = 1,
|
||||||
REPEAT_EACH_KEY = 2,
|
RepeatEachKey = 2,
|
||||||
ADD_OSK = 4,
|
AddOsk = 4,
|
||||||
EFFECTIVE_WITH_TIME = 8,
|
EffectiveWithTime = 8,
|
||||||
DISABLE_RESUME = 16,
|
DisableResume = 16,
|
||||||
DISABLE_CAPSLOCK_WITHOUT_SHIFT = 32,
|
DisableCapslockWithoutShift = 32,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeKeyboardOption)
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeKeyboardOption)
|
||||||
|
|
||||||
|
enum class OrbisImeOption : u32 {
|
||||||
|
DEFAULT = 0,
|
||||||
|
MULTILINE = 1,
|
||||||
|
NO_AUTO_CAPITALIZATION = 2,
|
||||||
|
PASSWORD = 4,
|
||||||
|
LANGUAGES_FORCED = 8,
|
||||||
|
EXT_KEYBOARD = 16,
|
||||||
|
NO_LEARNING = 32,
|
||||||
|
FIXED_POSITION = 64,
|
||||||
|
DISABLE_RESUME = 256,
|
||||||
|
DISABLE_AUTO_SPACE = 512,
|
||||||
|
DISABLE_POSITION_ADJUSTMENT = 2048,
|
||||||
|
EXPANDED_PREEDIT_BUFFER = 4096,
|
||||||
|
USE_JAPANESE_EISUU_KEY_AS_CAPSLOCK = 8192,
|
||||||
|
USE_2K_COORDINATES = 16384,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeOption)
|
||||||
|
|
||||||
struct OrbisImeKeyboardParam {
|
struct OrbisImeKeyboardParam {
|
||||||
OrbisImeKeyboardOption option;
|
OrbisImeKeyboardOption option;
|
||||||
s8 reserved1[4];
|
s8 reserved1[4];
|
||||||
@ -35,19 +53,19 @@ struct OrbisImeKeyboardParam {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeParam {
|
struct OrbisImeParam {
|
||||||
s32 userId;
|
s32 user_id;
|
||||||
OrbisImeType type;
|
OrbisImeType type;
|
||||||
u64 supportedLanguages;
|
u64 supported_languages;
|
||||||
OrbisImeEnterLabel enterLabel;
|
OrbisImeEnterLabel enter_label;
|
||||||
OrbisImeInputMethod inputMethod;
|
OrbisImeInputMethod input_method;
|
||||||
OrbisImeTextFilter filter;
|
OrbisImeTextFilter filter;
|
||||||
u32 option;
|
OrbisImeOption option;
|
||||||
u32 maxTextLength;
|
u32 maxTextLength;
|
||||||
char16_t* inputTextBuffer;
|
char16_t* inputTextBuffer;
|
||||||
float posx;
|
float posx;
|
||||||
float posy;
|
float posy;
|
||||||
OrbisImeHorizontalAlignment horizontalAlignment;
|
OrbisImeHorizontalAlignment horizontal_alignment;
|
||||||
OrbisImeVerticalAlignment verticalAlignment;
|
OrbisImeVerticalAlignment vertical_alignment;
|
||||||
void* work;
|
void* work;
|
||||||
void* arg;
|
void* arg;
|
||||||
OrbisImeEventHandler handler;
|
OrbisImeEventHandler handler;
|
||||||
@ -93,7 +111,7 @@ int PS4_SYSV_ABI sceImeOpenInternal();
|
|||||||
void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param);
|
void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param);
|
||||||
int PS4_SYSV_ABI sceImeSetCandidateIndex();
|
int PS4_SYSV_ABI sceImeSetCandidateIndex();
|
||||||
s32 PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret);
|
s32 PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret);
|
||||||
int PS4_SYSV_ABI sceImeSetText();
|
s32 PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length);
|
||||||
int PS4_SYSV_ABI sceImeSetTextGeometry();
|
int PS4_SYSV_ABI sceImeSetTextGeometry();
|
||||||
s32 PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler);
|
s32 PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler);
|
||||||
int PS4_SYSV_ABI sceImeVshClearPreedit();
|
int PS4_SYSV_ABI sceImeVshClearPreedit();
|
||||||
@ -117,4 +135,5 @@ int PS4_SYSV_ABI sceImeVshUpdateContext();
|
|||||||
int PS4_SYSV_ABI sceImeVshUpdateContext2();
|
int PS4_SYSV_ABI sceImeVshUpdateContext2();
|
||||||
|
|
||||||
void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Ime
|
|
||||||
|
} // namespace Libraries::Ime
|
||||||
|
@ -2,65 +2,64 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <sys/types.h>
|
|
||||||
#include "common/enum.h"
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/libraries/rtc/rtc.h"
|
#include "core/libraries/rtc/rtc.h"
|
||||||
|
|
||||||
enum class OrbisImeType : u32 {
|
enum class OrbisImeType : u32 {
|
||||||
DEFAULT = 0,
|
Default = 0,
|
||||||
BASIC_LATIN = 1,
|
BasicLatin = 1,
|
||||||
URL = 2,
|
Url = 2,
|
||||||
MAIL = 3,
|
Mail = 3,
|
||||||
NUMBER = 4,
|
Number = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeHorizontalAlignment : u32 {
|
enum class OrbisImeHorizontalAlignment : u32 {
|
||||||
LEFT = 0,
|
Left = 0,
|
||||||
CENTER = 1,
|
Center = 1,
|
||||||
RIGHT = 2,
|
Right = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeVerticalAlignment : u32 {
|
enum class OrbisImeVerticalAlignment : u32 {
|
||||||
TOP = 0,
|
Top = 0,
|
||||||
CENTER = 1,
|
Center = 1,
|
||||||
BOTTOM = 2,
|
Bottom = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeEnterLabel : u32 {
|
enum class OrbisImeEnterLabel : u32 {
|
||||||
DEFAULT = 0,
|
Default = 0,
|
||||||
SEND = 1,
|
Send = 1,
|
||||||
SEARCH = 2,
|
Search = 2,
|
||||||
GO = 3,
|
Go = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeInputMethod : u32 {
|
enum class OrbisImeInputMethod : u32 {
|
||||||
DEFAULT = 0,
|
Default = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeEventId : u32 {
|
enum class OrbisImeEventId : u32 {
|
||||||
OPEN = 0,
|
Open = 0,
|
||||||
UPDATE_TEXT = 1,
|
UpdateText = 1,
|
||||||
UPDATE_CARET = 2,
|
UpdateCaret = 2,
|
||||||
PRESS_CLOSE = 4,
|
PressClose = 4,
|
||||||
PRESS_ENTER = 5,
|
PressEnter = 5,
|
||||||
ABORT = 6,
|
Abort = 6,
|
||||||
CANDIDATE_LIST_START = 7,
|
CandidateListStart = 7,
|
||||||
CANDIDATE_LIST_END = 8,
|
CandidateListEnd = 8,
|
||||||
CANDIDATE_WORD = 9,
|
CandidateWord = 9,
|
||||||
CANDIDATE_INDEX = 10,
|
CandidateIndex = 10,
|
||||||
CANDIDATE_DONE = 11,
|
CandidateDone = 11,
|
||||||
CANDIDATE_CANCEL = 12,
|
CandidateCancel = 12,
|
||||||
CHANGE_DEVICE = 14,
|
ChangeDevice = 14,
|
||||||
CHANGE_INPUT_METHOD_STATE = 18,
|
ChangeInputMethodState = 18,
|
||||||
|
|
||||||
KEYBOARD_OPEN = 256,
|
KeyboardOpen = 256,
|
||||||
KEYBOARD_KEYCODE_DOWN = 257,
|
KeyboardKeycodeDoen = 257,
|
||||||
KEYBOARD_KEYCODE_UP = 258,
|
KeyboardKeycodeUp = 258,
|
||||||
KEYBOARD_KEYCODE_REPEAT = 259,
|
KeyboardKeycodeRepeat = 259,
|
||||||
KEYBOARD_CONNECTION = 260,
|
KeyboardConnection = 260,
|
||||||
KEYBOARD_DISCONNECTION = 261,
|
KeyboardDisconnection = 261,
|
||||||
KEYBOARD_ABORT = 262,
|
KeyboardAbort = 262,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeKeyboardType : u32 {
|
enum class OrbisImeKeyboardType : u32 {
|
||||||
@ -105,10 +104,10 @@ enum class OrbisImeKeyboardType : u32 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeDeviceType : u32 {
|
enum class OrbisImeDeviceType : u32 {
|
||||||
NONE = 0,
|
None = 0,
|
||||||
CONTROLLER = 1,
|
Controller = 1,
|
||||||
EXT_KEYBOARD = 2,
|
ExtKeyboard = 2,
|
||||||
REMOTE_OSK = 3,
|
RemoteOsk = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeRect {
|
struct OrbisImeRect {
|
||||||
@ -126,9 +125,9 @@ struct OrbisImeTextAreaProperty {
|
|||||||
|
|
||||||
struct OrbisImeEditText {
|
struct OrbisImeEditText {
|
||||||
char16_t* str;
|
char16_t* str;
|
||||||
u32 caretIndex;
|
u32 caret_index;
|
||||||
u32 areaNum;
|
u32 area_num;
|
||||||
OrbisImeTextAreaProperty textArea[4];
|
OrbisImeTextAreaProperty text_area[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeKeycode {
|
struct OrbisImeKeycode {
|
||||||
@ -136,40 +135,40 @@ struct OrbisImeKeycode {
|
|||||||
char16_t character;
|
char16_t character;
|
||||||
u32 status;
|
u32 status;
|
||||||
OrbisImeKeyboardType type;
|
OrbisImeKeyboardType type;
|
||||||
s32 userId;
|
s32 user_id;
|
||||||
u32 resourceId;
|
u32 resource_id;
|
||||||
Libraries::Rtc::OrbisRtcTick timestamp;
|
Libraries::Rtc::OrbisRtcTick timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeKeyboardResourceIdArray {
|
struct OrbisImeKeyboardResourceIdArray {
|
||||||
s32 userId;
|
s32 userId;
|
||||||
u32 resourceId[6];
|
u32 resourceId[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeCaretMovementDirection : u32 {
|
enum class OrbisImeCaretMovementDirection : u32 {
|
||||||
STILL = 0,
|
Still = 0,
|
||||||
LEFT = 1,
|
Left = 1,
|
||||||
RIGHT = 2,
|
Right = 2,
|
||||||
UP = 3,
|
Up = 3,
|
||||||
DOWN = 4,
|
Down = 4,
|
||||||
HOME = 5,
|
Home = 5,
|
||||||
END = 6,
|
End = 6,
|
||||||
PAGE_UP = 7,
|
PageUp = 7,
|
||||||
PAGE_DOWN = 8,
|
PageDown = 8,
|
||||||
TOP = 9,
|
Top = 9,
|
||||||
BOTTOM = 10,
|
Bottom = 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
union OrbisImeEventParam {
|
union OrbisImeEventParam {
|
||||||
OrbisImeRect rect;
|
OrbisImeRect rect;
|
||||||
OrbisImeEditText text;
|
OrbisImeEditText text;
|
||||||
OrbisImeCaretMovementDirection caretMove;
|
OrbisImeCaretMovementDirection caret_move;
|
||||||
OrbisImeKeycode keycode;
|
OrbisImeKeycode keycode;
|
||||||
OrbisImeKeyboardResourceIdArray resourceIdArray;
|
OrbisImeKeyboardResourceIdArray resource_id_array;
|
||||||
char16_t* candidateWord;
|
char16_t* candidate_word;
|
||||||
s32 candidateIndex;
|
s32 candidate_index;
|
||||||
OrbisImeDeviceType deviceType;
|
OrbisImeDeviceType device_type;
|
||||||
u32 inputMethodState;
|
u32 input_method_state;
|
||||||
s8 reserved[64];
|
s8 reserved[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,7 +177,7 @@ struct OrbisImeEvent {
|
|||||||
OrbisImeEventParam param;
|
OrbisImeEventParam param;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef PS4_SYSV_ABI int (*OrbisImeTextFilter)(char16_t* outText, u32* outTextLength,
|
using OrbisImeTextFilter = PS4_SYSV_ABI int (*)(char16_t* outText, u32* outTextLength,
|
||||||
const char16_t* srcText, u32 srcTextLength);
|
const char16_t* srcText, u32 srcTextLength);
|
||||||
|
|
||||||
typedef PS4_SYSV_ABI void (*OrbisImeEventHandler)(void* arg, const OrbisImeEvent* e);
|
using OrbisImeEventHandler = PS4_SYSV_ABI void (*)(void* arg, const OrbisImeEvent* e);
|
||||||
|
@ -14,24 +14,24 @@ static constexpr std::array<float, 2> MAX_Y_POSITIONS = {2160.0f, 1080.0f};
|
|||||||
|
|
||||||
namespace Libraries::ImeDialog {
|
namespace Libraries::ImeDialog {
|
||||||
|
|
||||||
static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::NONE;
|
static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::None;
|
||||||
static OrbisImeDialogResult g_ime_dlg_result{};
|
static OrbisImeDialogResult g_ime_dlg_result{};
|
||||||
static ImeDialogState g_ime_dlg_state{};
|
static ImeDialogState g_ime_dlg_state{};
|
||||||
static ImeDialogUi g_ime_dlg_ui;
|
static ImeDialogUi g_ime_dlg_ui;
|
||||||
|
|
||||||
static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
|
static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
|
||||||
if (False(~option &
|
if (False(~option &
|
||||||
(OrbisImeDialogOption::MULTILINE | OrbisImeDialogOption::NO_AUTO_COMPLETION))) {
|
(OrbisImeDialogOption::Multiline | OrbisImeDialogOption::NoAutoCompletion))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (True(option & OrbisImeDialogOption::MULTILINE) && type != OrbisImeType::DEFAULT &&
|
if (True(option & OrbisImeDialogOption::Multiline) && type != OrbisImeType::Default &&
|
||||||
type != OrbisImeType::BASIC_LATIN) {
|
type != OrbisImeType::BasicLatin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (True(option & OrbisImeDialogOption::NO_AUTO_COMPLETION) && type != OrbisImeType::NUMBER &&
|
if (True(option & OrbisImeDialogOption::NoAutoCompletion) && type != OrbisImeType::Number &&
|
||||||
type != OrbisImeType::BASIC_LATIN) {
|
type != OrbisImeType::BasicLatin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,29 +39,29 @@ static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogAbort() {
|
Error PS4_SYSV_ABI sceImeDialogAbort() {
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
||||||
return Error::DIALOG_NOT_IN_USE;
|
return Error::DIALOG_NOT_IN_USE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ime_dlg_status != OrbisImeDialogStatus::RUNNING) {
|
if (g_ime_dlg_status != OrbisImeDialogStatus::Running) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog not running");
|
LOG_INFO(Lib_ImeDialog, "IME dialog not running");
|
||||||
return Error::DIALOG_NOT_RUNNING;
|
return Error::DIALOG_NOT_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_dlg_status = OrbisImeDialogStatus::FINISHED;
|
g_ime_dlg_status = OrbisImeDialogStatus::Finished;
|
||||||
g_ime_dlg_result.endstatus = OrbisImeDialogEndStatus::ABORTED;
|
g_ime_dlg_result.endstatus = OrbisImeDialogEndStatus::Aborted;
|
||||||
|
|
||||||
return Error::OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogForceClose() {
|
Error PS4_SYSV_ABI sceImeDialogForceClose() {
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
||||||
return Error::DIALOG_NOT_IN_USE;
|
return Error::DIALOG_NOT_IN_USE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_dlg_status = OrbisImeDialogStatus::NONE;
|
g_ime_dlg_status = OrbisImeDialogStatus::None;
|
||||||
g_ime_dlg_ui = ImeDialogUi();
|
g_ime_dlg_ui = ImeDialogUi();
|
||||||
g_ime_dlg_state = ImeDialogState();
|
g_ime_dlg_state = ImeDialogState();
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog is not running");
|
LOG_INFO(Lib_ImeDialog, "IME dialog is not running");
|
||||||
return Error::DIALOG_NOT_IN_USE;
|
return Error::DIALOG_NOT_IN_USE;
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
|||||||
|
|
||||||
result->endstatus = g_ime_dlg_result.endstatus;
|
result->endstatus = g_ime_dlg_result.endstatus;
|
||||||
|
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
|
||||||
return Error::DIALOG_NOT_FINISHED;
|
return Error::DIALOG_NOT_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
|
OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
|
||||||
g_ime_dlg_state.CallTextFilter();
|
g_ime_dlg_state.CallTextFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) {
|
Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) {
|
||||||
if (g_ime_dlg_status != OrbisImeDialogStatus::NONE) {
|
if (g_ime_dlg_status != OrbisImeDialogStatus::None) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog is already running");
|
LOG_INFO(Lib_ImeDialog, "IME dialog is already running");
|
||||||
return Error::BUSY;
|
return Error::BUSY;
|
||||||
}
|
}
|
||||||
@ -142,24 +142,24 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||||||
|
|
||||||
if (param->posx < 0.0f ||
|
if (param->posx < 0.0f ||
|
||||||
param->posx >=
|
param->posx >=
|
||||||
MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) {
|
MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LargeResolution)]) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->posx");
|
LOG_INFO(Lib_ImeDialog, "Invalid param->posx");
|
||||||
return Error::INVALID_POSX;
|
return Error::INVALID_POSX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->posy < 0.0f ||
|
if (param->posy < 0.0f ||
|
||||||
param->posy >=
|
param->posy >=
|
||||||
MAX_Y_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) {
|
MAX_Y_POSITIONS[False(param->option & OrbisImeDialogOption::LargeResolution)]) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->posy");
|
LOG_INFO(Lib_ImeDialog, "Invalid param->posy");
|
||||||
return Error::INVALID_POSY;
|
return Error::INVALID_POSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!magic_enum::enum_contains(param->horizontalAlignment)) {
|
if (!magic_enum::enum_contains(param->horizontal_alignment)) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->horizontalAlignment");
|
LOG_INFO(Lib_ImeDialog, "Invalid param->horizontalAlignment");
|
||||||
return Error::INVALID_HORIZONTALIGNMENT;
|
return Error::INVALID_HORIZONTALIGNMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!magic_enum::enum_contains(param->verticalAlignment)) {
|
if (!magic_enum::enum_contains(param->vertical_alignment)) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->verticalAlignment");
|
LOG_INFO(Lib_ImeDialog, "Invalid param->verticalAlignment");
|
||||||
return Error::INVALID_VERTICALALIGNMENT;
|
return Error::INVALID_VERTICALALIGNMENT;
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||||||
return Error::INVALID_PARAM;
|
return Error::INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->inputTextBuffer == nullptr) {
|
if (param->input_text_buffer == nullptr) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->inputTextBuffer");
|
LOG_INFO(Lib_ImeDialog, "Invalid param->inputTextBuffer");
|
||||||
return Error::INVALID_INPUT_TEXT_BUFFER;
|
return Error::INVALID_INPUT_TEXT_BUFFER;
|
||||||
}
|
}
|
||||||
@ -182,25 +182,25 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||||||
|
|
||||||
// TODO: do correct extended->option validation
|
// TODO: do correct extended->option validation
|
||||||
|
|
||||||
if ((extended->extKeyboardMode & 0xe3fffffc) != 0) {
|
if ((extended->ext_keyboard_mode & 0xe3fffffc) != 0) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->extKeyboardMode");
|
LOG_INFO(Lib_ImeDialog, "Invalid extended->extKeyboardMode");
|
||||||
return Error::INVALID_EXTENDED;
|
return Error::INVALID_EXTENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extended->disableDevice > 7) {
|
if (extended->disable_device > 7) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->disableDevice");
|
LOG_INFO(Lib_ImeDialog, "Invalid extended->disableDevice");
|
||||||
return Error::INVALID_EXTENDED;
|
return Error::INVALID_EXTENDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->maxTextLength > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
|
if (param->max_text_length > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->maxTextLength");
|
LOG_INFO(Lib_ImeDialog, "Invalid param->maxTextLength");
|
||||||
return Error::INVALID_MAX_TEXT_LENGTH;
|
return Error::INVALID_MAX_TEXT_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_dlg_result = {};
|
g_ime_dlg_result = {};
|
||||||
g_ime_dlg_state = ImeDialogState(param, extended);
|
g_ime_dlg_state = ImeDialogState(param, extended);
|
||||||
g_ime_dlg_status = OrbisImeDialogStatus::RUNNING;
|
g_ime_dlg_status = OrbisImeDialogStatus::Running;
|
||||||
g_ime_dlg_ui = ImeDialogUi(&g_ime_dlg_state, &g_ime_dlg_status, &g_ime_dlg_result);
|
g_ime_dlg_ui = ImeDialogUi(&g_ime_dlg_state, &g_ime_dlg_status, &g_ime_dlg_result);
|
||||||
|
|
||||||
return Error::OK;
|
return Error::OK;
|
||||||
@ -227,17 +227,17 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogTerm() {
|
Error PS4_SYSV_ABI sceImeDialogTerm() {
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
||||||
return Error::DIALOG_NOT_IN_USE;
|
return Error::DIALOG_NOT_IN_USE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
|
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog is still running");
|
LOG_INFO(Lib_ImeDialog, "IME dialog is still running");
|
||||||
return Error::DIALOG_NOT_FINISHED;
|
return Error::DIALOG_NOT_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_dlg_status = OrbisImeDialogStatus::NONE;
|
g_ime_dlg_status = OrbisImeDialogStatus::None;
|
||||||
g_ime_dlg_ui = ImeDialogUi();
|
g_ime_dlg_ui = ImeDialogUi();
|
||||||
g_ime_dlg_state = ImeDialogState();
|
g_ime_dlg_state = ImeDialogState();
|
||||||
|
|
||||||
@ -274,4 +274,4 @@ void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("gyTyVn+bXMw", "libSceImeDialog", 1, "libSceImeDialog", 1, 1, sceImeDialogTerm);
|
LIB_FUNCTION("gyTyVn+bXMw", "libSceImeDialog", 1, "libSceImeDialog", 1, 1, sceImeDialogTerm);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Libraries::ImeDialog
|
} // namespace Libraries::ImeDialog
|
||||||
|
@ -58,32 +58,32 @@ enum class Error : u32 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeDialogStatus : u32 {
|
enum class OrbisImeDialogStatus : u32 {
|
||||||
NONE = 0,
|
None = 0,
|
||||||
RUNNING = 1,
|
Running = 1,
|
||||||
FINISHED = 2,
|
Finished = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeDialogEndStatus : u32 {
|
enum class OrbisImeDialogEndStatus : u32 {
|
||||||
OK = 0,
|
Ok = 0,
|
||||||
USER_CANCELED = 1,
|
UserCanceled = 1,
|
||||||
ABORTED = 2,
|
Aborted = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeDialogOption : u32 {
|
enum class OrbisImeDialogOption : u32 {
|
||||||
DEFAULT = 0,
|
Default = 0,
|
||||||
MULTILINE = 1,
|
Multiline = 1,
|
||||||
NO_AUTO_CORRECTION = 2,
|
NoAutoCorrection = 2,
|
||||||
NO_AUTO_COMPLETION = 4,
|
NoAutoCompletion = 4,
|
||||||
// TODO: Document missing options
|
// TODO: Document missing options
|
||||||
LARGE_RESOLUTION = 1024,
|
LargeResolution = 1024,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDialogOption)
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDialogOption)
|
||||||
|
|
||||||
enum class OrbisImePanelPriority : u32 {
|
enum class OrbisImePanelPriority : u32 {
|
||||||
DEFAULT = 0,
|
Default = 0,
|
||||||
ALPHABET = 1,
|
Alphabet = 1,
|
||||||
SYMBOL = 2,
|
Symbol = 2,
|
||||||
ACCENT = 3,
|
Accent = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeColor {
|
struct OrbisImeColor {
|
||||||
@ -103,29 +103,29 @@ struct OrbisImeKeycode {
|
|||||||
char16_t character;
|
char16_t character;
|
||||||
u32 status;
|
u32 status;
|
||||||
OrbisImeKeyboardType type;
|
OrbisImeKeyboardType type;
|
||||||
s32 userId;
|
s32 user_id;
|
||||||
u32 resourceId;
|
u32 resource_id;
|
||||||
u64 timestamp;
|
u64 timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef PS4_SYSV_ABI int (*OrbisImeExtKeyboardFilter)(const OrbisImeKeycode* srcKeycode,
|
using OrbisImeExtKeyboardFilter = PS4_SYSV_ABI int (*)(const OrbisImeKeycode* srcKeycode,
|
||||||
u16* outKeycode, u32* outStatus,
|
u16* outKeycode, u32* outStatus,
|
||||||
void* reserved);
|
void* reserved);
|
||||||
|
|
||||||
struct OrbisImeDialogParam {
|
struct OrbisImeDialogParam {
|
||||||
s32 userId;
|
s32 user_id;
|
||||||
OrbisImeType type;
|
OrbisImeType type;
|
||||||
u64 supportedLanguages;
|
u64 supported_languages;
|
||||||
OrbisImeEnterLabel enterLabel;
|
OrbisImeEnterLabel enter_label;
|
||||||
OrbisImeInputMethod inputMethod;
|
OrbisImeInputMethod input_method;
|
||||||
OrbisImeTextFilter filter;
|
OrbisImeTextFilter filter;
|
||||||
OrbisImeDialogOption option;
|
OrbisImeDialogOption option;
|
||||||
u32 maxTextLength;
|
u32 max_text_length;
|
||||||
char16_t* inputTextBuffer;
|
char16_t* input_text_buffer;
|
||||||
float posx;
|
float posx;
|
||||||
float posy;
|
float posy;
|
||||||
OrbisImeHorizontalAlignment horizontalAlignment;
|
OrbisImeHorizontalAlignment horizontal_alignment;
|
||||||
OrbisImeVerticalAlignment verticalAlignment;
|
OrbisImeVerticalAlignment vertical_alignment;
|
||||||
const char16_t* placeholder;
|
const char16_t* placeholder;
|
||||||
const char16_t* title;
|
const char16_t* title;
|
||||||
s8 reserved[16];
|
s8 reserved[16];
|
||||||
@ -133,20 +133,20 @@ struct OrbisImeDialogParam {
|
|||||||
|
|
||||||
struct OrbisImeParamExtended {
|
struct OrbisImeParamExtended {
|
||||||
u32 option; // OrbisImeDialogOptionExtended
|
u32 option; // OrbisImeDialogOptionExtended
|
||||||
OrbisImeColor colorBase;
|
OrbisImeColor color_base;
|
||||||
OrbisImeColor colorLine;
|
OrbisImeColor color_line;
|
||||||
OrbisImeColor colorTextField;
|
OrbisImeColor color_text_field;
|
||||||
OrbisImeColor colorPreedit;
|
OrbisImeColor color_preedit;
|
||||||
OrbisImeColor colorButtonDefault;
|
OrbisImeColor color_button_default;
|
||||||
OrbisImeColor colorButtonFunction;
|
OrbisImeColor color_button_function;
|
||||||
OrbisImeColor colorButtonSymbol;
|
OrbisImeColor color_button_symbol;
|
||||||
OrbisImeColor colorText;
|
OrbisImeColor color_text;
|
||||||
OrbisImeColor colorSpecial;
|
OrbisImeColor color_special;
|
||||||
OrbisImePanelPriority priority;
|
OrbisImePanelPriority priority;
|
||||||
char* additionalDictionaryPath;
|
char* additional_dictionary_path;
|
||||||
OrbisImeExtKeyboardFilter extKeyboardFilter;
|
OrbisImeExtKeyboardFilter ext_keyboard_filter;
|
||||||
uint32_t disableDevice;
|
uint32_t disable_device;
|
||||||
uint32_t extKeyboardMode;
|
uint32_t ext_keyboard_mode;
|
||||||
int8_t reserved[60];
|
int8_t reserved[60];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,4 +167,4 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition();
|
|||||||
Error PS4_SYSV_ABI sceImeDialogTerm();
|
Error PS4_SYSV_ABI sceImeDialogTerm();
|
||||||
|
|
||||||
void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::ImeDialog
|
} // namespace Libraries::ImeDialog
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/singleton.h"
|
|
||||||
#include "core/libraries/ime/ime_dialog.h"
|
#include "core/libraries/ime/ime_dialog.h"
|
||||||
#include "core/libraries/ime/ime_dialog_ui.h"
|
#include "core/libraries/ime/ime_dialog_ui.h"
|
||||||
#include "core/tls.h"
|
#include "core/tls.h"
|
||||||
@ -26,15 +25,15 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
userId = param->userId;
|
user_id = param->user_id;
|
||||||
is_multiLine = True(param->option & OrbisImeDialogOption::MULTILINE);
|
is_multi_line = True(param->option & OrbisImeDialogOption::Multiline);
|
||||||
is_numeric = param->type == OrbisImeType::NUMBER;
|
is_numeric = param->type == OrbisImeType::Number;
|
||||||
type = param->type;
|
type = param->type;
|
||||||
enter_label = param->enterLabel;
|
enter_label = param->enter_label;
|
||||||
text_filter = param->filter;
|
text_filter = param->filter;
|
||||||
keyboard_filter = extended ? extended->extKeyboardFilter : nullptr;
|
keyboard_filter = extended ? extended->ext_keyboard_filter : nullptr;
|
||||||
max_text_length = param->maxTextLength;
|
max_text_length = param->max_text_length;
|
||||||
text_buffer = param->inputTextBuffer;
|
text_buffer = param->input_text_buffer;
|
||||||
|
|
||||||
if (param->title) {
|
if (param->title) {
|
||||||
std::size_t title_len = std::char_traits<char16_t>::length(param->title);
|
std::size_t title_len = std::char_traits<char16_t>::length(param->title);
|
||||||
@ -65,12 +64,12 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept
|
ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept
|
||||||
: input_changed(other.input_changed), userId(other.userId), is_multiLine(other.is_multiLine),
|
: input_changed(other.input_changed), user_id(other.user_id),
|
||||||
is_numeric(other.is_numeric), type(other.type), enter_label(other.enter_label),
|
is_multi_line(other.is_multi_line), is_numeric(other.is_numeric), type(other.type),
|
||||||
text_filter(other.text_filter), keyboard_filter(other.keyboard_filter),
|
enter_label(other.enter_label), text_filter(other.text_filter),
|
||||||
max_text_length(other.max_text_length), text_buffer(other.text_buffer),
|
keyboard_filter(other.keyboard_filter), max_text_length(other.max_text_length),
|
||||||
title(std::move(other.title)), placeholder(std::move(other.placeholder)),
|
text_buffer(other.text_buffer), title(std::move(other.title)),
|
||||||
current_text(other.current_text) {
|
placeholder(std::move(other.placeholder)), current_text(other.current_text) {
|
||||||
|
|
||||||
other.text_buffer = nullptr;
|
other.text_buffer = nullptr;
|
||||||
}
|
}
|
||||||
@ -78,8 +77,8 @@ ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept
|
|||||||
ImeDialogState& ImeDialogState::operator=(ImeDialogState&& other) {
|
ImeDialogState& ImeDialogState::operator=(ImeDialogState&& other) {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
input_changed = other.input_changed;
|
input_changed = other.input_changed;
|
||||||
userId = other.userId;
|
user_id = other.user_id;
|
||||||
is_multiLine = other.is_multiLine;
|
is_multi_line = other.is_multi_line;
|
||||||
is_numeric = other.is_numeric;
|
is_numeric = other.is_numeric;
|
||||||
type = other.type;
|
type = other.type;
|
||||||
enter_label = other.enter_label;
|
enter_label = other.enter_label;
|
||||||
@ -171,7 +170,7 @@ ImeDialogUi::ImeDialogUi(ImeDialogState* state, OrbisImeDialogStatus* status,
|
|||||||
OrbisImeDialogResult* result)
|
OrbisImeDialogResult* result)
|
||||||
: state(state), status(status), result(result) {
|
: state(state), status(status), result(result) {
|
||||||
|
|
||||||
if (state && *status == OrbisImeDialogStatus::RUNNING) {
|
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +190,7 @@ ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
|
|||||||
other.status = nullptr;
|
other.status = nullptr;
|
||||||
other.result = nullptr;
|
other.result = nullptr;
|
||||||
|
|
||||||
if (state && *status == OrbisImeDialogStatus::RUNNING) {
|
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +207,7 @@ ImeDialogUi& ImeDialogUi::operator=(ImeDialogUi&& other) {
|
|||||||
other.status = nullptr;
|
other.status = nullptr;
|
||||||
other.result = nullptr;
|
other.result = nullptr;
|
||||||
|
|
||||||
if (state && *status == OrbisImeDialogStatus::RUNNING) {
|
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +225,7 @@ void ImeDialogUi::Draw() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status || *status != OrbisImeDialogStatus::RUNNING) {
|
if (!status || *status != OrbisImeDialogStatus::Running) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +234,7 @@ void ImeDialogUi::Draw() {
|
|||||||
|
|
||||||
ImVec2 window_size;
|
ImVec2 window_size;
|
||||||
|
|
||||||
if (state->is_multiLine) {
|
if (state->is_multi_line) {
|
||||||
window_size = {500.0f, 300.0f};
|
window_size = {500.0f, 300.0f};
|
||||||
} else {
|
} else {
|
||||||
window_size = {500.0f, 150.0f};
|
window_size = {500.0f, 150.0f};
|
||||||
@ -259,7 +258,7 @@ void ImeDialogUi::Draw() {
|
|||||||
SetWindowFontScale(1.0f);
|
SetWindowFontScale(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->is_multiLine) {
|
if (state->is_multi_line) {
|
||||||
DrawMultiLineInputText();
|
DrawMultiLineInputText();
|
||||||
} else {
|
} else {
|
||||||
DrawInputText();
|
DrawInputText();
|
||||||
@ -270,16 +269,16 @@ void ImeDialogUi::Draw() {
|
|||||||
const char* button_text;
|
const char* button_text;
|
||||||
|
|
||||||
switch (state->enter_label) {
|
switch (state->enter_label) {
|
||||||
case OrbisImeEnterLabel::GO:
|
case OrbisImeEnterLabel::Go:
|
||||||
button_text = "Go##ImeDialogOK";
|
button_text = "Go##ImeDialogOK";
|
||||||
break;
|
break;
|
||||||
case OrbisImeEnterLabel::SEARCH:
|
case OrbisImeEnterLabel::Search:
|
||||||
button_text = "Search##ImeDialogOK";
|
button_text = "Search##ImeDialogOK";
|
||||||
break;
|
break;
|
||||||
case OrbisImeEnterLabel::SEND:
|
case OrbisImeEnterLabel::Send:
|
||||||
button_text = "Send##ImeDialogOK";
|
button_text = "Send##ImeDialogOK";
|
||||||
break;
|
break;
|
||||||
case OrbisImeEnterLabel::DEFAULT:
|
case OrbisImeEnterLabel::Default:
|
||||||
default:
|
default:
|
||||||
button_text = "OK##ImeDialogOK";
|
button_text = "OK##ImeDialogOK";
|
||||||
break;
|
break;
|
||||||
@ -292,16 +291,16 @@ void ImeDialogUi::Draw() {
|
|||||||
SetCursorPosX(button_start_pos);
|
SetCursorPosX(button_start_pos);
|
||||||
|
|
||||||
if (Button(button_text, BUTTON_SIZE) ||
|
if (Button(button_text, BUTTON_SIZE) ||
|
||||||
(!state->is_multiLine && IsKeyPressed(ImGuiKey_Enter))) {
|
(!state->is_multi_line && IsKeyPressed(ImGuiKey_Enter))) {
|
||||||
*status = OrbisImeDialogStatus::FINISHED;
|
*status = OrbisImeDialogStatus::Finished;
|
||||||
result->endstatus = OrbisImeDialogEndStatus::OK;
|
result->endstatus = OrbisImeDialogEndStatus::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
SameLine(0.0f, button_spacing);
|
SameLine(0.0f, button_spacing);
|
||||||
|
|
||||||
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
||||||
*status = OrbisImeDialogStatus::FINISHED;
|
*status = OrbisImeDialogStatus::Finished;
|
||||||
result->endstatus = OrbisImeDialogEndStatus::USER_CANCELED;
|
result->endstatus = OrbisImeDialogEndStatus::UserCanceled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
End();
|
End();
|
||||||
@ -362,9 +361,10 @@ int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
.status = 1, // ??? 1 = key pressed, 0 = key released
|
.status = 1, // ??? 1 = key pressed, 0 = key released
|
||||||
.type = OrbisImeKeyboardType::ENGLISH_US, // TODO set this to the correct value (maybe use
|
.type = OrbisImeKeyboardType::ENGLISH_US, // TODO set this to the correct value (maybe use
|
||||||
// the current language?)
|
// the current language?)
|
||||||
.userId = ui->state->userId,
|
.user_id = ui->state->user_id,
|
||||||
.resourceId = 0,
|
.resource_id = 0,
|
||||||
.timestamp = 0};
|
.timestamp = 0,
|
||||||
|
};
|
||||||
|
|
||||||
if (!ui->state->ConvertUTF8ToOrbis(event_char, 4, &src_keycode.character, 1)) {
|
if (!ui->state->ConvertUTF8ToOrbis(event_char, 4, &src_keycode.character, 1)) {
|
||||||
LOG_ERROR(Lib_ImeDialog, "Failed to convert orbis char to utf8");
|
LOG_ERROR(Lib_ImeDialog, "Failed to convert orbis char to utf8");
|
||||||
|
@ -20,8 +20,8 @@ class ImeDialogState final {
|
|||||||
|
|
||||||
bool input_changed = false;
|
bool input_changed = false;
|
||||||
|
|
||||||
s32 userId{};
|
s32 user_id{};
|
||||||
bool is_multiLine{};
|
bool is_multi_line{};
|
||||||
bool is_numeric{};
|
bool is_numeric{};
|
||||||
OrbisImeType type{};
|
OrbisImeType type{};
|
||||||
OrbisImeEnterLabel enter_label{};
|
OrbisImeEnterLabel enter_label{};
|
||||||
|
51
src/core/libraries/ime/ime_error.h
Normal file
51
src/core/libraries/ime/ime_error.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// ImeDialog library
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_NOT_INITIALIZED = 0x80ED0001;
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_ALREADY_INITIALIZED = 0x80ED0002;
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_PARAM_INVALID = 0x80ED0003;
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_UNEXPECTED_FATAL = 0x80ED0004;
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_INVALID_STATE = 0x80ED0005;
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_SERVICE_BUSY = 0x80ED0006;
|
||||||
|
constexpr int ORBIS_ERROR_DIALOG_ERROR_INVALID_USER_ID = 0x80ED0007;
|
||||||
|
|
||||||
|
// Ime library
|
||||||
|
constexpr int ORBIS_IME_ERROR_BUSY = 0x80BC0001;
|
||||||
|
constexpr int ORBIS_IME_ERROR_NOT_OPENED = 0x80BC0002;
|
||||||
|
constexpr int ORBIS_IME_ERROR_NO_MEMORY = 0x80BC0003;
|
||||||
|
constexpr int ORBIS_IME_ERROR_CONNECTION_FAILED = 0x80BC0004;
|
||||||
|
constexpr int ORBIS_IME_ERROR_TOO_MANY_REQUESTS = 0x80BC0005;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_TEXT = 0x80BC0006;
|
||||||
|
constexpr int ORBIS_IME_ERROR_EVENT_OVERFLOW = 0x80BC0007;
|
||||||
|
constexpr int ORBIS_IME_ERROR_NOT_ACTIVE = 0x80BC0008;
|
||||||
|
constexpr int ORBIS_IME_ERROR_IME_SUSPENDING = 0x80BC0009;
|
||||||
|
constexpr int ORBIS_IME_ERROR_DEVICE_IN_USE = 0x80BC000A;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_USER_ID = 0x80BC0010;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_TYPE = 0x80BC0011;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_SUPPORTED_LANGUAGES = 0x80BC0012;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_ENTER_LABEL = 0x80BC0013;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_INPUT_METHOD = 0x80BC0014;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_OPTION = 0x80BC0015;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_MAX_TEXT_LENGTH = 0x80BC0016;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_INPUT_TEXT_BUFFER = 0x80BC0017;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_POSX = 0x80BC0018;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_POSY = 0x80BC0019;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_HORIZONTAL_ALIGNMENT = 0x80BC001A;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_VERTICAL_ALIGNMENT = 0x80BC001B;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_EXTENDED = 0x80BC001C;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_KEYBOARD_TYPE = 0x80BC001D;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_WORK = 0x80BC0020;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_ARG = 0x80BC0021;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_HANDLER = 0x80BC0022;
|
||||||
|
constexpr int ORBIS_IME_ERROR_NO_RESOURCE_ID = 0x80BC0023;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_MODE = 0x80BC0024;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_PARAM = 0x80BC0030;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_ADDRESS = 0x80BC0031;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_RESERVED = 0x80BC0032;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INVALID_TIMING = 0x80BC0033;
|
||||||
|
constexpr int ORBIS_IME_ERROR_INTERNAL = 0x80BC00FF;
|
@ -26,15 +26,13 @@ ImeState::ImeState(const OrbisImeParam* param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImeState::ImeState(ImeState&& other) noexcept
|
ImeState::ImeState(ImeState&& other) noexcept
|
||||||
: input_changed(other.input_changed), work_buffer(other.work_buffer),
|
: work_buffer(other.work_buffer), text_buffer(other.text_buffer),
|
||||||
text_buffer(other.text_buffer), current_text(std::move(other.current_text)),
|
current_text(std::move(other.current_text)), event_queue(std::move(other.event_queue)) {
|
||||||
event_queue(std::move(other.event_queue)) {
|
|
||||||
other.text_buffer = nullptr;
|
other.text_buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImeState& ImeState::operator=(ImeState&& other) noexcept {
|
ImeState& ImeState::operator=(ImeState&& other) noexcept {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
input_changed = other.input_changed;
|
|
||||||
work_buffer = other.work_buffer;
|
work_buffer = other.work_buffer;
|
||||||
text_buffer = other.text_buffer;
|
text_buffer = other.text_buffer;
|
||||||
current_text = std::move(other.current_text);
|
current_text = std::move(other.current_text);
|
||||||
@ -52,17 +50,21 @@ void ImeState::SendEvent(OrbisImeEvent* event) {
|
|||||||
|
|
||||||
void ImeState::SendEnterEvent() {
|
void ImeState::SendEnterEvent() {
|
||||||
OrbisImeEvent enterEvent{};
|
OrbisImeEvent enterEvent{};
|
||||||
enterEvent.id = OrbisImeEventId::PRESS_ENTER;
|
enterEvent.id = OrbisImeEventId::PressEnter;
|
||||||
SendEvent(&enterEvent);
|
SendEvent(&enterEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImeState::SendCloseEvent() {
|
void ImeState::SendCloseEvent() {
|
||||||
OrbisImeEvent closeEvent{};
|
OrbisImeEvent closeEvent{};
|
||||||
closeEvent.id = OrbisImeEventId::PRESS_CLOSE;
|
closeEvent.id = OrbisImeEventId::PressClose;
|
||||||
closeEvent.param.text.str = reinterpret_cast<char16_t*>(work_buffer);
|
closeEvent.param.text.str = reinterpret_cast<char16_t*>(work_buffer);
|
||||||
SendEvent(&closeEvent);
|
SendEvent(&closeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImeState::SetText(const char16_t* text, u32 length) {}
|
||||||
|
|
||||||
|
void ImeState::SetCaret(u32 position) {}
|
||||||
|
|
||||||
bool ImeState::ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len,
|
bool ImeState::ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len,
|
||||||
char* utf8_text, std::size_t utf8_text_len) {
|
char* utf8_text, std::size_t utf8_text_len) {
|
||||||
std::fill(utf8_text, utf8_text + utf8_text_len, '\0');
|
std::fill(utf8_text, utf8_text + utf8_text_len, '\0');
|
||||||
@ -182,7 +184,6 @@ void ImeUi::DrawInputText() {
|
|||||||
}
|
}
|
||||||
if (InputTextEx("##ImeInput", nullptr, state->current_text.begin(), ime_param->maxTextLength,
|
if (InputTextEx("##ImeInput", nullptr, state->current_text.begin(), ime_param->maxTextLength,
|
||||||
input_size, ImGuiInputTextFlags_CallbackAlways, InputTextCallback, this)) {
|
input_size, ImGuiInputTextFlags_CallbackAlways, InputTextCallback, this)) {
|
||||||
state->input_changed = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,36 +191,17 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
ImeUi* ui = static_cast<ImeUi*>(data->UserData);
|
ImeUi* ui = static_cast<ImeUi*>(data->UserData);
|
||||||
ASSERT(ui);
|
ASSERT(ui);
|
||||||
|
|
||||||
static int lastCaretPos = -1;
|
|
||||||
if (lastCaretPos == -1) {
|
|
||||||
lastCaretPos = data->CursorPos;
|
|
||||||
} else if (data->CursorPos != lastCaretPos) {
|
|
||||||
OrbisImeCaretMovementDirection caretDirection = OrbisImeCaretMovementDirection::STILL;
|
|
||||||
if (data->CursorPos < lastCaretPos) {
|
|
||||||
caretDirection = OrbisImeCaretMovementDirection::LEFT;
|
|
||||||
} else if (data->CursorPos > lastCaretPos) {
|
|
||||||
caretDirection = OrbisImeCaretMovementDirection::RIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
OrbisImeEvent event{};
|
|
||||||
event.id = OrbisImeEventId::UPDATE_CARET;
|
|
||||||
event.param.caretMove = caretDirection;
|
|
||||||
|
|
||||||
lastCaretPos = data->CursorPos;
|
|
||||||
ui->state->SendEvent(&event);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string lastText;
|
static std::string lastText;
|
||||||
std::string currentText(data->Buf, data->BufTextLen);
|
std::string currentText(data->Buf, data->BufTextLen);
|
||||||
if (currentText != lastText) {
|
if (currentText != lastText) {
|
||||||
OrbisImeEditText eventParam{};
|
OrbisImeEditText eventParam{};
|
||||||
eventParam.str = reinterpret_cast<char16_t*>(ui->ime_param->work);
|
eventParam.str = reinterpret_cast<char16_t*>(ui->ime_param->work);
|
||||||
eventParam.caretIndex = data->CursorPos;
|
eventParam.caret_index = data->CursorPos;
|
||||||
eventParam.areaNum = 1;
|
eventParam.area_num = 1;
|
||||||
|
|
||||||
eventParam.textArea[0].mode = 1; // Edit mode
|
eventParam.text_area[0].mode = 1; // Edit mode
|
||||||
eventParam.textArea[0].index = data->CursorPos;
|
eventParam.text_area[0].index = data->CursorPos;
|
||||||
eventParam.textArea[0].length = data->BufTextLen;
|
eventParam.text_area[0].length = data->BufTextLen;
|
||||||
|
|
||||||
if (!ui->state->ConvertUTF8ToOrbis(data->Buf, data->BufTextLen, eventParam.str,
|
if (!ui->state->ConvertUTF8ToOrbis(data->Buf, data->BufTextLen, eventParam.str,
|
||||||
ui->ime_param->maxTextLength)) {
|
ui->ime_param->maxTextLength)) {
|
||||||
@ -235,13 +217,32 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OrbisImeEvent event{};
|
OrbisImeEvent event{};
|
||||||
event.id = OrbisImeEventId::UPDATE_TEXT;
|
event.id = OrbisImeEventId::UpdateText;
|
||||||
event.param.text = eventParam;
|
event.param.text = eventParam;
|
||||||
|
|
||||||
lastText = currentText;
|
lastText = currentText;
|
||||||
ui->state->SendEvent(&event);
|
ui->state->SendEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lastCaretPos = -1;
|
||||||
|
if (lastCaretPos == -1) {
|
||||||
|
lastCaretPos = data->CursorPos;
|
||||||
|
} else if (data->CursorPos != lastCaretPos) {
|
||||||
|
OrbisImeCaretMovementDirection caretDirection = OrbisImeCaretMovementDirection::Still;
|
||||||
|
if (data->CursorPos < lastCaretPos) {
|
||||||
|
caretDirection = OrbisImeCaretMovementDirection::Left;
|
||||||
|
} else if (data->CursorPos > lastCaretPos) {
|
||||||
|
caretDirection = OrbisImeCaretMovementDirection::Right;
|
||||||
|
}
|
||||||
|
|
||||||
|
OrbisImeEvent event{};
|
||||||
|
event.id = OrbisImeEventId::UpdateCaret;
|
||||||
|
event.param.caret_move = caretDirection;
|
||||||
|
|
||||||
|
lastCaretPos = data->CursorPos;
|
||||||
|
ui->state->SendEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,4 +250,4 @@ void ImeUi::Free() {
|
|||||||
RemoveLayer(this);
|
RemoveLayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace Libraries::Ime
|
}; // namespace Libraries::Ime
|
||||||
|
@ -22,10 +22,7 @@ class ImeState {
|
|||||||
friend class ImeHandler;
|
friend class ImeHandler;
|
||||||
friend class ImeUi;
|
friend class ImeUi;
|
||||||
|
|
||||||
bool input_changed = false;
|
|
||||||
|
|
||||||
void* work_buffer{};
|
void* work_buffer{};
|
||||||
|
|
||||||
char16_t* text_buffer{};
|
char16_t* text_buffer{};
|
||||||
|
|
||||||
// A character can hold up to 4 bytes in UTF-8
|
// A character can hold up to 4 bytes in UTF-8
|
||||||
@ -43,6 +40,9 @@ public:
|
|||||||
void SendEnterEvent();
|
void SendEnterEvent();
|
||||||
void SendCloseEvent();
|
void SendCloseEvent();
|
||||||
|
|
||||||
|
void SetText(const char16_t* text, u32 length);
|
||||||
|
void SetCaret(u32 position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len, char* utf8_text,
|
bool ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len, char* utf8_text,
|
||||||
std::size_t native_text_len);
|
std::size_t native_text_len);
|
||||||
|
9
src/core/libraries/jpeg/jpeg_error.h
Normal file
9
src/core/libraries/jpeg/jpeg_error.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_ADDR = 0x80650101;
|
||||||
|
constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_SIZE = 0x80650102;
|
||||||
|
constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_PARAM = 0x80650103;
|
||||||
|
constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_HANDLE = 0x80650104;
|
207
src/core/libraries/jpeg/jpegenc.cpp
Normal file
207
src/core/libraries/jpeg/jpegenc.cpp
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <magic_enum.hpp>
|
||||||
|
#include "common/alignment.h"
|
||||||
|
#include "common/assert.h"
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
#include "core/libraries/libs.h"
|
||||||
|
#include "jpeg_error.h"
|
||||||
|
#include "jpegenc.h"
|
||||||
|
|
||||||
|
namespace Libraries::JpegEnc {
|
||||||
|
|
||||||
|
constexpr s32 ORBIS_JPEG_ENC_MINIMUM_MEMORY_SIZE = 0x800;
|
||||||
|
constexpr u32 ORBIS_JPEG_ENC_MAX_IMAGE_DIMENSION = 0xFFFF;
|
||||||
|
constexpr u32 ORBIS_JPEG_ENC_MAX_IMAGE_PITCH = 0xFFFFFFF;
|
||||||
|
constexpr u32 ORBIS_JPEG_ENC_MAX_IMAGE_SIZE = 0x7FFFFFFF;
|
||||||
|
|
||||||
|
static s32 ValidateJpegEncCreateParam(const OrbisJpegEncCreateParam* param) {
|
||||||
|
if (!param) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_ADDR;
|
||||||
|
}
|
||||||
|
if (param->size != sizeof(OrbisJpegEncCreateParam)) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_SIZE;
|
||||||
|
}
|
||||||
|
if (param->attr != ORBIS_JPEG_ENC_ATTRIBUTE_NONE) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s32 ValidateJpegEncMemory(const void* memory, const u32 memory_size) {
|
||||||
|
if (!memory) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_ADDR;
|
||||||
|
}
|
||||||
|
if (memory_size < ORBIS_JPEG_ENC_MINIMUM_MEMORY_SIZE) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_SIZE;
|
||||||
|
}
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s32 ValidateJpegEncEncodeParam(const OrbisJpegEncEncodeParam* param) {
|
||||||
|
|
||||||
|
// Validate addresses
|
||||||
|
if (!param) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_ADDR;
|
||||||
|
}
|
||||||
|
if (!param->image || (param->pixel_format != ORBIS_JPEG_ENC_PIXEL_FORMAT_Y8 &&
|
||||||
|
!Common::IsAligned(reinterpret_cast<VAddr>(param->image), 4))) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_ADDR;
|
||||||
|
}
|
||||||
|
if (!param->jpeg) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_ADDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate sizes
|
||||||
|
if (param->image_size == 0 || param->jpeg_size == 0) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate parameters
|
||||||
|
if (param->image_width > ORBIS_JPEG_ENC_MAX_IMAGE_DIMENSION ||
|
||||||
|
param->image_height > ORBIS_JPEG_ENC_MAX_IMAGE_DIMENSION) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (param->image_pitch == 0 || param->image_pitch > ORBIS_JPEG_ENC_MAX_IMAGE_PITCH ||
|
||||||
|
(param->pixel_format != ORBIS_JPEG_ENC_PIXEL_FORMAT_Y8 &&
|
||||||
|
!Common::IsAligned(param->image_pitch, 4))) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
const auto calculated_size = param->image_height * param->image_pitch;
|
||||||
|
if (calculated_size > ORBIS_JPEG_ENC_MAX_IMAGE_SIZE || calculated_size > param->image_size) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (param->encode_mode != ORBIS_JPEG_ENC_ENCODE_MODE_NORMAL &&
|
||||||
|
param->encode_mode != ORBIS_JPEG_ENC_ENCODE_MODE_MJPEG) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (param->color_space != ORBIS_JPEG_ENC_COLOR_SPACE_YCC &&
|
||||||
|
param->color_space != ORBIS_JPEG_ENC_COLOR_SPACE_GRAYSCALE) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (param->sampling_type != ORBIS_JPEG_ENC_SAMPLING_TYPE_FULL &&
|
||||||
|
param->sampling_type != ORBIS_JPEG_ENC_SAMPLING_TYPE_422 &&
|
||||||
|
param->sampling_type != ORBIS_JPEG_ENC_SAMPLING_TYPE_420) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (param->restart_interval > ORBIS_JPEG_ENC_MAX_IMAGE_DIMENSION) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
switch (param->pixel_format) {
|
||||||
|
case ORBIS_JPEG_ENC_PIXEL_FORMAT_R8G8B8A8:
|
||||||
|
case ORBIS_JPEG_ENC_PIXEL_FORMAT_B8G8R8A8:
|
||||||
|
if (param->image_pitch >> 2 < param->image_width ||
|
||||||
|
param->color_space != ORBIS_JPEG_ENC_COLOR_SPACE_YCC ||
|
||||||
|
param->sampling_type == ORBIS_JPEG_ENC_SAMPLING_TYPE_FULL) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ORBIS_JPEG_ENC_PIXEL_FORMAT_Y8U8Y8V8:
|
||||||
|
if (param->image_pitch >> 1 < Common::AlignUp(param->image_width, 2) ||
|
||||||
|
param->color_space != ORBIS_JPEG_ENC_COLOR_SPACE_YCC ||
|
||||||
|
param->sampling_type == ORBIS_JPEG_ENC_SAMPLING_TYPE_FULL) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ORBIS_JPEG_ENC_PIXEL_FORMAT_Y8:
|
||||||
|
if (param->image_pitch < param->image_width ||
|
||||||
|
param->color_space != ORBIS_JPEG_ENC_COLOR_SPACE_GRAYSCALE ||
|
||||||
|
param->sampling_type != ORBIS_JPEG_ENC_SAMPLING_TYPE_FULL) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s32 ValidateJpecEngHandle(OrbisJpegEncHandle handle) {
|
||||||
|
if (!handle || !Common::IsAligned(reinterpret_cast<VAddr>(handle), 0x20) ||
|
||||||
|
handle->handle != handle) {
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncCreate(const OrbisJpegEncCreateParam* param, void* memory,
|
||||||
|
const u32 memory_size, OrbisJpegEncHandle* handle) {
|
||||||
|
if (auto param_ret = ValidateJpegEncCreateParam(param); param_ret != ORBIS_OK) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid create param");
|
||||||
|
return param_ret;
|
||||||
|
}
|
||||||
|
if (auto memory_ret = ValidateJpegEncMemory(memory, memory_size); memory_ret != ORBIS_OK) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid memory");
|
||||||
|
return memory_ret;
|
||||||
|
}
|
||||||
|
if (!handle) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid handle output");
|
||||||
|
return ORBIS_JPEG_ENC_ERROR_INVALID_ADDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* handle_internal = reinterpret_cast<OrbisJpegEncHandleInternal*>(
|
||||||
|
Common::AlignUp(reinterpret_cast<VAddr>(memory), 0x20));
|
||||||
|
handle_internal->handle = handle_internal;
|
||||||
|
handle_internal->handle_size = sizeof(OrbisJpegEncHandleInternal*);
|
||||||
|
*handle = handle_internal;
|
||||||
|
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncDelete(OrbisJpegEncHandle handle) {
|
||||||
|
if (auto handle_ret = ValidateJpecEngHandle(handle); handle_ret != ORBIS_OK) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid handle");
|
||||||
|
return handle_ret;
|
||||||
|
}
|
||||||
|
handle->handle = nullptr;
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncEncode(OrbisJpegEncHandle handle, const OrbisJpegEncEncodeParam* param,
|
||||||
|
OrbisJpegEncOutputInfo* output_info) {
|
||||||
|
if (auto handle_ret = ValidateJpecEngHandle(handle); handle_ret != ORBIS_OK) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid handle");
|
||||||
|
return handle_ret;
|
||||||
|
}
|
||||||
|
if (auto param_ret = ValidateJpegEncEncodeParam(param); param_ret != ORBIS_OK) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid encode param");
|
||||||
|
return param_ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_ERROR(Lib_Jpeg,
|
||||||
|
"(STUBBED) image_size = {} , jpeg_size = {} , image_width = {} , image_height = {} , "
|
||||||
|
"image_pitch = {} , pixel_format = {} , encode_mode = {} , color_space = {} , "
|
||||||
|
"sampling_type = {} , compression_ratio = {} , restart_interval = {}",
|
||||||
|
param->image_size, param->jpeg_size, param->image_width, param->image_height,
|
||||||
|
param->image_pitch, magic_enum::enum_name(param->pixel_format),
|
||||||
|
magic_enum::enum_name(param->encode_mode), magic_enum::enum_name(param->color_space),
|
||||||
|
magic_enum::enum_name(param->sampling_type), param->compression_ratio,
|
||||||
|
param->restart_interval);
|
||||||
|
|
||||||
|
if (output_info) {
|
||||||
|
output_info->size = param->jpeg_size;
|
||||||
|
output_info->height = param->image_height;
|
||||||
|
}
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncQueryMemorySize(const OrbisJpegEncCreateParam* param) {
|
||||||
|
if (auto param_ret = ValidateJpegEncCreateParam(param); param_ret != ORBIS_OK) {
|
||||||
|
LOG_ERROR(Lib_Jpeg, "Invalid create param");
|
||||||
|
return param_ret;
|
||||||
|
}
|
||||||
|
return ORBIS_JPEG_ENC_MINIMUM_MEMORY_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterlibSceJpegEnc(Core::Loader::SymbolsResolver* sym) {
|
||||||
|
LIB_FUNCTION("K+rocojkr-I", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncCreate);
|
||||||
|
LIB_FUNCTION("j1LyMdaM+C0", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncDelete);
|
||||||
|
LIB_FUNCTION("QbrU0cUghEM", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncEncode);
|
||||||
|
LIB_FUNCTION("o6ZgXfFdWXQ", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1,
|
||||||
|
sceJpegEncQueryMemorySize);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Libraries::JpegEnc
|
84
src/core/libraries/jpeg/jpegenc.h
Normal file
84
src/core/libraries/jpeg/jpegenc.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
|
namespace Core::Loader {
|
||||||
|
class SymbolsResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Libraries::JpegEnc {
|
||||||
|
|
||||||
|
enum OrbisJpegEncCreateParamAttributes : u32 { ORBIS_JPEG_ENC_ATTRIBUTE_NONE = 0 };
|
||||||
|
|
||||||
|
enum OrbisJpegEncEncodeParamPixelFormat : u16 {
|
||||||
|
ORBIS_JPEG_ENC_PIXEL_FORMAT_R8G8B8A8 = 0,
|
||||||
|
ORBIS_JPEG_ENC_PIXEL_FORMAT_B8G8R8A8 = 1,
|
||||||
|
ORBIS_JPEG_ENC_PIXEL_FORMAT_Y8U8Y8V8 = 10,
|
||||||
|
ORBIS_JPEG_ENC_PIXEL_FORMAT_Y8 = 11
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OrbisJpengEncEncodeParamEncodeMode : u16 {
|
||||||
|
ORBIS_JPEG_ENC_ENCODE_MODE_NORMAL = 0,
|
||||||
|
ORBIS_JPEG_ENC_ENCODE_MODE_MJPEG = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OrbisJpengEncEncodeParamColorSpace : u16 {
|
||||||
|
ORBIS_JPEG_ENC_COLOR_SPACE_YCC = 1,
|
||||||
|
ORBIS_JPEG_ENC_COLOR_SPACE_GRAYSCALE = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OrbisJpengEncEncodeParamSamplingType : u8 {
|
||||||
|
ORBIS_JPEG_ENC_SAMPLING_TYPE_FULL = 0,
|
||||||
|
ORBIS_JPEG_ENC_SAMPLING_TYPE_422 = 1,
|
||||||
|
ORBIS_JPEG_ENC_SAMPLING_TYPE_420 = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisJpegEncHandleInternal {
|
||||||
|
OrbisJpegEncHandleInternal* handle;
|
||||||
|
u32 handle_size;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(OrbisJpegEncHandleInternal) == 0x10);
|
||||||
|
|
||||||
|
typedef OrbisJpegEncHandleInternal* OrbisJpegEncHandle;
|
||||||
|
|
||||||
|
struct OrbisJpegEncCreateParam {
|
||||||
|
u32 size;
|
||||||
|
OrbisJpegEncCreateParamAttributes attr;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(OrbisJpegEncCreateParam) == 0x8);
|
||||||
|
|
||||||
|
struct OrbisJpegEncEncodeParam {
|
||||||
|
void* image;
|
||||||
|
void* jpeg;
|
||||||
|
u32 image_size;
|
||||||
|
u32 jpeg_size;
|
||||||
|
u32 image_width;
|
||||||
|
u32 image_height;
|
||||||
|
u32 image_pitch;
|
||||||
|
OrbisJpegEncEncodeParamPixelFormat pixel_format;
|
||||||
|
OrbisJpengEncEncodeParamEncodeMode encode_mode;
|
||||||
|
OrbisJpengEncEncodeParamColorSpace color_space;
|
||||||
|
OrbisJpengEncEncodeParamSamplingType sampling_type;
|
||||||
|
u8 compression_ratio;
|
||||||
|
s32 restart_interval;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(OrbisJpegEncEncodeParam) == 0x30);
|
||||||
|
|
||||||
|
struct OrbisJpegEncOutputInfo {
|
||||||
|
u32 size;
|
||||||
|
u32 height;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(OrbisJpegEncOutputInfo) == 0x8);
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncCreate(const OrbisJpegEncCreateParam* param, void* memory,
|
||||||
|
u32 memory_size, OrbisJpegEncHandle* handle);
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncDelete(OrbisJpegEncHandle handle);
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncEncode(OrbisJpegEncHandle handle, const OrbisJpegEncEncodeParam* param,
|
||||||
|
OrbisJpegEncOutputInfo* output_info);
|
||||||
|
s32 PS4_SYSV_ABI sceJpegEncQueryMemorySize(const OrbisJpegEncCreateParam* param);
|
||||||
|
|
||||||
|
void RegisterlibSceJpegEnc(Core::Loader::SymbolsResolver* sym);
|
||||||
|
} // namespace Libraries::JpegEnc
|
@ -4,8 +4,8 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/equeue.h"
|
#include "core/libraries/kernel/equeue.h"
|
||||||
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
@ -77,9 +77,8 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
|
|||||||
bool has_found = false;
|
bool has_found = false;
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
|
|
||||||
for (auto& event : m_events) {
|
for (auto& event : m_events) {
|
||||||
if ((event.event.ident == ident) && (event.event.filter == filter)) {
|
if (event.event.ident == ident && event.event.filter == filter) {
|
||||||
event.Trigger(trigger_data);
|
event.Trigger(trigger_data);
|
||||||
has_found = true;
|
has_found = true;
|
||||||
}
|
}
|
||||||
@ -91,7 +90,6 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
|
|||||||
|
|
||||||
int EqueueInternal::GetTriggeredEvents(SceKernelEvent* ev, int num) {
|
int EqueueInternal::GetTriggeredEvents(SceKernelEvent* ev, int num) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (auto& event : m_events) {
|
for (auto& event : m_events) {
|
||||||
if (event.IsTriggered()) {
|
if (event.IsTriggered()) {
|
||||||
if (event.event.flags & SceKernelEvent::Flags::Clear) {
|
if (event.event.flags & SceKernelEvent::Flags::Clear) {
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/file_system.h"
|
#include "core/libraries/kernel/file_system.h"
|
||||||
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
@ -174,12 +174,12 @@ int PS4_SYSV_ABI sceKernelClose(int d) {
|
|||||||
return ORBIS_KERNEL_ERROR_EPERM;
|
return ORBIS_KERNEL_ERROR_EPERM;
|
||||||
}
|
}
|
||||||
if (d == 2003) { // dev/urandom case
|
if (d == 2003) { // dev/urandom case
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
auto* file = h->GetFile(d);
|
auto* file = h->GetFile(d);
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EBADF;
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
}
|
}
|
||||||
if (file->type == Core::FileSys::FileType::Regular) {
|
if (file->type == Core::FileSys::FileType::Regular) {
|
||||||
file->f.Close();
|
file->f.Close();
|
||||||
@ -188,7 +188,7 @@ int PS4_SYSV_ABI sceKernelClose(int d) {
|
|||||||
LOG_INFO(Kernel_Fs, "Closing {}", file->m_guest_name);
|
LOG_INFO(Kernel_Fs, "Closing {}", file->m_guest_name);
|
||||||
// FIXME: Lock file mutex before deleting it?
|
// FIXME: Lock file mutex before deleting it?
|
||||||
h->DeleteHandle(d);
|
h->DeleteHandle(d);
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_close(int d) {
|
int PS4_SYSV_ABI posix_close(int d) {
|
||||||
@ -205,7 +205,7 @@ size_t PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) {
|
|||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
auto* file = h->GetFile(d);
|
auto* file = h->GetFile(d);
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EBADF;
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::scoped_lock lk{file->m_mutex};
|
std::scoped_lock lk{file->m_mutex};
|
||||||
@ -217,7 +217,7 @@ size_t PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
|
int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
@ -226,15 +226,15 @@ int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
|
|||||||
bool ro = false;
|
bool ro = false;
|
||||||
const auto host_path = mnt->GetHostPath(path, &ro);
|
const auto host_path = mnt->GetHostPath(path, &ro);
|
||||||
if (host_path.empty()) {
|
if (host_path.empty()) {
|
||||||
return SCE_KERNEL_ERROR_EACCES;
|
return ORBIS_KERNEL_ERROR_EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ro) {
|
if (ro) {
|
||||||
return SCE_KERNEL_ERROR_EROFS;
|
return ORBIS_KERNEL_ERROR_EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::filesystem::is_directory(host_path)) {
|
if (std::filesystem::is_directory(host_path)) {
|
||||||
return SCE_KERNEL_ERROR_EPERM;
|
return ORBIS_KERNEL_ERROR_EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* file = h->GetFile(host_path);
|
auto* file = h->GetFile(host_path);
|
||||||
@ -243,7 +243,7 @@ int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Kernel_Fs, "Unlinked {}", path);
|
LOG_INFO(Kernel_Fs, "Unlinked {}", path);
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PS4_SYSV_ABI _readv(int d, const SceKernelIovec* iov, int iovcnt) {
|
size_t PS4_SYSV_ABI _readv(int d, const SceKernelIovec* iov, int iovcnt) {
|
||||||
@ -318,7 +318,7 @@ s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) {
|
|||||||
|
|
||||||
if (!file->f.Seek(offset, origin)) {
|
if (!file->f.Seek(offset, origin)) {
|
||||||
LOG_CRITICAL(Kernel_Fs, "sceKernelLseek: failed to seek");
|
LOG_CRITICAL(Kernel_Fs, "sceKernelLseek: failed to seek");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
return file->f.Tell();
|
return file->f.Tell();
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) {
|
|||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
auto* file = h->GetFile(d);
|
auto* file = h->GetFile(d);
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EBADF;
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::scoped_lock lk{file->m_mutex};
|
std::scoped_lock lk{file->m_mutex};
|
||||||
@ -367,7 +367,7 @@ int PS4_SYSV_ABI posix_read(int d, void* buf, size_t nbytes) {
|
|||||||
int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
|
int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
|
||||||
LOG_INFO(Kernel_Fs, "path = {} mode = {}", path, mode);
|
LOG_INFO(Kernel_Fs, "path = {} mode = {}", path, mode);
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||||
|
|
||||||
@ -375,21 +375,21 @@ int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
|
|||||||
const auto dir_name = mnt->GetHostPath(path, &ro);
|
const auto dir_name = mnt->GetHostPath(path, &ro);
|
||||||
|
|
||||||
if (std::filesystem::exists(dir_name)) {
|
if (std::filesystem::exists(dir_name)) {
|
||||||
return SCE_KERNEL_ERROR_EEXIST;
|
return ORBIS_KERNEL_ERROR_EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ro) {
|
if (ro) {
|
||||||
return SCE_KERNEL_ERROR_EROFS;
|
return ORBIS_KERNEL_ERROR_EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CUSA02456: path = /aotl after sceSaveDataMount(mode = 1)
|
// CUSA02456: path = /aotl after sceSaveDataMount(mode = 1)
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
if (dir_name.empty() || !std::filesystem::create_directory(dir_name, ec)) {
|
if (dir_name.empty() || !std::filesystem::create_directory(dir_name, ec)) {
|
||||||
return SCE_KERNEL_ERROR_EIO;
|
return ORBIS_KERNEL_ERROR_EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::filesystem::exists(dir_name)) {
|
if (!std::filesystem::exists(dir_name)) {
|
||||||
return SCE_KERNEL_ERROR_ENOENT;
|
return ORBIS_KERNEL_ERROR_ENOENT;
|
||||||
}
|
}
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -413,13 +413,13 @@ int PS4_SYSV_ABI sceKernelRmdir(const char* path) {
|
|||||||
if (dir_name.empty()) {
|
if (dir_name.empty()) {
|
||||||
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, permission denied",
|
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, permission denied",
|
||||||
fmt::UTF(dir_name.u8string()));
|
fmt::UTF(dir_name.u8string()));
|
||||||
return SCE_KERNEL_ERROR_EACCES;
|
return ORBIS_KERNEL_ERROR_EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ro) {
|
if (ro) {
|
||||||
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, directory is read only",
|
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, directory is read only",
|
||||||
fmt::UTF(dir_name.u8string()));
|
fmt::UTF(dir_name.u8string()));
|
||||||
return SCE_KERNEL_ERROR_EROFS;
|
return ORBIS_KERNEL_ERROR_EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::filesystem::is_directory(dir_name)) {
|
if (!std::filesystem::is_directory(dir_name)) {
|
||||||
@ -507,7 +507,7 @@ int PS4_SYSV_ABI sceKernelCheckReachability(const char* path) {
|
|||||||
}
|
}
|
||||||
const auto path_name = mnt->GetHostPath(guest_path);
|
const auto path_name = mnt->GetHostPath(guest_path);
|
||||||
if (!std::filesystem::exists(path_name)) {
|
if (!std::filesystem::exists(path_name)) {
|
||||||
return SCE_KERNEL_ERROR_ENOENT;
|
return ORBIS_KERNEL_ERROR_ENOENT;
|
||||||
}
|
}
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ s32 PS4_SYSV_ABI sceKernelFsync(int fd) {
|
|||||||
s32 PS4_SYSV_ABI posix_fsync(int fd) {
|
s32 PS4_SYSV_ABI posix_fsync(int fd) {
|
||||||
s32 result = sceKernelFsync(fd);
|
s32 result = sceKernelFsync(fd);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
LOG_ERROR(Kernel_Pthread, "posix_fstat: error = {}", result);
|
LOG_ERROR(Kernel_Pthread, "posix_fsync: error = {}", result);
|
||||||
ErrSceToPosix(result);
|
ErrSceToPosix(result);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -628,7 +628,7 @@ int PS4_SYSV_ABI sceKernelFtruncate(int fd, s64 length) {
|
|||||||
auto* file = h->GetFile(fd);
|
auto* file = h->GetFile(fd);
|
||||||
|
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EBADF;
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->type == Core::FileSys::FileType::Device) {
|
if (file->type == Core::FileSys::FileType::Device) {
|
||||||
@ -636,11 +636,11 @@ int PS4_SYSV_ABI sceKernelFtruncate(int fd, s64 length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file->m_host_name.empty()) {
|
if (file->m_host_name.empty()) {
|
||||||
return SCE_KERNEL_ERROR_EACCES;
|
return ORBIS_KERNEL_ERROR_EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->f.SetSize(length);
|
file->f.SetSize(length);
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetDents(int fd, char* buf, int nbytes, s64* basep) {
|
static int GetDents(int fd, char* buf, int nbytes, s64* basep) {
|
||||||
@ -732,11 +732,11 @@ s32 PS4_SYSV_ABI sceKernelRename(const char* from, const char* to) {
|
|||||||
return ORBIS_KERNEL_ERROR_ENOENT;
|
return ORBIS_KERNEL_ERROR_ENOENT;
|
||||||
}
|
}
|
||||||
if (ro) {
|
if (ro) {
|
||||||
return SCE_KERNEL_ERROR_EROFS;
|
return ORBIS_KERNEL_ERROR_EROFS;
|
||||||
}
|
}
|
||||||
const auto dst_path = mnt->GetHostPath(to, &ro);
|
const auto dst_path = mnt->GetHostPath(to, &ro);
|
||||||
if (ro) {
|
if (ro) {
|
||||||
return SCE_KERNEL_ERROR_EROFS;
|
return ORBIS_KERNEL_ERROR_EROFS;
|
||||||
}
|
}
|
||||||
const bool src_is_dir = std::filesystem::is_directory(src_path);
|
const bool src_is_dir = std::filesystem::is_directory(src_path);
|
||||||
const bool dst_is_dir = std::filesystem::is_directory(dst_path);
|
const bool dst_is_dir = std::filesystem::is_directory(dst_path);
|
||||||
|
@ -37,8 +37,8 @@ struct OrbisKernelStat {
|
|||||||
u32 st_gen;
|
u32 st_gen;
|
||||||
s32 st_lspare;
|
s32 st_lspare;
|
||||||
OrbisKernelTimespec st_birthtim;
|
OrbisKernelTimespec st_birthtim;
|
||||||
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
|
u32 : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
|
||||||
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
|
u32 : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisKernelDirent {
|
struct OrbisKernelDirent {
|
||||||
|
@ -2,14 +2,12 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include <boost/asio/io_context.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/polyfill_thread.h"
|
#include "common/polyfill_thread.h"
|
||||||
#include "common/singleton.h"
|
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "common/va_ctx.h"
|
#include "common/va_ctx.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
@ -18,21 +16,16 @@
|
|||||||
#include "core/libraries/kernel/file_system.h"
|
#include "core/libraries/kernel/file_system.h"
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
#include "core/libraries/kernel/memory.h"
|
#include "core/libraries/kernel/memory.h"
|
||||||
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/process.h"
|
#include "core/libraries/kernel/process.h"
|
||||||
#include "core/libraries/kernel/threads.h"
|
#include "core/libraries/kernel/threads.h"
|
||||||
#include "core/libraries/kernel/threads/exception.h"
|
#include "core/libraries/kernel/threads/exception.h"
|
||||||
#include "core/libraries/kernel/time.h"
|
#include "core/libraries/kernel/time.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/linker.h"
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#include <io.h>
|
#include <Rpc.h>
|
||||||
#include <objbase.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <date/tz.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
@ -40,10 +33,10 @@ namespace Libraries::Kernel {
|
|||||||
static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; // dummy return
|
static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; // dummy return
|
||||||
|
|
||||||
boost::asio::io_context io_context;
|
boost::asio::io_context io_context;
|
||||||
std::mutex m_asio_req;
|
static std::mutex m_asio_req;
|
||||||
std::condition_variable_any cv_asio_req;
|
static std::condition_variable_any cv_asio_req;
|
||||||
std::atomic<u32> asio_requests;
|
static std::atomic<u32> asio_requests;
|
||||||
std::jthread service_thread;
|
static std::jthread service_thread;
|
||||||
|
|
||||||
void KernelSignalRequest() {
|
void KernelSignalRequest() {
|
||||||
std::unique_lock lock{m_asio_req};
|
std::unique_lock lock{m_asio_req};
|
||||||
@ -81,16 +74,12 @@ int* PS4_SYSV_ABI __Error() {
|
|||||||
return &g_posix_errno;
|
return &g_posix_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrSceToPosix(int result) {
|
void ErrSceToPosix(int error) {
|
||||||
const int rt = result > SCE_KERNEL_ERROR_UNKNOWN && result <= SCE_KERNEL_ERROR_ESTOP
|
g_posix_errno = error - ORBIS_KERNEL_ERROR_UNKNOWN;
|
||||||
? result + -SCE_KERNEL_ERROR_UNKNOWN
|
|
||||||
: POSIX_EOTHER;
|
|
||||||
g_posix_errno = rt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ErrnoToSceKernelError(int e) {
|
int ErrnoToSceKernelError(int error) {
|
||||||
const auto res = SCE_KERNEL_ERROR_UNKNOWN + e;
|
return error + ORBIS_KERNEL_ERROR_UNKNOWN;
|
||||||
return res > SCE_KERNEL_ERROR_ESTOP ? SCE_KERNEL_ERROR_UNKNOWN : res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPosixErrno(int e) {
|
void SetPosixErrno(int e) {
|
||||||
@ -236,7 +225,7 @@ int PS4_SYSV_ABI _sigprocmask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_getpagesize() {
|
int PS4_SYSV_ABI posix_getpagesize() {
|
||||||
return 4096;
|
return 16_KB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
|
void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "common/logging/log.h"
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
class SymbolsResolver;
|
class SymbolsResolver;
|
||||||
@ -38,7 +37,7 @@ struct WrapperImpl<name, PS4_SYSV_ABI R (*)(Args...), f> {
|
|||||||
u32 ret = f(args...);
|
u32 ret = f(args...);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
// LOG_ERROR(Lib_Kernel, "Function {} returned {}", std::string_view{name.value}, ret);
|
// LOG_ERROR(Lib_Kernel, "Function {} returned {}", std::string_view{name.value}, ret);
|
||||||
ret += SCE_KERNEL_ERROR_UNKNOWN;
|
ret += ORBIS_KERNEL_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,9 @@
|
|||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
#include "core/libraries/kernel/memory.h"
|
#include "core/libraries/kernel/memory.h"
|
||||||
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/linker.h"
|
#include "core/linker.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
@ -27,20 +28,20 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
|||||||
u64 alignment, int memoryType, s64* physAddrOut) {
|
u64 alignment, int memoryType, s64* physAddrOut) {
|
||||||
if (searchStart < 0 || searchEnd <= searchStart) {
|
if (searchStart < 0 || searchEnd <= searchStart) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
const bool is_in_range = searchEnd - searchStart >= len;
|
const bool is_in_range = searchEnd - searchStart >= len;
|
||||||
if (len <= 0 || !Common::Is16KBAligned(len) || !is_in_range) {
|
if (len <= 0 || !Common::Is16KBAligned(len) || !is_in_range) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (alignment != 0 && !Common::Is16KBAligned(alignment)) {
|
if (alignment != 0 && !Common::Is16KBAligned(alignment)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (physAddrOut == nullptr) {
|
if (physAddrOut == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
|
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
@ -52,7 +53,7 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
|||||||
"alignment = {:#x}, memoryType = {:#x}, physAddrOut = {:#x}",
|
"alignment = {:#x}, memoryType = {:#x}, physAddrOut = {:#x}",
|
||||||
searchStart, searchEnd, len, alignment, memoryType, phys_addr);
|
searchStart, searchEnd, len, alignment, memoryType, phys_addr);
|
||||||
|
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment, int memoryType,
|
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment, int memoryType,
|
||||||
@ -110,7 +111,7 @@ s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, int flags, OrbisVirtual
|
|||||||
size_t infoSize) {
|
size_t infoSize) {
|
||||||
LOG_INFO(Kernel_Vmm, "called addr = {}, flags = {:#x}", fmt::ptr(addr), flags);
|
LOG_INFO(Kernel_Vmm, "called addr = {}, flags = {:#x}", fmt::ptr(addr), flags);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
return SCE_KERNEL_ERROR_EACCES;
|
return ORBIS_KERNEL_ERROR_EACCES;
|
||||||
}
|
}
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
return memory->VirtualQuery(std::bit_cast<VAddr>(addr), flags, info);
|
return memory->VirtualQuery(std::bit_cast<VAddr>(addr), flags, info);
|
||||||
@ -122,16 +123,16 @@ s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u
|
|||||||
|
|
||||||
if (addr == nullptr) {
|
if (addr == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (len == 0 || !Common::Is16KBAligned(len)) {
|
if (len == 0 || !Common::Is16KBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 16KB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 16KB aligned!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (alignment != 0) {
|
if (alignment != 0) {
|
||||||
if ((!std::has_single_bit(alignment) && !Common::Is16KBAligned(alignment))) {
|
if ((!std::has_single_bit(alignment) && !Common::Is16KBAligned(alignment))) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u
|
|||||||
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
||||||
memory->Reserve(addr, in_addr, len, map_flags, alignment);
|
memory->Reserve(addr, in_addr, len, map_flags, alignment);
|
||||||
|
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, int flags,
|
int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, int flags,
|
||||||
@ -148,16 +149,16 @@ int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, i
|
|||||||
const char* name) {
|
const char* name) {
|
||||||
if (len == 0 || !Common::Is16KBAligned(len)) {
|
if (len == 0 || !Common::Is16KBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 16KB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 16KB aligned!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (!Common::Is16KBAligned(directMemoryStart)) {
|
if (!Common::Is16KBAligned(directMemoryStart)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Start address is not 16KB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Start address is not 16KB aligned!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (alignment != 0) {
|
if (alignment != 0) {
|
||||||
if ((!std::has_single_bit(alignment) && !Common::Is16KBAligned(alignment))) {
|
if ((!std::has_single_bit(alignment) && !Common::Is16KBAligned(alignment))) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,20 +357,20 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, size_
|
|||||||
size_t alignment, u64* physAddrOut) {
|
size_t alignment, u64* physAddrOut) {
|
||||||
if (searchStart < 0 || searchEnd <= searchStart) {
|
if (searchStart < 0 || searchEnd <= searchStart) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
const bool is_in_range = searchEnd - searchStart >= len;
|
const bool is_in_range = searchEnd - searchStart >= len;
|
||||||
if (len <= 0 || !Common::Is64KBAligned(len) || !is_in_range) {
|
if (len <= 0 || !Common::Is64KBAligned(len) || !is_in_range) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (alignment != 0 && !Common::Is64KBAligned(alignment)) {
|
if (alignment != 0 && !Common::Is64KBAligned(alignment)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (physAddrOut == nullptr) {
|
if (physAddrOut == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
|
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
@ -390,16 +391,16 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t ali
|
|||||||
|
|
||||||
if (addrIn == nullptr) {
|
if (addrIn == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (len == 0 || !Common::Is2MBAligned(len)) {
|
if (len == 0 || !Common::Is2MBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 2MB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 2MB aligned!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (alignment != 0) {
|
if (alignment != 0) {
|
||||||
if ((!std::has_single_bit(alignment) && !Common::Is2MBAligned(alignment))) {
|
if ((!std::has_single_bit(alignment) && !Common::Is2MBAligned(alignment))) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,11 +415,11 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t ali
|
|||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int prot, int flags) {
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int prot, int flags) {
|
||||||
if (addr == nullptr) {
|
if (addr == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (len == 0 || !Common::Is64KBAligned(len)) {
|
if (len == 0 || !Common::Is64KBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 64KB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 64KB aligned!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, type = {:#x}, prot = {:#x}, flags = {:#x}",
|
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, type = {:#x}, prot = {:#x}, flags = {:#x}",
|
||||||
@ -433,11 +434,11 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int
|
|||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, size_t len, int flags) {
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, size_t len, int flags) {
|
||||||
if (addr == nullptr) {
|
if (addr == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (len == 0 || !Common::Is64KBAligned(len)) {
|
if (len == 0 || !Common::Is64KBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 64KB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 64KB aligned!");
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, flags = {:#x}", fmt::ptr(addr), len, flags);
|
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, flags = {:#x}", fmt::ptr(addr), len, flags);
|
||||||
@ -492,7 +493,17 @@ int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) {
|
|||||||
}
|
}
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
memory->UnmapMemory(std::bit_cast<VAddr>(addr), len);
|
memory->UnmapMemory(std::bit_cast<VAddr>(addr), len);
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI posix_munmap(void* addr, size_t len) {
|
||||||
|
int result = sceKernelMunmap(addr, len);
|
||||||
|
if (result < 0) {
|
||||||
|
LOG_ERROR(Kernel_Pthread, "posix_munmap: error = {}", result);
|
||||||
|
ErrSceToPosix(result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
||||||
@ -517,6 +528,8 @@ void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("mL8NDH86iQI", "libkernel", 1, "libkernel", 1, 1, sceKernelMapNamedFlexibleMemory);
|
LIB_FUNCTION("mL8NDH86iQI", "libkernel", 1, "libkernel", 1, 1, sceKernelMapNamedFlexibleMemory);
|
||||||
LIB_FUNCTION("aNz11fnnzi4", "libkernel", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("aNz11fnnzi4", "libkernel", 1, "libkernel", 1, 1,
|
||||||
sceKernelAvailableFlexibleMemorySize);
|
sceKernelAvailableFlexibleMemorySize);
|
||||||
|
LIB_FUNCTION("aNz11fnnzi4", "libkernel_avlfmem", 1, "libkernel", 1, 1,
|
||||||
|
sceKernelAvailableFlexibleMemorySize);
|
||||||
LIB_FUNCTION("IWIBBdTHit4", "libkernel", 1, "libkernel", 1, 1, sceKernelMapFlexibleMemory);
|
LIB_FUNCTION("IWIBBdTHit4", "libkernel", 1, "libkernel", 1, 1, sceKernelMapFlexibleMemory);
|
||||||
LIB_FUNCTION("p5EcQeEeJAE", "libkernel", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("p5EcQeEeJAE", "libkernel", 1, "libkernel", 1, 1,
|
||||||
_sceKernelRtldSetApplicationHeapAPI);
|
_sceKernelRtldSetApplicationHeapAPI);
|
||||||
@ -537,6 +550,8 @@ void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
|||||||
|
|
||||||
LIB_FUNCTION("BPE9s9vQQXo", "libkernel", 1, "libkernel", 1, 1, posix_mmap);
|
LIB_FUNCTION("BPE9s9vQQXo", "libkernel", 1, "libkernel", 1, 1, posix_mmap);
|
||||||
LIB_FUNCTION("BPE9s9vQQXo", "libScePosix", 1, "libkernel", 1, 1, posix_mmap);
|
LIB_FUNCTION("BPE9s9vQQXo", "libScePosix", 1, "libkernel", 1, 1, posix_mmap);
|
||||||
|
LIB_FUNCTION("UqDGjXA5yUM", "libkernel", 1, "libkernel", 1, 1, posix_munmap);
|
||||||
|
LIB_FUNCTION("UqDGjXA5yUM", "libScePosix", 1, "libkernel", 1, 1, posix_munmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
||||||
|
108
src/core/libraries/kernel/orbis_error.h
Normal file
108
src/core/libraries/kernel/orbis_error.h
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// Libkernel library
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_UNKNOWN = 0x80020000;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPERM = 0x80020001;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOENT = 0x80020002;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ESRCH = 0x80020003;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EINTR = 0x80020004;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EIO = 0x80020005;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENXIO = 0x80020006;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_E2BIG = 0x80020007;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOEXEC = 0x80020008;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EBADF = 0x80020009;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ECHILD = 0x8002000A;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EDEADLK = 0x8002000B;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOMEM = 0x8002000C;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EACCES = 0x8002000D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EFAULT = 0x8002000E;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTBLK = 0x8002000F;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EBUSY = 0x80020010;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EEXIST = 0x80020011;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EXDEV = 0x80020012;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENODEV = 0x80020013;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTDIR = 0x80020014;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EISDIR = 0x80020015;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EINVAL = 0x80020016;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENFILE = 0x80020017;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EMFILE = 0x80020018;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTTY = 0x80020019;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ETXTBSY = 0x8002001A;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EFBIG = 0x8002001B;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOSPC = 0x8002001C;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ESPIPE = 0x8002001D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EROFS = 0x8002001E;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EMLINK = 0x8002001F;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPIPE = 0x80020020;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EDOM = 0x80020021;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ERANGE = 0x80020022;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EAGAIN = 0x80020023;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EWOULDBLOCK = 0x80020023;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EINPROGRESS = 0x80020024;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EALREADY = 0x80020025;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTSOCK = 0x80020026;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EDESTADDRREQ = 0x80020027;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EMSGSIZE = 0x80020028;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROTOTYPE = 0x80020029;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOPROTOOPT = 0x8002002A;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROTONOSUPPORT = 0x8002002B;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ESOCKTNOSUPPORT = 0x8002002C;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTSUP = 0x8002002D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EOPNOTSUPP = 0x8002002D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPFNOSUPPORT = 0x8002002E;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EAFNOSUPPORT = 0x8002002F;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EADDRINUSE = 0x80020030;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EADDRNOTAVAIL = 0x80020031;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENETDOWN = 0x80020032;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENETUNREACH = 0x80020033;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENETRESET = 0x80020034;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ECONNABORTED = 0x80020035;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ECONNRESET = 0x80020036;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOBUFS = 0x80020037;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EISCONN = 0x80020038;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTCONN = 0x80020039;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ESHUTDOWN = 0x8002003A;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ETOOMANYREFS = 0x8002003B;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ETIMEDOUT = 0x8002003C;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ECONNREFUSED = 0x8002003D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ELOOP = 0x8002003E;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENAMETOOLONG = 0x8002003F;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EHOSTDOWN = 0x80020040;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EHOSTUNREACH = 0x80020041;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTEMPTY = 0x80020042;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROCLIM = 0x80020043;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EUSERS = 0x80020044;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EDQUOT = 0x80020045;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ESTALE = 0x80020046;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EREMOTE = 0x80020047;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EBADRPC = 0x80020048;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ERPCMISMATCH = 0x80020049;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROGUNAVAIL = 0x8002004A;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROGMISMATCH = 0x8002004B;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROCUNAVAIL = 0x8002004C;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOLCK = 0x8002004D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOSYS = 0x8002004E;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EFTYPE = 0x8002004F;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EAUTH = 0x80020050;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENEEDAUTH = 0x80020051;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EIDRM = 0x80020052;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOMSG = 0x80020053;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EOVERFLOW = 0x80020054;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ECANCELED = 0x80020055;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EILSEQ = 0x80020056;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOATTR = 0x80020057;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EDOOFUS = 0x80020058;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EBADMSG = 0x80020059;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EMULTIHOP = 0x8002005A;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOLINK = 0x8002005B;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EPROTO = 0x8002005C;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOTCAPABLE = 0x8002005D;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ECAPMODE = 0x8002005E;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOBLK = 0x8002005F;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_EICV = 0x80020060;
|
||||||
|
constexpr int ORBIS_KERNEL_ERROR_ENOPLAYGOENT = 0x80020061;
|
128
src/core/libraries/kernel/posix_error.h
Normal file
128
src/core/libraries/kernel/posix_error.h
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// Posix error codes
|
||||||
|
constexpr int POSIX_EPERM = 1;
|
||||||
|
constexpr int POSIX_ENOENT = 2;
|
||||||
|
constexpr int POSIX_ESRCH = 3;
|
||||||
|
constexpr int POSIX_EINTR = 4;
|
||||||
|
constexpr int POSIX_EIO = 5;
|
||||||
|
constexpr int POSIX_ENXIO = 6;
|
||||||
|
constexpr int POSIX_E2BIG = 7;
|
||||||
|
constexpr int POSIX_ENOEXEC = 8;
|
||||||
|
constexpr int POSIX_EBADF = 9;
|
||||||
|
constexpr int POSIX_ECHILD = 10;
|
||||||
|
constexpr int POSIX_EDEADLK = 11;
|
||||||
|
constexpr int POSIX_ENOMEM = 12;
|
||||||
|
constexpr int POSIX_EACCES = 13;
|
||||||
|
constexpr int POSIX_EFAULT = 14;
|
||||||
|
constexpr int POSIX_ENOTBLK = 15;
|
||||||
|
constexpr int POSIX_EBUSY = 16;
|
||||||
|
constexpr int POSIX_EEXIST = 17;
|
||||||
|
constexpr int POSIX_EXDEV = 18;
|
||||||
|
constexpr int POSIX_ENODEV = 19;
|
||||||
|
constexpr int POSIX_ENOTDIR = 20;
|
||||||
|
constexpr int POSIX_EISDIR = 21;
|
||||||
|
constexpr int POSIX_EINVAL = 22;
|
||||||
|
constexpr int POSIX_ENFILE = 23;
|
||||||
|
constexpr int POSIX_EMFILE = 24;
|
||||||
|
constexpr int POSIX_ENOTTY = 25;
|
||||||
|
constexpr int POSIX_ETXTBSY = 26;
|
||||||
|
constexpr int POSIX_EFBIG = 27;
|
||||||
|
constexpr int POSIX_ENOSPC = 28;
|
||||||
|
constexpr int POSIX_ESPIPE = 29;
|
||||||
|
constexpr int POSIX_EROFS = 30;
|
||||||
|
constexpr int POSIX_EMLINK = 31;
|
||||||
|
constexpr int POSIX_EPIPE = 32;
|
||||||
|
constexpr int POSIX_EDOM = 33;
|
||||||
|
constexpr int POSIX_ERANGE = 34;
|
||||||
|
constexpr int POSIX_EAGAIN = 35;
|
||||||
|
constexpr int POSIX_EWOULDBLOCK = 35;
|
||||||
|
constexpr int POSIX_EINPROGRESS = 36;
|
||||||
|
constexpr int POSIX_EALREADY = 37;
|
||||||
|
constexpr int POSIX_ENOTSOCK = 38;
|
||||||
|
constexpr int POSIX_EDESTADDRREQ = 39;
|
||||||
|
constexpr int POSIX_EMSGSIZE = 40;
|
||||||
|
constexpr int POSIX_EPROTOTYPE = 41;
|
||||||
|
constexpr int POSIX_ENOPROTOOPT = 42;
|
||||||
|
constexpr int POSIX_EPROTONOSUPPORT = 43;
|
||||||
|
constexpr int POSIX_ESOCKTNOSUPPORT = 44;
|
||||||
|
constexpr int POSIX_EOPNOTSUPP = 45;
|
||||||
|
constexpr int POSIX_ENOTSUP = 45;
|
||||||
|
constexpr int POSIX_EPFNOSUPPORT = 46;
|
||||||
|
constexpr int POSIX_EAFNOSUPPORT = 47;
|
||||||
|
constexpr int POSIX_EADDRINUSE = 48;
|
||||||
|
constexpr int POSIX_EADDRNOTAVAIL = 49;
|
||||||
|
constexpr int POSIX_ENETDOWN = 50;
|
||||||
|
constexpr int POSIX_ENETUNREACH = 51;
|
||||||
|
constexpr int POSIX_ENETRESET = 52;
|
||||||
|
constexpr int POSIX_ECONNABORTED = 53;
|
||||||
|
constexpr int POSIX_ECONNRESET = 54;
|
||||||
|
constexpr int POSIX_ENOBUFS = 55;
|
||||||
|
constexpr int POSIX_EISCONN = 56;
|
||||||
|
constexpr int POSIX_ENOTCONN = 57;
|
||||||
|
constexpr int POSIX_ESHUTDOWN = 58;
|
||||||
|
constexpr int POSIX_ETOOMANYREFS = 59;
|
||||||
|
constexpr int POSIX_ETIMEDOUT = 60;
|
||||||
|
constexpr int POSIX_ECONNREFUSED = 61;
|
||||||
|
constexpr int POSIX_ELOOP = 62;
|
||||||
|
constexpr int POSIX_ENAMETOOLONG = 63;
|
||||||
|
constexpr int POSIX_EHOSTDOWN = 64;
|
||||||
|
constexpr int POSIX_EHOSTUNREACH = 65;
|
||||||
|
constexpr int POSIX_ENOTEMPTY = 66;
|
||||||
|
constexpr int POSIX_EPROCLIM = 67;
|
||||||
|
constexpr int POSIX_EUSERS = 68;
|
||||||
|
constexpr int POSIX_EDQUOT = 69;
|
||||||
|
constexpr int POSIX_ESTALE = 70;
|
||||||
|
constexpr int POSIX_EREMOTE = 71;
|
||||||
|
constexpr int POSIX_EBADRPC = 72;
|
||||||
|
constexpr int POSIX_ERPCMISMATCH = 73;
|
||||||
|
constexpr int POSIX_EPROGUNAVAIL = 74;
|
||||||
|
constexpr int POSIX_EPROGMISMATCH = 75;
|
||||||
|
constexpr int POSIX_EPROCUNAVAIL = 76;
|
||||||
|
constexpr int POSIX_ENOLCK = 77;
|
||||||
|
constexpr int POSIX_ENOSYS = 78;
|
||||||
|
constexpr int POSIX_EFTYPE = 79;
|
||||||
|
constexpr int POSIX_EAUTH = 80;
|
||||||
|
constexpr int POSIX_ENEEDAUTH = 81;
|
||||||
|
constexpr int POSIX_EIDRM = 82;
|
||||||
|
constexpr int POSIX_ENOMSG = 83;
|
||||||
|
constexpr int POSIX_EOVERFLOW = 84;
|
||||||
|
constexpr int POSIX_ECANCELED = 85;
|
||||||
|
constexpr int POSIX_EILSEQ = 86;
|
||||||
|
constexpr int POSIX_ENOATTR = 87;
|
||||||
|
constexpr int POSIX_EDOOFUS = 88;
|
||||||
|
constexpr int POSIX_EBADMSG = 89;
|
||||||
|
constexpr int POSIX_EMULTIHOP = 90;
|
||||||
|
constexpr int POSIX_ENOLINK = 91;
|
||||||
|
constexpr int POSIX_EPROTO = 92;
|
||||||
|
constexpr int POSIX_ENOTCAPABLE = 93;
|
||||||
|
constexpr int POSIX_ECAPMODE = 94;
|
||||||
|
constexpr int POSIX_ENOBLK = 95;
|
||||||
|
constexpr int POSIX_EICV = 96;
|
||||||
|
constexpr int POSIX_ENOPLAYGOENT = 97;
|
||||||
|
constexpr int POSIX_EREVOKE = 98;
|
||||||
|
constexpr int POSIX_ESDKVERSION = 99;
|
||||||
|
constexpr int POSIX_ESTART = 100;
|
||||||
|
constexpr int POSIX_ESTOP = 101;
|
||||||
|
constexpr int POSIX_EINVALID2MB = 102;
|
||||||
|
constexpr int POSIX_ELAST = 102;
|
||||||
|
constexpr int POSIX_EADHOC = 160;
|
||||||
|
constexpr int POSIX_EINACTIVEDISABLED = 163;
|
||||||
|
constexpr int POSIX_ENETNODATA = 164;
|
||||||
|
constexpr int POSIX_ENETDESC = 165;
|
||||||
|
constexpr int POSIX_ENETDESCTIMEDOUT = 166;
|
||||||
|
constexpr int POSIX_ENETINTR = 167;
|
||||||
|
constexpr int POSIX_ERETURN = 205;
|
||||||
|
constexpr int POSIX_EFPOS = 152;
|
||||||
|
constexpr int POSIX_ENODATA = 1040;
|
||||||
|
constexpr int POSIX_ENOSR = 1050;
|
||||||
|
constexpr int POSIX_ENOSTR = 1051;
|
||||||
|
constexpr int POSIX_ENOTRECOVERABLE = 1056;
|
||||||
|
constexpr int POSIX_EOTHER = 1062;
|
||||||
|
constexpr int POSIX_EOWNERDEAD = 1064;
|
||||||
|
constexpr int POSIX_ETIME = 1074;
|
@ -5,7 +5,7 @@
|
|||||||
#include "common/elf_info.h"
|
#include "common/elf_info.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/kernel/process.h"
|
#include "core/libraries/kernel/process.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/linker.h"
|
#include "core/linker.h"
|
||||||
@ -91,7 +91,7 @@ s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, int flags,
|
|||||||
OrbisModuleInfoForUnwind* info) {
|
OrbisModuleInfoForUnwind* info) {
|
||||||
if (flags >= 3) {
|
if (flags >= 3) {
|
||||||
std::memset(info, 0, sizeof(OrbisModuleInfoForUnwind));
|
std::memset(info, 0, sizeof(OrbisModuleInfoForUnwind));
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return ORBIS_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/kernel/threads/sleepq.h"
|
#include "core/libraries/kernel/threads/sleepq.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
@ -122,7 +122,7 @@ int PthreadCond::Wait(PthreadMutexT* mutex, const OrbisKernelTimespec* abstime,
|
|||||||
SleepqUnlock(this);
|
SleepqUnlock(this);
|
||||||
|
|
||||||
//_thr_cancel_enter2(curthread, 0);
|
//_thr_cancel_enter2(curthread, 0);
|
||||||
int error = curthread->Sleep(abstime, usec) ? 0 : POSIX_ETIMEDOUT;
|
error = curthread->Sleep(abstime, usec) ? 0 : POSIX_ETIMEDOUT;
|
||||||
//_thr_cancel_leave(curthread, 0);
|
//_thr_cancel_leave(curthread, 0);
|
||||||
|
|
||||||
SleepqLock(this);
|
SleepqLock(this);
|
||||||
@ -145,7 +145,10 @@ int PthreadCond::Wait(PthreadMutexT* mutex, const OrbisKernelTimespec* abstime,
|
|||||||
}
|
}
|
||||||
SleepqUnlock(this);
|
SleepqUnlock(this);
|
||||||
curthread->mutex_obj = nullptr;
|
curthread->mutex_obj = nullptr;
|
||||||
mp->CvLock(recurse);
|
int error2 = mp->CvLock(recurse);
|
||||||
|
if (error == 0) {
|
||||||
|
error = error2;
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/scope_exit.h"
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
@ -121,6 +120,7 @@ int PthreadMutex::SelfTryLock() {
|
|||||||
switch (Type()) {
|
switch (Type()) {
|
||||||
case PthreadMutexType::ErrorCheck:
|
case PthreadMutexType::ErrorCheck:
|
||||||
case PthreadMutexType::Normal:
|
case PthreadMutexType::Normal:
|
||||||
|
case PthreadMutexType::AdaptiveNp:
|
||||||
return POSIX_EBUSY;
|
return POSIX_EBUSY;
|
||||||
case PthreadMutexType::Recursive: {
|
case PthreadMutexType::Recursive: {
|
||||||
/* Increment the lock count: */
|
/* Increment the lock count: */
|
||||||
@ -224,7 +224,7 @@ int PthreadMutex::Lock(const OrbisKernelTimespec* abstime, u64 usec) {
|
|||||||
[[unlikely]] {
|
[[unlikely]] {
|
||||||
ret = POSIX_EINVAL;
|
ret = POSIX_EINVAL;
|
||||||
} else {
|
} else {
|
||||||
if (THR_RELTIME) {
|
if (abstime == THR_RELTIME) {
|
||||||
ret = m_lock.try_lock_for(std::chrono::microseconds(usec)) ? 0 : POSIX_ETIMEDOUT;
|
ret = m_lock.try_lock_for(std::chrono::microseconds(usec)) ? 0 : POSIX_ETIMEDOUT;
|
||||||
} else {
|
} else {
|
||||||
ret = m_lock.try_lock_until(abstime->TimePoint()) ? 0 : POSIX_ETIMEDOUT;
|
ret = m_lock.try_lock_until(abstime->TimePoint()) ? 0 : POSIX_ETIMEDOUT;
|
||||||
@ -336,7 +336,7 @@ int PS4_SYSV_ABI posix_pthread_mutex_isowned_np(PthreadMutexT* mutex) {
|
|||||||
return m->m_owner == g_curthread;
|
return m->m_owner == g_curthread;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PthreadMutex::IsOwned(Pthread* curthread) const {
|
int PthreadMutex::IsOwned(Pthread* curthread) const {
|
||||||
if (this <= THR_MUTEX_DESTROYED) [[unlikely]] {
|
if (this <= THR_MUTEX_DESTROYED) [[unlikely]] {
|
||||||
if (this == THR_MUTEX_DESTROYED) {
|
if (this == THR_MUTEX_DESTROYED) {
|
||||||
return POSIX_EINVAL;
|
return POSIX_EINVAL;
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "core/debug_state.h"
|
#include "core/debug_state.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/kernel/threads/thread_state.h"
|
#include "core/libraries/kernel/threads/thread_state.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
@ -281,7 +281,7 @@ int PS4_SYSV_ABI posix_pthread_create_name_np(PthreadT* thread, const PthreadAtt
|
|||||||
|
|
||||||
/* Create thread */
|
/* Create thread */
|
||||||
new_thread->native_thr = Core::Thread();
|
new_thread->native_thr = Core::Thread();
|
||||||
int ret = new_thread->native_thr.Create(RunThread, new_thread);
|
int ret = new_thread->native_thr.Create(RunThread, new_thread, &new_thread->attr);
|
||||||
ASSERT_MSG(ret == 0, "Failed to create thread with error {}", ret);
|
ASSERT_MSG(ret == 0, "Failed to create thread with error {}", ret);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
*thread = nullptr;
|
*thread = nullptr;
|
||||||
@ -380,7 +380,7 @@ int PS4_SYSV_ABI posix_sched_get_priority_min() {
|
|||||||
int PS4_SYSV_ABI posix_pthread_rename_np(PthreadT thread, const char* name) {
|
int PS4_SYSV_ABI posix_pthread_rename_np(PthreadT thread, const char* name) {
|
||||||
LOG_INFO(Kernel_Pthread, "name = {}", name);
|
LOG_INFO(Kernel_Pthread, "name = {}", name);
|
||||||
thread->name = name;
|
thread->name = name;
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_pthread_getschedparam(PthreadT pthread, SchedPolicy* policy,
|
int PS4_SYSV_ABI posix_pthread_getschedparam(PthreadT pthread, SchedPolicy* policy,
|
||||||
@ -421,29 +421,27 @@ int PS4_SYSV_ABI scePthreadGetprio(PthreadT thread, int* priority) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePthreadSetprio(PthreadT thread, int prio) {
|
int PS4_SYSV_ABI posix_pthread_setprio(PthreadT thread, int prio) {
|
||||||
SchedParam param;
|
SchedParam param;
|
||||||
int ret;
|
|
||||||
|
|
||||||
param.sched_priority = prio;
|
param.sched_priority = prio;
|
||||||
|
|
||||||
auto* thread_state = ThrState::Instance();
|
auto* thread_state = ThrState::Instance();
|
||||||
if (thread == g_curthread) {
|
if (thread == g_curthread) {
|
||||||
g_curthread->lock.lock();
|
g_curthread->lock.lock();
|
||||||
} else if (int ret = thread_state->FindThread(thread, /*include dead*/ 0)) {
|
} else if (int ret = thread_state->FindThread(thread, /*include dead*/ 0); ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread->attr.sched_policy == SchedPolicy::Other || thread->attr.prio == prio) {
|
if (thread->attr.sched_policy == SchedPolicy::Other || thread->attr.prio == prio) {
|
||||||
thread->attr.prio = prio;
|
thread->attr.prio = prio;
|
||||||
ret = 0;
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: _thr_setscheduler
|
// TODO: _thr_setscheduler
|
||||||
thread->attr.prio = prio;
|
thread->attr.prio = prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->lock.unlock();
|
thread->lock.unlock();
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class PthreadCancelState : u32 {
|
enum class PthreadCancelState : u32 {
|
||||||
@ -495,6 +493,8 @@ void RegisterThread(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("OxhIB8LB-PQ", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_create);
|
LIB_FUNCTION("OxhIB8LB-PQ", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_create);
|
||||||
LIB_FUNCTION("Jmi+9w9u0E4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_create_name_np);
|
LIB_FUNCTION("Jmi+9w9u0E4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_create_name_np);
|
||||||
LIB_FUNCTION("lZzFeSxPl08", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setcancelstate);
|
LIB_FUNCTION("lZzFeSxPl08", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setcancelstate);
|
||||||
|
LIB_FUNCTION("a2P9wYGeZvc", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setprio);
|
||||||
|
LIB_FUNCTION("FIs3-UQT9sg", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_getschedparam);
|
||||||
LIB_FUNCTION("6XG4B33N09g", "libScePosix", 1, "libkernel", 1, 1, sched_yield);
|
LIB_FUNCTION("6XG4B33N09g", "libScePosix", 1, "libkernel", 1, 1, sched_yield);
|
||||||
|
|
||||||
// Posix-Kernel
|
// Posix-Kernel
|
||||||
@ -517,7 +517,7 @@ void RegisterThread(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("T72hz6ffq08", "libkernel", 1, "libkernel", 1, 1, posix_pthread_yield);
|
LIB_FUNCTION("T72hz6ffq08", "libkernel", 1, "libkernel", 1, 1, posix_pthread_yield);
|
||||||
LIB_FUNCTION("EI-5-jlq2dE", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getthreadid_np);
|
LIB_FUNCTION("EI-5-jlq2dE", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getthreadid_np);
|
||||||
LIB_FUNCTION("1tKyG7RlMJo", "libkernel", 1, "libkernel", 1, 1, scePthreadGetprio);
|
LIB_FUNCTION("1tKyG7RlMJo", "libkernel", 1, "libkernel", 1, 1, scePthreadGetprio);
|
||||||
LIB_FUNCTION("W0Hpm2X0uPE", "libkernel", 1, "libkernel", 1, 1, scePthreadSetprio);
|
LIB_FUNCTION("W0Hpm2X0uPE", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_setprio));
|
||||||
LIB_FUNCTION("rNhWz+lvOMU", "libkernel", 1, "libkernel", 1, 1, _sceKernelSetThreadDtors);
|
LIB_FUNCTION("rNhWz+lvOMU", "libkernel", 1, "libkernel", 1, 1, _sceKernelSetThreadDtors);
|
||||||
LIB_FUNCTION("6XG4B33N09g", "libkernel", 1, "libkernel", 1, 1, sched_yield);
|
LIB_FUNCTION("6XG4B33N09g", "libkernel", 1, "libkernel", 1, 1, sched_yield);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ struct PthreadMutex {
|
|||||||
return Unlock();
|
return Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsOwned(Pthread* curthread) const;
|
int IsOwned(Pthread* curthread) const;
|
||||||
};
|
};
|
||||||
using PthreadMutexT = PthreadMutex*;
|
using PthreadMutexT = PthreadMutex*;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/kernel/threads/thread_state.h"
|
#include "core/libraries/kernel/threads/thread_state.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
@ -303,6 +303,8 @@ void RegisterThreadAttr(Core::Loader::SymbolsResolver* sym) {
|
|||||||
posix_pthread_attr_getstacksize);
|
posix_pthread_attr_getstacksize);
|
||||||
LIB_FUNCTION("VUT1ZSrHT0I", "libScePosix", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("VUT1ZSrHT0I", "libScePosix", 1, "libkernel", 1, 1,
|
||||||
posix_pthread_attr_getdetachstate);
|
posix_pthread_attr_getdetachstate);
|
||||||
|
LIB_FUNCTION("JKyG3SWyA10", "libScePosix", 1, "libkernel", 1, 1,
|
||||||
|
posix_pthread_attr_setguardsize);
|
||||||
|
|
||||||
// Orbis
|
// Orbis
|
||||||
LIB_FUNCTION("4+h9EzwKF4I", "libkernel", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("4+h9EzwKF4I", "libkernel", 1, "libkernel", 1, 1,
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
@ -150,6 +149,7 @@ void RegisterSpec(Core::Loader::SymbolsResolver* sym) {
|
|||||||
|
|
||||||
// Orbis
|
// Orbis
|
||||||
LIB_FUNCTION("geDaqgH9lTg", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_create));
|
LIB_FUNCTION("geDaqgH9lTg", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_create));
|
||||||
|
LIB_FUNCTION("PrdHuuDekhY", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_delete));
|
||||||
LIB_FUNCTION("eoht7mQOCmo", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getspecific);
|
LIB_FUNCTION("eoht7mQOCmo", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getspecific);
|
||||||
LIB_FUNCTION("+BzXYkqYeLE", "libkernel", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("+BzXYkqYeLE", "libkernel", 1, "libkernel", 1, 1,
|
||||||
ORBIS(posix_pthread_setspecific));
|
ORBIS(posix_pthread_setspecific));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <semaphore>
|
#include <semaphore>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/kernel/kernel.h"
|
#include "core/libraries/kernel/kernel.h"
|
||||||
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/kernel/time.h"
|
#include "core/libraries/kernel/time.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
@ -41,7 +43,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timeout && *timeout == 0) {
|
if (timeout && *timeout == 0) {
|
||||||
return SCE_KERNEL_ERROR_ETIMEDOUT;
|
return ORBIS_KERNEL_ERROR_ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create waiting thread object and add it into the list of waiters.
|
// Create waiting thread object and add it into the list of waiters.
|
||||||
@ -49,10 +51,8 @@ public:
|
|||||||
const auto it = AddWaiter(&waiter);
|
const auto it = AddWaiter(&waiter);
|
||||||
|
|
||||||
// Perform the wait.
|
// Perform the wait.
|
||||||
lk.unlock();
|
const s32 result = waiter.Wait(lk, timeout);
|
||||||
const s32 result = waiter.Wait(timeout);
|
if (result == ORBIS_KERNEL_ERROR_ETIMEDOUT) {
|
||||||
lk.lock();
|
|
||||||
if (result == SCE_KERNEL_ERROR_ETIMEDOUT) {
|
|
||||||
wait_list.erase(it);
|
wait_list.erase(it);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -74,7 +74,8 @@ public:
|
|||||||
}
|
}
|
||||||
it = wait_list.erase(it);
|
it = wait_list.erase(it);
|
||||||
token_count -= waiter->need_count;
|
token_count -= waiter->need_count;
|
||||||
waiter->sema.release();
|
waiter->was_signaled = true;
|
||||||
|
waiter->cv.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -87,7 +88,7 @@ public:
|
|||||||
}
|
}
|
||||||
for (auto* waiter : wait_list) {
|
for (auto* waiter : wait_list) {
|
||||||
waiter->was_cancled = true;
|
waiter->was_cancled = true;
|
||||||
waiter->sema.release();
|
waiter->cv.notify_one();
|
||||||
}
|
}
|
||||||
wait_list.clear();
|
wait_list.clear();
|
||||||
token_count = set_count < 0 ? init_count : set_count;
|
token_count = set_count < 0 ? init_count : set_count;
|
||||||
@ -98,20 +99,21 @@ public:
|
|||||||
std::scoped_lock lk{mutex};
|
std::scoped_lock lk{mutex};
|
||||||
for (auto* waiter : wait_list) {
|
for (auto* waiter : wait_list) {
|
||||||
waiter->was_deleted = true;
|
waiter->was_deleted = true;
|
||||||
waiter->sema.release();
|
waiter->cv.notify_one();
|
||||||
}
|
}
|
||||||
wait_list.clear();
|
wait_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct WaitingThread {
|
struct WaitingThread {
|
||||||
std::binary_semaphore sema;
|
std::condition_variable cv;
|
||||||
u32 priority;
|
u32 priority;
|
||||||
s32 need_count;
|
s32 need_count;
|
||||||
|
bool was_signaled{};
|
||||||
bool was_deleted{};
|
bool was_deleted{};
|
||||||
bool was_cancled{};
|
bool was_cancled{};
|
||||||
|
|
||||||
explicit WaitingThread(s32 need_count, bool is_fifo) : sema{0}, need_count{need_count} {
|
explicit WaitingThread(s32 need_count, bool is_fifo) : need_count{need_count} {
|
||||||
// Retrieve calling thread priority for sorting into waiting threads list.
|
// Retrieve calling thread priority for sorting into waiting threads list.
|
||||||
if (!is_fifo) {
|
if (!is_fifo) {
|
||||||
priority = g_curthread->attr.prio;
|
priority = g_curthread->attr.prio;
|
||||||
@ -120,35 +122,36 @@ public:
|
|||||||
|
|
||||||
int GetResult(bool timed_out) {
|
int GetResult(bool timed_out) {
|
||||||
if (timed_out) {
|
if (timed_out) {
|
||||||
return SCE_KERNEL_ERROR_ETIMEDOUT;
|
return ORBIS_KERNEL_ERROR_ETIMEDOUT;
|
||||||
}
|
}
|
||||||
if (was_deleted) {
|
if (was_deleted) {
|
||||||
return SCE_KERNEL_ERROR_EACCES;
|
return ORBIS_KERNEL_ERROR_EACCES;
|
||||||
}
|
}
|
||||||
if (was_cancled) {
|
if (was_cancled) {
|
||||||
return SCE_KERNEL_ERROR_ECANCELED;
|
return ORBIS_KERNEL_ERROR_ECANCELED;
|
||||||
}
|
}
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Wait(u32* timeout) {
|
int Wait(std::unique_lock<std::mutex>& lk, u32* timeout) {
|
||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
// Wait indefinitely until we are woken up.
|
// Wait indefinitely until we are woken up.
|
||||||
sema.acquire();
|
cv.wait(lk);
|
||||||
return GetResult(false);
|
return GetResult(false);
|
||||||
}
|
}
|
||||||
// Wait until timeout runs out, recording how much remaining time there was.
|
// Wait until timeout runs out, recording how much remaining time there was.
|
||||||
const auto start = std::chrono::high_resolution_clock::now();
|
const auto start = std::chrono::high_resolution_clock::now();
|
||||||
const auto sema_timeout = !sema.try_acquire_for(std::chrono::microseconds(*timeout));
|
const auto signaled = cv.wait_for(lk, std::chrono::microseconds(*timeout),
|
||||||
|
[this] { return was_signaled; });
|
||||||
const auto end = std::chrono::high_resolution_clock::now();
|
const auto end = std::chrono::high_resolution_clock::now();
|
||||||
const auto time =
|
const auto time =
|
||||||
std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
|
std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
|
||||||
if (sema_timeout) {
|
if (signaled) {
|
||||||
*timeout = 0;
|
|
||||||
} else {
|
|
||||||
*timeout -= time;
|
*timeout -= time;
|
||||||
|
} else {
|
||||||
|
*timeout = 0;
|
||||||
}
|
}
|
||||||
return GetResult(sema_timeout);
|
return GetResult(!signaled);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -222,13 +225,13 @@ int PS4_SYSV_ABI sceKernelCancelSema(OrbisKernelSema sem, s32 setCount, s32* pNu
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelDeleteSema(OrbisKernelSema sem) {
|
int PS4_SYSV_ABI sceKernelDeleteSema(OrbisKernelSema sem) {
|
||||||
if (!sem) {
|
if (!sem) {
|
||||||
return SCE_KERNEL_ERROR_ESRCH;
|
return ORBIS_KERNEL_ERROR_ESRCH;
|
||||||
}
|
}
|
||||||
sem->Delete();
|
sem->Delete();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_sem_init(PthreadSem** sem, int pshared, unsigned int value) {
|
int PS4_SYSV_ABI posix_sem_init(PthreadSem** sem, int pshared, u32 value) {
|
||||||
if (value > ORBIS_KERNEL_SEM_VALUE_MAX) {
|
if (value > ORBIS_KERNEL_SEM_VALUE_MAX) {
|
||||||
*__Error() = POSIX_EINVAL;
|
*__Error() = POSIX_EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <list>
|
|
||||||
#include <boost/intrusive/list.hpp>
|
#include <boost/intrusive/list.hpp>
|
||||||
#include <boost/intrusive/list_hook.hpp>
|
#include <boost/intrusive/list_hook.hpp>
|
||||||
#include "common/types.h"
|
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
|
||||||
struct Pthread;
|
struct Pthread;
|
||||||
|
struct SleepQueue;
|
||||||
|
|
||||||
using ListBaseHook =
|
using ListBaseHook =
|
||||||
boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::auto_unlink>>;
|
boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::auto_unlink>>;
|
||||||
@ -17,7 +16,7 @@ using ListBaseHook =
|
|||||||
using SleepqList = boost::intrusive::list<SleepQueue, boost::intrusive::constant_time_size<false>>;
|
using SleepqList = boost::intrusive::list<SleepQueue, boost::intrusive::constant_time_size<false>>;
|
||||||
|
|
||||||
struct SleepQueue : public ListBaseHook {
|
struct SleepQueue : public ListBaseHook {
|
||||||
std::list<Pthread*> sq_blocked;
|
std::forward_list<Pthread*> sq_blocked;
|
||||||
SleepqList sq_freeq;
|
SleepqList sq_freeq;
|
||||||
void* sq_wchan;
|
void* sq_wchan;
|
||||||
int sq_type;
|
int sq_type;
|
||||||
@ -35,4 +34,4 @@ int SleepqRemove(SleepQueue* sq, Pthread* td);
|
|||||||
|
|
||||||
void SleepqDrop(SleepQueue* sq, void (*callback)(Pthread*, void*), void* arg);
|
void SleepqDrop(SleepQueue* sq, void (*callback)(Pthread*, void*), void* arg);
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/kernel/posix_error.h"
|
||||||
#include "core/libraries/kernel/threads/pthread.h"
|
#include "core/libraries/kernel/threads/pthread.h"
|
||||||
#include "core/libraries/kernel/threads/sleepq.h"
|
#include "core/libraries/kernel/threads/sleepq.h"
|
||||||
#include "core/libraries/kernel/threads/thread_state.h"
|
#include "core/libraries/kernel/threads/thread_state.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/native_clock.h"
|
#include "common/native_clock.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/kernel/orbis_error.h"
|
||||||
#include "core/libraries/kernel/time.h"
|
#include "core/libraries/kernel/time.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ u32 PS4_SYSV_ABI sceKernelSleep(u32 seconds) {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
||||||
if (tp == nullptr) {
|
if (tp == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
}
|
}
|
||||||
clockid_t pclock_id = CLOCK_REALTIME;
|
clockid_t pclock_id = CLOCK_REALTIME;
|
||||||
switch (clock_id) {
|
switch (clock_id) {
|
||||||
@ -105,9 +105,9 @@ int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
|||||||
tp->tv_sec = t.tv_sec;
|
tp->tv_sec = t.tv_sec;
|
||||||
tp->tv_nsec = t.tv_nsec;
|
tp->tv_nsec = t.tv_nsec;
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_clock_gettime(s32 clock_id, OrbisKernelTimespec* time) {
|
int PS4_SYSV_ABI posix_clock_gettime(s32 clock_id, OrbisKernelTimespec* time) {
|
||||||
@ -126,11 +126,11 @@ int PS4_SYSV_ABI posix_nanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTim
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelNanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTimespec* rmtp) {
|
int PS4_SYSV_ABI sceKernelNanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTimespec* rmtp) {
|
||||||
if (!rqtp || !rmtp) {
|
if (!rqtp || !rmtp) {
|
||||||
return SCE_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0) {
|
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0) {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return posix_nanosleep(rqtp, rmtp);
|
return posix_nanosleep(rqtp, rmtp);
|
||||||
@ -197,7 +197,7 @@ s32 PS4_SYSV_ABI sceKernelGettimezone(OrbisKernelTimezone* tz) {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI posix_clock_getres(u32 clock_id, OrbisKernelTimespec* res) {
|
int PS4_SYSV_ABI posix_clock_getres(u32 clock_id, OrbisKernelTimespec* res) {
|
||||||
if (res == nullptr) {
|
if (res == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
}
|
}
|
||||||
clockid_t pclock_id = CLOCK_REALTIME;
|
clockid_t pclock_id = CLOCK_REALTIME;
|
||||||
switch (clock_id) {
|
switch (clock_id) {
|
||||||
@ -221,9 +221,9 @@ int PS4_SYSV_ABI posix_clock_getres(u32 clock_id, OrbisKernelTimespec* res) {
|
|||||||
res->tv_sec = t.tv_sec;
|
res->tv_sec = t.tv_sec;
|
||||||
res->tv_nsec = t.tv_nsec;
|
res->tv_nsec = t.tv_nsec;
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2, time_t* seconds,
|
int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2, time_t* seconds,
|
||||||
@ -237,9 +237,9 @@ int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2,
|
|||||||
if (dst_seconds)
|
if (dst_seconds)
|
||||||
*dst_seconds = timezone->tz_dsttime * 60;
|
*dst_seconds = timezone->tz_dsttime * 60;
|
||||||
} else {
|
} else {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
return SCE_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Dev {
|
namespace Dev {
|
||||||
@ -254,7 +254,7 @@ Common::NativeClock* GetClock() {
|
|||||||
} // namespace Dev
|
} // namespace Dev
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
|
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
|
||||||
struct OrbisTimesec* st, unsigned long* dst_sec) {
|
struct OrbisTimesec* st, u64* dst_sec) {
|
||||||
LOG_TRACE(Kernel, "Called");
|
LOG_TRACE(Kernel, "Called");
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// std::chrono::current_zone() not available yet.
|
// std::chrono::current_zone() not available yet.
|
||||||
|
@ -81,7 +81,7 @@ int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2,
|
|||||||
OrbisKernelTimezone* timezone, int* dst_seconds);
|
OrbisKernelTimezone* timezone, int* dst_seconds);
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time, OrbisTimesec* st,
|
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time, OrbisTimesec* st,
|
||||||
unsigned long* dst_sec);
|
u64* dst_sec);
|
||||||
|
|
||||||
void RegisterTime(Core::Loader::SymbolsResolver* sym);
|
void RegisterTime(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/libpng/pngdec.h"
|
||||||
|
#include "core/libraries/libpng/pngdec_error.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "pngdec.h"
|
|
||||||
|
|
||||||
namespace Libraries::PngDec {
|
namespace Libraries::PngDec {
|
||||||
|
|
||||||
@ -15,24 +15,25 @@ struct PngHandler {
|
|||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PngStruct {
|
||||||
|
const u8* data;
|
||||||
|
size_t size;
|
||||||
|
u64 offset;
|
||||||
|
};
|
||||||
|
|
||||||
static inline OrbisPngDecColorSpace MapPngColor(int color) {
|
static inline OrbisPngDecColorSpace MapPngColor(int color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case PNG_COLOR_TYPE_GRAY:
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE;
|
return OrbisPngDecColorSpace::Grayscale;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE_ALPHA;
|
return OrbisPngDecColorSpace::GrayscaleAlpha;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_PALETTE:
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_CLUT;
|
return OrbisPngDecColorSpace::Clut;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB:
|
case PNG_COLOR_TYPE_RGB:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_RGB;
|
return OrbisPngDecColorSpace::Rgb;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_RGBA;
|
return OrbisPngDecColorSpace::Rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNREACHABLE_MSG("unknown png color type");
|
UNREACHABLE_MSG("unknown png color type");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +55,8 @@ s32 PS4_SYSV_ABI scePngDecCreate(const OrbisPngDecCreateParam* param, void* memo
|
|||||||
LOG_ERROR(Lib_Png, "Invalid memory address!");
|
LOG_ERROR(Lib_Png, "Invalid memory address!");
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
||||||
}
|
}
|
||||||
if (param->maxImageWidth - 1 > 1000000) {
|
if (param->max_image_width - 1 > 1000000) {
|
||||||
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->maxImageWidth);
|
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->max_image_width);
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_SIZE;
|
return ORBIS_PNG_DEC_ERROR_INVALID_SIZE;
|
||||||
}
|
}
|
||||||
auto pngh = (PngHandler*)memoryAddress;
|
auto pngh = (PngHandler*)memoryAddress;
|
||||||
@ -86,88 +87,86 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
LOG_ERROR(Lib_Png, "Invalid param!");
|
LOG_ERROR(Lib_Png, "Invalid param!");
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_PARAM;
|
return ORBIS_PNG_DEC_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
if (param->pngMemAddr == nullptr || param->pngMemAddr == nullptr) {
|
if (param->png_mem_addr == nullptr || param->image_mem_addr == nullptr) {
|
||||||
LOG_ERROR(Lib_Png, "invalid image address!");
|
LOG_ERROR(Lib_Png, "invalid image address!");
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
||||||
}
|
}
|
||||||
LOG_TRACE(Lib_Png,
|
LOG_TRACE(Lib_Png,
|
||||||
"pngMemSize = {} , imageMemSize = {} , pixelFormat = {} , alphaValue = {} , "
|
"pngMemSize = {} , imageMemSize = {} , pixelFormat = {} , alphaValue = {} , "
|
||||||
"imagePitch = {}",
|
"imagePitch = {}",
|
||||||
param->pngMemSize, param->imageMemSize, param->pixelFormat, param->alphaValue,
|
param->png_mem_size, param->image_mem_size, int(param->pixel_format),
|
||||||
param->imagePitch);
|
param->alpha_value, param->image_pitch);
|
||||||
|
|
||||||
auto pngh = (PngHandler*)handle;
|
auto pngh = (PngHandler*)handle;
|
||||||
|
|
||||||
struct pngstruct {
|
const auto pngdata = PngStruct{
|
||||||
const u8* data;
|
.data = param->png_mem_addr,
|
||||||
size_t size;
|
.size = param->png_mem_size,
|
||||||
u64 offset;
|
|
||||||
} pngdata = {
|
|
||||||
.data = (const u8*)param->pngMemAddr,
|
|
||||||
.size = param->pngMemSize,
|
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read png from memory
|
|
||||||
png_set_read_fn(pngh->png_ptr, (void*)&pngdata,
|
png_set_read_fn(pngh->png_ptr, (void*)&pngdata,
|
||||||
[](png_structp ps, png_bytep data, png_size_t len) {
|
[](png_structp ps, png_bytep data, png_size_t len) {
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return;
|
return;
|
||||||
auto pngdata = (pngstruct*)png_get_io_ptr(ps);
|
auto pngdata = (PngStruct*)png_get_io_ptr(ps);
|
||||||
::memcpy(data, pngdata->data + pngdata->offset, len);
|
::memcpy(data, pngdata->data + pngdata->offset, len);
|
||||||
pngdata->offset += len;
|
pngdata->offset += len;
|
||||||
});
|
});
|
||||||
|
|
||||||
u32 width, height;
|
|
||||||
int color_type, bit_depth;
|
|
||||||
png_read_info(pngh->png_ptr, pngh->info_ptr);
|
png_read_info(pngh->png_ptr, pngh->info_ptr);
|
||||||
|
const u32 width = png_get_image_width(pngh->png_ptr, pngh->info_ptr);
|
||||||
width = png_get_image_width(pngh->png_ptr, pngh->info_ptr);
|
const u32 height = png_get_image_height(pngh->png_ptr, pngh->info_ptr);
|
||||||
height = png_get_image_height(pngh->png_ptr, pngh->info_ptr);
|
const auto color_type = MapPngColor(png_get_color_type(pngh->png_ptr, pngh->info_ptr));
|
||||||
color_type = MapPngColor(png_get_color_type(pngh->png_ptr, pngh->info_ptr));
|
const auto bit_depth = png_get_bit_depth(pngh->png_ptr, pngh->info_ptr);
|
||||||
bit_depth = png_get_bit_depth(pngh->png_ptr, pngh->info_ptr);
|
|
||||||
|
|
||||||
if (imageInfo != nullptr) {
|
if (imageInfo != nullptr) {
|
||||||
imageInfo->bitDepth = bit_depth;
|
imageInfo->bit_depth = bit_depth;
|
||||||
imageInfo->imageWidth = width;
|
imageInfo->image_width = width;
|
||||||
imageInfo->imageHeight = height;
|
imageInfo->image_height = height;
|
||||||
imageInfo->colorSpace = color_type;
|
imageInfo->color_space = color_type;
|
||||||
imageInfo->imageFlag = 0;
|
imageInfo->image_flag = OrbisPngDecImageFlag::None;
|
||||||
if (png_get_interlace_type(pngh->png_ptr, pngh->info_ptr) == 1) {
|
if (png_get_interlace_type(pngh->png_ptr, pngh->info_ptr) == 1) {
|
||||||
imageInfo->imageFlag |= OrbisPngDecImageFlag::ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE;
|
imageInfo->image_flag |= OrbisPngDecImageFlag::Adam7Interlace;
|
||||||
}
|
}
|
||||||
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
|
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
|
||||||
|
imageInfo->image_flag |= OrbisPngDecImageFlag::TrnsChunkExist;
|
||||||
imageInfo->imageFlag |= ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16) {
|
||||||
png_set_strip_16(pngh->png_ptr);
|
png_set_strip_16(pngh->png_ptr);
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
}
|
||||||
|
if (color_type == OrbisPngDecColorSpace::Clut) {
|
||||||
png_set_palette_to_rgb(pngh->png_ptr);
|
png_set_palette_to_rgb(pngh->png_ptr);
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
}
|
||||||
|
if (color_type == OrbisPngDecColorSpace::Grayscale && bit_depth < 8) {
|
||||||
png_set_expand_gray_1_2_4_to_8(pngh->png_ptr);
|
png_set_expand_gray_1_2_4_to_8(pngh->png_ptr);
|
||||||
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS))
|
}
|
||||||
|
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
|
||||||
png_set_tRNS_to_alpha(pngh->png_ptr);
|
png_set_tRNS_to_alpha(pngh->png_ptr);
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
}
|
||||||
|
if (color_type == OrbisPngDecColorSpace::Grayscale ||
|
||||||
|
color_type == OrbisPngDecColorSpace::GrayscaleAlpha) {
|
||||||
png_set_gray_to_rgb(pngh->png_ptr);
|
png_set_gray_to_rgb(pngh->png_ptr);
|
||||||
if (param->pixelFormat == OrbisPngDecPixelFormat::ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8)
|
}
|
||||||
|
if (param->pixel_format == OrbisPngDecPixelFormat::B8G8R8A8) {
|
||||||
png_set_bgr(pngh->png_ptr);
|
png_set_bgr(pngh->png_ptr);
|
||||||
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY ||
|
}
|
||||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == OrbisPngDecColorSpace::Rgb ||
|
||||||
png_set_add_alpha(pngh->png_ptr, param->alphaValue, PNG_FILLER_AFTER);
|
color_type == OrbisPngDecColorSpace::Grayscale ||
|
||||||
|
color_type == OrbisPngDecColorSpace::Clut) {
|
||||||
|
png_set_add_alpha(pngh->png_ptr, param->alpha_value, PNG_FILLER_AFTER);
|
||||||
|
}
|
||||||
|
|
||||||
int pass = png_set_interlace_handling(pngh->png_ptr);
|
const s32 pass = png_set_interlace_handling(pngh->png_ptr);
|
||||||
png_read_update_info(pngh->png_ptr, pngh->info_ptr);
|
png_read_update_info(pngh->png_ptr, pngh->info_ptr);
|
||||||
|
|
||||||
auto const numChannels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
|
const s32 num_channels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
|
||||||
auto horizontal_bytes = numChannels * width;
|
const s32 horizontal_bytes = num_channels * width;
|
||||||
|
const s32 stride = param->image_pitch > 0 ? param->image_pitch : horizontal_bytes;
|
||||||
|
|
||||||
int stride = param->imagePitch > 0 ? param->imagePitch : horizontal_bytes;
|
for (int j = 0; j < pass; j++) {
|
||||||
|
auto ptr = reinterpret_cast<png_bytep>(param->image_mem_addr);
|
||||||
for (int j = 0; j < pass; j++) { // interlaced
|
|
||||||
auto ptr = (png_bytep)param->imageMemAddr;
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
png_read_row(pngh->png_ptr, ptr, nullptr);
|
png_read_row(pngh->png_ptr, ptr, nullptr);
|
||||||
ptr += stride;
|
ptr += stride;
|
||||||
@ -196,7 +195,7 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
|
|||||||
}
|
}
|
||||||
|
|
||||||
u8 header[8];
|
u8 header[8];
|
||||||
memcpy(header, param->pngMemAddr, 8);
|
memcpy(header, param->png_mem_addr, 8);
|
||||||
// Check if the header indicates a valid PNG file
|
// Check if the header indicates a valid PNG file
|
||||||
if (png_sig_cmp(header, 0, 8)) {
|
if (png_sig_cmp(header, 0, 8)) {
|
||||||
LOG_ERROR(Lib_Png, "Memory doesn't contain a valid png file");
|
LOG_ERROR(Lib_Png, "Memory doesn't contain a valid png file");
|
||||||
@ -209,18 +208,14 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
|
|||||||
// Create a libpng info structure
|
// Create a libpng info structure
|
||||||
auto info_ptr = png_create_info_struct(png_ptr);
|
auto info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
struct pngstruct {
|
const auto pngdata = PngStruct{
|
||||||
const u8* data;
|
.data = param->png_mem_addr,
|
||||||
size_t size;
|
.size = param->png_mem_size,
|
||||||
u64 offset;
|
|
||||||
} pngdata = {
|
|
||||||
.data = (const u8*)param->pngMemAddr,
|
|
||||||
.size = param->pngMemSize,
|
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
png_set_read_fn(png_ptr, (void*)&pngdata, [](png_structp ps, png_bytep data, png_size_t len) {
|
png_set_read_fn(png_ptr, (void*)&pngdata, [](png_structp ps, png_bytep data, png_size_t len) {
|
||||||
auto pngdata = (pngstruct*)png_get_io_ptr(ps);
|
auto pngdata = (PngStruct*)png_get_io_ptr(ps);
|
||||||
::memcpy(data, pngdata->data + pngdata->offset, len);
|
::memcpy(data, pngdata->data + pngdata->offset, len);
|
||||||
pngdata->offset += len;
|
pngdata->offset += len;
|
||||||
});
|
});
|
||||||
@ -229,25 +224,24 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
|
|||||||
// info.
|
// info.
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
imageInfo->imageWidth = png_get_image_width(png_ptr, info_ptr);
|
imageInfo->image_width = png_get_image_width(png_ptr, info_ptr);
|
||||||
imageInfo->imageHeight = png_get_image_height(png_ptr, info_ptr);
|
imageInfo->image_height = png_get_image_height(png_ptr, info_ptr);
|
||||||
imageInfo->colorSpace = MapPngColor(png_get_color_type(png_ptr, info_ptr));
|
imageInfo->color_space = MapPngColor(png_get_color_type(png_ptr, info_ptr));
|
||||||
imageInfo->bitDepth = png_get_bit_depth(png_ptr, info_ptr);
|
imageInfo->bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||||
imageInfo->imageFlag = 0;
|
imageInfo->image_flag = OrbisPngDecImageFlag::None;
|
||||||
if (png_get_interlace_type(png_ptr, info_ptr) == 1) {
|
if (png_get_interlace_type(png_ptr, info_ptr) == 1) {
|
||||||
imageInfo->imageFlag |= OrbisPngDecImageFlag::ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE;
|
imageInfo->image_flag |= OrbisPngDecImageFlag::Adam7Interlace;
|
||||||
}
|
}
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
|
||||||
|
imageInfo->image_flag |= OrbisPngDecImageFlag::TrnsChunkExist;
|
||||||
imageInfo->imageFlag |= ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
||||||
LOG_TRACE(
|
LOG_TRACE(
|
||||||
Lib_Png,
|
Lib_Png,
|
||||||
"imageWidth = {} , imageHeight = {} , colorSpace = {} , bitDepth = {} , imageFlag = {}",
|
"imageWidth = {} , imageHeight = {} , colorSpace = {} , bitDepth = {} , imageFlag = {}",
|
||||||
imageInfo->imageWidth, imageInfo->imageHeight, imageInfo->colorSpace, imageInfo->bitDepth,
|
imageInfo->image_width, imageInfo->image_height, int(imageInfo->color_space),
|
||||||
imageInfo->imageFlag);
|
imageInfo->bit_depth, int(imageInfo->image_flag));
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,8 +254,8 @@ s32 PS4_SYSV_ABI scePngDecQueryMemorySize(const OrbisPngDecCreateParam* param) {
|
|||||||
LOG_ERROR(Lib_Png, "Invalid attribute! attribute = {}", param->attribute);
|
LOG_ERROR(Lib_Png, "Invalid attribute! attribute = {}", param->attribute);
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
||||||
}
|
}
|
||||||
if (param->maxImageWidth - 1 > 1000000) {
|
if (param->max_image_width - 1 > 1000000) {
|
||||||
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->maxImageWidth);
|
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->max_image_width);
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_SIZE;
|
return ORBIS_PNG_DEC_ERROR_INVALID_SIZE;
|
||||||
}
|
}
|
||||||
return sizeof(PngHandler);
|
return sizeof(PngHandler);
|
||||||
@ -279,4 +273,4 @@ void RegisterlibScePngDec(Core::Loader::SymbolsResolver* sym) {
|
|||||||
scePngDecDecodeWithInputControl);
|
scePngDecDecodeWithInputControl);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Libraries::PngDec
|
} // namespace Libraries::PngDec
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/enum.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
@ -11,59 +12,61 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::PngDec {
|
namespace Libraries::PngDec {
|
||||||
|
|
||||||
enum OrbisPngDecColorSpace {
|
enum class OrbisPngDecColorSpace : u16 {
|
||||||
ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE = 2,
|
Grayscale = 2,
|
||||||
ORBIS_PNG_DEC_COLOR_SPACE_RGB,
|
Rgb,
|
||||||
ORBIS_PNG_DEC_COLOR_SPACE_CLUT,
|
Clut,
|
||||||
ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE_ALPHA = 18,
|
GrayscaleAlpha = 18,
|
||||||
ORBIS_PNG_DEC_COLOR_SPACE_RGBA
|
Rgba,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisPngDecImageFlag {
|
enum class OrbisPngDecImageFlag : u32 {
|
||||||
ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE = 1,
|
None = 0,
|
||||||
ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST = 2
|
Adam7Interlace = 1,
|
||||||
|
TrnsChunkExist = 2,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisPngDecImageFlag)
|
||||||
|
|
||||||
|
enum class OrbisPngDecPixelFormat : u16 {
|
||||||
|
R8G8B8A8 = 0,
|
||||||
|
B8G8R8A8,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisPngDecPixelFormat {
|
enum class OrbisPngDecAttribute {
|
||||||
ORBIS_PNG_DEC_PIXEL_FORMAT_R8G8B8A8 = 0,
|
None = 0,
|
||||||
ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8
|
BitDepth16,
|
||||||
};
|
|
||||||
|
|
||||||
enum OrbisPngDecAttribute {
|
|
||||||
ORBIS_PNG_DEC_ATTRIBUTE_NONE = 0,
|
|
||||||
ORBIS_PNG_DEC_ATTRIBUTE_BIT_DEPTH_16
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisPngDecParseParam {
|
struct OrbisPngDecParseParam {
|
||||||
const void* pngMemAddr;
|
const u8* png_mem_addr;
|
||||||
u32 pngMemSize;
|
u32 png_mem_size;
|
||||||
u32 reserved;
|
u32 reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisPngDecImageInfo {
|
struct OrbisPngDecImageInfo {
|
||||||
u32 imageWidth;
|
u32 image_width;
|
||||||
u32 imageHeight;
|
u32 image_height;
|
||||||
u16 colorSpace;
|
OrbisPngDecColorSpace color_space;
|
||||||
u16 bitDepth;
|
u16 bit_depth;
|
||||||
u32 imageFlag;
|
OrbisPngDecImageFlag image_flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisPngDecCreateParam {
|
struct OrbisPngDecCreateParam {
|
||||||
u32 thisSize;
|
u32 this_size;
|
||||||
u32 attribute;
|
u32 attribute;
|
||||||
u32 maxImageWidth;
|
u32 max_image_width;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void* OrbisPngDecHandle;
|
using OrbisPngDecHandle = void*;
|
||||||
|
|
||||||
struct OrbisPngDecDecodeParam {
|
struct OrbisPngDecDecodeParam {
|
||||||
const void* pngMemAddr;
|
const u8* png_mem_addr;
|
||||||
void* imageMemAddr;
|
u8* image_mem_addr;
|
||||||
u32 pngMemSize;
|
u32 png_mem_size;
|
||||||
u32 imageMemSize;
|
u32 image_mem_size;
|
||||||
u16 pixelFormat;
|
OrbisPngDecPixelFormat pixel_format;
|
||||||
u16 alphaValue;
|
u16 alpha_value;
|
||||||
u32 imagePitch;
|
u32 image_pitch;
|
||||||
};
|
};
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePngDecCreate(const OrbisPngDecCreateParam* param, void* memoryAddress,
|
s32 PS4_SYSV_ABI scePngDecCreate(const OrbisPngDecCreateParam* param, void* memoryAddress,
|
||||||
@ -77,4 +80,4 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
|
|||||||
s32 PS4_SYSV_ABI scePngDecQueryMemorySize(const OrbisPngDecCreateParam* param);
|
s32 PS4_SYSV_ABI scePngDecQueryMemorySize(const OrbisPngDecCreateParam* param);
|
||||||
|
|
||||||
void RegisterlibScePngDec(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibScePngDec(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::PngDec
|
} // namespace Libraries::PngDec
|
||||||
|
17
src/core/libraries/libpng/pngdec_error.h
Normal file
17
src/core/libraries/libpng/pngdec_error.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
|
||||||
|
// PngDec library
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_ADDR = 0x80690001;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_SIZE = 0x80690002;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_PARAM = 0x80690003;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_HANDLE = 0x80690004;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_WORK_MEMORY = 0x80690005;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_INVALID_DATA = 0x80690010;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_UNSUPPORT_DATA = 0x80690011;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_DECODE_ERROR = 0x80690012;
|
||||||
|
constexpr int ORBIS_PNG_DEC_ERROR_FATAL = 0x80690020;
|
@ -27,7 +27,9 @@
|
|||||||
#include "core/libraries/np_trophy/np_trophy.h"
|
#include "core/libraries/np_trophy/np_trophy.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
#include "core/libraries/playgo/playgo.h"
|
#include "core/libraries/playgo/playgo.h"
|
||||||
|
#include "core/libraries/playgo/playgo_dialog.h"
|
||||||
#include "core/libraries/random/random.h"
|
#include "core/libraries/random/random.h"
|
||||||
|
#include "core/libraries/razor_cpu/razor_cpu.h"
|
||||||
#include "core/libraries/remote_play/remoteplay.h"
|
#include "core/libraries/remote_play/remoteplay.h"
|
||||||
#include "core/libraries/rtc/rtc.h"
|
#include "core/libraries/rtc/rtc.h"
|
||||||
#include "core/libraries/save_data/dialog/savedatadialog.h"
|
#include "core/libraries/save_data/dialog/savedatadialog.h"
|
||||||
@ -73,6 +75,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
|
|||||||
Libraries::AppContent::RegisterlibSceAppContent(sym);
|
Libraries::AppContent::RegisterlibSceAppContent(sym);
|
||||||
Libraries::PngDec::RegisterlibScePngDec(sym);
|
Libraries::PngDec::RegisterlibScePngDec(sym);
|
||||||
Libraries::PlayGo::RegisterlibScePlayGo(sym);
|
Libraries::PlayGo::RegisterlibScePlayGo(sym);
|
||||||
|
Libraries::PlayGo::Dialog::RegisterlibScePlayGoDialog(sym);
|
||||||
Libraries::Random::RegisterlibSceRandom(sym);
|
Libraries::Random::RegisterlibSceRandom(sym);
|
||||||
Libraries::Usbd::RegisterlibSceUsbd(sym);
|
Libraries::Usbd::RegisterlibSceUsbd(sym);
|
||||||
Libraries::Pad::RegisterlibScePad(sym);
|
Libraries::Pad::RegisterlibScePad(sym);
|
||||||
@ -87,6 +90,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
|
|||||||
Libraries::SharePlay::RegisterlibSceSharePlay(sym);
|
Libraries::SharePlay::RegisterlibSceSharePlay(sym);
|
||||||
Libraries::Remoteplay::RegisterlibSceRemoteplay(sym);
|
Libraries::Remoteplay::RegisterlibSceRemoteplay(sym);
|
||||||
Libraries::Videodec::RegisterlibSceVideodec(sym);
|
Libraries::Videodec::RegisterlibSceVideodec(sym);
|
||||||
|
Libraries::RazorCpu::RegisterlibSceRazorCpu(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries
|
} // namespace Libraries
|
||||||
|
@ -23,7 +23,7 @@ constexpr int ORBIS_NET_CTL_HOSTNAME_LEN = 255 + 1;
|
|||||||
constexpr int ORBIS_NET_CTL_AUTH_NAME_LEN = 127 + 1;
|
constexpr int ORBIS_NET_CTL_AUTH_NAME_LEN = 127 + 1;
|
||||||
constexpr int ORBIS_NET_CTL_IPV4_ADDR_STR_LEN = 16;
|
constexpr int ORBIS_NET_CTL_IPV4_ADDR_STR_LEN = 16;
|
||||||
|
|
||||||
typedef union OrbisNetCtlInfo {
|
union OrbisNetCtlInfo {
|
||||||
u32 device;
|
u32 device;
|
||||||
OrbisNetEtherAddr ether_addr;
|
OrbisNetEtherAddr ether_addr;
|
||||||
u32 mtu;
|
u32 mtu;
|
||||||
@ -45,7 +45,7 @@ typedef union OrbisNetCtlInfo {
|
|||||||
u32 http_proxy_config;
|
u32 http_proxy_config;
|
||||||
char http_proxy_server[ORBIS_NET_CTL_HOSTNAME_LEN];
|
char http_proxy_server[ORBIS_NET_CTL_HOSTNAME_LEN];
|
||||||
u16 http_proxy_port;
|
u16 http_proxy_port;
|
||||||
} SceNetCtlInfo;
|
};
|
||||||
|
|
||||||
// GetInfo codes
|
// GetInfo codes
|
||||||
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;
|
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "ngs2.h"
|
|
||||||
#include "ngs2_error.h"
|
|
||||||
#include "ngs2_impl.h"
|
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
#include "core/libraries/ngs2/ngs2.h"
|
||||||
|
#include "core/libraries/ngs2/ngs2_error.h"
|
||||||
|
#include "core/libraries/ngs2/ngs2_impl.h"
|
||||||
|
|
||||||
namespace Libraries::Ngs2 {
|
namespace Libraries::Ngs2 {
|
||||||
|
|
||||||
@ -416,4 +415,4 @@ void RegisterlibSceNgs2(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("AbYvTOZ8Pts", "libSceNgs2", 1, "libSceNgs2", 1, 1, sceNgs2VoiceRunCommands);
|
LIB_FUNCTION("AbYvTOZ8Pts", "libSceNgs2", 1, "libSceNgs2", 1, 1, sceNgs2VoiceRunCommands);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Libraries::Ngs2
|
} // namespace Libraries::Ngs2
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/types.h"
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
class SymbolsResolver;
|
class SymbolsResolver;
|
||||||
@ -18,7 +16,9 @@ class Ngs2;
|
|||||||
|
|
||||||
using SceNgs2Handle = Ngs2*;
|
using SceNgs2Handle = Ngs2*;
|
||||||
|
|
||||||
enum SceNgs2HandleType { SCE_NGS2_HANDLE_TYPE_SYSTEM = 0 };
|
enum class SceNgs2HandleType : u32 {
|
||||||
|
System = 0,
|
||||||
|
};
|
||||||
|
|
||||||
struct Ngs2Handle {
|
struct Ngs2Handle {
|
||||||
void* selfPointer;
|
void* selfPointer;
|
||||||
@ -69,4 +69,5 @@ struct StackBuffer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void RegisterlibSceNgs2(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceNgs2(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Ngs2
|
|
||||||
|
} // namespace Libraries::Ngs2
|
||||||
|
@ -971,12 +971,11 @@ int PS4_SYSV_ABI sceNpGetGamePresenceStatusA() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId userId, OrbisNpId* npId) {
|
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId user_id, OrbisNpId* np_id) {
|
||||||
LOG_INFO(Lib_NpManager, "userId {}", userId);
|
LOG_INFO(Lib_NpManager, "user_id {}", user_id);
|
||||||
std::string name = Config::getUserName();
|
const auto name = Config::getUserName();
|
||||||
// Fill the unused stuffs to 0
|
std::memset(np_id, 0, sizeof(OrbisNpId));
|
||||||
memset(npId, 0, sizeof(*npId));
|
name.copy(np_id->handle.data, sizeof(np_id->handle.data));
|
||||||
strcpy(npId->handle.data, name.c_str());
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,12 +984,11 @@ int PS4_SYSV_ABI sceNpGetNpReachabilityState() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpGetOnlineId(s32 userId, OrbisNpOnlineId* onlineId) {
|
int PS4_SYSV_ABI sceNpGetOnlineId(s32 user_id, OrbisNpOnlineId* online_id) {
|
||||||
LOG_DEBUG(Lib_NpManager, "userId {}", userId);
|
LOG_DEBUG(Lib_NpManager, "user_id {}", user_id);
|
||||||
std::string name = Config::getUserName();
|
const auto name = Config::getUserName();
|
||||||
// Fill the unused stuffs to 0
|
std::memset(online_id, 0, sizeof(OrbisNpOnlineId));
|
||||||
memset(onlineId, 0, sizeof(*onlineId));
|
name.copy(online_id->data, sizeof(online_id->data));
|
||||||
strcpy(onlineId->data, name.c_str());
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,7 +1003,7 @@ int PS4_SYSV_ABI sceNpGetParentalControlInfoA() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state) {
|
int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state) {
|
||||||
*state = ORBIS_NP_STATE_SIGNED_OUT;
|
*state = OrbisNpState::SignedOut;
|
||||||
LOG_DEBUG(Lib_NpManager, "Signed out");
|
LOG_DEBUG(Lib_NpManager, "Signed out");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -2518,7 +2516,7 @@ struct NpStateCallbackForNpToolkit {
|
|||||||
NpStateCallbackForNpToolkit NpStateCbForNp;
|
NpStateCallbackForNpToolkit NpStateCbForNp;
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpCheckCallbackForLib() {
|
int PS4_SYSV_ABI sceNpCheckCallbackForLib() {
|
||||||
Core::ExecuteGuest(NpStateCbForNp.func, 1, ORBIS_NP_STATE_SIGNED_OUT, NpStateCbForNp.userdata);
|
Core::ExecuteGuest(NpStateCbForNp.func, 1, OrbisNpState::SignedOut, NpStateCbForNp.userdata);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user