mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
Compare commits
218 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
824d332d0f | ||
|
19c3d05ac1 | ||
|
8dc50ffc79 | ||
|
ea37ea11fc | ||
|
4d3578edbe | ||
|
800b332f60 | ||
|
b4ec1bd371 | ||
|
0ad7fcb341 | ||
|
16a6469b75 | ||
|
7502739425 | ||
|
de11de43f2 | ||
|
14ef56d148 | ||
|
9e2af5f619 | ||
|
637e503685 | ||
|
1fc9eedbab | ||
|
bad9cd097a | ||
|
a4c5fa4b5c | ||
|
95a386308a | ||
|
0706223aaf | ||
|
fd03fe2b5a | ||
|
f0cd981548 | ||
|
bd0102c8d0 | ||
|
0b72a795eb | ||
|
2ae7037c08 | ||
|
af67473de3 | ||
|
b56039b15a | ||
|
3019bfb978 | ||
|
76f003d388 | ||
|
fafd3fb564 | ||
|
e914099ae2 | ||
|
1689cdb1a2 | ||
|
fddded8d20 | ||
|
161aa49f37 | ||
|
68b147488e | ||
|
aeab525a7f | ||
|
499451bb80 | ||
|
cf8a6efd37 | ||
|
6e350a5085 | ||
|
a82698d601 | ||
|
83475ac828 | ||
|
6d6068e0e2 | ||
|
4407ebdd9b | ||
|
87f6cce7b1 | ||
|
bf623d4f85 | ||
|
97daee836a | ||
|
b68ca43166 | ||
|
00f4eeddaf | ||
|
399a725343 | ||
|
b403e1be33 | ||
|
8bc30270c8 | ||
|
88abb93669 | ||
|
ee97c5c110 | ||
|
27cbd6647f | ||
|
dc6ef99dc7 | ||
|
7d4b875ee3 | ||
|
f5336358ea | ||
|
df4314f831 | ||
|
e5f899aae3 | ||
|
2d1a2982df | ||
|
ddede4a52d | ||
|
80f7ec2681 | ||
|
7fedbd52e0 | ||
|
d6163a6edb | ||
|
4eaa992aff | ||
|
70eef0de90 | ||
|
146e81a56a | ||
|
5eef2fd28a | ||
|
d1f5a7e8fb | ||
|
78cb5334cf | ||
|
f56eecea44 | ||
|
41b05ce7ed | ||
|
a63db68114 | ||
|
4f99f304e6 | ||
|
a050c9d65b | ||
|
b22da77f9a | ||
|
df22c4225e | ||
|
48460d1cbe | ||
|
7431b30005 | ||
|
9eae6b57ce | ||
|
efa7093f34 | ||
|
0594dac405 | ||
|
5789fd881c | ||
|
1757dfaf5a | ||
|
77117abb31 | ||
|
64dfccdf26 | ||
|
6bf3c44b9c | ||
|
434dcde9f3 | ||
|
bdd2419de9 | ||
|
7f727340aa | ||
|
59dd73492b | ||
|
83056712e0 | ||
|
fa32537f40 | ||
|
09b584b23f | ||
|
4bfd8b967b | ||
|
52bd92b97d | ||
|
8e44a7099f | ||
|
0a58ead5f6 | ||
|
9f37ede336 | ||
|
a49b13fe66 | ||
|
6eaec7a004 | ||
|
075d6425e2 | ||
|
70e4f81655 | ||
|
12198f9255 | ||
|
4bfa8c9fc7 | ||
|
669b19c2f3 | ||
|
d9dac05db2 | ||
|
802124309d | ||
|
5b5096e9ea | ||
|
54163ffaa5 | ||
|
2d335f436c | ||
|
1fc95bf44b | ||
|
0bb1ee167f | ||
|
a62027d4c2 | ||
|
8dcd9cc0f9 | ||
|
7b0249d9ca | ||
|
551751df3c | ||
|
be12305f65 | ||
|
e214ca6884 | ||
|
43321fb45a | ||
|
423254692a | ||
|
612f340292 | ||
|
6d65ea7314 | ||
|
e389d03601 | ||
|
33f46202d2 | ||
|
8e06b1b2b0 | ||
|
1437c5a1de | ||
|
20670186ab | ||
|
5bc4cc761a | ||
|
efa8f6a154 | ||
|
9dd35c3a42 | ||
|
21d14abaee | ||
|
c27f45c8c0 | ||
|
d0e2a40cdc | ||
|
e2b8ceb6ba | ||
|
213ca72fa1 | ||
|
de69f2b40b | ||
|
3f40a8d46e | ||
|
226058d2e9 | ||
|
ae6f7b8d5a | ||
|
1a27af6951 | ||
|
c35141b33f | ||
|
a1d6cd15f4 | ||
|
34d0d85c15 | ||
|
c71dc740e2 | ||
|
69a50fa713 | ||
|
34a1ffbcda | ||
|
3e0ec9ebef | ||
|
2741829545 | ||
|
dedf6de2ac | ||
|
fc4fd0107d | ||
|
ca92e72efe | ||
|
b49340dff8 | ||
|
9981c8df03 | ||
|
e0c930f2d8 | ||
|
e2b726382e | ||
|
0444e590e0 | ||
|
64bbedeb82 | ||
|
217d32b502 | ||
|
a71bfb30a2 | ||
|
046cf50412 | ||
|
d7051f15f4 | ||
|
12f4a8f073 | ||
|
c20d02dd40 | ||
|
ae2053c487 | ||
|
14b082f5ea | ||
|
ce42eccc9d | ||
|
8ffcfc87bd | ||
|
5004e41100 | ||
|
a07a6bb9d3 | ||
|
f2bbb6847d | ||
|
ce84e80f65 | ||
|
952cef5a15 | ||
|
2bc199a41b | ||
|
5d064dd89f | ||
|
2857ef34f0 | ||
|
5edd9ff54b | ||
|
91d29459fb | ||
|
fff3bf9917 | ||
|
43bf4ed1bc | ||
|
3b3026ff1c | ||
|
0e9420a7b2 | ||
|
93222c6f9f | ||
|
285df1b5be | ||
|
d4fbeea085 | ||
|
4d1a1ce9c2 | ||
|
23710f397e | ||
|
88f6cb4d41 | ||
|
5b6fc788b3 | ||
|
8cdd8dd725 | ||
|
c09d1c3cff | ||
|
ca0f458505 | ||
|
bb3f8af81a | ||
|
eed99141b3 | ||
|
2c78272185 | ||
|
1930a2132c | ||
|
6bdd83684b | ||
|
b1af1334c9 | ||
|
bb199865cf | ||
|
c09e463b8e | ||
|
4019319d92 | ||
|
790b54bf29 | ||
|
2091bc5651 | ||
|
8fffdc3918 | ||
|
6cdc52cdde | ||
|
aca8e7e9eb | ||
|
eb9f66c349 | ||
|
7f0503bf8b | ||
|
95f04b746d | ||
|
e0309a4b01 | ||
|
139a253edc | ||
|
99ccf56938 | ||
|
149898193f | ||
|
10d09ac977 | ||
|
e5c6c88835 | ||
|
d124f40503 | ||
|
e518a7062c | ||
|
f9bbde9c79 | ||
|
37887e8fde |
4
.github/ISSUE_TEMPLATE/game-bug-report.yaml
vendored
4
.github/ISSUE_TEMPLATE/game-bug-report.yaml
vendored
@ -17,7 +17,7 @@ body:
|
|||||||
|
|
||||||
This repository does not provide support for game patches. If you are having issues with patches please refer to [Cheats and Patches Repository](https://github.com/shadps4-emu/ps4_cheats).
|
This repository does not provide support for game patches. If you are having issues with patches please refer to [Cheats and Patches Repository](https://github.com/shadps4-emu/ps4_cheats).
|
||||||
|
|
||||||
Before submitting an issue please check [Game Compatibility Repository](https://github.com/shadps4-emu/shadps4-game-compatibility) for the information about the status of the game.
|
Before submitting an issue please check [Game Compatibility Repository](https://github.com/shadps4-compatibility/shadps4-game-compatibility) for the information about the status of the game.
|
||||||
|
|
||||||
Please make an effort to make sure your issue isn't already reported.
|
Please make an effort to make sure your issue isn't already reported.
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
- label: I have disabled all patches and cheats and the issue is still present.
|
- label: I have disabled all patches and cheats and the issue is still present.
|
||||||
required: true
|
required: true
|
||||||
- label: I have all the required [system modules](https://github.com/shadps4-emu/shadps4-game-compatibility?tab=readme-ov-file#informations) installed.
|
- label: I have all the required [system modules](https://github.com/shadps4-emu/shadPS4/wiki/I.-Quick-start-%5BUsers%5D#4-adding-modules) installed.
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: desc
|
id: desc
|
||||||
|
41
.github/workflows/build.yml
vendored
41
.github/workflows/build.yml
vendored
@ -76,18 +76,13 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{ runner.os }}-sdl-cache-cmake-build
|
cache-name: ${{ runner.os }}-sdl-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
append-timestamp: false
|
append-timestamp: false
|
||||||
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
|
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
|
||||||
|
|
||||||
- name: Setup VS Environment
|
|
||||||
uses: ilammy/msvc-dev-cmd@v1.13.0
|
|
||||||
with:
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=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}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
@ -111,7 +106,7 @@ jobs:
|
|||||||
- name: Setup Qt
|
- name: Setup Qt
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
version: 6.9.0
|
version: 6.9.1
|
||||||
host: windows
|
host: windows
|
||||||
target: desktop
|
target: desktop
|
||||||
arch: win64_msvc2022_64
|
arch: win64_msvc2022_64
|
||||||
@ -130,18 +125,13 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{ runner.os }}-qt-cache-cmake-build
|
cache-name: ${{ runner.os }}-qt-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
append-timestamp: false
|
append-timestamp: false
|
||||||
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
|
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
|
||||||
|
|
||||||
- name: Setup VS Environment
|
|
||||||
uses: ilammy/msvc-dev-cmd@v1.13.0
|
|
||||||
with:
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=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_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
@ -186,7 +176,7 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{runner.os}}-sdl-cache-cmake-build
|
cache-name: ${{runner.os}}-sdl-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
@ -228,13 +218,16 @@ jobs:
|
|||||||
- name: Setup Qt
|
- name: Setup Qt
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
version: 6.9.0
|
version: 6.9.1
|
||||||
host: mac
|
host: mac
|
||||||
target: desktop
|
target: desktop
|
||||||
arch: clang_64
|
arch: clang_64
|
||||||
archives: qtbase qttools
|
archives: qtbase qttools
|
||||||
modules: qtmultimedia
|
modules: qtmultimedia
|
||||||
|
|
||||||
|
- name: Workaround Qt <=6.9.1 issue
|
||||||
|
run: sed -i '' '/target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_agl_fw_path})/d' ${{env.QT_ROOT_DIR}}/lib/cmake/Qt6/FindWrapOpenGL.cmake
|
||||||
|
|
||||||
- name: Cache CMake Configuration
|
- name: Cache CMake Configuration
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
env:
|
env:
|
||||||
@ -247,7 +240,7 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{runner.os}}-qt-cache-cmake-build
|
cache-name: ${{runner.os}}-qt-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
@ -301,7 +294,7 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{ runner.os }}-sdl-cache-cmake-build
|
cache-name: ${{ runner.os }}-sdl-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
@ -362,7 +355,7 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{ runner.os }}-qt-cache-cmake-build
|
cache-name: ${{ runner.os }}-qt-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
@ -409,7 +402,7 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{ runner.os }}-sdl-gcc-cache-cmake-build
|
cache-name: ${{ runner.os }}-sdl-gcc-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
@ -445,7 +438,7 @@ jobs:
|
|||||||
${{ env.cache-name }}-
|
${{ env.cache-name }}-
|
||||||
|
|
||||||
- name: Cache CMake Build
|
- name: Cache CMake Build
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.17
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
||||||
env:
|
env:
|
||||||
cache-name: ${{ runner.os }}-qt-gcc-cache-cmake-build
|
cache-name: ${{ runner.os }}-qt-gcc-cache-cmake-build
|
||||||
with:
|
with:
|
||||||
@ -494,7 +487,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.SHADPS4_TOKEN_REPO }}
|
token: ${{ secrets.SHADPS4_TOKEN_REPO }}
|
||||||
name: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
|
name: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
|
||||||
tag: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
|
tag: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.fullhash }}"
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
body: "Full Changelog: [${{ env.last_release_tag }}...${{ needs.get-info.outputs.shorthash }}](https://github.com/shadps4-emu/shadPS4/compare/${{ env.last_release_tag }}...${{ needs.get-info.outputs.fullhash }})"
|
body: "Full Changelog: [${{ env.last_release_tag }}...${{ needs.get-info.outputs.shorthash }}](https://github.com/shadps4-emu/shadPS4/compare/${{ env.last_release_tag }}...${{ needs.get-info.outputs.fullhash }})"
|
||||||
@ -530,14 +523,14 @@ jobs:
|
|||||||
|
|
||||||
# Check if release already exists and get ID
|
# Check if release already exists and get ID
|
||||||
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
||||||
"https://api.github.com/repos/$REPO/releases/tags/Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}" | jq -r '.id')
|
"https://api.github.com/repos/$REPO/releases/tags/Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.fullhash }}" | jq -r '.id')
|
||||||
|
|
||||||
if [[ "$release_id" == "null" ]]; then
|
if [[ "$release_id" == "null" ]]; then
|
||||||
echo "Creating release in $REPO for $filename"
|
echo "Creating release in $REPO for $filename"
|
||||||
release_id=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
|
release_id=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
-d '{
|
-d '{
|
||||||
"tag_name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
|
"tag_name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.fullhash }}",
|
||||||
"name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
|
"name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
|
||||||
"draft": false,
|
"draft": false,
|
||||||
"prerelease": true,
|
"prerelease": true,
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -103,6 +103,6 @@
|
|||||||
path = externals/MoltenVK/cereal
|
path = externals/MoltenVK/cereal
|
||||||
url = https://github.com/USCiLab/cereal
|
url = https://github.com/USCiLab/cereal
|
||||||
shallow = true
|
shallow = true
|
||||||
[submodule "externals/libusb"]
|
[submodule "externals/ext-libusb"]
|
||||||
path = externals/libusb
|
path = externals/ext-libusb
|
||||||
url = https://github.com/libusb/libusb-cmake.git
|
url = https://github.com/shadps4-emu/ext-libusb.git
|
||||||
|
21
CMakeLinuxPresets.json
Normal file
21
CMakeLinuxPresets.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": 9,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 30,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Base",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/Build/${presetName}",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "clang",
|
||||||
|
"CMAKE_CXX_COMPILER": "clang++",
|
||||||
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/Build/${presetName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -126,7 +126,7 @@ execute_process(
|
|||||||
|
|
||||||
# If there's no upstream set or the command failed, check remote.pushDefault
|
# If there's no upstream set or the command failed, check remote.pushDefault
|
||||||
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
||||||
message("check default push")
|
message(STATUS "check default push")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git config --get remote.pushDefault
|
COMMAND git config --get remote.pushDefault
|
||||||
OUTPUT_VARIABLE GIT_REMOTE_NAME
|
OUTPUT_VARIABLE GIT_REMOTE_NAME
|
||||||
@ -134,30 +134,30 @@ if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
|||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
message("got remote: ${GIT_REMOTE_NAME}")
|
message(STATUS "got remote: ${GIT_REMOTE_NAME}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# If running in GitHub Actions and the above fails
|
# If running in GitHub Actions and the above fails
|
||||||
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
||||||
message("check github")
|
message(STATUS "check github")
|
||||||
set(GIT_REMOTE_NAME "origin")
|
set(GIT_REMOTE_NAME "origin")
|
||||||
|
|
||||||
# Retrieve environment variables
|
# Retrieve environment variables
|
||||||
if (DEFINED ENV{GITHUB_HEAD_REF} AND NOT "$ENV{GITHUB_HEAD_REF}" STREQUAL "")
|
if (DEFINED ENV{GITHUB_HEAD_REF} AND NOT "$ENV{GITHUB_HEAD_REF}" STREQUAL "")
|
||||||
message("github head ref: $ENV{GITHUB_HEAD_REF}")
|
message(STATUS "github head ref: $ENV{GITHUB_HEAD_REF}")
|
||||||
set(GITHUB_HEAD_REF "$ENV{GITHUB_HEAD_REF}")
|
set(GITHUB_HEAD_REF "$ENV{GITHUB_HEAD_REF}")
|
||||||
else()
|
else()
|
||||||
set(GITHUB_HEAD_REF "")
|
set(GITHUB_HEAD_REF "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DEFINED ENV{GITHUB_REF} AND NOT "$ENV{GITHUB_REF}" STREQUAL "")
|
if (DEFINED ENV{GITHUB_REF} AND NOT "$ENV{GITHUB_REF}" STREQUAL "")
|
||||||
message("github ref: $ENV{GITHUB_REF}")
|
message(STATUS "github ref: $ENV{GITHUB_REF}")
|
||||||
string(REGEX REPLACE "^refs/[^/]*/" "" GITHUB_BRANCH "$ENV{GITHUB_REF}")
|
string(REGEX REPLACE "^refs/[^/]*/" "" GITHUB_BRANCH "$ENV{GITHUB_REF}")
|
||||||
string(REGEX MATCH "refs/pull/([0-9]+)/merge" MATCHED_REF "$ENV{GITHUB_REF}")
|
string(REGEX MATCH "refs/pull/([0-9]+)/merge" MATCHED_REF "$ENV{GITHUB_REF}")
|
||||||
if (MATCHED_REF)
|
if (MATCHED_REF)
|
||||||
set(PR_NUMBER "${CMAKE_MATCH_1}")
|
set(PR_NUMBER "${CMAKE_MATCH_1}")
|
||||||
set(GITHUB_BRANCH "")
|
set(GITHUB_BRANCH "")
|
||||||
message("PR number: ${PR_NUMBER}")
|
message(STATUS "PR number: ${PR_NUMBER}")
|
||||||
else()
|
else()
|
||||||
set(PR_NUMBER "")
|
set(PR_NUMBER "")
|
||||||
endif()
|
endif()
|
||||||
@ -179,7 +179,7 @@ if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
|||||||
elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_REF}" STREQUAL "")
|
elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_REF}" STREQUAL "")
|
||||||
set(GIT_BRANCH "${GITHUB_REF}")
|
set(GIT_BRANCH "${GITHUB_REF}")
|
||||||
elseif("${GIT_BRANCH}" STREQUAL "")
|
elseif("${GIT_BRANCH}" STREQUAL "")
|
||||||
message("couldn't find branch")
|
message(STATUS "couldn't find branch")
|
||||||
set(GIT_BRANCH "detached-head")
|
set(GIT_BRANCH "detached-head")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
@ -188,13 +188,13 @@ else()
|
|||||||
if (INDEX GREATER -1)
|
if (INDEX GREATER -1)
|
||||||
string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME)
|
string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME)
|
||||||
elseif("${GIT_REMOTE_NAME}" STREQUAL "")
|
elseif("${GIT_REMOTE_NAME}" STREQUAL "")
|
||||||
message("reset to origin")
|
message(STATUS "reset to origin")
|
||||||
set(GIT_REMOTE_NAME "origin")
|
set(GIT_REMOTE_NAME "origin")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Get remote link
|
# Get remote link
|
||||||
message("getting remote link")
|
message(STATUS "getting remote link")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git config --get remote.${GIT_REMOTE_NAME}.url
|
COMMAND git config --get remote.${GIT_REMOTE_NAME}.url
|
||||||
OUTPUT_VARIABLE GIT_REMOTE_URL
|
OUTPUT_VARIABLE GIT_REMOTE_URL
|
||||||
@ -203,16 +203,26 @@ execute_process(
|
|||||||
|
|
||||||
# Set Version
|
# Set Version
|
||||||
set(EMULATOR_VERSION_MAJOR "0")
|
set(EMULATOR_VERSION_MAJOR "0")
|
||||||
set(EMULATOR_VERSION_MINOR "9")
|
set(EMULATOR_VERSION_MINOR "10")
|
||||||
set(EMULATOR_VERSION_PATCH "0")
|
set(EMULATOR_VERSION_PATCH "1")
|
||||||
|
|
||||||
set_source_files_properties(src/shadps4.rc PROPERTIES COMPILE_DEFINITIONS "EMULATOR_VERSION_MAJOR=${EMULATOR_VERSION_MAJOR};EMULATOR_VERSION_MINOR=${EMULATOR_VERSION_MINOR};EMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH}")
|
set_source_files_properties(src/shadps4.rc PROPERTIES COMPILE_DEFINITIONS "EMULATOR_VERSION_MAJOR=${EMULATOR_VERSION_MAJOR};EMULATOR_VERSION_MINOR=${EMULATOR_VERSION_MINOR};EMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH}")
|
||||||
|
|
||||||
set(APP_VERSION "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH}")
|
set(APP_VERSION "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH} WIP")
|
||||||
set(APP_IS_RELEASE true)
|
set(APP_IS_RELEASE false)
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY)
|
||||||
|
|
||||||
message("end git things, remote: ${GIT_REMOTE_NAME}, branch: ${GIT_BRANCH}")
|
message("-- end git things, remote: ${GIT_REMOTE_NAME}, branch: ${GIT_BRANCH}, link: ${GIT_REMOTE_URL}")
|
||||||
|
|
||||||
|
string(TOLOWER "${GIT_REMOTE_URL}" GIT_REMOTE_URL_LOWER)
|
||||||
|
if(NOT GIT_REMOTE_URL_LOWER MATCHES "shadps4-emu/shadps4" OR NOT GIT_BRANCH STREQUAL "main")
|
||||||
|
message(STATUS "not main, disabling auto update")
|
||||||
|
set(ENABLE_UPDATER OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32 AND ENABLE_QT_GUI AND NOT CMAKE_PREFIX_PATH)
|
||||||
|
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/DetectQtInstallation.cmake")
|
||||||
|
endif ()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
find_package(Boost 1.84.0 CONFIG)
|
find_package(Boost 1.84.0 CONFIG)
|
||||||
@ -227,14 +237,13 @@ find_package(SDL3 3.1.2 CONFIG)
|
|||||||
find_package(stb MODULE)
|
find_package(stb MODULE)
|
||||||
find_package(toml11 4.2.0 CONFIG)
|
find_package(toml11 4.2.0 CONFIG)
|
||||||
find_package(tsl-robin-map 1.3.0 CONFIG)
|
find_package(tsl-robin-map 1.3.0 CONFIG)
|
||||||
find_package(VulkanHeaders 1.4.309 CONFIG)
|
find_package(VulkanHeaders 1.4.314 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 1.3 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)
|
||||||
find_package(libusb 1.0.27 MODULE)
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
find_package(date 3.0.1 CONFIG)
|
find_package(date 3.0.1 CONFIG)
|
||||||
endif()
|
endif()
|
||||||
@ -251,7 +260,6 @@ endif()
|
|||||||
|
|
||||||
add_subdirectory(externals)
|
add_subdirectory(externals)
|
||||||
include_directories(src)
|
include_directories(src)
|
||||||
include_directories(Resources)
|
|
||||||
|
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent LinguistTools Network Multimedia)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent LinguistTools Network Multimedia)
|
||||||
@ -296,6 +304,10 @@ set(AJM_LIB src/core/libraries/ajm/ajm.cpp
|
|||||||
|
|
||||||
set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
|
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/sdl_in.h
|
||||||
|
src/core/libraries/audio/sdl_in.cpp
|
||||||
|
src/core/libraries/voice/voice.cpp
|
||||||
|
src/core/libraries/voice/voice.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/audioout_backend.h
|
src/core/libraries/audio/audioout_backend.h
|
||||||
@ -603,6 +615,8 @@ set(CAMERA_LIBS src/core/libraries/camera/camera.cpp
|
|||||||
|
|
||||||
set(COMPANION_LIBS src/core/libraries/companion/companion_httpd.cpp
|
set(COMPANION_LIBS src/core/libraries/companion/companion_httpd.cpp
|
||||||
src/core/libraries/companion/companion_httpd.h
|
src/core/libraries/companion/companion_httpd.h
|
||||||
|
src/core/libraries/companion/companion_util.cpp
|
||||||
|
src/core/libraries/companion/companion_util.h
|
||||||
src/core/libraries/companion/companion_error.h
|
src/core/libraries/companion/companion_error.h
|
||||||
)
|
)
|
||||||
set(DEV_TOOLS src/core/devtools/layer.cpp
|
set(DEV_TOOLS src/core/devtools/layer.cpp
|
||||||
@ -622,6 +636,8 @@ set(DEV_TOOLS src/core/devtools/layer.cpp
|
|||||||
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.cpp
|
||||||
src/core/devtools/widget/memory_map.h
|
src/core/devtools/widget/memory_map.h
|
||||||
|
src/core/devtools/widget/module_list.cpp
|
||||||
|
src/core/devtools/widget/module_list.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
|
||||||
@ -647,6 +663,7 @@ set(COMMON src/common/logging/backend.cpp
|
|||||||
src/common/arch.h
|
src/common/arch.h
|
||||||
src/common/assert.cpp
|
src/common/assert.cpp
|
||||||
src/common/assert.h
|
src/common/assert.h
|
||||||
|
src/common/bit_array.h
|
||||||
src/common/bit_field.h
|
src/common/bit_field.h
|
||||||
src/common/bounded_threadsafe_queue.h
|
src/common/bounded_threadsafe_queue.h
|
||||||
src/common/concepts.h
|
src/common/concepts.h
|
||||||
@ -672,9 +689,13 @@ set(COMMON src/common/logging/backend.cpp
|
|||||||
src/common/path_util.h
|
src/common/path_util.h
|
||||||
src/common/object_pool.h
|
src/common/object_pool.h
|
||||||
src/common/polyfill_thread.h
|
src/common/polyfill_thread.h
|
||||||
|
src/common/range_lock.h
|
||||||
src/common/rdtsc.cpp
|
src/common/rdtsc.cpp
|
||||||
src/common/rdtsc.h
|
src/common/rdtsc.h
|
||||||
|
src/common/recursive_lock.cpp
|
||||||
|
src/common/recursive_lock.h
|
||||||
src/common/sha1.h
|
src/common/sha1.h
|
||||||
|
src/common/shared_first_mutex.h
|
||||||
src/common/signal_context.h
|
src/common/signal_context.h
|
||||||
src/common/signal_context.cpp
|
src/common/signal_context.cpp
|
||||||
src/common/singleton.h
|
src/common/singleton.h
|
||||||
@ -862,8 +883,10 @@ set(SHADER_RECOMPILER src/shader_recompiler/exception.h
|
|||||||
src/shader_recompiler/ir/passes/ring_access_elimination.cpp
|
src/shader_recompiler/ir/passes/ring_access_elimination.cpp
|
||||||
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp
|
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/shared_memory_barrier_pass.cpp
|
src/shader_recompiler/ir/passes/shared_memory_barrier_pass.cpp
|
||||||
|
src/shader_recompiler/ir/passes/shared_memory_simplify_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/shared_memory_to_storage_pass.cpp
|
src/shader_recompiler/ir/passes/shared_memory_to_storage_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/ssa_rewrite_pass.cpp
|
src/shader_recompiler/ir/passes/ssa_rewrite_pass.cpp
|
||||||
|
src/shader_recompiler/ir/abstract_syntax_list.cpp
|
||||||
src/shader_recompiler/ir/abstract_syntax_list.h
|
src/shader_recompiler/ir/abstract_syntax_list.h
|
||||||
src/shader_recompiler/ir/attribute.cpp
|
src/shader_recompiler/ir/attribute.cpp
|
||||||
src/shader_recompiler/ir/attribute.h
|
src/shader_recompiler/ir/attribute.h
|
||||||
@ -903,9 +926,10 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
|
|||||||
src/video_core/buffer_cache/buffer.h
|
src/video_core/buffer_cache/buffer.h
|
||||||
src/video_core/buffer_cache/buffer_cache.cpp
|
src/video_core/buffer_cache/buffer_cache.cpp
|
||||||
src/video_core/buffer_cache/buffer_cache.h
|
src/video_core/buffer_cache/buffer_cache.h
|
||||||
src/video_core/buffer_cache/memory_tracker_base.h
|
src/video_core/buffer_cache/memory_tracker.h
|
||||||
src/video_core/buffer_cache/range_set.h
|
src/video_core/buffer_cache/range_set.h
|
||||||
src/video_core/buffer_cache/word_manager.h
|
src/video_core/buffer_cache/region_definitions.h
|
||||||
|
src/video_core/buffer_cache/region_manager.h
|
||||||
src/video_core/renderer_vulkan/liverpool_to_vk.cpp
|
src/video_core/renderer_vulkan/liverpool_to_vk.cpp
|
||||||
src/video_core/renderer_vulkan/liverpool_to_vk.h
|
src/video_core/renderer_vulkan/liverpool_to_vk.h
|
||||||
src/video_core/renderer_vulkan/vk_common.cpp
|
src/video_core/renderer_vulkan/vk_common.cpp
|
||||||
@ -942,6 +966,10 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
|
|||||||
src/video_core/renderer_vulkan/host_passes/fsr_pass.h
|
src/video_core/renderer_vulkan/host_passes/fsr_pass.h
|
||||||
src/video_core/renderer_vulkan/host_passes/pp_pass.cpp
|
src/video_core/renderer_vulkan/host_passes/pp_pass.cpp
|
||||||
src/video_core/renderer_vulkan/host_passes/pp_pass.h
|
src/video_core/renderer_vulkan/host_passes/pp_pass.h
|
||||||
|
src/video_core/texture_cache/blit_helper.cpp
|
||||||
|
src/video_core/texture_cache/blit_helper.h
|
||||||
|
src/video_core/texture_cache/host_compatibility.cpp
|
||||||
|
src/video_core/texture_cache/host_compatibility.h
|
||||||
src/video_core/texture_cache/image.cpp
|
src/video_core/texture_cache/image.cpp
|
||||||
src/video_core/texture_cache/image.h
|
src/video_core/texture_cache/image.h
|
||||||
src/video_core/texture_cache/image_info.cpp
|
src/video_core/texture_cache/image_info.cpp
|
||||||
@ -955,7 +983,6 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
|
|||||||
src/video_core/texture_cache/tile_manager.cpp
|
src/video_core/texture_cache/tile_manager.cpp
|
||||||
src/video_core/texture_cache/tile_manager.h
|
src/video_core/texture_cache/tile_manager.h
|
||||||
src/video_core/texture_cache/types.h
|
src/video_core/texture_cache/types.h
|
||||||
src/video_core/texture_cache/host_compatibility.h
|
|
||||||
src/video_core/page_manager.cpp
|
src/video_core/page_manager.cpp
|
||||||
src/video_core/page_manager.h
|
src/video_core/page_manager.h
|
||||||
src/video_core/multi_level_page_table.h
|
src/video_core/multi_level_page_table.h
|
||||||
@ -1044,6 +1071,12 @@ set(QT_GUI src/qt_gui/about_dialog.cpp
|
|||||||
src/qt_gui/settings_dialog.h
|
src/qt_gui/settings_dialog.h
|
||||||
src/qt_gui/settings_dialog.ui
|
src/qt_gui/settings_dialog.ui
|
||||||
src/qt_gui/main.cpp
|
src/qt_gui/main.cpp
|
||||||
|
src/qt_gui/gui_settings.cpp
|
||||||
|
src/qt_gui/gui_settings.h
|
||||||
|
src/qt_gui/settings.cpp
|
||||||
|
src/qt_gui/settings.h
|
||||||
|
src/qt_gui/sdl_event_wrapper.cpp
|
||||||
|
src/qt_gui/sdl_event_wrapper.h
|
||||||
${EMULATOR}
|
${EMULATOR}
|
||||||
${RESOURCE_FILES}
|
${RESOURCE_FILES}
|
||||||
${TRANSLATIONS}
|
${TRANSLATIONS}
|
||||||
@ -1109,6 +1142,10 @@ if (APPLE)
|
|||||||
set(MVK_BUNDLE_PATH "Resources/vulkan/icd.d")
|
set(MVK_BUNDLE_PATH "Resources/vulkan/icd.d")
|
||||||
set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path/../${MVK_BUNDLE_PATH}")
|
set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path/../${MVK_BUNDLE_PATH}")
|
||||||
set(MVK_DST ${CMAKE_CURRENT_BINARY_DIR}/shadps4.app/Contents/${MVK_BUNDLE_PATH})
|
set(MVK_DST ${CMAKE_CURRENT_BINARY_DIR}/shadps4.app/Contents/${MVK_BUNDLE_PATH})
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${MVK_DST}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${MVK_DST})
|
||||||
else()
|
else()
|
||||||
set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path")
|
set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path")
|
||||||
set(MVK_DST ${CMAKE_CURRENT_BINARY_DIR})
|
set(MVK_DST ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
@ -1119,9 +1156,6 @@ if (APPLE)
|
|||||||
set(MVK_ICD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/externals/MoltenVK/MoltenVK/MoltenVK/icd/MoltenVK_icd.json)
|
set(MVK_ICD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/externals/MoltenVK/MoltenVK/MoltenVK/icd/MoltenVK_icd.json)
|
||||||
set(MVK_ICD_DST ${MVK_DST}/MoltenVK_icd.json)
|
set(MVK_ICD_DST ${MVK_DST}/MoltenVK_icd.json)
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${MVK_DST}
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${MVK_DST})
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${MVK_ICD_DST}
|
OUTPUT ${MVK_ICD_DST}
|
||||||
DEPENDS ${MVK_ICD_SRC} ${MVK_DST}
|
DEPENDS ${MVK_ICD_SRC} ${MVK_DST}
|
||||||
@ -1136,17 +1170,13 @@ if (APPLE)
|
|||||||
|
|
||||||
if (ARCHITECTURE STREQUAL "x86_64")
|
if (ARCHITECTURE STREQUAL "x86_64")
|
||||||
# Reserve system-managed memory space.
|
# Reserve system-managed memory space.
|
||||||
target_link_options(shadps4 PRIVATE -Wl,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x4000,-segaddr,TCB_SPACE,0x4000,-segaddr,SYSTEM_MANAGED,0x400000,-segaddr,SYSTEM_RESERVED,0x7FFFFC000,-image_base,0x20000000000)
|
target_link_options(shadps4 PRIVATE -Wl,-ld_classic,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x4000,-segaddr,TCB_SPACE,0x4000,-segaddr,SYSTEM_MANAGED,0x400000,-segaddr,SYSTEM_RESERVED,0x7FFFFC000,-image_base,0x20000000000)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Replacement for std::chrono::time_zone
|
# Replacement for std::chrono::time_zone
|
||||||
target_link_libraries(shadps4 PRIVATE date::date-tz)
|
target_link_libraries(shadps4 PRIVATE date::date-tz)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT ENABLE_QT_GUI)
|
|
||||||
target_link_libraries(shadps4 PRIVATE SDL3::SDL3)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_QT_GUI)
|
if (ENABLE_QT_GUI)
|
||||||
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network Qt6::Multimedia)
|
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network Qt6::Multimedia)
|
||||||
add_definitions(-DENABLE_QT_GUI)
|
add_definitions(-DENABLE_QT_GUI)
|
||||||
@ -1213,6 +1243,7 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeRC.cmake")
|
|||||||
cmrc_add_resource_library(embedded-resources
|
cmrc_add_resource_library(embedded-resources
|
||||||
ALIAS res::embedded
|
ALIAS res::embedded
|
||||||
NAMESPACE res
|
NAMESPACE res
|
||||||
|
src/images/trophy.wav
|
||||||
src/images/bronze.png
|
src/images/bronze.png
|
||||||
src/images/gold.png
|
src/images/gold.png
|
||||||
src/images/platinum.png
|
src/images/platinum.png
|
||||||
|
62
CMakePresets.json
Normal file
62
CMakePresets.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"version": 9,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 30,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"include": ["CMake${hostSystemName}Presets.json"],
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Debug",
|
||||||
|
"displayName": "Clang x64 Debug",
|
||||||
|
"inherits": ["x64-Clang-Base"],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Debug-Qt",
|
||||||
|
"displayName": "Clang x64 Debug with Qt",
|
||||||
|
"inherits": ["x64-Clang-Base"],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug",
|
||||||
|
"ENABLE_QT_GUI": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Release",
|
||||||
|
"displayName": "Clang x64 Release",
|
||||||
|
"inherits": ["x64-Clang-Base"],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Release-Qt",
|
||||||
|
"displayName": "Clang x64 Release with Qt",
|
||||||
|
"inherits": ["x64-Clang-Base"],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release",
|
||||||
|
"ENABLE_QT_GUI": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-RelWithDebInfo",
|
||||||
|
"displayName": "Clang x64 RelWithDebInfo",
|
||||||
|
"inherits": ["x64-Clang-Base"],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-RelWithDebInfo-Qt",
|
||||||
|
"displayName": "Clang x64 RelWithDebInfo with Qt",
|
||||||
|
"inherits": ["x64-Clang-Base"],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||||
|
"ENABLE_QT_GUI": "ON"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -12,6 +12,18 @@
|
|||||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
"intelliSenseMode": "windows-clang-x64"
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Release-Qt",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Release",
|
||||||
|
"buildRoot": "${projectDir}\\Build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\Install\\${name}",
|
||||||
|
"cmakeCommandArgs": "-DENABLE_QT_GUI=ON",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Clang-Debug",
|
"name": "x64-Clang-Debug",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
@ -24,6 +36,18 @@
|
|||||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
"intelliSenseMode": "windows-clang-x64"
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Debug-Qt",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Debug",
|
||||||
|
"buildRoot": "${projectDir}\\Build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\Install\\${name}",
|
||||||
|
"cmakeCommandArgs": "-DENABLE_QT_GUI=ON",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Clang-RelWithDebInfo",
|
"name": "x64-Clang-RelWithDebInfo",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
@ -35,6 +59,18 @@
|
|||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
"intelliSenseMode": "windows-clang-x64"
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-RelWithDebInfo-Qt",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "RelWithDebInfo",
|
||||||
|
"buildRoot": "${projectDir}\\Build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\Install\\${name}",
|
||||||
|
"cmakeCommandArgs": "-DENABLE_QT_GUI=ON",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
26
CMakeWindowsPresets.json
Normal file
26
CMakeWindowsPresets.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": 9,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 30,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Base",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/Build/${presetName}",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "clang-cl",
|
||||||
|
"CMAKE_CXX_COMPILER": "clang-cl",
|
||||||
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/Build/${presetName}"
|
||||||
|
},
|
||||||
|
"vendor": {
|
||||||
|
"microsoft.com/VisualStudioSettings/CMake/1.0": {
|
||||||
|
"intelliSenseMode": "windows-clang-x64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
README.md
15
README.md
@ -36,8 +36,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
|
|
||||||
**shadPS4** is an early **PlayStation 4** emulator for **Windows**, **Linux** and **macOS** written in C++.
|
**shadPS4** is an early **PlayStation 4** emulator for **Windows**, **Linux** and **macOS** written in C++.
|
||||||
|
|
||||||
If you encounter problems or have doubts, do not hesitate to look at the [**Quickstart**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Quickstart/Quickstart.md).\
|
If you encounter problems or have doubts, do not hesitate to look at the [**Quickstart**](https://github.com/shadps4-emu/shadPS4/wiki/I.-Quick-start-%5BUsers%5D).\
|
||||||
To verify that a game works, you can look at [**shadPS4 Game Compatibility**](https://github.com/shadps4-emu/shadps4-game-compatibility).\
|
To verify that a game works, you can look at [**shadPS4 Game Compatibility**](https://github.com/shadps4-compatibility/shadps4-game-compatibility).\
|
||||||
To discuss shadPS4 development, suggest ideas or to ask for help, join our [**Discord server**](https://discord.gg/bFJxfftGW6).\
|
To discuss shadPS4 development, suggest ideas or to ask for help, join our [**Discord server**](https://discord.gg/bFJxfftGW6).\
|
||||||
To get the latest news, go to our [**X (Twitter)**](https://x.com/shadps4) or our [**website**](https://shadps4.net/).\
|
To get the latest news, go to our [**X (Twitter)**](https://x.com/shadps4) or our [**website**](https://shadps4.net/).\
|
||||||
For those who'd like to donate to the project, we now have a [**Kofi page**](https://ko-fi.com/shadps4)!
|
For those who'd like to donate to the project, we now have a [**Kofi page**](https://ko-fi.com/shadps4)!
|
||||||
@ -124,8 +124,8 @@ Keyboard and mouse inputs can be customized in the settings menu by clicking the
|
|||||||
|
|
||||||
# Firmware files
|
# Firmware files
|
||||||
|
|
||||||
shadPS4 can load some PlayStation 4 firmware files, these must be dumped from your legally owned PlayStation 4 console.\
|
shadPS4 can load some PlayStation 4 firmware files, these must be dumped from your legally owned PlayStation 4 console.
|
||||||
The following firmware modules are supported and must be placed in shadPS4's `user/sys_modules` folder.
|
The following firmware modules are supported and must be placed in shadPS4's `sys_modules` folder.
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
@ -138,8 +138,7 @@ The following firmware modules are supported and must be placed in shadPS4's `us
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
> [!Caution]
|
> [!Caution]
|
||||||
> The above modules are required to run the games properly and must be extracted from your PlayStation 4.\
|
> The above modules are required to run the games properly and must be extracted from your PlayStation 4.
|
||||||
> **We do not provide any information or support on how to do this**.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +147,7 @@ The following firmware modules are supported and must be placed in shadPS4's `us
|
|||||||
- [**georgemoralis**](https://github.com/georgemoralis)
|
- [**georgemoralis**](https://github.com/georgemoralis)
|
||||||
- [**psucien**](https://github.com/psucien)
|
- [**psucien**](https://github.com/psucien)
|
||||||
- [**viniciuslrangel**](https://github.com/viniciuslrangel)
|
- [**viniciuslrangel**](https://github.com/viniciuslrangel)
|
||||||
- [**roamic**](https://github.com/vladmikhalin)
|
- [**roamic**](https://github.com/roamic)
|
||||||
- [**squidbus**](https://github.com/squidbus)
|
- [**squidbus**](https://github.com/squidbus)
|
||||||
- [**frodo**](https://github.com/baggins183)
|
- [**frodo**](https://github.com/baggins183)
|
||||||
- [**Stephen Miller**](https://github.com/StevenMiller123)
|
- [**Stephen Miller**](https://github.com/StevenMiller123)
|
||||||
@ -158,7 +157,7 @@ Logo is done by [**Xphalnos**](https://github.com/Xphalnos)
|
|||||||
|
|
||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
If you want to contribute, please look the [**CONTRIBUTING.md**](https://github.com/shadps4-emu/shadPS4/blob/main/CONTRIBUTING.md) file.\
|
If you want to contribute, please read the [**CONTRIBUTING.md**](https://github.com/shadps4-emu/shadPS4/blob/main/CONTRIBUTING.md) file.\
|
||||||
Open a PR and we'll check it :)
|
Open a PR and we'll check it :)
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
|
11
REUSE.toml
11
REUSE.toml
@ -5,10 +5,13 @@ path = [
|
|||||||
"REUSE.toml",
|
"REUSE.toml",
|
||||||
"crowdin.yml",
|
"crowdin.yml",
|
||||||
"CMakeSettings.json",
|
"CMakeSettings.json",
|
||||||
|
"CMakeLinuxPresets.json",
|
||||||
|
"CMakeWindowsPresets.json",
|
||||||
|
"CMakePresets.json",
|
||||||
".github/FUNDING.yml",
|
".github/FUNDING.yml",
|
||||||
".github/shadps4.png",
|
".github/shadps4.png",
|
||||||
".github/workflows/scripts/update_translation.sh",
|
".github/workflows/scripts/update_translation.sh",
|
||||||
".github/workflows/update_translation.yml",
|
".github/workflows/update_translation.yml",
|
||||||
".gitmodules",
|
".gitmodules",
|
||||||
"dist/MacOSBundleInfo.plist.in",
|
"dist/MacOSBundleInfo.plist.in",
|
||||||
"dist/net.shadps4.shadPS4.desktop",
|
"dist/net.shadps4.shadPS4.desktop",
|
||||||
@ -29,6 +32,7 @@ path = [
|
|||||||
"src/images/discord.png",
|
"src/images/discord.png",
|
||||||
"src/images/dump_icon.png",
|
"src/images/dump_icon.png",
|
||||||
"src/images/exit_icon.png",
|
"src/images/exit_icon.png",
|
||||||
|
"src/images/favorite_icon.png",
|
||||||
"src/images/file_icon.png",
|
"src/images/file_icon.png",
|
||||||
"src/images/trophy_icon.png",
|
"src/images/trophy_icon.png",
|
||||||
"src/images/flag_china.png",
|
"src/images/flag_china.png",
|
||||||
@ -69,9 +73,10 @@ path = [
|
|||||||
"src/images/shadps4.svg",
|
"src/images/shadps4.svg",
|
||||||
"src/images/website.svg",
|
"src/images/website.svg",
|
||||||
"src/images/youtube.svg",
|
"src/images/youtube.svg",
|
||||||
|
"src/images/trophy.wav",
|
||||||
"src/shadps4.qrc",
|
"src/shadps4.qrc",
|
||||||
"src/shadps4.rc",
|
"src/shadps4.rc",
|
||||||
"src/qt_gui/translations/update_translation.sh",
|
"src/qt_gui/translations/update_translation.sh",
|
||||||
]
|
]
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "shadPS4 Emulator Project"
|
SPDX-FileCopyrightText = "shadPS4 Emulator Project"
|
||||||
|
28
cmake/DetectQtInstallation.cmake
Normal file
28
cmake/DetectQtInstallation.cmake
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
set(highest_version "0")
|
||||||
|
set(CANDIDATE_DRIVES A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
|
||||||
|
|
||||||
|
foreach(drive ${CANDIDATE_DRIVES})
|
||||||
|
file(GLOB kits LIST_DIRECTORIES true CONFIGURE_DEPENDS "${drive}:/Qt/*/msvc*_64")
|
||||||
|
foreach(kit IN LISTS kits)
|
||||||
|
get_filename_component(version_dir "${kit}" DIRECTORY)
|
||||||
|
get_filename_component(kit_version "${version_dir}" NAME)
|
||||||
|
|
||||||
|
message(STATUS "DetectQtInstallation.cmake: Detected Qt: ${kit}")
|
||||||
|
|
||||||
|
if (kit_version VERSION_GREATER highest_version)
|
||||||
|
set(highest_version "${kit_version}")
|
||||||
|
set(QT_PREFIX "${kit}")
|
||||||
|
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(QT_PREFIX)
|
||||||
|
set(CMAKE_PREFIX_PATH "${QT_PREFIX}" CACHE PATH "Qt prefix auto‑detected" FORCE)
|
||||||
|
message(STATUS "DetectQtInstallation.cmake: Choose newest Qt: ${QT_PREFIX}")
|
||||||
|
else()
|
||||||
|
message(STATUS "DetectQtInstallation.cmake: No Qt‑Directory found in <drive>:/Qt – please set CMAKE_PREFIX_PATH manually")
|
||||||
|
endif()
|
3
dist/net.shadps4.shadPS4.metainfo.xml
vendored
3
dist/net.shadps4.shadPS4.metainfo.xml
vendored
@ -37,6 +37,9 @@
|
|||||||
<category translate="no">Game</category>
|
<category translate="no">Game</category>
|
||||||
</categories>
|
</categories>
|
||||||
<releases>
|
<releases>
|
||||||
|
<release version="0.10.0" date="2025-07-06">
|
||||||
|
<url>https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.10.0</url>
|
||||||
|
</release>
|
||||||
<release version="0.9.0" date="2025-05-22">
|
<release version="0.9.0" date="2025-05-22">
|
||||||
<url>https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.9.0</url>
|
<url>https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.9.0</url>
|
||||||
</release>
|
</release>
|
||||||
|
@ -147,7 +147,7 @@ Accurately identifying games will help other developers that own that game recog
|
|||||||
- If your issue is small or you aren't sure whether you have properly identified something, [join the Discord server](https://discord.gg/MyZRaBngxA) and use the #development channel
|
- If your issue is small or you aren't sure whether you have properly identified something, [join the Discord server](https://discord.gg/MyZRaBngxA) and use the #development channel
|
||||||
to concisely explain the issue, as well as any findings you currently have.
|
to concisely explain the issue, as well as any findings you currently have.
|
||||||
|
|
||||||
- It is recommended that you check the [game compatibility issue tracker](https://github.com/shadps4-emu/shadps4-game-compatibility/issues) and post very short summaries of progress changes there,
|
- It is recommended that you check the [game compatibility issue tracker](https://github.com/shadps4-compatibility/shadps4-game-compatibility/issues) and post very short summaries of progress changes there,
|
||||||
(such as the game now booting into the menu or getting in-game) for organizational and status update purposes.
|
(such as the game now booting into the menu or getting in-game) for organizational and status update purposes.
|
||||||
|
|
||||||
- ⚠ **Do not post theoretical, unproven game-specific issues in the emulator issue tracker that you cannot verify and locate in the emulator source code as being a bug.**\
|
- ⚠ **Do not post theoretical, unproven game-specific issues in the emulator issue tracker that you cannot verify and locate in the emulator source code as being a bug.**\
|
||||||
|
@ -25,11 +25,11 @@ sudo apt install build-essential clang git cmake libasound2-dev \
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo dnf install clang git cmake libatomic alsa-lib-devel \
|
sudo dnf install clang git cmake libatomic alsa-lib-devel \
|
||||||
pipewire-jack-audio-connection-kit-devel openal-devel \
|
pipewire-jack-audio-connection-kit-devel openal-soft-devel \
|
||||||
openssl-devel libevdev-devel libudev-devel libXext-devel \
|
openssl-devel libevdev-devel libudev-devel libXext-devel \
|
||||||
qt6-qtbase-devel qt6-qtbase-private-devel \
|
qt6-qtbase-devel qt6-qtbase-private-devel \
|
||||||
qt6-qtmultimedia-devel qt6-qtsvg-devel qt6-qttools-devel \
|
qt6-qtmultimedia-devel qt6-qtsvg-devel qt6-qttools-devel \
|
||||||
vulkan-devel vulkan-validation-layers libpng-devel
|
vulkan-devel vulkan-validation-layers libpng-devel libuuid-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Arch Linux
|
#### Arch Linux
|
||||||
@ -74,6 +74,7 @@ and install the dependencies on that container as cited above.
|
|||||||
This option is **highly recommended** for distributions with immutable/atomic filesystems (example: Fedora Kinoite, SteamOS).
|
This option is **highly recommended** for distributions with immutable/atomic filesystems (example: Fedora Kinoite, SteamOS).
|
||||||
|
|
||||||
### Cloning
|
### Cloning
|
||||||
|
The project uses submodules to manage dependencies, and they need to be initialized before you can build the project. To achieve this, make sure you've cloned the repository with the --recursive flag
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone --recursive https://github.com/shadps4-emu/shadPS4.git
|
git clone --recursive https://github.com/shadps4-emu/shadPS4.git
|
||||||
|
2
externals/CMakeLists.txt
vendored
2
externals/CMakeLists.txt
vendored
@ -197,7 +197,7 @@ endif()
|
|||||||
|
|
||||||
# libusb
|
# libusb
|
||||||
if (NOT TARGET libusb::usb)
|
if (NOT TARGET libusb::usb)
|
||||||
add_subdirectory(libusb)
|
add_subdirectory(ext-libusb)
|
||||||
add_library(libusb::usb ALIAS usb-1.0)
|
add_library(libusb::usb ALIAS usb-1.0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
2
externals/MoltenVK/MoltenVK
vendored
2
externals/MoltenVK/MoltenVK
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 87a8e8b13d4ad8835367fea1ebad1896d0460946
|
Subproject commit 00abd384ce01cbd439045905d2fa6cf799dfa2f6
|
2
externals/MoltenVK/SPIRV-Cross
vendored
2
externals/MoltenVK/SPIRV-Cross
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 7918775748c5e2f5c40d9918ce68825035b5a1e1
|
Subproject commit 1a69a919fa302e92b337594bd0a8aaea61037d91
|
1
externals/ext-libusb
vendored
Submodule
1
externals/ext-libusb
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit e1f4ac1472bdf6aab27f8b836a2f47df85465bac
|
1
externals/libusb
vendored
1
externals/libusb
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit a63a7e43e0950a595cf4b98a0eaf4051749ace5f
|
|
2
externals/sirit
vendored
2
externals/sirit
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 09a1416ab1b59ddfebd2618412f118f2004f3b2c
|
Subproject commit 282083a595dcca86814dedab2f2b0363ef38f1ec
|
2
externals/vulkan-headers
vendored
2
externals/vulkan-headers
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 5ceb9ed481e58e705d0d9b5326537daedd06b97d
|
Subproject commit 9c77de5c3dd216f28e407eec65ed9c0a296c1f74
|
@ -18,6 +18,9 @@ public:
|
|||||||
void unlock() {
|
void unlock() {
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] bool try_lock() {
|
||||||
|
return pthread_mutex_trylock(&mutex) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
|
pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
|
||||||
|
406
src/common/bit_array.h
Normal file
406
src/common/bit_array.h
Normal file
@ -0,0 +1,406 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstddef>
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
|
#ifdef __AVX2__
|
||||||
|
#define BIT_ARRAY_USE_AVX
|
||||||
|
#include <immintrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
template <size_t N>
|
||||||
|
class BitArray {
|
||||||
|
static_assert(N % 64 == 0, "BitArray size must be a multiple of 64 bits.");
|
||||||
|
|
||||||
|
static constexpr size_t BITS_PER_WORD = 64;
|
||||||
|
static constexpr size_t WORD_COUNT = N / BITS_PER_WORD;
|
||||||
|
static constexpr size_t WORDS_PER_AVX = 4;
|
||||||
|
static constexpr size_t AVX_WORD_COUNT = WORD_COUNT / WORDS_PER_AVX;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Range = std::pair<size_t, size_t>;
|
||||||
|
|
||||||
|
class Iterator {
|
||||||
|
public:
|
||||||
|
explicit Iterator(const BitArray& bit_array_, u64 start) : bit_array(bit_array_) {
|
||||||
|
range = bit_array.FirstRangeFrom(start);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator& operator++() {
|
||||||
|
range = bit_array.FirstRangeFrom(range.second);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Iterator& other) const {
|
||||||
|
return range == other.range;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Iterator& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Range& operator*() const {
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Range* operator->() const {
|
||||||
|
return ⦥
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const BitArray& bit_array;
|
||||||
|
Range range;
|
||||||
|
};
|
||||||
|
|
||||||
|
using const_iterator = Iterator;
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using value_type = Range;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using pointer = const Range*;
|
||||||
|
using reference = const Range&;
|
||||||
|
|
||||||
|
BitArray() = default;
|
||||||
|
BitArray(const BitArray& other) = default;
|
||||||
|
BitArray& operator=(const BitArray& other) = default;
|
||||||
|
BitArray(BitArray&& other) noexcept = default;
|
||||||
|
BitArray& operator=(BitArray&& other) noexcept = default;
|
||||||
|
~BitArray() = default;
|
||||||
|
|
||||||
|
BitArray(const BitArray& other, size_t start, size_t end) {
|
||||||
|
if (start >= end || end > N) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const size_t first_word = start / BITS_PER_WORD;
|
||||||
|
const size_t last_word = (end - 1) / BITS_PER_WORD;
|
||||||
|
const size_t start_bit = start % BITS_PER_WORD;
|
||||||
|
const size_t end_bit = (end - 1) % BITS_PER_WORD;
|
||||||
|
const u64 start_mask = ~((1ULL << start_bit) - 1);
|
||||||
|
const u64 end_mask = end_bit == BITS_PER_WORD - 1 ? ~0ULL : (1ULL << (end_bit + 1)) - 1;
|
||||||
|
if (first_word == last_word) {
|
||||||
|
data[first_word] = other.data[first_word] & (start_mask & end_mask);
|
||||||
|
} else {
|
||||||
|
data[first_word] = other.data[first_word] & start_mask;
|
||||||
|
size_t i = first_word + 1;
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
for (; i + WORDS_PER_AVX <= last_word; i += WORDS_PER_AVX) {
|
||||||
|
const __m256i current =
|
||||||
|
_mm256_loadu_si256(reinterpret_cast<const __m256i*>(&other.data[i]));
|
||||||
|
_mm256_storeu_si256(reinterpret_cast<__m256i*>(&data[i]), current);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; i < last_word; ++i) {
|
||||||
|
data[i] = other.data[i];
|
||||||
|
}
|
||||||
|
data[last_word] = other.data[last_word] & end_mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BitArray(const BitArray& other, const Range& range)
|
||||||
|
: BitArray(other, range.first, range.second) {}
|
||||||
|
|
||||||
|
const_iterator begin() const {
|
||||||
|
return Iterator(*this, 0);
|
||||||
|
}
|
||||||
|
const_iterator end() const {
|
||||||
|
return Iterator(*this, N);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr void Set(size_t idx) {
|
||||||
|
data[idx / BITS_PER_WORD] |= (1ULL << (idx % BITS_PER_WORD));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr void Unset(size_t idx) {
|
||||||
|
data[idx / BITS_PER_WORD] &= ~(1ULL << (idx % BITS_PER_WORD));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr bool Get(size_t idx) const {
|
||||||
|
return (data[idx / BITS_PER_WORD] & (1ULL << (idx % BITS_PER_WORD))) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetRange(size_t start, size_t end) {
|
||||||
|
if (start >= end || end > N) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const size_t first_word = start / BITS_PER_WORD;
|
||||||
|
const size_t last_word = (end - 1) / BITS_PER_WORD;
|
||||||
|
const size_t start_bit = start % BITS_PER_WORD;
|
||||||
|
const size_t end_bit = (end - 1) % BITS_PER_WORD;
|
||||||
|
const u64 start_mask = ~((1ULL << start_bit) - 1);
|
||||||
|
const u64 end_mask = end_bit == BITS_PER_WORD - 1 ? ~0ULL : (1ULL << (end_bit + 1)) - 1;
|
||||||
|
if (first_word == last_word) {
|
||||||
|
data[first_word] |= start_mask & end_mask;
|
||||||
|
} else {
|
||||||
|
data[first_word] |= start_mask;
|
||||||
|
size_t i = first_word + 1;
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
const __m256i value = _mm256_set1_epi64x(-1);
|
||||||
|
for (; i + WORDS_PER_AVX <= last_word; i += WORDS_PER_AVX) {
|
||||||
|
_mm256_storeu_si256(reinterpret_cast<__m256i*>(&data[i]), value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; i < last_word; ++i) {
|
||||||
|
data[i] = ~0ULL;
|
||||||
|
}
|
||||||
|
data[last_word] |= end_mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void UnsetRange(size_t start, size_t end) {
|
||||||
|
if (start >= end || end > N) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
size_t first_word = start / BITS_PER_WORD;
|
||||||
|
const size_t last_word = (end - 1) / BITS_PER_WORD;
|
||||||
|
const size_t start_bit = start % BITS_PER_WORD;
|
||||||
|
const size_t end_bit = (end - 1) % BITS_PER_WORD;
|
||||||
|
const u64 start_mask = (1ULL << start_bit) - 1;
|
||||||
|
const u64 end_mask = end_bit == BITS_PER_WORD - 1 ? 0ULL : ~((1ULL << (end_bit + 1)) - 1);
|
||||||
|
if (first_word == last_word) {
|
||||||
|
data[first_word] &= start_mask | end_mask;
|
||||||
|
} else {
|
||||||
|
data[first_word] &= start_mask;
|
||||||
|
size_t i = first_word + 1;
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
const __m256i value = _mm256_setzero_si256();
|
||||||
|
for (; i + WORDS_PER_AVX <= last_word; i += WORDS_PER_AVX) {
|
||||||
|
_mm256_storeu_si256(reinterpret_cast<__m256i*>(&data[i]), value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; i < last_word; ++i) {
|
||||||
|
data[i] = 0ULL;
|
||||||
|
}
|
||||||
|
data[last_word] &= end_mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr void SetRange(const Range& range) {
|
||||||
|
SetRange(range.first, range.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr void UnsetRange(const Range& range) {
|
||||||
|
UnsetRange(range.first, range.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr void Clear() {
|
||||||
|
data.fill(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr void Fill() {
|
||||||
|
data.fill(~0ULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr bool None() const {
|
||||||
|
u64 result = 0;
|
||||||
|
for (const auto& word : data) {
|
||||||
|
result |= word;
|
||||||
|
}
|
||||||
|
return result == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr bool Any() const {
|
||||||
|
return !None();
|
||||||
|
}
|
||||||
|
|
||||||
|
Range FirstRangeFrom(size_t start) const {
|
||||||
|
if (start >= N) {
|
||||||
|
return {N, N};
|
||||||
|
}
|
||||||
|
const auto find_end_bit = [&](size_t word) {
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
const __m256i all_one = _mm256_set1_epi64x(-1);
|
||||||
|
for (; word + WORDS_PER_AVX <= WORD_COUNT; word += WORDS_PER_AVX) {
|
||||||
|
const __m256i current =
|
||||||
|
_mm256_loadu_si256(reinterpret_cast<const __m256i*>(&data[word]));
|
||||||
|
const __m256i cmp = _mm256_cmpeq_epi64(current, all_one);
|
||||||
|
if (_mm256_movemask_epi8(cmp) != 0xFFFFFFFF) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; word < WORD_COUNT; ++word) {
|
||||||
|
if (data[word] != ~0ULL) {
|
||||||
|
return (word * BITS_PER_WORD) + std::countr_one(data[word]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return N;
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto word_bits = [&](size_t index, u64 word) {
|
||||||
|
const int empty_bits = std::countr_zero(word);
|
||||||
|
const int ones_count = std::countr_one(word >> empty_bits);
|
||||||
|
const size_t start_bit = index * BITS_PER_WORD + empty_bits;
|
||||||
|
if (ones_count + empty_bits < BITS_PER_WORD) {
|
||||||
|
return Range{start_bit, start_bit + ones_count};
|
||||||
|
}
|
||||||
|
return Range{start_bit, find_end_bit(index + 1)};
|
||||||
|
};
|
||||||
|
|
||||||
|
const size_t start_word = start / BITS_PER_WORD;
|
||||||
|
const size_t start_bit = start % BITS_PER_WORD;
|
||||||
|
const u64 masked_first = data[start_word] & (~((1ULL << start_bit) - 1));
|
||||||
|
if (masked_first) {
|
||||||
|
return word_bits(start_word, masked_first);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t word = start_word + 1;
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
for (; word + WORDS_PER_AVX <= WORD_COUNT; word += WORDS_PER_AVX) {
|
||||||
|
const __m256i current =
|
||||||
|
_mm256_loadu_si256(reinterpret_cast<const __m256i*>(&data[word]));
|
||||||
|
if (!_mm256_testz_si256(current, current)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; word < WORD_COUNT; ++word) {
|
||||||
|
if (data[word] != 0) {
|
||||||
|
return word_bits(word, data[word]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {N, N};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr Range FirstRange() const {
|
||||||
|
return FirstRangeFrom(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Range LastRangeFrom(size_t end) const {
|
||||||
|
if (end == 0) {
|
||||||
|
return {0, 0};
|
||||||
|
}
|
||||||
|
if (end > N) {
|
||||||
|
end = N;
|
||||||
|
}
|
||||||
|
const auto find_start_bit = [&](size_t word) {
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
const __m256i all_zero = _mm256_setzero_si256();
|
||||||
|
for (; word >= WORDS_PER_AVX; word -= WORDS_PER_AVX) {
|
||||||
|
const __m256i current = _mm256_loadu_si256(
|
||||||
|
reinterpret_cast<const __m256i*>(&data[word - WORDS_PER_AVX]));
|
||||||
|
const __m256i cmp = _mm256_cmpeq_epi64(current, all_zero);
|
||||||
|
if (_mm256_movemask_epi8(cmp) != 0xFFFFFFFF) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; word > 0; --word) {
|
||||||
|
if (data[word - 1] != ~0ULL) {
|
||||||
|
return word * BITS_PER_WORD - std::countl_one(data[word - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return size_t(0);
|
||||||
|
};
|
||||||
|
const auto word_bits = [&](size_t index, u64 word) {
|
||||||
|
const int empty_bits = std::countl_zero(word);
|
||||||
|
const int ones_count = std::countl_one(word << empty_bits);
|
||||||
|
const size_t end_bit = index * BITS_PER_WORD - empty_bits;
|
||||||
|
if (empty_bits + ones_count < BITS_PER_WORD) {
|
||||||
|
return Range{end_bit - ones_count, end_bit};
|
||||||
|
}
|
||||||
|
return Range{find_start_bit(index - 1), end_bit};
|
||||||
|
};
|
||||||
|
const size_t end_word = ((end - 1) / BITS_PER_WORD) + 1;
|
||||||
|
const size_t end_bit = (end - 1) % BITS_PER_WORD;
|
||||||
|
u64 masked_last = data[end_word - 1];
|
||||||
|
if (end_bit < BITS_PER_WORD - 1) {
|
||||||
|
masked_last &= (1ULL << (end_bit + 1)) - 1;
|
||||||
|
}
|
||||||
|
if (masked_last) {
|
||||||
|
return word_bits(end_word, masked_last);
|
||||||
|
}
|
||||||
|
size_t word = end_word - 1;
|
||||||
|
#ifdef BIT_ARRAY_USE_AVX
|
||||||
|
for (; word >= WORDS_PER_AVX; word -= WORDS_PER_AVX) {
|
||||||
|
const __m256i current =
|
||||||
|
_mm256_loadu_si256(reinterpret_cast<const __m256i*>(&data[word - WORDS_PER_AVX]));
|
||||||
|
if (!_mm256_testz_si256(current, current)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (; word > 0; --word) {
|
||||||
|
if (data[word - 1] != 0) {
|
||||||
|
return word_bits(word, data[word - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr Range LastRange() const {
|
||||||
|
return LastRangeFrom(N);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr size_t Size() const {
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray& operator|=(const BitArray& other) {
|
||||||
|
for (size_t i = 0; i < WORD_COUNT; ++i) {
|
||||||
|
data[i] |= other.data[i];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray& operator&=(const BitArray& other) {
|
||||||
|
for (size_t i = 0; i < WORD_COUNT; ++i) {
|
||||||
|
data[i] &= other.data[i];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray& operator^=(const BitArray& other) {
|
||||||
|
for (size_t i = 0; i < WORD_COUNT; ++i) {
|
||||||
|
data[i] ^= other.data[i];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray operator|(const BitArray& other) const {
|
||||||
|
BitArray result = *this;
|
||||||
|
result |= other;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray operator&(const BitArray& other) const {
|
||||||
|
BitArray result = *this;
|
||||||
|
result &= other;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray operator^(const BitArray& other) const {
|
||||||
|
BitArray result = *this;
|
||||||
|
result ^= other;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr BitArray operator~() const {
|
||||||
|
BitArray result = *this;
|
||||||
|
for (size_t i = 0; i < WORD_COUNT; ++i) {
|
||||||
|
result.data[i] = ~result.data[i];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr bool operator==(const BitArray& other) const {
|
||||||
|
u64 result = 0;
|
||||||
|
for (size_t i = 0; i < WORD_COUNT; ++i) {
|
||||||
|
result |= data[i] ^ other.data[i];
|
||||||
|
}
|
||||||
|
return result == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr bool operator!=(const BitArray& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::array<u64, WORD_COUNT> data{};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Common
|
@ -31,35 +31,56 @@ std::filesystem::path find_fs_path_or(const basic_value<TC>& v, const K& ky,
|
|||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
|
|
||||||
|
// General
|
||||||
|
static int volumeSlider = 100;
|
||||||
static bool isNeo = false;
|
static bool isNeo = false;
|
||||||
static bool isDevKit = false;
|
static bool isDevKit = false;
|
||||||
static bool playBGM = false;
|
static bool isPSNSignedIn = false;
|
||||||
static bool isTrophyPopupDisabled = false;
|
static bool isTrophyPopupDisabled = false;
|
||||||
static int BGMvolume = 50;
|
static double trophyNotificationDuration = 6.0;
|
||||||
static bool enableDiscordRPC = false;
|
static bool enableDiscordRPC = false;
|
||||||
static u32 screenWidth = 1280;
|
static std::string logFilter = "";
|
||||||
static u32 screenHeight = 720;
|
|
||||||
static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select
|
|
||||||
static std::string logFilter;
|
|
||||||
static std::string logType = "sync";
|
static std::string logType = "sync";
|
||||||
static std::string userName = "shadPS4";
|
static std::string userName = "shadPS4";
|
||||||
static std::string updateChannel;
|
static std::string chooseHomeTab = "General";
|
||||||
static std::string chooseHomeTab;
|
static bool isShowSplash = false;
|
||||||
static std::string backButtonBehavior = "left";
|
static std::string isSideTrophy = "right";
|
||||||
|
static bool compatibilityData = false;
|
||||||
|
static bool checkCompatibilityOnStartup = false;
|
||||||
|
static bool isConnectedToNetwork = false;
|
||||||
|
|
||||||
|
// Input
|
||||||
|
static int cursorState = HideCursorState::Idle;
|
||||||
|
static int cursorHideTimeout = 5; // 5 seconds (default)
|
||||||
static bool useSpecialPad = false;
|
static bool useSpecialPad = false;
|
||||||
static int specialPadClass = 1;
|
static int specialPadClass = 1;
|
||||||
static bool isMotionControlsEnabled = true;
|
static bool isMotionControlsEnabled = true;
|
||||||
static bool isDebugDump = false;
|
static bool useUnifiedInputConfig = true;
|
||||||
static bool isShaderDebug = false;
|
static std::string micDevice = "Default Device";
|
||||||
static bool isShowSplash = false;
|
|
||||||
static bool isAutoUpdate = false;
|
// These two entries aren't stored in the config
|
||||||
static bool isAlwaysShowChangelog = false;
|
static bool overrideControllerColor = false;
|
||||||
static std::string isSideTrophy = "right";
|
static int controllerCustomColorRGB[3] = {0, 0, 255};
|
||||||
|
|
||||||
|
// GPU
|
||||||
|
static u32 windowWidth = 1280;
|
||||||
|
static u32 windowHeight = 720;
|
||||||
|
static u32 internalScreenWidth = 1280;
|
||||||
|
static u32 internalScreenHeight = 720;
|
||||||
static bool isNullGpu = false;
|
static bool isNullGpu = false;
|
||||||
static bool shouldCopyGPUBuffers = false;
|
static bool shouldCopyGPUBuffers = false;
|
||||||
|
static bool readbacksEnabled = false;
|
||||||
|
static bool readbackLinearImagesEnabled = false;
|
||||||
|
static bool directMemoryAccessEnabled = false;
|
||||||
static bool shouldDumpShaders = false;
|
static bool shouldDumpShaders = false;
|
||||||
static bool shouldPatchShaders = true;
|
static bool shouldPatchShaders = false;
|
||||||
static u32 vblankDivider = 1;
|
static u32 vblankDivider = 1;
|
||||||
|
static bool isFullscreen = false;
|
||||||
|
static std::string fullscreenMode = "Windowed";
|
||||||
|
static bool isHDRAllowed = false;
|
||||||
|
|
||||||
|
// Vulkan
|
||||||
|
static s32 gpuId = -1;
|
||||||
static bool vkValidation = false;
|
static bool vkValidation = false;
|
||||||
static bool vkValidationSync = false;
|
static bool vkValidationSync = false;
|
||||||
static bool vkValidationGpu = false;
|
static bool vkValidationGpu = false;
|
||||||
@ -67,49 +88,32 @@ static bool vkCrashDiagnostic = false;
|
|||||||
static bool vkHostMarkers = false;
|
static bool vkHostMarkers = false;
|
||||||
static bool vkGuestMarkers = false;
|
static bool vkGuestMarkers = false;
|
||||||
static bool rdocEnable = false;
|
static bool rdocEnable = false;
|
||||||
static bool isFpsColor = true;
|
|
||||||
static bool isSeparateLogFilesEnabled = false;
|
|
||||||
static s16 cursorState = HideCursorState::Idle;
|
|
||||||
static int cursorHideTimeout = 5; // 5 seconds (default)
|
|
||||||
static double trophyNotificationDuration = 6.0;
|
|
||||||
static bool useUnifiedInputConfig = true;
|
|
||||||
static bool overrideControllerColor = false;
|
|
||||||
static int controllerCustomColorRGB[3] = {0, 0, 255};
|
|
||||||
static bool compatibilityData = false;
|
|
||||||
static bool checkCompatibilityOnStartup = false;
|
|
||||||
static std::string trophyKey;
|
|
||||||
|
|
||||||
// Gui
|
// Debug
|
||||||
|
static bool isDebugDump = false;
|
||||||
|
static bool isShaderDebug = false;
|
||||||
|
static bool isSeparateLogFilesEnabled = false;
|
||||||
|
static bool isFpsColor = true;
|
||||||
|
|
||||||
|
// GUI
|
||||||
static bool load_game_size = true;
|
static bool load_game_size = true;
|
||||||
static std::vector<GameInstallDir> settings_install_dirs = {};
|
static std::vector<GameInstallDir> settings_install_dirs = {};
|
||||||
std::vector<bool> install_dirs_enabled = {};
|
std::vector<bool> install_dirs_enabled = {};
|
||||||
std::filesystem::path settings_addon_install_dir = {};
|
std::filesystem::path settings_addon_install_dir = {};
|
||||||
std::filesystem::path save_data_path = {};
|
std::filesystem::path save_data_path = {};
|
||||||
u32 main_window_geometry_x = 400;
|
|
||||||
u32 main_window_geometry_y = 400;
|
|
||||||
u32 main_window_geometry_w = 1280;
|
|
||||||
u32 main_window_geometry_h = 720;
|
|
||||||
u32 mw_themes = 0;
|
|
||||||
u32 m_icon_size = 36;
|
|
||||||
u32 m_icon_size_grid = 69;
|
|
||||||
u32 m_slider_pos = 0;
|
|
||||||
u32 m_slider_pos_grid = 0;
|
|
||||||
u32 m_table_mode = 0;
|
|
||||||
u32 m_window_size_W = 1280;
|
|
||||||
u32 m_window_size_H = 720;
|
|
||||||
std::vector<std::string> m_elf_viewer;
|
|
||||||
std::vector<std::string> m_recent_files;
|
|
||||||
std::string emulator_language = "en_US";
|
|
||||||
static int backgroundImageOpacity = 50;
|
|
||||||
static bool showBackgroundImage = true;
|
|
||||||
static bool isFullscreen = false;
|
|
||||||
static std::string fullscreenMode = "Windowed";
|
|
||||||
static bool isHDRAllowed = false;
|
|
||||||
static bool showLabelsUnderIcons = true;
|
|
||||||
|
|
||||||
// Language
|
// Settings
|
||||||
u32 m_language = 1; // english
|
u32 m_language = 1; // english
|
||||||
|
|
||||||
|
// Keys
|
||||||
|
static std::string trophyKey = "";
|
||||||
|
|
||||||
|
// Config version, used to determine if a user's config file is outdated.
|
||||||
|
static std::string config_version = Common::g_scm_rev;
|
||||||
|
|
||||||
|
int getVolumeSlider() {
|
||||||
|
return volumeSlider;
|
||||||
|
}
|
||||||
bool allowHDR() {
|
bool allowHDR() {
|
||||||
return isHDRAllowed;
|
return isHDRAllowed;
|
||||||
}
|
}
|
||||||
@ -159,6 +163,10 @@ std::filesystem::path GetSaveDataPath() {
|
|||||||
return save_data_path;
|
return save_data_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setVolumeSlider(int volumeValue) {
|
||||||
|
volumeSlider = volumeValue;
|
||||||
|
}
|
||||||
|
|
||||||
void setLoadGameSizeEnabled(bool enable) {
|
void setLoadGameSizeEnabled(bool enable) {
|
||||||
load_game_size = enable;
|
load_game_size = enable;
|
||||||
}
|
}
|
||||||
@ -175,14 +183,6 @@ bool getIsFullscreen() {
|
|||||||
return isFullscreen;
|
return isFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getShowLabelsUnderIcons() {
|
|
||||||
return showLabelsUnderIcons;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool setShowLabelsUnderIcons() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getFullscreenMode() {
|
std::string getFullscreenMode() {
|
||||||
return fullscreenMode;
|
return fullscreenMode;
|
||||||
}
|
}
|
||||||
@ -191,14 +191,6 @@ bool getisTrophyPopupDisabled() {
|
|||||||
return isTrophyPopupDisabled;
|
return isTrophyPopupDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getPlayBGM() {
|
|
||||||
return playBGM;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getBGMvolume() {
|
|
||||||
return BGMvolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getEnableDiscordRPC() {
|
bool getEnableDiscordRPC() {
|
||||||
return enableDiscordRPC;
|
return enableDiscordRPC;
|
||||||
}
|
}
|
||||||
@ -211,16 +203,28 @@ int getCursorHideTimeout() {
|
|||||||
return cursorHideTimeout;
|
return cursorHideTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getMicDevice() {
|
||||||
|
return micDevice;
|
||||||
|
}
|
||||||
|
|
||||||
double getTrophyNotificationDuration() {
|
double getTrophyNotificationDuration() {
|
||||||
return trophyNotificationDuration;
|
return trophyNotificationDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getScreenWidth() {
|
u32 getWindowWidth() {
|
||||||
return screenWidth;
|
return windowWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getScreenHeight() {
|
u32 getWindowHeight() {
|
||||||
return screenHeight;
|
return windowHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 getInternalScreenWidth() {
|
||||||
|
return internalScreenHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 getInternalScreenHeight() {
|
||||||
|
return internalScreenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 getGpuId() {
|
s32 getGpuId() {
|
||||||
@ -239,18 +243,10 @@ std::string getUserName() {
|
|||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getUpdateChannel() {
|
|
||||||
return updateChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getChooseHomeTab() {
|
std::string getChooseHomeTab() {
|
||||||
return chooseHomeTab;
|
return chooseHomeTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getBackButtonBehavior() {
|
|
||||||
return backButtonBehavior;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getUseSpecialPad() {
|
bool getUseSpecialPad() {
|
||||||
return useSpecialPad;
|
return useSpecialPad;
|
||||||
}
|
}
|
||||||
@ -275,14 +271,6 @@ bool showSplash() {
|
|||||||
return isShowSplash;
|
return isShowSplash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool autoUpdate() {
|
|
||||||
return isAutoUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool alwaysShowChangelog() {
|
|
||||||
return isAlwaysShowChangelog;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string sideTrophy() {
|
std::string sideTrophy() {
|
||||||
return isSideTrophy;
|
return isSideTrophy;
|
||||||
}
|
}
|
||||||
@ -295,6 +283,18 @@ bool copyGPUCmdBuffers() {
|
|||||||
return shouldCopyGPUBuffers;
|
return shouldCopyGPUBuffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool readbacks() {
|
||||||
|
return readbacksEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool readbackLinearImages() {
|
||||||
|
return readbackLinearImagesEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool directMemoryAccess() {
|
||||||
|
return directMemoryAccessEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
bool dumpShaders() {
|
bool dumpShaders() {
|
||||||
return shouldDumpShaders;
|
return shouldDumpShaders;
|
||||||
}
|
}
|
||||||
@ -359,16 +359,28 @@ bool getCheckCompatibilityOnStartup() {
|
|||||||
return checkCompatibilityOnStartup;
|
return checkCompatibilityOnStartup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getIsConnectedToNetwork() {
|
||||||
|
return isConnectedToNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
void setGpuId(s32 selectedGpuId) {
|
void setGpuId(s32 selectedGpuId) {
|
||||||
gpuId = selectedGpuId;
|
gpuId = selectedGpuId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScreenWidth(u32 width) {
|
void setWindowWidth(u32 width) {
|
||||||
screenWidth = width;
|
windowWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScreenHeight(u32 height) {
|
void setWindowHeight(u32 height) {
|
||||||
screenHeight = height;
|
windowHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInternalScreenWidth(u32 width) {
|
||||||
|
internalScreenWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInternalScreenHeight(u32 height) {
|
||||||
|
internalScreenHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDebugDump(bool enable) {
|
void setDebugDump(bool enable) {
|
||||||
@ -383,14 +395,6 @@ void setShowSplash(bool enable) {
|
|||||||
isShowSplash = enable;
|
isShowSplash = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAutoUpdate(bool enable) {
|
|
||||||
isAutoUpdate = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAlwaysShowChangelog(bool enable) {
|
|
||||||
isAlwaysShowChangelog = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSideTrophy(std::string side) {
|
void setSideTrophy(std::string side) {
|
||||||
isSideTrophy = side;
|
isSideTrophy = side;
|
||||||
}
|
}
|
||||||
@ -407,6 +411,14 @@ void setCopyGPUCmdBuffers(bool enable) {
|
|||||||
shouldCopyGPUBuffers = enable;
|
shouldCopyGPUBuffers = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setReadbacks(bool enable) {
|
||||||
|
readbacksEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDirectMemoryAccess(bool enable) {
|
||||||
|
directMemoryAccessEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void setDumpShaders(bool enable) {
|
void setDumpShaders(bool enable) {
|
||||||
shouldDumpShaders = enable;
|
shouldDumpShaders = enable;
|
||||||
}
|
}
|
||||||
@ -430,9 +442,6 @@ void setVblankDiv(u32 value) {
|
|||||||
void setIsFullscreen(bool enable) {
|
void setIsFullscreen(bool enable) {
|
||||||
isFullscreen = enable;
|
isFullscreen = enable;
|
||||||
}
|
}
|
||||||
static void setShowLabelsUnderIcons(bool enable) {
|
|
||||||
showLabelsUnderIcons = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFullscreenMode(std::string mode) {
|
void setFullscreenMode(std::string mode) {
|
||||||
fullscreenMode = mode;
|
fullscreenMode = mode;
|
||||||
@ -442,14 +451,6 @@ void setisTrophyPopupDisabled(bool disable) {
|
|||||||
isTrophyPopupDisabled = disable;
|
isTrophyPopupDisabled = disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPlayBGM(bool enable) {
|
|
||||||
playBGM = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBGMvolume(int volume) {
|
|
||||||
BGMvolume = volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEnableDiscordRPC(bool enable) {
|
void setEnableDiscordRPC(bool enable) {
|
||||||
enableDiscordRPC = enable;
|
enableDiscordRPC = enable;
|
||||||
}
|
}
|
||||||
@ -461,6 +462,11 @@ void setCursorState(s16 newCursorState) {
|
|||||||
void setCursorHideTimeout(int newcursorHideTimeout) {
|
void setCursorHideTimeout(int newcursorHideTimeout) {
|
||||||
cursorHideTimeout = newcursorHideTimeout;
|
cursorHideTimeout = newcursorHideTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMicDevice(std::string device) {
|
||||||
|
micDevice = device;
|
||||||
|
}
|
||||||
|
|
||||||
void setTrophyNotificationDuration(double newTrophyNotificationDuration) {
|
void setTrophyNotificationDuration(double newTrophyNotificationDuration) {
|
||||||
trophyNotificationDuration = newTrophyNotificationDuration;
|
trophyNotificationDuration = newTrophyNotificationDuration;
|
||||||
}
|
}
|
||||||
@ -489,17 +495,10 @@ void setUserName(const std::string& type) {
|
|||||||
userName = type;
|
userName = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUpdateChannel(const std::string& type) {
|
|
||||||
updateChannel = type;
|
|
||||||
}
|
|
||||||
void setChooseHomeTab(const std::string& type) {
|
void setChooseHomeTab(const std::string& type) {
|
||||||
chooseHomeTab = type;
|
chooseHomeTab = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBackButtonBehavior(const std::string& type) {
|
|
||||||
backButtonBehavior = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUseSpecialPad(bool use) {
|
void setUseSpecialPad(bool use) {
|
||||||
useSpecialPad = use;
|
useSpecialPad = use;
|
||||||
}
|
}
|
||||||
@ -520,13 +519,6 @@ void setCheckCompatibilityOnStartup(bool use) {
|
|||||||
checkCompatibilityOnStartup = use;
|
checkCompatibilityOnStartup = use;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
|
|
||||||
main_window_geometry_x = x;
|
|
||||||
main_window_geometry_y = y;
|
|
||||||
main_window_geometry_w = w;
|
|
||||||
main_window_geometry_h = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled) {
|
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled) {
|
||||||
for (const auto& install_dir : settings_install_dirs) {
|
for (const auto& install_dir : settings_install_dirs) {
|
||||||
if (install_dir.path == dir) {
|
if (install_dir.path == dir) {
|
||||||
@ -559,52 +551,6 @@ void setAddonInstallDir(const std::filesystem::path& dir) {
|
|||||||
settings_addon_install_dir = dir;
|
settings_addon_install_dir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowTheme(u32 theme) {
|
|
||||||
mw_themes = theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIconSize(u32 size) {
|
|
||||||
m_icon_size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIconSizeGrid(u32 size) {
|
|
||||||
m_icon_size_grid = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSliderPosition(u32 pos) {
|
|
||||||
m_slider_pos = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSliderPositionGrid(u32 pos) {
|
|
||||||
m_slider_pos_grid = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTableMode(u32 mode) {
|
|
||||||
m_table_mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMainWindowWidth(u32 width) {
|
|
||||||
m_window_size_W = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMainWindowHeight(u32 height) {
|
|
||||||
m_window_size_H = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setElfViewer(const std::vector<std::string>& elfList) {
|
|
||||||
m_elf_viewer.resize(elfList.size());
|
|
||||||
m_elf_viewer = elfList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRecentFiles(const std::vector<std::string>& recentFiles) {
|
|
||||||
m_recent_files.resize(recentFiles.size());
|
|
||||||
m_recent_files = recentFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEmulatorLanguage(std::string language) {
|
|
||||||
emulator_language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
|
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
|
||||||
settings_install_dirs.clear();
|
settings_install_dirs.clear();
|
||||||
for (const auto& dir : dirs_config) {
|
for (const auto& dir : dirs_config) {
|
||||||
@ -620,22 +566,6 @@ void setSaveDataPath(const std::filesystem::path& path) {
|
|||||||
save_data_path = path;
|
save_data_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryX() {
|
|
||||||
return main_window_geometry_x;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getMainWindowGeometryY() {
|
|
||||||
return main_window_geometry_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getMainWindowGeometryW() {
|
|
||||||
return main_window_geometry_w;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getMainWindowGeometryH() {
|
|
||||||
return main_window_geometry_h;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::filesystem::path> getGameInstallDirs() {
|
const std::vector<std::filesystem::path> getGameInstallDirs() {
|
||||||
std::vector<std::filesystem::path> enabled_dirs;
|
std::vector<std::filesystem::path> enabled_dirs;
|
||||||
for (const auto& dir : settings_install_dirs) {
|
for (const auto& dir : settings_install_dirs) {
|
||||||
@ -662,50 +592,6 @@ std::filesystem::path getAddonInstallDir() {
|
|||||||
return settings_addon_install_dir;
|
return settings_addon_install_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowTheme() {
|
|
||||||
return mw_themes;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getIconSize() {
|
|
||||||
return m_icon_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getIconSizeGrid() {
|
|
||||||
return m_icon_size_grid;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getSliderPosition() {
|
|
||||||
return m_slider_pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getSliderPositionGrid() {
|
|
||||||
return m_slider_pos_grid;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getTableMode() {
|
|
||||||
return m_table_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getMainWindowWidth() {
|
|
||||||
return m_window_size_W;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getMainWindowHeight() {
|
|
||||||
return m_window_size_H;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> getElfViewer() {
|
|
||||||
return m_elf_viewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> getRecentFiles() {
|
|
||||||
return m_recent_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getEmulatorLanguage() {
|
|
||||||
return emulator_language;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GetLanguage() {
|
u32 GetLanguage() {
|
||||||
return m_language;
|
return m_language;
|
||||||
}
|
}
|
||||||
@ -714,20 +600,12 @@ bool getSeparateLogFilesEnabled() {
|
|||||||
return isSeparateLogFilesEnabled;
|
return isSeparateLogFilesEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBackgroundImageOpacity() {
|
bool getPSNSignedIn() {
|
||||||
return backgroundImageOpacity;
|
return isPSNSignedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBackgroundImageOpacity(int opacity) {
|
void setPSNSignedIn(bool sign) {
|
||||||
backgroundImageOpacity = std::clamp(opacity, 0, 100);
|
isPSNSignedIn = sign;
|
||||||
}
|
|
||||||
|
|
||||||
bool getShowBackgroundImage() {
|
|
||||||
return showBackgroundImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setShowBackgroundImage(bool show) {
|
|
||||||
showBackgroundImage = show;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(const std::filesystem::path& path) {
|
void load(const std::filesystem::path& path) {
|
||||||
@ -749,95 +627,99 @@ void load(const std::filesystem::path& path) {
|
|||||||
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("General")) {
|
if (data.contains("General")) {
|
||||||
const toml::value& general = data.at("General");
|
const toml::value& general = data.at("General");
|
||||||
|
|
||||||
isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
|
volumeSlider = toml::find_or<int>(general, "volumeSlider", volumeSlider);
|
||||||
isDevKit = toml::find_or<bool>(general, "isDevKit", false);
|
isNeo = toml::find_or<bool>(general, "isPS4Pro", isNeo);
|
||||||
playBGM = toml::find_or<bool>(general, "playBGM", false);
|
isDevKit = toml::find_or<bool>(general, "isDevKit", isDevKit);
|
||||||
isTrophyPopupDisabled = toml::find_or<bool>(general, "isTrophyPopupDisabled", false);
|
isPSNSignedIn = toml::find_or<bool>(general, "isPSNSignedIn", isPSNSignedIn);
|
||||||
trophyNotificationDuration =
|
isTrophyPopupDisabled =
|
||||||
toml::find_or<double>(general, "trophyNotificationDuration", 5.0);
|
toml::find_or<bool>(general, "isTrophyPopupDisabled", isTrophyPopupDisabled);
|
||||||
BGMvolume = toml::find_or<int>(general, "BGMvolume", 50);
|
trophyNotificationDuration = toml::find_or<double>(general, "trophyNotificationDuration",
|
||||||
enableDiscordRPC = toml::find_or<bool>(general, "enableDiscordRPC", true);
|
trophyNotificationDuration);
|
||||||
logFilter = toml::find_or<std::string>(general, "logFilter", "");
|
enableDiscordRPC = toml::find_or<bool>(general, "enableDiscordRPC", enableDiscordRPC);
|
||||||
logType = toml::find_or<std::string>(general, "logType", "sync");
|
logFilter = toml::find_or<std::string>(general, "logFilter", logFilter);
|
||||||
userName = toml::find_or<std::string>(general, "userName", "shadPS4");
|
logType = toml::find_or<std::string>(general, "logType", logType);
|
||||||
if (Common::g_is_release) {
|
userName = toml::find_or<std::string>(general, "userName", userName);
|
||||||
updateChannel = toml::find_or<std::string>(general, "updateChannel", "Release");
|
isShowSplash = toml::find_or<bool>(general, "showSplash", isShowSplash);
|
||||||
} else {
|
isSideTrophy = toml::find_or<std::string>(general, "sideTrophy", isSideTrophy);
|
||||||
updateChannel = toml::find_or<std::string>(general, "updateChannel", "Nightly");
|
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", compatibilityData);
|
||||||
}
|
checkCompatibilityOnStartup = toml::find_or<bool>(general, "checkCompatibilityOnStartup",
|
||||||
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
|
checkCompatibilityOnStartup);
|
||||||
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false);
|
|
||||||
isAlwaysShowChangelog = toml::find_or<bool>(general, "alwaysShowChangelog", false);
|
isConnectedToNetwork =
|
||||||
isSideTrophy = toml::find_or<std::string>(general, "sideTrophy", "right");
|
toml::find_or<bool>(general, "isConnectedToNetwork", isConnectedToNetwork);
|
||||||
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", false);
|
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", chooseHomeTab);
|
||||||
checkCompatibilityOnStartup =
|
|
||||||
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
|
|
||||||
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", "Release");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Input")) {
|
if (data.contains("Input")) {
|
||||||
const toml::value& input = data.at("Input");
|
const toml::value& input = data.at("Input");
|
||||||
|
|
||||||
cursorState = toml::find_or<int>(input, "cursorState", HideCursorState::Idle);
|
cursorState = toml::find_or<int>(input, "cursorState", cursorState);
|
||||||
cursorHideTimeout = toml::find_or<int>(input, "cursorHideTimeout", 5);
|
cursorHideTimeout = toml::find_or<int>(input, "cursorHideTimeout", cursorHideTimeout);
|
||||||
backButtonBehavior = toml::find_or<std::string>(input, "backButtonBehavior", "left");
|
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", useSpecialPad);
|
||||||
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false);
|
specialPadClass = toml::find_or<int>(input, "specialPadClass", specialPadClass);
|
||||||
specialPadClass = toml::find_or<int>(input, "specialPadClass", 1);
|
isMotionControlsEnabled =
|
||||||
isMotionControlsEnabled = toml::find_or<bool>(input, "isMotionControlsEnabled", true);
|
toml::find_or<bool>(input, "isMotionControlsEnabled", isMotionControlsEnabled);
|
||||||
useUnifiedInputConfig = toml::find_or<bool>(input, "useUnifiedInputConfig", true);
|
useUnifiedInputConfig =
|
||||||
|
toml::find_or<bool>(input, "useUnifiedInputConfig", useUnifiedInputConfig);
|
||||||
|
micDevice = toml::find_or<std::string>(input, "micDevice", micDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("GPU")) {
|
if (data.contains("GPU")) {
|
||||||
const toml::value& gpu = data.at("GPU");
|
const toml::value& gpu = data.at("GPU");
|
||||||
|
|
||||||
screenWidth = toml::find_or<int>(gpu, "screenWidth", screenWidth);
|
windowWidth = toml::find_or<int>(gpu, "screenWidth", windowWidth);
|
||||||
screenHeight = toml::find_or<int>(gpu, "screenHeight", screenHeight);
|
windowHeight = toml::find_or<int>(gpu, "screenHeight", windowHeight);
|
||||||
isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
|
internalScreenWidth = toml::find_or<int>(gpu, "internalScreenWidth", internalScreenWidth);
|
||||||
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
|
internalScreenHeight =
|
||||||
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
|
toml::find_or<int>(gpu, "internalScreenHeight", internalScreenHeight);
|
||||||
shouldPatchShaders = toml::find_or<bool>(gpu, "patchShaders", true);
|
isNullGpu = toml::find_or<bool>(gpu, "nullGpu", isNullGpu);
|
||||||
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
|
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", shouldCopyGPUBuffers);
|
||||||
isFullscreen = toml::find_or<bool>(gpu, "Fullscreen", false);
|
readbacksEnabled = toml::find_or<bool>(gpu, "readbacks", readbacksEnabled);
|
||||||
fullscreenMode = toml::find_or<std::string>(gpu, "FullscreenMode", "Windowed");
|
readbackLinearImagesEnabled =
|
||||||
isHDRAllowed = toml::find_or<bool>(gpu, "allowHDR", false);
|
toml::find_or<bool>(gpu, "readbackLinearImages", readbackLinearImagesEnabled);
|
||||||
|
directMemoryAccessEnabled =
|
||||||
|
toml::find_or<bool>(gpu, "directMemoryAccess", directMemoryAccessEnabled);
|
||||||
|
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", shouldDumpShaders);
|
||||||
|
shouldPatchShaders = toml::find_or<bool>(gpu, "patchShaders", shouldPatchShaders);
|
||||||
|
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", vblankDivider);
|
||||||
|
isFullscreen = toml::find_or<bool>(gpu, "Fullscreen", isFullscreen);
|
||||||
|
fullscreenMode = toml::find_or<std::string>(gpu, "FullscreenMode", fullscreenMode);
|
||||||
|
isHDRAllowed = toml::find_or<bool>(gpu, "allowHDR", isHDRAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Vulkan")) {
|
if (data.contains("Vulkan")) {
|
||||||
const toml::value& vk = data.at("Vulkan");
|
const toml::value& vk = data.at("Vulkan");
|
||||||
|
|
||||||
gpuId = toml::find_or<int>(vk, "gpuId", -1);
|
gpuId = toml::find_or<int>(vk, "gpuId", gpuId);
|
||||||
vkValidation = toml::find_or<bool>(vk, "validation", false);
|
vkValidation = toml::find_or<bool>(vk, "validation", vkValidation);
|
||||||
vkValidationSync = toml::find_or<bool>(vk, "validation_sync", false);
|
vkValidationSync = toml::find_or<bool>(vk, "validation_sync", vkValidationSync);
|
||||||
vkValidationGpu = toml::find_or<bool>(vk, "validation_gpu", true);
|
vkValidationGpu = toml::find_or<bool>(vk, "validation_gpu", vkValidationGpu);
|
||||||
vkCrashDiagnostic = toml::find_or<bool>(vk, "crashDiagnostic", false);
|
vkCrashDiagnostic = toml::find_or<bool>(vk, "crashDiagnostic", vkCrashDiagnostic);
|
||||||
vkHostMarkers = toml::find_or<bool>(vk, "hostMarkers", false);
|
vkHostMarkers = toml::find_or<bool>(vk, "hostMarkers", vkHostMarkers);
|
||||||
vkGuestMarkers = toml::find_or<bool>(vk, "guestMarkers", false);
|
vkGuestMarkers = toml::find_or<bool>(vk, "guestMarkers", vkGuestMarkers);
|
||||||
rdocEnable = toml::find_or<bool>(vk, "rdocEnable", false);
|
rdocEnable = toml::find_or<bool>(vk, "rdocEnable", rdocEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string current_version = {};
|
||||||
if (data.contains("Debug")) {
|
if (data.contains("Debug")) {
|
||||||
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", isDebugDump);
|
||||||
isSeparateLogFilesEnabled = toml::find_or<bool>(debug, "isSeparateLogFilesEnabled", false);
|
isSeparateLogFilesEnabled =
|
||||||
isShaderDebug = toml::find_or<bool>(debug, "CollectShader", false);
|
toml::find_or<bool>(debug, "isSeparateLogFilesEnabled", isSeparateLogFilesEnabled);
|
||||||
isFpsColor = toml::find_or<bool>(debug, "FPSColor", true);
|
isShaderDebug = toml::find_or<bool>(debug, "CollectShader", isShaderDebug);
|
||||||
|
isFpsColor = toml::find_or<bool>(debug, "FPSColor", isFpsColor);
|
||||||
|
current_version = toml::find_or<std::string>(debug, "ConfigVersion", current_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("GUI")) {
|
if (data.contains("GUI")) {
|
||||||
const toml::value& gui = data.at("GUI");
|
const toml::value& gui = data.at("GUI");
|
||||||
|
|
||||||
load_game_size = toml::find_or<bool>(gui, "loadGameSizeEnabled", true);
|
load_game_size = toml::find_or<bool>(gui, "loadGameSizeEnabled", load_game_size);
|
||||||
m_icon_size = toml::find_or<int>(gui, "iconSize", 0);
|
|
||||||
m_icon_size_grid = toml::find_or<int>(gui, "iconSizeGrid", 0);
|
|
||||||
m_slider_pos = toml::find_or<int>(gui, "sliderPos", 0);
|
|
||||||
m_slider_pos_grid = toml::find_or<int>(gui, "sliderPosGrid", 0);
|
|
||||||
mw_themes = toml::find_or<int>(gui, "theme", 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);
|
|
||||||
|
|
||||||
const auto install_dir_array =
|
const auto install_dir_array =
|
||||||
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
|
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
|
||||||
@ -859,41 +741,25 @@ void load(const std::filesystem::path& path) {
|
|||||||
{std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]});
|
{std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]});
|
||||||
}
|
}
|
||||||
|
|
||||||
save_data_path = toml::find_fs_path_or(gui, "saveDataPath", {});
|
save_data_path = toml::find_fs_path_or(gui, "saveDataPath", save_data_path);
|
||||||
|
|
||||||
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
|
settings_addon_install_dir =
|
||||||
main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
|
toml::find_fs_path_or(gui, "addonInstallDir", settings_addon_install_dir);
|
||||||
main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
|
|
||||||
main_window_geometry_w = toml::find_or<int>(gui, "geometry_w", 0);
|
|
||||||
main_window_geometry_h = toml::find_or<int>(gui, "geometry_h", 0);
|
|
||||||
m_elf_viewer = toml::find_or<std::vector<std::string>>(gui, "elfDirs", {});
|
|
||||||
m_recent_files = toml::find_or<std::vector<std::string>>(gui, "recentFiles", {});
|
|
||||||
m_table_mode = toml::find_or<int>(gui, "gameTableMode", 0);
|
|
||||||
emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en_US");
|
|
||||||
backgroundImageOpacity = toml::find_or<int>(gui, "backgroundImageOpacity", 50);
|
|
||||||
showBackgroundImage = toml::find_or<bool>(gui, "showBackgroundImage", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Settings")) {
|
if (data.contains("Settings")) {
|
||||||
const toml::value& settings = data.at("Settings");
|
const toml::value& settings = data.at("Settings");
|
||||||
|
m_language = toml::find_or<int>(settings, "consoleLanguage", m_language);
|
||||||
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Keys")) {
|
if (data.contains("Keys")) {
|
||||||
const toml::value& keys = data.at("Keys");
|
const toml::value& keys = data.at("Keys");
|
||||||
trophyKey = toml::find_or<std::string>(keys, "TrophyKey", "");
|
trophyKey = toml::find_or<std::string>(keys, "TrophyKey", trophyKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the loaded language is in the allowed list
|
// Run save after loading to generate any missing fields with default values.
|
||||||
const std::vector<std::string> allowed_languages = {
|
if (config_version != current_version) {
|
||||||
"ar_SA", "da_DK", "de_DE", "el_GR", "en_US", "es_ES", "fa_IR", "fi_FI", "fr_FR", "hu_HU",
|
fmt::print("Outdated config detected, updating config file.\n");
|
||||||
"id_ID", "it_IT", "ja_JP", "ko_KR", "lt_LT", "nb_NO", "nl_NL", "pl_PL", "pt_BR", "pt_PT",
|
|
||||||
"ro_RO", "ru_RU", "sq_AL", "sv_SE", "tr_TR", "uk_UA", "vi_VN", "zh_CN", "zh_TW"};
|
|
||||||
|
|
||||||
if (std::find(allowed_languages.begin(), allowed_languages.end(), emulator_language) ==
|
|
||||||
allowed_languages.end()) {
|
|
||||||
emulator_language = "en_US"; // Default to en_US if not in the list
|
|
||||||
save(path);
|
save(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -951,35 +817,38 @@ void save(const std::filesystem::path& path) {
|
|||||||
fmt::print("Saving new configuration file {}\n", fmt::UTF(path.u8string()));
|
fmt::print("Saving new configuration file {}\n", fmt::UTF(path.u8string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data["General"]["volumeSlider"] = volumeSlider;
|
||||||
data["General"]["isPS4Pro"] = isNeo;
|
data["General"]["isPS4Pro"] = isNeo;
|
||||||
data["General"]["isDevKit"] = isDevKit;
|
data["General"]["isDevKit"] = isDevKit;
|
||||||
|
data["General"]["isPSNSignedIn"] = isPSNSignedIn;
|
||||||
data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled;
|
data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled;
|
||||||
data["General"]["trophyNotificationDuration"] = trophyNotificationDuration;
|
data["General"]["trophyNotificationDuration"] = trophyNotificationDuration;
|
||||||
data["General"]["playBGM"] = playBGM;
|
|
||||||
data["General"]["BGMvolume"] = BGMvolume;
|
|
||||||
data["General"]["enableDiscordRPC"] = enableDiscordRPC;
|
data["General"]["enableDiscordRPC"] = enableDiscordRPC;
|
||||||
data["General"]["logFilter"] = logFilter;
|
data["General"]["logFilter"] = logFilter;
|
||||||
data["General"]["logType"] = logType;
|
data["General"]["logType"] = logType;
|
||||||
data["General"]["userName"] = userName;
|
data["General"]["userName"] = userName;
|
||||||
data["General"]["updateChannel"] = updateChannel;
|
|
||||||
data["General"]["chooseHomeTab"] = chooseHomeTab;
|
data["General"]["chooseHomeTab"] = chooseHomeTab;
|
||||||
data["General"]["showSplash"] = isShowSplash;
|
data["General"]["showSplash"] = isShowSplash;
|
||||||
data["General"]["autoUpdate"] = isAutoUpdate;
|
|
||||||
data["General"]["alwaysShowChangelog"] = isAlwaysShowChangelog;
|
|
||||||
data["General"]["sideTrophy"] = isSideTrophy;
|
data["General"]["sideTrophy"] = isSideTrophy;
|
||||||
data["General"]["compatibilityEnabled"] = compatibilityData;
|
data["General"]["compatibilityEnabled"] = compatibilityData;
|
||||||
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||||
|
data["General"]["isConnectedToNetwork"] = isConnectedToNetwork;
|
||||||
data["Input"]["cursorState"] = cursorState;
|
data["Input"]["cursorState"] = cursorState;
|
||||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||||
data["Input"]["backButtonBehavior"] = backButtonBehavior;
|
|
||||||
data["Input"]["useSpecialPad"] = useSpecialPad;
|
data["Input"]["useSpecialPad"] = useSpecialPad;
|
||||||
data["Input"]["specialPadClass"] = specialPadClass;
|
data["Input"]["specialPadClass"] = specialPadClass;
|
||||||
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
|
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
|
||||||
data["Input"]["useUnifiedInputConfig"] = useUnifiedInputConfig;
|
data["Input"]["useUnifiedInputConfig"] = useUnifiedInputConfig;
|
||||||
data["GPU"]["screenWidth"] = screenWidth;
|
data["Input"]["micDevice"] = micDevice;
|
||||||
data["GPU"]["screenHeight"] = screenHeight;
|
data["GPU"]["screenWidth"] = windowWidth;
|
||||||
|
data["GPU"]["screenHeight"] = windowHeight;
|
||||||
|
data["GPU"]["internalScreenWidth"] = internalScreenWidth;
|
||||||
|
data["GPU"]["internalScreenHeight"] = internalScreenHeight;
|
||||||
data["GPU"]["nullGpu"] = isNullGpu;
|
data["GPU"]["nullGpu"] = isNullGpu;
|
||||||
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
|
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
|
||||||
|
data["GPU"]["readbacks"] = readbacksEnabled;
|
||||||
|
data["GPU"]["readbackLinearImages"] = readbackLinearImagesEnabled;
|
||||||
|
data["GPU"]["directMemoryAccess"] = directMemoryAccessEnabled;
|
||||||
data["GPU"]["dumpShaders"] = shouldDumpShaders;
|
data["GPU"]["dumpShaders"] = shouldDumpShaders;
|
||||||
data["GPU"]["patchShaders"] = shouldPatchShaders;
|
data["GPU"]["patchShaders"] = shouldPatchShaders;
|
||||||
data["GPU"]["vblankDivider"] = vblankDivider;
|
data["GPU"]["vblankDivider"] = vblankDivider;
|
||||||
@ -998,6 +867,7 @@ void save(const std::filesystem::path& path) {
|
|||||||
data["Debug"]["CollectShader"] = isShaderDebug;
|
data["Debug"]["CollectShader"] = isShaderDebug;
|
||||||
data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled;
|
data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled;
|
||||||
data["Debug"]["FPSColor"] = isFpsColor;
|
data["Debug"]["FPSColor"] = isFpsColor;
|
||||||
|
data["Debug"]["ConfigVersion"] = config_version;
|
||||||
data["Keys"]["TrophyKey"] = trophyKey;
|
data["Keys"]["TrophyKey"] = trophyKey;
|
||||||
|
|
||||||
std::vector<std::string> install_dirs;
|
std::vector<std::string> install_dirs;
|
||||||
@ -1034,9 +904,6 @@ void save(const std::filesystem::path& path) {
|
|||||||
|
|
||||||
data["GUI"]["addonInstallDir"] =
|
data["GUI"]["addonInstallDir"] =
|
||||||
std::string{fmt::UTF(settings_addon_install_dir.u8string()).data};
|
std::string{fmt::UTF(settings_addon_install_dir.u8string()).data};
|
||||||
data["GUI"]["emulatorLanguage"] = emulator_language;
|
|
||||||
data["GUI"]["backgroundImageOpacity"] = backgroundImageOpacity;
|
|
||||||
data["GUI"]["showBackgroundImage"] = showBackgroundImage;
|
|
||||||
data["Settings"]["consoleLanguage"] = m_language;
|
data["Settings"]["consoleLanguage"] = m_language;
|
||||||
|
|
||||||
// Sorting of TOML sections
|
// Sorting of TOML sections
|
||||||
@ -1045,90 +912,59 @@ void save(const std::filesystem::path& path) {
|
|||||||
std::ofstream file(path, std::ios::binary);
|
std::ofstream file(path, std::ios::binary);
|
||||||
file << data;
|
file << data;
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
saveMainWindow(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveMainWindow(const std::filesystem::path& path) {
|
|
||||||
toml::ordered_value data;
|
|
||||||
|
|
||||||
std::error_code error;
|
|
||||||
if (std::filesystem::exists(path, error)) {
|
|
||||||
try {
|
|
||||||
std::ifstream ifs;
|
|
||||||
ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
|
||||||
ifs.open(path, std::ios_base::binary);
|
|
||||||
data = toml::parse<toml::ordered_type_config>(
|
|
||||||
ifs, std::string{fmt::UTF(path.filename().u8string()).data});
|
|
||||||
} catch (const std::exception& ex) {
|
|
||||||
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (error) {
|
|
||||||
fmt::print("Filesystem error: {}\n", error.message());
|
|
||||||
}
|
|
||||||
fmt::print("Saving new configuration file {}\n", fmt::UTF(path.u8string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
data["GUI"]["mw_width"] = m_window_size_W;
|
|
||||||
data["GUI"]["mw_height"] = m_window_size_H;
|
|
||||||
data["GUI"]["theme"] = mw_themes;
|
|
||||||
data["GUI"]["iconSize"] = m_icon_size;
|
|
||||||
data["GUI"]["sliderPos"] = m_slider_pos;
|
|
||||||
data["GUI"]["iconSizeGrid"] = m_icon_size_grid;
|
|
||||||
data["GUI"]["sliderPosGrid"] = m_slider_pos_grid;
|
|
||||||
data["GUI"]["gameTableMode"] = m_table_mode;
|
|
||||||
data["GUI"]["geometry_x"] = main_window_geometry_x;
|
|
||||||
data["GUI"]["geometry_y"] = main_window_geometry_y;
|
|
||||||
data["GUI"]["geometry_w"] = main_window_geometry_w;
|
|
||||||
data["GUI"]["geometry_h"] = main_window_geometry_h;
|
|
||||||
data["GUI"]["elfDirs"] = m_elf_viewer;
|
|
||||||
data["GUI"]["recentFiles"] = m_recent_files;
|
|
||||||
|
|
||||||
// Sorting of TOML sections
|
|
||||||
sortTomlSections(data);
|
|
||||||
|
|
||||||
std::ofstream file(path, std::ios::binary);
|
|
||||||
file << data;
|
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaultValues() {
|
void setDefaultValues() {
|
||||||
isHDRAllowed = false;
|
// General
|
||||||
|
volumeSlider = 100;
|
||||||
isNeo = false;
|
isNeo = false;
|
||||||
isDevKit = false;
|
isDevKit = false;
|
||||||
isFullscreen = false;
|
isPSNSignedIn = false;
|
||||||
isTrophyPopupDisabled = false;
|
isTrophyPopupDisabled = false;
|
||||||
playBGM = false;
|
trophyNotificationDuration = 6.0;
|
||||||
BGMvolume = 50;
|
enableDiscordRPC = false;
|
||||||
enableDiscordRPC = true;
|
|
||||||
screenWidth = 1280;
|
|
||||||
screenHeight = 720;
|
|
||||||
logFilter = "";
|
logFilter = "";
|
||||||
logType = "sync";
|
logType = "sync";
|
||||||
userName = "shadPS4";
|
userName = "shadPS4";
|
||||||
if (Common::g_is_release) {
|
|
||||||
updateChannel = "Release";
|
|
||||||
} else {
|
|
||||||
updateChannel = "Nightly";
|
|
||||||
}
|
|
||||||
chooseHomeTab = "General";
|
chooseHomeTab = "General";
|
||||||
|
isShowSplash = false;
|
||||||
|
isSideTrophy = "right";
|
||||||
|
compatibilityData = false;
|
||||||
|
checkCompatibilityOnStartup = false;
|
||||||
|
isConnectedToNetwork = false;
|
||||||
|
|
||||||
|
// Input
|
||||||
cursorState = HideCursorState::Idle;
|
cursorState = HideCursorState::Idle;
|
||||||
cursorHideTimeout = 5;
|
cursorHideTimeout = 5;
|
||||||
trophyNotificationDuration = 6.0;
|
|
||||||
backButtonBehavior = "left";
|
|
||||||
useSpecialPad = false;
|
useSpecialPad = false;
|
||||||
specialPadClass = 1;
|
specialPadClass = 1;
|
||||||
isDebugDump = false;
|
isMotionControlsEnabled = true;
|
||||||
isShaderDebug = false;
|
useUnifiedInputConfig = true;
|
||||||
isShowSplash = false;
|
overrideControllerColor = false;
|
||||||
isAutoUpdate = false;
|
controllerCustomColorRGB[0] = 0;
|
||||||
isAlwaysShowChangelog = false;
|
controllerCustomColorRGB[1] = 0;
|
||||||
isSideTrophy = "right";
|
controllerCustomColorRGB[2] = 255;
|
||||||
|
micDevice = "Default Device";
|
||||||
|
|
||||||
|
// GPU
|
||||||
|
windowWidth = 1280;
|
||||||
|
windowHeight = 720;
|
||||||
|
internalScreenWidth = 1280;
|
||||||
|
internalScreenHeight = 720;
|
||||||
isNullGpu = false;
|
isNullGpu = false;
|
||||||
|
shouldCopyGPUBuffers = false;
|
||||||
|
readbacksEnabled = false;
|
||||||
|
readbackLinearImagesEnabled = false;
|
||||||
|
directMemoryAccessEnabled = false;
|
||||||
shouldDumpShaders = false;
|
shouldDumpShaders = false;
|
||||||
|
shouldPatchShaders = false;
|
||||||
vblankDivider = 1;
|
vblankDivider = 1;
|
||||||
|
isFullscreen = false;
|
||||||
|
fullscreenMode = "Windowed";
|
||||||
|
isHDRAllowed = false;
|
||||||
|
|
||||||
|
// Vulkan
|
||||||
|
gpuId = -1;
|
||||||
vkValidation = false;
|
vkValidation = false;
|
||||||
vkValidationSync = false;
|
vkValidationSync = false;
|
||||||
vkValidationGpu = false;
|
vkValidationGpu = false;
|
||||||
@ -1136,13 +972,18 @@ void setDefaultValues() {
|
|||||||
vkHostMarkers = false;
|
vkHostMarkers = false;
|
||||||
vkGuestMarkers = false;
|
vkGuestMarkers = false;
|
||||||
rdocEnable = false;
|
rdocEnable = false;
|
||||||
emulator_language = "en_US";
|
|
||||||
|
// Debug
|
||||||
|
isDebugDump = false;
|
||||||
|
isShaderDebug = false;
|
||||||
|
isSeparateLogFilesEnabled = false;
|
||||||
|
isFpsColor = true;
|
||||||
|
|
||||||
|
// GUI
|
||||||
|
load_game_size = true;
|
||||||
|
|
||||||
|
// Settings
|
||||||
m_language = 1;
|
m_language = 1;
|
||||||
gpuId = -1;
|
|
||||||
compatibilityData = false;
|
|
||||||
checkCompatibilityOnStartup = false;
|
|
||||||
backgroundImageOpacity = 50;
|
|
||||||
showBackgroundImage = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::string_view GetDefaultKeyboardConfig() {
|
constexpr std::string_view GetDefaultKeyboardConfig() {
|
||||||
@ -1168,7 +1009,7 @@ l3 = x
|
|||||||
r3 = m
|
r3 = m
|
||||||
|
|
||||||
options = enter
|
options = enter
|
||||||
touchpad = space
|
touchpad_center = space
|
||||||
|
|
||||||
pad_up = up
|
pad_up = up
|
||||||
pad_down = down
|
pad_down = down
|
||||||
@ -1200,7 +1041,7 @@ r2 = r2
|
|||||||
r3 = r3
|
r3 = r3
|
||||||
|
|
||||||
options = options
|
options = options
|
||||||
touchpad = back
|
touchpad_center = back
|
||||||
|
|
||||||
pad_up = pad_up
|
pad_up = pad_up
|
||||||
pad_down = pad_down
|
pad_down = pad_down
|
||||||
|
@ -14,172 +14,134 @@ struct GameInstallDir {
|
|||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum HideCursorState : s16 { Never, Idle, Always };
|
enum HideCursorState : int { Never, Idle, Always };
|
||||||
|
|
||||||
void load(const std::filesystem::path& path);
|
void load(const std::filesystem::path& path);
|
||||||
void save(const std::filesystem::path& path);
|
void save(const std::filesystem::path& path);
|
||||||
void saveMainWindow(const std::filesystem::path& path);
|
|
||||||
|
|
||||||
|
int getVolumeSlider();
|
||||||
|
void setVolumeSlider(int volumeValue);
|
||||||
std::string getTrophyKey();
|
std::string getTrophyKey();
|
||||||
void setTrophyKey(std::string key);
|
void setTrophyKey(std::string key);
|
||||||
|
bool getIsFullscreen();
|
||||||
|
void setIsFullscreen(bool enable);
|
||||||
|
std::string getFullscreenMode();
|
||||||
|
void setFullscreenMode(std::string mode);
|
||||||
|
u32 getWindowWidth();
|
||||||
|
u32 getWindowHeight();
|
||||||
|
void setWindowWidth(u32 width);
|
||||||
|
void setWindowHeight(u32 height);
|
||||||
|
u32 getInternalScreenWidth();
|
||||||
|
u32 getInternalScreenHeight();
|
||||||
|
void setInternalScreenWidth(u32 width);
|
||||||
|
void setInternalScreenHeight(u32 height);
|
||||||
|
bool debugDump();
|
||||||
|
void setDebugDump(bool enable);
|
||||||
|
s32 getGpuId();
|
||||||
|
void setGpuId(s32 selectedGpuId);
|
||||||
|
bool allowHDR();
|
||||||
|
void setAllowHDR(bool enable);
|
||||||
|
bool collectShadersForDebug();
|
||||||
|
void setCollectShaderForDebug(bool enable);
|
||||||
|
bool showSplash();
|
||||||
|
void setShowSplash(bool enable);
|
||||||
|
std::string sideTrophy();
|
||||||
|
void setSideTrophy(std::string side);
|
||||||
|
bool nullGpu();
|
||||||
|
void setNullGpu(bool enable);
|
||||||
|
bool copyGPUCmdBuffers();
|
||||||
|
void setCopyGPUCmdBuffers(bool enable);
|
||||||
|
bool readbacks();
|
||||||
|
void setReadbacks(bool enable);
|
||||||
|
bool readbackLinearImages();
|
||||||
|
bool directMemoryAccess();
|
||||||
|
void setDirectMemoryAccess(bool enable);
|
||||||
|
bool dumpShaders();
|
||||||
|
void setDumpShaders(bool enable);
|
||||||
|
u32 vblankDiv();
|
||||||
|
void setVblankDiv(u32 value);
|
||||||
|
bool getisTrophyPopupDisabled();
|
||||||
|
void setisTrophyPopupDisabled(bool disable);
|
||||||
|
s16 getCursorState();
|
||||||
|
void setCursorState(s16 cursorState);
|
||||||
|
bool vkValidationEnabled();
|
||||||
|
void setVkValidation(bool enable);
|
||||||
|
bool vkValidationSyncEnabled();
|
||||||
|
void setVkSyncValidation(bool enable);
|
||||||
|
bool getVkCrashDiagnosticEnabled();
|
||||||
|
void setVkCrashDiagnosticEnabled(bool enable);
|
||||||
|
bool getVkHostMarkersEnabled();
|
||||||
|
void setVkHostMarkersEnabled(bool enable);
|
||||||
|
bool getVkGuestMarkersEnabled();
|
||||||
|
void setVkGuestMarkersEnabled(bool enable);
|
||||||
|
bool getEnableDiscordRPC();
|
||||||
|
void setEnableDiscordRPC(bool enable);
|
||||||
|
bool isRdocEnabled();
|
||||||
|
void setRdocEnabled(bool enable);
|
||||||
|
std::string getLogType();
|
||||||
|
void setLogType(const std::string& type);
|
||||||
|
std::string getLogFilter();
|
||||||
|
void setLogFilter(const std::string& type);
|
||||||
|
double getTrophyNotificationDuration();
|
||||||
|
void setTrophyNotificationDuration(double newTrophyNotificationDuration);
|
||||||
|
int getCursorHideTimeout();
|
||||||
|
std::string getMicDevice();
|
||||||
|
void setCursorHideTimeout(int newcursorHideTimeout);
|
||||||
|
void setMicDevice(std::string device);
|
||||||
|
void setSeparateLogFilesEnabled(bool enabled);
|
||||||
|
bool getSeparateLogFilesEnabled();
|
||||||
|
u32 GetLanguage();
|
||||||
|
void setLanguage(u32 language);
|
||||||
|
void setUseSpecialPad(bool use);
|
||||||
|
bool getUseSpecialPad();
|
||||||
|
void setSpecialPadClass(int type);
|
||||||
|
int getSpecialPadClass();
|
||||||
|
bool getPSNSignedIn();
|
||||||
|
void setPSNSignedIn(bool sign); // no ui setting
|
||||||
|
bool patchShaders(); // no set
|
||||||
|
bool fpsColor(); // no set
|
||||||
|
bool isNeoModeConsole();
|
||||||
|
void setNeoMode(bool enable); // no ui setting
|
||||||
|
bool isDevKitConsole(); // no set
|
||||||
|
bool vkValidationGpuEnabled(); // no set
|
||||||
|
bool getIsMotionControlsEnabled();
|
||||||
|
void setIsMotionControlsEnabled(bool use);
|
||||||
|
|
||||||
|
// TODO
|
||||||
bool GetLoadGameSizeEnabled();
|
bool GetLoadGameSizeEnabled();
|
||||||
std::filesystem::path GetSaveDataPath();
|
std::filesystem::path GetSaveDataPath();
|
||||||
void setLoadGameSizeEnabled(bool enable);
|
void setLoadGameSizeEnabled(bool enable);
|
||||||
bool getIsFullscreen();
|
|
||||||
bool getShowLabelsUnderIcons();
|
|
||||||
bool setShowLabelsUnderIcons();
|
|
||||||
std::string getFullscreenMode();
|
|
||||||
bool isNeoModeConsole();
|
|
||||||
bool isDevKitConsole();
|
|
||||||
bool getPlayBGM();
|
|
||||||
int getBGMvolume();
|
|
||||||
bool getisTrophyPopupDisabled();
|
|
||||||
bool getEnableDiscordRPC();
|
|
||||||
bool getCompatibilityEnabled();
|
bool getCompatibilityEnabled();
|
||||||
bool getCheckCompatibilityOnStartup();
|
bool getCheckCompatibilityOnStartup();
|
||||||
int getBackgroundImageOpacity();
|
bool getIsConnectedToNetwork();
|
||||||
bool getShowBackgroundImage();
|
|
||||||
|
|
||||||
std::string getLogFilter();
|
|
||||||
std::string getLogType();
|
|
||||||
std::string getUserName();
|
std::string getUserName();
|
||||||
std::string getUpdateChannel();
|
|
||||||
std::string getChooseHomeTab();
|
std::string getChooseHomeTab();
|
||||||
|
|
||||||
s16 getCursorState();
|
|
||||||
int getCursorHideTimeout();
|
|
||||||
double getTrophyNotificationDuration();
|
|
||||||
std::string getBackButtonBehavior();
|
|
||||||
bool getUseSpecialPad();
|
|
||||||
int getSpecialPadClass();
|
|
||||||
bool getIsMotionControlsEnabled();
|
|
||||||
bool GetUseUnifiedInputConfig();
|
bool GetUseUnifiedInputConfig();
|
||||||
void SetUseUnifiedInputConfig(bool use);
|
void SetUseUnifiedInputConfig(bool use);
|
||||||
bool GetOverrideControllerColor();
|
bool GetOverrideControllerColor();
|
||||||
void SetOverrideControllerColor(bool enable);
|
void SetOverrideControllerColor(bool enable);
|
||||||
int* GetControllerCustomColor();
|
int* GetControllerCustomColor();
|
||||||
void SetControllerCustomColor(int r, int b, int g);
|
void SetControllerCustomColor(int r, int b, int g);
|
||||||
|
|
||||||
u32 getScreenWidth();
|
|
||||||
u32 getScreenHeight();
|
|
||||||
s32 getGpuId();
|
|
||||||
bool allowHDR();
|
|
||||||
|
|
||||||
bool debugDump();
|
|
||||||
bool collectShadersForDebug();
|
|
||||||
bool showSplash();
|
|
||||||
bool autoUpdate();
|
|
||||||
bool alwaysShowChangelog();
|
|
||||||
std::string sideTrophy();
|
|
||||||
bool nullGpu();
|
|
||||||
bool copyGPUCmdBuffers();
|
|
||||||
bool dumpShaders();
|
|
||||||
bool patchShaders();
|
|
||||||
bool isRdocEnabled();
|
|
||||||
bool fpsColor();
|
|
||||||
u32 vblankDiv();
|
|
||||||
|
|
||||||
void setDebugDump(bool enable);
|
|
||||||
void setCollectShaderForDebug(bool enable);
|
|
||||||
void setShowSplash(bool enable);
|
|
||||||
void setAutoUpdate(bool enable);
|
|
||||||
void setAlwaysShowChangelog(bool enable);
|
|
||||||
void setSideTrophy(std::string side);
|
|
||||||
void setNullGpu(bool enable);
|
|
||||||
void setAllowHDR(bool enable);
|
|
||||||
void setCopyGPUCmdBuffers(bool enable);
|
|
||||||
void setDumpShaders(bool enable);
|
|
||||||
void setVblankDiv(u32 value);
|
|
||||||
void setGpuId(s32 selectedGpuId);
|
|
||||||
void setScreenWidth(u32 width);
|
|
||||||
void setScreenHeight(u32 height);
|
|
||||||
void setIsFullscreen(bool enable);
|
|
||||||
void setFullscreenMode(std::string mode);
|
|
||||||
void setisTrophyPopupDisabled(bool disable);
|
|
||||||
void setPlayBGM(bool enable);
|
|
||||||
void setBGMvolume(int volume);
|
|
||||||
void setEnableDiscordRPC(bool enable);
|
|
||||||
void setLanguage(u32 language);
|
|
||||||
void setNeoMode(bool enable);
|
|
||||||
void setUserName(const std::string& type);
|
void setUserName(const std::string& type);
|
||||||
void setUpdateChannel(const std::string& type);
|
|
||||||
void setChooseHomeTab(const std::string& type);
|
void setChooseHomeTab(const std::string& type);
|
||||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config);
|
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config);
|
||||||
void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config);
|
void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config);
|
||||||
void setSaveDataPath(const std::filesystem::path& path);
|
void setSaveDataPath(const std::filesystem::path& path);
|
||||||
void setCompatibilityEnabled(bool use);
|
void setCompatibilityEnabled(bool use);
|
||||||
void setCheckCompatibilityOnStartup(bool use);
|
void setCheckCompatibilityOnStartup(bool use);
|
||||||
void setBackgroundImageOpacity(int opacity);
|
|
||||||
void setShowBackgroundImage(bool show);
|
|
||||||
|
|
||||||
void setCursorState(s16 cursorState);
|
|
||||||
void setCursorHideTimeout(int newcursorHideTimeout);
|
|
||||||
void setTrophyNotificationDuration(double newTrophyNotificationDuration);
|
|
||||||
void setBackButtonBehavior(const std::string& type);
|
|
||||||
void setUseSpecialPad(bool use);
|
|
||||||
void setSpecialPadClass(int type);
|
|
||||||
void setIsMotionControlsEnabled(bool use);
|
|
||||||
|
|
||||||
void setLogType(const std::string& type);
|
|
||||||
void setLogFilter(const std::string& type);
|
|
||||||
void setSeparateLogFilesEnabled(bool enabled);
|
|
||||||
bool getSeparateLogFilesEnabled();
|
|
||||||
void setVkValidation(bool enable);
|
|
||||||
void setVkSyncValidation(bool enable);
|
|
||||||
void setRdocEnabled(bool enable);
|
|
||||||
|
|
||||||
bool vkValidationEnabled();
|
|
||||||
bool vkValidationSyncEnabled();
|
|
||||||
bool vkValidationGpuEnabled();
|
|
||||||
bool getVkCrashDiagnosticEnabled();
|
|
||||||
bool getVkHostMarkersEnabled();
|
|
||||||
bool getVkGuestMarkersEnabled();
|
|
||||||
void setVkCrashDiagnosticEnabled(bool enable);
|
|
||||||
void setVkHostMarkersEnabled(bool enable);
|
|
||||||
void setVkGuestMarkersEnabled(bool enable);
|
|
||||||
|
|
||||||
// Gui
|
// Gui
|
||||||
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h);
|
|
||||||
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true);
|
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true);
|
||||||
void removeGameInstallDir(const std::filesystem::path& dir);
|
void removeGameInstallDir(const std::filesystem::path& dir);
|
||||||
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled);
|
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled);
|
||||||
void setAddonInstallDir(const std::filesystem::path& dir);
|
void setAddonInstallDir(const std::filesystem::path& dir);
|
||||||
void setMainWindowTheme(u32 theme);
|
|
||||||
void setIconSize(u32 size);
|
|
||||||
void setIconSizeGrid(u32 size);
|
|
||||||
void setSliderPosition(u32 pos);
|
|
||||||
void setSliderPositionGrid(u32 pos);
|
|
||||||
void setTableMode(u32 mode);
|
|
||||||
void setMainWindowWidth(u32 width);
|
|
||||||
void setMainWindowHeight(u32 height);
|
|
||||||
void setElfViewer(const std::vector<std::string>& elfList);
|
|
||||||
void setRecentFiles(const std::vector<std::string>& recentFiles);
|
|
||||||
void setEmulatorLanguage(std::string language);
|
|
||||||
|
|
||||||
u32 getMainWindowGeometryX();
|
|
||||||
u32 getMainWindowGeometryY();
|
|
||||||
u32 getMainWindowGeometryW();
|
|
||||||
u32 getMainWindowGeometryH();
|
|
||||||
const std::vector<std::filesystem::path> getGameInstallDirs();
|
const std::vector<std::filesystem::path> getGameInstallDirs();
|
||||||
const std::vector<bool> getGameInstallDirsEnabled();
|
const std::vector<bool> getGameInstallDirsEnabled();
|
||||||
std::filesystem::path getAddonInstallDir();
|
std::filesystem::path getAddonInstallDir();
|
||||||
u32 getMainWindowTheme();
|
|
||||||
u32 getIconSize();
|
|
||||||
u32 getIconSizeGrid();
|
|
||||||
u32 getSliderPosition();
|
|
||||||
u32 getSliderPositionGrid();
|
|
||||||
u32 getTableMode();
|
|
||||||
u32 getMainWindowWidth();
|
|
||||||
u32 getMainWindowHeight();
|
|
||||||
std::vector<std::string> getElfViewer();
|
|
||||||
std::vector<std::string> getRecentFiles();
|
|
||||||
std::string getEmulatorLanguage();
|
|
||||||
|
|
||||||
void setDefaultValues();
|
void setDefaultValues();
|
||||||
|
|
||||||
// todo: name and function location pending
|
// todo: name and function location pending
|
||||||
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id = "");
|
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id = "");
|
||||||
|
|
||||||
// settings
|
|
||||||
u32 GetLanguage();
|
|
||||||
}; // namespace Config
|
}; // namespace Config
|
||||||
|
@ -71,6 +71,7 @@ class ElfInfo {
|
|||||||
PSFAttributes psf_attributes{};
|
PSFAttributes psf_attributes{};
|
||||||
|
|
||||||
std::filesystem::path splash_path{};
|
std::filesystem::path splash_path{};
|
||||||
|
std::filesystem::path game_folder{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr u32 FW_15 = 0x1500000;
|
static constexpr u32 FW_15 = 0x1500000;
|
||||||
@ -123,6 +124,10 @@ public:
|
|||||||
[[nodiscard]] const std::filesystem::path& GetSplashPath() const {
|
[[nodiscard]] const std::filesystem::path& GetSplashPath() const {
|
||||||
return splash_path;
|
return splash_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] const std::filesystem::path& GetGameFolder() const {
|
||||||
|
return game_folder;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
@ -186,7 +186,9 @@ public:
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t WriteRaw(const void* data, size_t size) const {
|
size_t WriteRaw(const void* data, size_t size) const {
|
||||||
return std::fwrite(data, sizeof(T), size, file);
|
auto bytes = std::fwrite(data, sizeof(T), size, file);
|
||||||
|
std::fflush(file);
|
||||||
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -140,6 +140,8 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
|||||||
SUB(Lib, SigninDialog) \
|
SUB(Lib, SigninDialog) \
|
||||||
SUB(Lib, Camera) \
|
SUB(Lib, Camera) \
|
||||||
SUB(Lib, CompanionHttpd) \
|
SUB(Lib, CompanionHttpd) \
|
||||||
|
SUB(Lib, CompanionUtil) \
|
||||||
|
SUB(Lib, Voice) \
|
||||||
CLS(Frontend) \
|
CLS(Frontend) \
|
||||||
CLS(Render) \
|
CLS(Render) \
|
||||||
SUB(Render, Vulkan) \
|
SUB(Render, Vulkan) \
|
||||||
|
@ -98,6 +98,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_Voice, ///< The LibSceVoice implementation.
|
||||||
Lib_RazorCpu, ///< The LibRazorCpu implementation.
|
Lib_RazorCpu, ///< The LibRazorCpu implementation.
|
||||||
Lib_Mouse, ///< The LibSceMouse implementation
|
Lib_Mouse, ///< The LibSceMouse implementation
|
||||||
Lib_WebBrowserDialog, ///< The LibSceWebBrowserDialog implementation
|
Lib_WebBrowserDialog, ///< The LibSceWebBrowserDialog implementation
|
||||||
@ -107,6 +108,7 @@ enum class Class : u8 {
|
|||||||
Lib_SigninDialog, ///< The LibSigninDialog implementation.
|
Lib_SigninDialog, ///< The LibSigninDialog implementation.
|
||||||
Lib_Camera, ///< The LibCamera implementation.
|
Lib_Camera, ///< The LibCamera implementation.
|
||||||
Lib_CompanionHttpd, ///< The LibCompanionHttpd implementation.
|
Lib_CompanionHttpd, ///< The LibCompanionHttpd implementation.
|
||||||
|
Lib_CompanionUtil, ///< The LibCompanionUtil implementation.
|
||||||
Frontend, ///< Emulator UI
|
Frontend, ///< Emulator UI
|
||||||
Render, ///< Video Core
|
Render, ///< Video Core
|
||||||
Render_Vulkan, ///< Vulkan backend
|
Render_Vulkan, ///< Vulkan backend
|
||||||
|
101
src/common/range_lock.h
Normal file
101
src/common/range_lock.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
// From boost thread locking
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct RangeLockGuard {
|
||||||
|
Iterator begin;
|
||||||
|
Iterator end;
|
||||||
|
|
||||||
|
RangeLockGuard(Iterator begin_, Iterator end_) : begin(begin_), end(end_) {
|
||||||
|
LockRange(begin, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
void release() {
|
||||||
|
begin = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
~RangeLockGuard() {
|
||||||
|
for (; begin != end; ++begin) {
|
||||||
|
begin->unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
Iterator TryLockRange(Iterator begin, Iterator end) {
|
||||||
|
using LockType = typename std::iterator_traits<Iterator>::value_type;
|
||||||
|
|
||||||
|
if (begin == end) {
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_lock<LockType> guard(*begin, std::try_to_lock);
|
||||||
|
if (!guard.owns_lock()) {
|
||||||
|
return begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator failed = TryLockRange(++begin, end);
|
||||||
|
if (failed == end) {
|
||||||
|
guard.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
void LockRange(Iterator begin, Iterator end) {
|
||||||
|
using LockType = typename std::iterator_traits<Iterator>::value_type;
|
||||||
|
|
||||||
|
if (begin == end) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool start_with_begin = true;
|
||||||
|
Iterator second = begin;
|
||||||
|
++second;
|
||||||
|
Iterator next = second;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
std::unique_lock<LockType> begin_lock(*begin, std::defer_lock);
|
||||||
|
if (start_with_begin) {
|
||||||
|
begin_lock.lock();
|
||||||
|
|
||||||
|
const Iterator failed_lock = TryLockRange(next, end);
|
||||||
|
if (failed_lock == end) {
|
||||||
|
begin_lock.release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
start_with_begin = false;
|
||||||
|
next = failed_lock;
|
||||||
|
} else {
|
||||||
|
RangeLockGuard<Iterator> guard(next, end);
|
||||||
|
|
||||||
|
if (begin_lock.try_lock()) {
|
||||||
|
const Iterator failed_lock = TryLockRange(second, next);
|
||||||
|
if (failed_lock == next) {
|
||||||
|
begin_lock.release();
|
||||||
|
guard.release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
start_with_begin = false;
|
||||||
|
next = failed_lock;
|
||||||
|
} else {
|
||||||
|
start_with_begin = true;
|
||||||
|
next = second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common
|
37
src/common/recursive_lock.cpp
Normal file
37
src/common/recursive_lock.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
#include "common/assert.h"
|
||||||
|
#include "common/recursive_lock.h"
|
||||||
|
|
||||||
|
namespace Common::Detail {
|
||||||
|
|
||||||
|
struct RecursiveLockState {
|
||||||
|
RecursiveLockType type;
|
||||||
|
int count;
|
||||||
|
};
|
||||||
|
|
||||||
|
thread_local std::unordered_map<void*, RecursiveLockState> g_recursive_locks;
|
||||||
|
|
||||||
|
bool IncrementRecursiveLock(void* mutex, RecursiveLockType type) {
|
||||||
|
auto& state = g_recursive_locks[mutex];
|
||||||
|
if (state.count == 0) {
|
||||||
|
ASSERT(state.type == RecursiveLockType::None);
|
||||||
|
state.type = type;
|
||||||
|
}
|
||||||
|
ASSERT(state.type == type);
|
||||||
|
return state.count++ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DecrementRecursiveLock(void* mutex, RecursiveLockType type) {
|
||||||
|
auto& state = g_recursive_locks[mutex];
|
||||||
|
ASSERT(state.type == type && state.count > 0);
|
||||||
|
if (--state.count == 0) {
|
||||||
|
g_recursive_locks.erase(mutex);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common::Detail
|
67
src/common/recursive_lock.h
Normal file
67
src/common/recursive_lock.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <optional>
|
||||||
|
#include <shared_mutex>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
namespace Detail {
|
||||||
|
|
||||||
|
enum class RecursiveLockType { None, Shared, Exclusive };
|
||||||
|
|
||||||
|
bool IncrementRecursiveLock(void* mutex, RecursiveLockType type);
|
||||||
|
bool DecrementRecursiveLock(void* mutex, RecursiveLockType type);
|
||||||
|
|
||||||
|
} // namespace Detail
|
||||||
|
|
||||||
|
template <typename MutexType>
|
||||||
|
class RecursiveScopedLock {
|
||||||
|
public:
|
||||||
|
explicit RecursiveScopedLock(MutexType& mutex) : m_mutex(mutex), m_locked(false) {
|
||||||
|
if (Detail::IncrementRecursiveLock(&m_mutex, Detail::RecursiveLockType::Exclusive)) {
|
||||||
|
m_locked = true;
|
||||||
|
m_lock.emplace(m_mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~RecursiveScopedLock() {
|
||||||
|
Detail::DecrementRecursiveLock(&m_mutex, Detail::RecursiveLockType::Exclusive);
|
||||||
|
if (m_locked) {
|
||||||
|
m_lock.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MutexType& m_mutex;
|
||||||
|
std::optional<std::unique_lock<MutexType>> m_lock;
|
||||||
|
bool m_locked = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename MutexType>
|
||||||
|
class RecursiveSharedLock {
|
||||||
|
public:
|
||||||
|
explicit RecursiveSharedLock(MutexType& mutex) : m_mutex(mutex), m_locked(false) {
|
||||||
|
if (Detail::IncrementRecursiveLock(&m_mutex, Detail::RecursiveLockType::Shared)) {
|
||||||
|
m_locked = true;
|
||||||
|
m_lock.emplace(m_mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~RecursiveSharedLock() {
|
||||||
|
Detail::DecrementRecursiveLock(&m_mutex, Detail::RecursiveLockType::Shared);
|
||||||
|
if (m_locked) {
|
||||||
|
m_lock.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MutexType& m_mutex;
|
||||||
|
std::optional<std::shared_lock<MutexType>> m_lock;
|
||||||
|
bool m_locked = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Common
|
@ -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 <string>
|
||||||
|
|
||||||
#include "common/scm_rev.h"
|
#include "common/scm_rev.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
@ -15,5 +17,26 @@ constexpr char g_scm_remote_name[] = "@GIT_REMOTE_NAME@";
|
|||||||
constexpr char g_scm_remote_url[] = "@GIT_REMOTE_URL@";
|
constexpr char g_scm_remote_url[] = "@GIT_REMOTE_URL@";
|
||||||
constexpr char g_scm_date[] = "@BUILD_DATE@";
|
constexpr char g_scm_date[] = "@BUILD_DATE@";
|
||||||
|
|
||||||
|
const std::string GetRemoteNameFromLink() {
|
||||||
|
std::string remote_url(Common::g_scm_remote_url);
|
||||||
|
std::string remote_host;
|
||||||
|
try {
|
||||||
|
if (remote_url.starts_with("http")) {
|
||||||
|
if (*remote_url.rbegin() == '/') {
|
||||||
|
remote_url.pop_back();
|
||||||
|
}
|
||||||
|
remote_host = remote_url.substr(19, remote_url.rfind('/') - 19);
|
||||||
|
} else if (remote_url.starts_with("git@")) {
|
||||||
|
auto after_comma_pos = remote_url.find(':') + 1, slash_pos = remote_url.find('/');
|
||||||
|
remote_host = remote_url.substr(after_comma_pos, slash_pos - after_comma_pos);
|
||||||
|
} else {
|
||||||
|
remote_host = "unknown";
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
remote_host = "unknown";
|
||||||
|
}
|
||||||
|
return remote_host;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
extern const char g_version[];
|
extern const char g_version[];
|
||||||
@ -15,4 +17,6 @@ extern const char g_scm_remote_name[];
|
|||||||
extern const char g_scm_remote_url[];
|
extern const char g_scm_remote_url[];
|
||||||
extern const char g_scm_date[];
|
extern const char g_scm_date[];
|
||||||
|
|
||||||
|
const std::string GetRemoteNameFromLink();
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
46
src/common/shared_first_mutex.h
Normal file
46
src/common/shared_first_mutex.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
// Like std::shared_mutex, but reader has priority over writer.
|
||||||
|
class SharedFirstMutex {
|
||||||
|
public:
|
||||||
|
void lock() {
|
||||||
|
std::unique_lock<std::mutex> lock(mtx);
|
||||||
|
cv.wait(lock, [this]() { return !writer_active && readers == 0; });
|
||||||
|
writer_active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unlock() {
|
||||||
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
writer_active = false;
|
||||||
|
cv.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lock_shared() {
|
||||||
|
std::unique_lock<std::mutex> lock(mtx);
|
||||||
|
cv.wait(lock, [this]() { return !writer_active; });
|
||||||
|
++readers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unlock_shared() {
|
||||||
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
if (--readers == 0) {
|
||||||
|
cv.notify_all();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::mutex mtx;
|
||||||
|
std::condition_variable cv;
|
||||||
|
int readers = 0;
|
||||||
|
bool writer_active = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Common
|
@ -14,6 +14,9 @@ namespace Common {
|
|||||||
struct SlotId {
|
struct SlotId {
|
||||||
static constexpr u32 INVALID_INDEX = std::numeric_limits<u32>::max();
|
static constexpr u32 INVALID_INDEX = std::numeric_limits<u32>::max();
|
||||||
|
|
||||||
|
SlotId() noexcept = default;
|
||||||
|
constexpr SlotId(u32 index) noexcept : index(index) {}
|
||||||
|
|
||||||
constexpr auto operator<=>(const SlotId&) const noexcept = default;
|
constexpr auto operator<=>(const SlotId&) const noexcept = default;
|
||||||
|
|
||||||
constexpr explicit operator bool() const noexcept {
|
constexpr explicit operator bool() const noexcept {
|
||||||
@ -28,6 +31,63 @@ class SlotVector {
|
|||||||
constexpr static std::size_t InitialCapacity = 2048;
|
constexpr static std::size_t InitialCapacity = 2048;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template <typename ValueType, typename Pointer, typename Reference>
|
||||||
|
class Iterator {
|
||||||
|
public:
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using value_type = ValueType;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using pointer = Pointer;
|
||||||
|
using reference = Reference;
|
||||||
|
|
||||||
|
Iterator(SlotVector& vector_, SlotId index_) : vector(vector_), slot(index_) {
|
||||||
|
AdvanceToValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
reference operator*() const {
|
||||||
|
return vector[slot];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer operator->() const {
|
||||||
|
return &vector[slot];
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator& operator++() {
|
||||||
|
++slot.index;
|
||||||
|
AdvanceToValid();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator operator++(int) {
|
||||||
|
Iterator temp = *this;
|
||||||
|
++(*this);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Iterator& other) const {
|
||||||
|
return slot == other.slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Iterator& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void AdvanceToValid() {
|
||||||
|
while (slot < vector.values_capacity && !vector.ReadStorageBit(slot.index)) {
|
||||||
|
++slot.index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SlotVector& vector;
|
||||||
|
SlotId slot;
|
||||||
|
};
|
||||||
|
|
||||||
|
using iterator = Iterator<T, T*, T&>;
|
||||||
|
using const_iterator = Iterator<const T, const T*, const T&>;
|
||||||
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
|
||||||
SlotVector() {
|
SlotVector() {
|
||||||
Reserve(InitialCapacity);
|
Reserve(InitialCapacity);
|
||||||
}
|
}
|
||||||
@ -60,7 +120,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
[[nodiscard]] SlotId insert(Args&&... args) noexcept {
|
SlotId insert(Args&&... args) noexcept {
|
||||||
const u32 index = FreeValueIndex();
|
const u32 index = FreeValueIndex();
|
||||||
new (&values[index].object) T(std::forward<Args>(args)...);
|
new (&values[index].object) T(std::forward<Args>(args)...);
|
||||||
SetStorageBit(index);
|
SetStorageBit(index);
|
||||||
@ -78,6 +138,54 @@ public:
|
|||||||
return values_capacity - free_list.size();
|
return values_capacity - free_list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iterator begin() noexcept {
|
||||||
|
return iterator(*this, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator begin() const noexcept {
|
||||||
|
return const_iterator(*this, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator cbegin() const noexcept {
|
||||||
|
return begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
iterator end() noexcept {
|
||||||
|
return iterator(*this, values_capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator end() const noexcept {
|
||||||
|
return const_iterator(*this, values_capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator cend() const noexcept {
|
||||||
|
return end();
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rbegin() noexcept {
|
||||||
|
return reverse_iterator(end());
|
||||||
|
}
|
||||||
|
|
||||||
|
const_reverse_iterator rbegin() const noexcept {
|
||||||
|
return const_reverse_iterator(end());
|
||||||
|
}
|
||||||
|
|
||||||
|
const_reverse_iterator crbegin() const noexcept {
|
||||||
|
return rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rend() noexcept {
|
||||||
|
return reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
const_reverse_iterator rend() const noexcept {
|
||||||
|
return const_reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
const_reverse_iterator crend() const noexcept {
|
||||||
|
return rend();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct NonTrivialDummy {
|
struct NonTrivialDummy {
|
||||||
NonTrivialDummy() noexcept {}
|
NonTrivialDummy() noexcept {}
|
||||||
|
@ -302,14 +302,15 @@ struct AddressSpace::Impl {
|
|||||||
new_flags = PAGE_READWRITE;
|
new_flags = PAGE_READWRITE;
|
||||||
} else if (read && !write) {
|
} else if (read && !write) {
|
||||||
new_flags = PAGE_READONLY;
|
new_flags = PAGE_READONLY;
|
||||||
} else if (execute && !read && not write) {
|
} else if (execute && !read && !write) {
|
||||||
new_flags = PAGE_EXECUTE;
|
new_flags = PAGE_EXECUTE;
|
||||||
} else if (!read && !write && !execute) {
|
} else if (!read && !write && !execute) {
|
||||||
new_flags = PAGE_NOACCESS;
|
new_flags = PAGE_NOACCESS;
|
||||||
} else {
|
} else {
|
||||||
LOG_CRITICAL(Common_Memory,
|
LOG_CRITICAL(Common_Memory,
|
||||||
"Unsupported protection flag combination for address {:#x}, size {}",
|
"Unsupported protection flag combination for address {:#x}, size {}, "
|
||||||
virtual_addr, size);
|
"read={}, write={}, execute={}",
|
||||||
|
virtual_addr, size, read, write, execute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,9 +358,17 @@ enum PosixPageProtection {
|
|||||||
[[nodiscard]] constexpr PosixPageProtection ToPosixProt(Core::MemoryProt prot) {
|
[[nodiscard]] constexpr PosixPageProtection ToPosixProt(Core::MemoryProt prot) {
|
||||||
if (True(prot & Core::MemoryProt::CpuReadWrite) ||
|
if (True(prot & Core::MemoryProt::CpuReadWrite) ||
|
||||||
True(prot & Core::MemoryProt::GpuReadWrite)) {
|
True(prot & Core::MemoryProt::GpuReadWrite)) {
|
||||||
return PAGE_READWRITE;
|
if (True(prot & Core::MemoryProt::CpuExec)) {
|
||||||
|
return PAGE_EXECUTE_READWRITE;
|
||||||
|
} else {
|
||||||
|
return PAGE_READWRITE;
|
||||||
|
}
|
||||||
} else if (True(prot & Core::MemoryProt::CpuRead) || True(prot & Core::MemoryProt::GpuRead)) {
|
} else if (True(prot & Core::MemoryProt::CpuRead) || True(prot & Core::MemoryProt::GpuRead)) {
|
||||||
return PAGE_READONLY;
|
if (True(prot & Core::MemoryProt::CpuExec)) {
|
||||||
|
return PAGE_EXECUTE_READ;
|
||||||
|
} else {
|
||||||
|
return PAGE_READONLY;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return PAGE_NOACCESS;
|
return PAGE_NOACCESS;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
enum class MemoryPermission : u32 {
|
enum class MemoryPermission : u32 {
|
||||||
|
None = 0,
|
||||||
Read = 1 << 0,
|
Read = 1 << 0,
|
||||||
Write = 1 << 1,
|
Write = 1 << 1,
|
||||||
ReadWrite = Read | Write,
|
ReadWrite = Read | Write,
|
||||||
|
@ -88,7 +88,8 @@ static bool FilterTcbAccess(const ZydisDecodedOperand* operands) {
|
|||||||
dst_op.reg.value <= ZYDIS_REGISTER_R15;
|
dst_op.reg.value <= ZYDIS_REGISTER_R15;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
static void GenerateTcbAccess(void* /* address */, const ZydisDecodedOperand* operands,
|
||||||
|
Xbyak::CodeGenerator& c) {
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -126,7 +127,8 @@ static bool FilterNoSSE4a(const ZydisDecodedOperand*) {
|
|||||||
return !cpu.has(Cpu::tSSE4a);
|
return !cpu.has(Cpu::tSSE4a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
static void GenerateEXTRQ(void* /* address */, const ZydisDecodedOperand* operands,
|
||||||
|
Xbyak::CodeGenerator& c) {
|
||||||
bool immediateForm = operands[1].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
bool immediateForm = operands[1].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
||||||
operands[2].type == ZYDIS_OPERAND_TYPE_IMMEDIATE;
|
operands[2].type == ZYDIS_OPERAND_TYPE_IMMEDIATE;
|
||||||
|
|
||||||
@ -161,7 +163,9 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera
|
|||||||
mask = (1ULL << length) - 1;
|
mask = (1ULL << length) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_MSG(length + index <= 64, "length + index must be less than or equal to 64.");
|
if (length + index > 64) {
|
||||||
|
mask = 0xFFFF'FFFF'FFFF'FFFF;
|
||||||
|
}
|
||||||
|
|
||||||
// Get lower qword from xmm register
|
// Get lower qword from xmm register
|
||||||
c.vmovq(scratch1, xmm_dst);
|
c.vmovq(scratch1, xmm_dst);
|
||||||
@ -175,8 +179,8 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera
|
|||||||
c.mov(scratch2, mask);
|
c.mov(scratch2, mask);
|
||||||
c.and_(scratch1, scratch2);
|
c.and_(scratch1, scratch2);
|
||||||
|
|
||||||
// Writeback to xmm register, extrq instruction says top 64-bits are undefined so we don't
|
// Writeback to xmm register, extrq instruction says top 64-bits are undefined but zeroed on
|
||||||
// care to preserve them
|
// AMD CPUs
|
||||||
c.vmovq(xmm_dst, scratch1);
|
c.vmovq(xmm_dst, scratch1);
|
||||||
|
|
||||||
c.pop(scratch2);
|
c.pop(scratch2);
|
||||||
@ -245,7 +249,8 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
static void GenerateINSERTQ(void* /* address */, const ZydisDecodedOperand* operands,
|
||||||
|
Xbyak::CodeGenerator& c) {
|
||||||
bool immediateForm = operands[2].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
bool immediateForm = operands[2].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
||||||
operands[3].type == ZYDIS_OPERAND_TYPE_IMMEDIATE;
|
operands[3].type == ZYDIS_OPERAND_TYPE_IMMEDIATE;
|
||||||
|
|
||||||
@ -284,7 +289,9 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
|
|||||||
mask_value = (1ULL << length) - 1;
|
mask_value = (1ULL << length) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_MSG(length + index <= 64, "length + index must be less than or equal to 64.");
|
if (length + index > 64) {
|
||||||
|
mask_value = 0xFFFF'FFFF'FFFF'FFFF;
|
||||||
|
}
|
||||||
|
|
||||||
c.vmovq(scratch1, xmm_src);
|
c.vmovq(scratch1, xmm_src);
|
||||||
c.vmovq(scratch2, xmm_dst);
|
c.vmovq(scratch2, xmm_dst);
|
||||||
@ -304,8 +311,9 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
|
|||||||
// dst |= src
|
// dst |= src
|
||||||
c.or_(scratch2, scratch1);
|
c.or_(scratch2, scratch1);
|
||||||
|
|
||||||
// Insert scratch2 into low 64 bits of dst, upper 64 bits are unaffected
|
// Insert scratch2 into low 64 bits of dst, upper 64 bits are undefined but zeroed on AMD
|
||||||
c.vpinsrq(xmm_dst, xmm_dst, scratch2, 0);
|
// CPUs
|
||||||
|
c.vmovq(xmm_dst, scratch2);
|
||||||
|
|
||||||
c.pop(mask);
|
c.pop(mask);
|
||||||
c.pop(scratch2);
|
c.pop(scratch2);
|
||||||
@ -371,7 +379,7 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
|
|||||||
c.and_(scratch2, mask);
|
c.and_(scratch2, mask);
|
||||||
c.or_(scratch2, scratch1);
|
c.or_(scratch2, scratch1);
|
||||||
|
|
||||||
// Upper 64 bits are undefined in insertq
|
// Upper 64 bits are undefined in insertq but AMD CPUs zero them
|
||||||
c.vmovq(xmm_dst, scratch2);
|
c.vmovq(xmm_dst, scratch2);
|
||||||
|
|
||||||
c.pop(mask);
|
c.pop(mask);
|
||||||
@ -383,8 +391,44 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ReplaceMOVNT(void* address, u8 rep_prefix) {
|
||||||
|
// Find the opcode byte
|
||||||
|
// There can be any amount of prefixes but the instruction can't be more than 15 bytes
|
||||||
|
// And we know for sure this is a MOVNTSS/MOVNTSD
|
||||||
|
bool found = false;
|
||||||
|
bool rep_prefix_found = false;
|
||||||
|
int index = 0;
|
||||||
|
u8* ptr = reinterpret_cast<u8*>(address);
|
||||||
|
for (int i = 0; i < 15; i++) {
|
||||||
|
if (ptr[i] == rep_prefix) {
|
||||||
|
rep_prefix_found = true;
|
||||||
|
} else if (ptr[i] == 0x2B) {
|
||||||
|
index = i;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some sanity checks
|
||||||
|
ASSERT(found);
|
||||||
|
ASSERT(index >= 2);
|
||||||
|
ASSERT(ptr[index - 1] == 0x0F);
|
||||||
|
ASSERT(rep_prefix_found);
|
||||||
|
|
||||||
|
// This turns the MOVNTSS/MOVNTSD to a MOVSS/MOVSD m, xmm
|
||||||
|
ptr[index] = 0x11;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ReplaceMOVNTSS(void* address, const ZydisDecodedOperand*, Xbyak::CodeGenerator&) {
|
||||||
|
ReplaceMOVNT(address, 0xF3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ReplaceMOVNTSD(void* address, const ZydisDecodedOperand*, Xbyak::CodeGenerator&) {
|
||||||
|
ReplaceMOVNT(address, 0xF2);
|
||||||
|
}
|
||||||
|
|
||||||
using PatchFilter = bool (*)(const ZydisDecodedOperand*);
|
using PatchFilter = bool (*)(const ZydisDecodedOperand*);
|
||||||
using InstructionGenerator = void (*)(const ZydisDecodedOperand*, Xbyak::CodeGenerator&);
|
using InstructionGenerator = void (*)(void*, const ZydisDecodedOperand*, Xbyak::CodeGenerator&);
|
||||||
struct PatchInfo {
|
struct PatchInfo {
|
||||||
/// Filter for more granular patch conditions past just the instruction mnemonic.
|
/// Filter for more granular patch conditions past just the instruction mnemonic.
|
||||||
PatchFilter filter;
|
PatchFilter filter;
|
||||||
@ -400,6 +444,8 @@ static const std::unordered_map<ZydisMnemonic, PatchInfo> Patches = {
|
|||||||
// SSE4a
|
// SSE4a
|
||||||
{ZYDIS_MNEMONIC_EXTRQ, {FilterNoSSE4a, GenerateEXTRQ, true}},
|
{ZYDIS_MNEMONIC_EXTRQ, {FilterNoSSE4a, GenerateEXTRQ, true}},
|
||||||
{ZYDIS_MNEMONIC_INSERTQ, {FilterNoSSE4a, GenerateINSERTQ, true}},
|
{ZYDIS_MNEMONIC_INSERTQ, {FilterNoSSE4a, GenerateINSERTQ, true}},
|
||||||
|
{ZYDIS_MNEMONIC_MOVNTSS, {FilterNoSSE4a, ReplaceMOVNTSS, false}},
|
||||||
|
{ZYDIS_MNEMONIC_MOVNTSD, {FilterNoSSE4a, ReplaceMOVNTSD, false}},
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// Windows needs a trampoline.
|
// Windows needs a trampoline.
|
||||||
@ -477,7 +523,7 @@ static std::pair<bool, u64> TryPatch(u8* code, PatchModule* module) {
|
|||||||
auto& trampoline_gen = module->trampoline_gen;
|
auto& trampoline_gen = module->trampoline_gen;
|
||||||
const auto trampoline_ptr = trampoline_gen.getCurr();
|
const auto trampoline_ptr = trampoline_gen.getCurr();
|
||||||
|
|
||||||
patch_info.generator(operands, trampoline_gen);
|
patch_info.generator(code, operands, trampoline_gen);
|
||||||
|
|
||||||
// Return to the following instruction at the end of the trampoline.
|
// Return to the following instruction at the end of the trampoline.
|
||||||
trampoline_gen.jmp(code + instruction.length);
|
trampoline_gen.jmp(code + instruction.length);
|
||||||
@ -485,7 +531,7 @@ static std::pair<bool, u64> TryPatch(u8* code, PatchModule* module) {
|
|||||||
// Replace instruction with near jump to the trampoline.
|
// Replace instruction with near jump to the trampoline.
|
||||||
patch_gen.jmp(trampoline_ptr, Xbyak::CodeGenerator::LabelType::T_NEAR);
|
patch_gen.jmp(trampoline_ptr, Xbyak::CodeGenerator::LabelType::T_NEAR);
|
||||||
} else {
|
} else {
|
||||||
patch_info.generator(operands, patch_gen);
|
patch_info.generator(code, operands, patch_gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto patch_size = patch_gen.getCurr() - code;
|
const auto patch_size = patch_gen.getCurr() - code;
|
||||||
@ -594,6 +640,7 @@ static bool TryExecuteIllegalInstruction(void* ctx, void* code_address) {
|
|||||||
lowQWordDst >>= index;
|
lowQWordDst >>= index;
|
||||||
lowQWordDst &= mask;
|
lowQWordDst &= mask;
|
||||||
|
|
||||||
|
memset((u8*)dst + sizeof(u64), 0, sizeof(u64));
|
||||||
memcpy(dst, &lowQWordDst, sizeof(lowQWordDst));
|
memcpy(dst, &lowQWordDst, sizeof(lowQWordDst));
|
||||||
|
|
||||||
Common::IncrementRip(ctx, 4);
|
Common::IncrementRip(ctx, 4);
|
||||||
@ -634,6 +681,7 @@ static bool TryExecuteIllegalInstruction(void* ctx, void* code_address) {
|
|||||||
lowQWordDst &= ~(mask << index);
|
lowQWordDst &= ~(mask << index);
|
||||||
lowQWordDst |= lowQWordSrc << index;
|
lowQWordDst |= lowQWordSrc << index;
|
||||||
|
|
||||||
|
memset((u8*)dst + sizeof(u64), 0, sizeof(u64));
|
||||||
memcpy(dst, &lowQWordDst, sizeof(lowQWordDst));
|
memcpy(dst, &lowQWordDst, sizeof(lowQWordDst));
|
||||||
|
|
||||||
Common::IncrementRip(ctx, 4);
|
Common::IncrementRip(ctx, 4);
|
||||||
@ -705,6 +753,10 @@ static bool PatchesIllegalInstructionHandler(void* context) {
|
|||||||
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
|
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
|
||||||
const auto status =
|
const auto status =
|
||||||
Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address);
|
Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address);
|
||||||
|
if (ZYAN_SUCCESS(status) && instruction.mnemonic == ZydisMnemonic::ZYDIS_MNEMONIC_UD2)
|
||||||
|
[[unlikely]] {
|
||||||
|
UNREACHABLE_MSG("ud2 at code address {:#x}", (u64)code_address);
|
||||||
|
}
|
||||||
LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: {}", (u64)code_address,
|
LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: {}", (u64)code_address,
|
||||||
ZYAN_SUCCESS(status) ? ZydisMnemonicGetString(instruction.mnemonic)
|
ZYAN_SUCCESS(status) ? ZydisMnemonicGetString(instruction.mnemonic)
|
||||||
: "Failed to decode");
|
: "Failed to decode");
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#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/memory_map.h"
|
||||||
|
#include "widget/module_list.h"
|
||||||
#include "widget/shader_list.h"
|
#include "widget/shader_list.h"
|
||||||
|
|
||||||
extern std::unique_ptr<Vulkan::Presenter> presenter;
|
extern std::unique_ptr<Vulkan::Presenter> presenter;
|
||||||
@ -40,6 +41,7 @@ static bool just_opened_options = false;
|
|||||||
|
|
||||||
static Widget::MemoryMapViewer memory_map;
|
static Widget::MemoryMapViewer memory_map;
|
||||||
static Widget::ShaderList shader_list;
|
static Widget::ShaderList shader_list;
|
||||||
|
static Widget::ModuleList module_list;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static std::string help_text =
|
static std::string help_text =
|
||||||
@ -108,6 +110,9 @@ void L::DrawMenuBar() {
|
|||||||
if (MenuItem("Memory map")) {
|
if (MenuItem("Memory map")) {
|
||||||
memory_map.open = true;
|
memory_map.open = true;
|
||||||
}
|
}
|
||||||
|
if (MenuItem("Module list")) {
|
||||||
|
module_list.open = true;
|
||||||
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +261,9 @@ void L::DrawAdvanced() {
|
|||||||
if (shader_list.open) {
|
if (shader_list.open) {
|
||||||
shader_list.Draw();
|
shader_list.Draw();
|
||||||
}
|
}
|
||||||
|
if (module_list.open) {
|
||||||
|
module_list.Draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void L::DrawSimple() {
|
void L::DrawSimple() {
|
||||||
|
55
src/core/devtools/widget/module_list.cpp
Normal file
55
src/core/devtools/widget/module_list.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "module_list.h"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "core/debug_state.h"
|
||||||
|
#include "imgui/imgui_std.h"
|
||||||
|
|
||||||
|
using namespace ImGui;
|
||||||
|
|
||||||
|
namespace Core::Devtools::Widget {
|
||||||
|
void ModuleList::Draw() {
|
||||||
|
SetNextWindowSize({550.0f, 600.0f}, ImGuiCond_FirstUseEver);
|
||||||
|
if (!Begin("Module List", &open)) {
|
||||||
|
End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BeginTable("ModuleTable", 3,
|
||||||
|
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable |
|
||||||
|
ImGuiTableFlags_RowBg)) {
|
||||||
|
TableSetupColumn("Modulname", ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
TableHeadersRow();
|
||||||
|
|
||||||
|
std::scoped_lock lock(modules_mutex);
|
||||||
|
for (const auto& module : modules) {
|
||||||
|
TableNextRow();
|
||||||
|
|
||||||
|
TableSetColumnIndex(0);
|
||||||
|
TextUnformatted(module.name.c_str());
|
||||||
|
|
||||||
|
TableSetColumnIndex(1);
|
||||||
|
if (module.is_sys_module) {
|
||||||
|
TextColored({0.2f, 0.6f, 0.8f, 1.0f}, "System Module");
|
||||||
|
} else {
|
||||||
|
TextColored({0.8f, 0.4f, 0.2f, 1.0f}, "Game Module");
|
||||||
|
}
|
||||||
|
|
||||||
|
TableSetColumnIndex(2);
|
||||||
|
if (module.is_lle) {
|
||||||
|
TextColored({0.4f, 0.7f, 0.4f, 1.0f}, "LLE");
|
||||||
|
} else {
|
||||||
|
TextColored({0.7f, 0.4f, 0.5f, 1.0f}, "HLE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
End();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core::Devtools::Widget
|
82
src/core/devtools/widget/module_list.h
Normal file
82
src/core/devtools/widget/module_list.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "common/elf_info.h"
|
||||||
|
#include "common/path_util.h"
|
||||||
|
|
||||||
|
namespace Core::Devtools::Widget {
|
||||||
|
|
||||||
|
class ModuleList {
|
||||||
|
public:
|
||||||
|
ModuleList() = default;
|
||||||
|
~ModuleList() = default;
|
||||||
|
|
||||||
|
void Draw();
|
||||||
|
bool open = false;
|
||||||
|
|
||||||
|
static bool IsSystemModule(const std::filesystem::path& path) {
|
||||||
|
const auto sys_modules_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir);
|
||||||
|
|
||||||
|
const auto abs_path = std::filesystem::absolute(path).lexically_normal();
|
||||||
|
const auto abs_sys_path = std::filesystem::absolute(sys_modules_path).lexically_normal();
|
||||||
|
|
||||||
|
const auto path_str = abs_path.string();
|
||||||
|
const auto sys_path_str = abs_sys_path.string();
|
||||||
|
|
||||||
|
return path_str.starts_with(sys_path_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsSystemModule(const std::string& name) {
|
||||||
|
const auto game_modules_path = Common::ElfInfo::Instance().GetGameFolder() / "sce_module";
|
||||||
|
const auto prx_path = game_modules_path / name;
|
||||||
|
|
||||||
|
if (!std::filesystem::exists(prx_path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AddModule(const std::string& name, std::filesystem::path path) {
|
||||||
|
if (name == "eboot.bin") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::scoped_lock lock(modules_mutex);
|
||||||
|
modules.push_back({name, IsSystemModule(path), true});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AddModule(std::string name) {
|
||||||
|
name = name + ".prx";
|
||||||
|
std::scoped_lock lock(modules_mutex);
|
||||||
|
|
||||||
|
bool is_sys_module = IsSystemModule(name);
|
||||||
|
bool is_lle = false;
|
||||||
|
auto it = std::find_if(modules.begin(), modules.end(),
|
||||||
|
[&name, is_sys_module, is_lle](const ModuleInfo& entry) {
|
||||||
|
return entry.name == name && !entry.is_lle;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it == modules.end()) {
|
||||||
|
modules.push_back({name, is_sys_module, is_lle});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct ModuleInfo {
|
||||||
|
std::string name;
|
||||||
|
bool is_sys_module;
|
||||||
|
bool is_lle;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline std::mutex modules_mutex;
|
||||||
|
|
||||||
|
static inline std::vector<ModuleInfo> modules;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core::Devtools::Widget
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
namespace Core::FileSys {
|
namespace Core::FileSys {
|
||||||
|
|
||||||
|
bool MntPoints::ignore_game_patches = false;
|
||||||
|
|
||||||
std::string RemoveTrailingSlashes(const std::string& path) {
|
std::string RemoveTrailingSlashes(const std::string& path) {
|
||||||
// Remove trailing slashes to make comparisons simpler.
|
// Remove trailing slashes to make comparisons simpler.
|
||||||
std::string path_sanitized = path;
|
std::string path_sanitized = path;
|
||||||
@ -77,7 +79,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
|
|||||||
patch_path /= rel_path;
|
patch_path /= rel_path;
|
||||||
|
|
||||||
if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) &&
|
if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) &&
|
||||||
!force_base_path && std::filesystem::exists(patch_path)) {
|
!force_base_path && !ignore_game_patches && std::filesystem::exists(patch_path)) {
|
||||||
return patch_path;
|
return patch_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +139,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
|
|||||||
return std::optional<std::filesystem::path>(current_path);
|
return std::optional<std::filesystem::path>(current_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!force_base_path) {
|
if (!force_base_path && !ignore_game_patches) {
|
||||||
if (const auto path = search(patch_path)) {
|
if (const auto path = search(patch_path)) {
|
||||||
return *path;
|
return *path;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class MntPoints {
|
|||||||
static constexpr bool NeedsCaseInsensitiveSearch = true;
|
static constexpr bool NeedsCaseInsensitiveSearch = true;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
|
static bool ignore_game_patches;
|
||||||
struct MntPair {
|
struct MntPair {
|
||||||
std::filesystem::path host_path;
|
std::filesystem::path host_path;
|
||||||
std::string mount; // e.g /app0
|
std::string mount; // e.g /app0
|
||||||
|
@ -219,7 +219,7 @@ int PS4_SYSV_ABI sceAjmStrError() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceAjm(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("NVDXiUesSbA", "libSceAjm", 1, "libSceAjm", 1, 1, sceAjmBatchCancel);
|
LIB_FUNCTION("NVDXiUesSbA", "libSceAjm", 1, "libSceAjm", 1, 1, sceAjmBatchCancel);
|
||||||
LIB_FUNCTION("WfAiBW8Wcek", "libSceAjm", 1, "libSceAjm", 1, 1, sceAjmBatchErrorDump);
|
LIB_FUNCTION("WfAiBW8Wcek", "libSceAjm", 1, "libSceAjm", 1, 1, sceAjmBatchErrorDump);
|
||||||
LIB_FUNCTION("dmDybN--Fn8", "libSceAjm", 1, "libSceAjm", 1, 1, sceAjmBatchJobControlBufferRa);
|
LIB_FUNCTION("dmDybN--Fn8", "libSceAjm", 1, "libSceAjm", 1, 1, sceAjmBatchJobControlBufferRa);
|
||||||
|
@ -229,5 +229,5 @@ int PS4_SYSV_ABI sceAjmModuleRegister(u32 context, AjmCodecType codec_type, s64
|
|||||||
int PS4_SYSV_ABI sceAjmModuleUnregister();
|
int PS4_SYSV_ABI sceAjmModuleUnregister();
|
||||||
int PS4_SYSV_ABI sceAjmStrError();
|
int PS4_SYSV_ABI sceAjmStrError();
|
||||||
|
|
||||||
void RegisterlibSceAjm(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Ajm
|
} // namespace Libraries::Ajm
|
||||||
|
@ -369,7 +369,7 @@ int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceAppContent(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("AS45QoYHjc4", "libSceAppContent", 1, "libSceAppContentUtil", 1, 1, _Z5dummyv);
|
LIB_FUNCTION("AS45QoYHjc4", "libSceAppContent", 1, "libSceAppContentUtil", 1, 1, _Z5dummyv);
|
||||||
LIB_FUNCTION("ZiATpP9gEkA", "libSceAppContent", 1, "libSceAppContentUtil", 1, 1,
|
LIB_FUNCTION("ZiATpP9gEkA", "libSceAppContent", 1, "libSceAppContentUtil", 1, 1,
|
||||||
sceAppContentAddcontDelete);
|
sceAppContentAddcontDelete);
|
||||||
|
@ -119,5 +119,5 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfoByEntitlementId();
|
|||||||
int PS4_SYSV_ABI sceAppContentGetAddcontInfoListByIroTag();
|
int PS4_SYSV_ABI sceAppContentGetAddcontInfoListByIroTag();
|
||||||
int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry();
|
int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry();
|
||||||
|
|
||||||
void RegisterlibSceAppContent(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::AppContent
|
} // namespace Libraries::AppContent
|
||||||
|
@ -3,18 +3,21 @@
|
|||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/audio/audioin.h"
|
#include "core/libraries/audio/audioin.h"
|
||||||
|
#include "core/libraries/audio/sdl_in.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::AudioIn {
|
namespace Libraries::AudioIn {
|
||||||
|
|
||||||
|
static std::unique_ptr<SDLAudioIn> audio = std::make_unique<SDLAudioIn>();
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInChangeAppModuleState() {
|
int PS4_SYSV_ABI sceAudioInChangeAppModuleState() {
|
||||||
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
|
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInClose() {
|
int PS4_SYSV_ABI sceAudioInClose(s32 handle) {
|
||||||
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
|
audio->AudioInClose(handle);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,9 +96,13 @@ int PS4_SYSV_ABI sceAudioInGetSilentState() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInHqOpen() {
|
int PS4_SYSV_ABI sceAudioInHqOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||||
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
|
u32 index, u32 len, u32 freq, u32 param) {
|
||||||
return ORBIS_OK;
|
int result = audio->AudioInOpen(type, len, freq, param);
|
||||||
|
if (result < 0) {
|
||||||
|
LOG_ERROR(Lib_AudioIn, "Error returned {:#x}", result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInHqOpenEx() {
|
int PS4_SYSV_ABI sceAudioInHqOpenEx() {
|
||||||
@ -108,9 +115,8 @@ int PS4_SYSV_ABI sceAudioInInit() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInInput() {
|
int PS4_SYSV_ABI sceAudioInInput(s32 handle, void* dest) {
|
||||||
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
|
return audio->AudioInInput(handle, dest);
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInInputs() {
|
int PS4_SYSV_ABI sceAudioInInputs() {
|
||||||
@ -123,9 +129,13 @@ int PS4_SYSV_ABI sceAudioInIsSharedDevice() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInOpen() {
|
int PS4_SYSV_ABI sceAudioInOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||||
LOG_ERROR(Lib_AudioIn, "(DUMMY) called");
|
u32 index, u32 len, u32 freq, u32 param) {
|
||||||
return 0x80260005; // ports are full return
|
int result = audio->AudioInOpen(type, len, freq, param);
|
||||||
|
if (result < 0) {
|
||||||
|
LOG_ERROR(Lib_AudioIn, "Error returned {:#x}", result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInOpenEx() {
|
int PS4_SYSV_ABI sceAudioInOpenEx() {
|
||||||
@ -218,7 +228,7 @@ int PS4_SYSV_ABI sceAudioInVmicWrite() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceAudioIn(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("IQtWgnrw6v8", "libSceAudioIn", 1, "libSceAudioIn", 1, 1,
|
LIB_FUNCTION("IQtWgnrw6v8", "libSceAudioIn", 1, "libSceAudioIn", 1, 1,
|
||||||
sceAudioInChangeAppModuleState);
|
sceAudioInChangeAppModuleState);
|
||||||
LIB_FUNCTION("Jh6WbHhnI68", "libSceAudioIn", 1, "libSceAudioIn", 1, 1, sceAudioInClose);
|
LIB_FUNCTION("Jh6WbHhnI68", "libSceAudioIn", 1, "libSceAudioIn", 1, 1, sceAudioInClose);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <core/libraries/system/userservice.h>
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
@ -11,8 +12,12 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::AudioIn {
|
namespace Libraries::AudioIn {
|
||||||
|
|
||||||
|
enum class OrbisAudioInParamFormat : u32 { S16Mono = 0, S16Stereo = 2 };
|
||||||
|
|
||||||
|
enum class OrbisAudioInType : u32 { VoiceChat = 0, General = 1, VoiceRecognition = 5 };
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioInChangeAppModuleState();
|
int PS4_SYSV_ABI sceAudioInChangeAppModuleState();
|
||||||
int PS4_SYSV_ABI sceAudioInClose();
|
int PS4_SYSV_ABI sceAudioInClose(s32 handle);
|
||||||
int PS4_SYSV_ABI sceAudioInCountPorts();
|
int PS4_SYSV_ABI sceAudioInCountPorts();
|
||||||
int PS4_SYSV_ABI sceAudioInDeviceHqOpen();
|
int PS4_SYSV_ABI sceAudioInDeviceHqOpen();
|
||||||
int PS4_SYSV_ABI sceAudioInDeviceIdHqOpen();
|
int PS4_SYSV_ABI sceAudioInDeviceIdHqOpen();
|
||||||
@ -28,13 +33,15 @@ int PS4_SYSV_ABI sceAudioInGetGain();
|
|||||||
int PS4_SYSV_ABI sceAudioInGetHandleStatusInfo();
|
int PS4_SYSV_ABI sceAudioInGetHandleStatusInfo();
|
||||||
int PS4_SYSV_ABI sceAudioInGetRerouteCount();
|
int PS4_SYSV_ABI sceAudioInGetRerouteCount();
|
||||||
int PS4_SYSV_ABI sceAudioInGetSilentState();
|
int PS4_SYSV_ABI sceAudioInGetSilentState();
|
||||||
int PS4_SYSV_ABI sceAudioInHqOpen();
|
int PS4_SYSV_ABI sceAudioInHqOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||||
|
u32 index, u32 len, u32 freq, u32 param);
|
||||||
int PS4_SYSV_ABI sceAudioInHqOpenEx();
|
int PS4_SYSV_ABI sceAudioInHqOpenEx();
|
||||||
int PS4_SYSV_ABI sceAudioInInit();
|
int PS4_SYSV_ABI sceAudioInInit();
|
||||||
int PS4_SYSV_ABI sceAudioInInput();
|
int PS4_SYSV_ABI sceAudioInInput(s32 handle, void* dest);
|
||||||
int PS4_SYSV_ABI sceAudioInInputs();
|
int PS4_SYSV_ABI sceAudioInInputs();
|
||||||
int PS4_SYSV_ABI sceAudioInIsSharedDevice();
|
int PS4_SYSV_ABI sceAudioInIsSharedDevice();
|
||||||
int PS4_SYSV_ABI sceAudioInOpen();
|
int PS4_SYSV_ABI sceAudioInOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||||
|
u32 index, u32 len, u32 freq, u32 param);
|
||||||
int PS4_SYSV_ABI sceAudioInOpenEx();
|
int PS4_SYSV_ABI sceAudioInOpenEx();
|
||||||
int PS4_SYSV_ABI sceAudioInSetAllMute();
|
int PS4_SYSV_ABI sceAudioInSetAllMute();
|
||||||
int PS4_SYSV_ABI sceAudioInSetCompressorPreGain();
|
int PS4_SYSV_ABI sceAudioInSetCompressorPreGain();
|
||||||
@ -54,5 +61,5 @@ int PS4_SYSV_ABI sceAudioInVmicCreate();
|
|||||||
int PS4_SYSV_ABI sceAudioInVmicDestroy();
|
int PS4_SYSV_ABI sceAudioInVmicDestroy();
|
||||||
int PS4_SYSV_ABI sceAudioInVmicWrite();
|
int PS4_SYSV_ABI sceAudioInVmicWrite();
|
||||||
|
|
||||||
void RegisterlibSceAudioIn(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::AudioIn
|
} // namespace Libraries::AudioIn
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "core/libraries/audio/audioout.h"
|
#include "core/libraries/audio/audioout.h"
|
||||||
#include "core/libraries/audio/audioout_backend.h"
|
#include "core/libraries/audio/audioout_backend.h"
|
||||||
#include "core/libraries/audio/audioout_error.h"
|
#include "core/libraries/audio/audioout_error.h"
|
||||||
|
#include "core/libraries/kernel/time.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::AudioOut {
|
namespace Libraries::AudioOut {
|
||||||
@ -168,8 +169,19 @@ int PS4_SYSV_ABI sceAudioOutGetInfoOpenNum() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() {
|
int PS4_SYSV_ABI sceAudioOutGetLastOutputTime(s32 handle, u64* output_time) {
|
||||||
LOG_ERROR(Lib_AudioOut, "(STUBBED) called");
|
LOG_DEBUG(Lib_AudioOut, "called, handle: {}, output time: {}", handle, fmt::ptr(output_time));
|
||||||
|
if (!output_time) {
|
||||||
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_POINTER;
|
||||||
|
}
|
||||||
|
if (handle >= ports_out.size()) {
|
||||||
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
auto& port = ports_out.at(handle - 1);
|
||||||
|
if (!port.IsOpen()) {
|
||||||
|
return ORBIS_AUDIO_OUT_ERROR_NOT_OPENED;
|
||||||
|
}
|
||||||
|
*output_time = port.last_output_time;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,6 +408,7 @@ s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, void* ptr) {
|
|||||||
if (ptr != nullptr && port.IsOpen()) {
|
if (ptr != nullptr && port.IsOpen()) {
|
||||||
std::memcpy(port.output_buffer, ptr, port.BufferSize());
|
std::memcpy(port.output_buffer, ptr, port.BufferSize());
|
||||||
port.output_ready = true;
|
port.output_ready = true;
|
||||||
|
port.last_output_time = Kernel::sceKernelGetProcessTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
port.output_cv.notify_one();
|
port.output_cv.notify_one();
|
||||||
@ -523,9 +536,24 @@ s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
|
|||||||
}
|
}
|
||||||
port.impl->SetVolume(port.volume);
|
port.impl->SetVolume(port.volume);
|
||||||
}
|
}
|
||||||
|
AdjustVol();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdjustVol() {
|
||||||
|
if (audio == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ports_out.size(); i++) {
|
||||||
|
std::unique_lock lock{ports_out[i].mutex};
|
||||||
|
if (!ports_out[i].IsOpen()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ports_out[i].impl->SetVolume(ports_out[i].volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
||||||
LOG_ERROR(Lib_AudioOut, "(STUBBED) called");
|
LOG_ERROR(Lib_AudioOut, "(STUBBED) called");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -596,7 +624,7 @@ int PS4_SYSV_ABI sceAudioOutSetSystemDebugState() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceAudioOut(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("cx2dYFbzIAg", "libSceAudioOutDeviceService", 1, "libSceAudioOut", 1, 1,
|
LIB_FUNCTION("cx2dYFbzIAg", "libSceAudioOutDeviceService", 1, "libSceAudioOut", 1, 1,
|
||||||
sceAudioOutDeviceIdOpen);
|
sceAudioOutDeviceIdOpen);
|
||||||
LIB_FUNCTION("tKumjQSzhys", "libSceAudioDeviceControl", 1, "libSceAudioOut", 1, 1,
|
LIB_FUNCTION("tKumjQSzhys", "libSceAudioDeviceControl", 1, "libSceAudioOut", 1, 1,
|
||||||
|
@ -96,6 +96,7 @@ struct PortOut {
|
|||||||
AudioFormatInfo format_info;
|
AudioFormatInfo format_info;
|
||||||
u32 sample_rate;
|
u32 sample_rate;
|
||||||
u32 buffer_frames;
|
u32 buffer_frames;
|
||||||
|
u64 last_output_time;
|
||||||
std::array<s32, 8> volume;
|
std::array<s32, 8> volume;
|
||||||
|
|
||||||
[[nodiscard]] bool IsOpen() const {
|
[[nodiscard]] bool IsOpen() const {
|
||||||
@ -127,7 +128,7 @@ int PS4_SYSV_ABI sceAudioOutGetFocusEnablePid();
|
|||||||
int PS4_SYSV_ABI sceAudioOutGetHandleStatusInfo();
|
int PS4_SYSV_ABI sceAudioOutGetHandleStatusInfo();
|
||||||
int PS4_SYSV_ABI sceAudioOutGetInfo();
|
int PS4_SYSV_ABI sceAudioOutGetInfo();
|
||||||
int PS4_SYSV_ABI sceAudioOutGetInfoOpenNum();
|
int PS4_SYSV_ABI sceAudioOutGetInfoOpenNum();
|
||||||
int PS4_SYSV_ABI sceAudioOutGetLastOutputTime();
|
int PS4_SYSV_ABI sceAudioOutGetLastOutputTime(s32 handle, u64* output_time);
|
||||||
int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state);
|
int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state);
|
||||||
int PS4_SYSV_ABI sceAudioOutGetSimulatedBusUsableStatusByBusType();
|
int PS4_SYSV_ABI sceAudioOutGetSimulatedBusUsableStatusByBusType();
|
||||||
int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo();
|
int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo();
|
||||||
@ -181,5 +182,6 @@ int PS4_SYSV_ABI sceAudioOutSystemControlSet();
|
|||||||
int PS4_SYSV_ABI sceAudioOutSparkControlSetEqCoef();
|
int PS4_SYSV_ABI sceAudioOutSparkControlSetEqCoef();
|
||||||
int PS4_SYSV_ABI sceAudioOutSetSystemDebugState();
|
int PS4_SYSV_ABI sceAudioOutSetSystemDebugState();
|
||||||
|
|
||||||
void RegisterlibSceAudioOut(Core::Loader::SymbolsResolver* sym);
|
void AdjustVol();
|
||||||
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::AudioOut
|
} // namespace Libraries::AudioOut
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <SDL3/SDL_audio.h>
|
#include <SDL3/SDL_audio.h>
|
||||||
#include <SDL3/SDL_hints.h>
|
#include <SDL3/SDL_hints.h>
|
||||||
|
#include <common/config.h>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/audio/audioout.h"
|
#include "core/libraries/audio/audioout.h"
|
||||||
@ -41,6 +42,7 @@ public:
|
|||||||
stream = nullptr;
|
stream = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SDL_SetAudioStreamGain(stream, Config::getVolumeSlider() / 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SDLPortBackend() override {
|
~SDLPortBackend() override {
|
||||||
@ -77,7 +79,8 @@ public:
|
|||||||
}
|
}
|
||||||
// SDL does not have per-channel volumes, for now just take the maximum of the channels.
|
// SDL does not have per-channel volumes, for now just take the maximum of the channels.
|
||||||
const auto vol = *std::ranges::max_element(ch_volumes);
|
const auto vol = *std::ranges::max_element(ch_volumes);
|
||||||
if (!SDL_SetAudioStreamGain(stream, static_cast<float>(vol) / SCE_AUDIO_OUT_VOLUME_0DB)) {
|
if (!SDL_SetAudioStreamGain(stream, static_cast<float>(vol) / SCE_AUDIO_OUT_VOLUME_0DB *
|
||||||
|
Config::getVolumeSlider() / 100.0f)) {
|
||||||
LOG_WARNING(Lib_AudioOut, "Failed to change SDL audio stream volume: {}",
|
LOG_WARNING(Lib_AudioOut, "Failed to change SDL audio stream volume: {}",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
}
|
}
|
||||||
|
135
src/core/libraries/audio/sdl_in.cpp
Normal file
135
src/core/libraries/audio/sdl_in.cpp
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <common/config.h>
|
||||||
|
#include <common/logging/log.h>
|
||||||
|
#include "sdl_in.h"
|
||||||
|
|
||||||
|
int SDLAudioIn::AudioInit() {
|
||||||
|
return SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDLAudioIn::AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint32_t format) {
|
||||||
|
std::scoped_lock lock{m_mutex};
|
||||||
|
|
||||||
|
for (int id = 0; id < static_cast<int>(portsIn.size()); ++id) {
|
||||||
|
auto& port = portsIn[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 Libraries::AudioIn::ORBIS_AUDIO_IN_PARAM_FORMAT_S16_MONO:
|
||||||
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
|
port.channels_num = 1;
|
||||||
|
port.sample_size = 2;
|
||||||
|
break;
|
||||||
|
case Libraries::AudioIn::ORBIS_AUDIO_IN_PARAM_FORMAT_S16_STEREO:
|
||||||
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
|
port.channels_num = 2;
|
||||||
|
port.sample_size = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
port.isOpen = false;
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_AudioSpec fmt;
|
||||||
|
SDL_zero(fmt);
|
||||||
|
fmt.format = sampleFormat;
|
||||||
|
fmt.channels = port.channels_num;
|
||||||
|
fmt.freq = port.freq;
|
||||||
|
|
||||||
|
std::string micDevStr = Config::getMicDevice();
|
||||||
|
uint32_t devId;
|
||||||
|
|
||||||
|
if (micDevStr == "None") {
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
} else if (micDevStr == "Default Device") {
|
||||||
|
devId = SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
devId = static_cast<uint32_t>(std::stoul(micDevStr));
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
port.stream = SDL_OpenAudioDeviceStream(devId, &fmt, nullptr, nullptr);
|
||||||
|
|
||||||
|
if (!port.stream) {
|
||||||
|
port.isOpen = false;
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_ResumeAudioStreamDevice(port.stream) == false) {
|
||||||
|
SDL_DestroyAudioStream(port.stream);
|
||||||
|
port = {};
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_STREAM_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDLAudioIn::AudioInInput(int handle, void* out_buffer) {
|
||||||
|
std::scoped_lock lock{m_mutex};
|
||||||
|
|
||||||
|
if (handle < 1 || handle > static_cast<int>(portsIn.size()) || !out_buffer)
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
|
||||||
|
auto& port = portsIn[handle - 1];
|
||||||
|
if (!port.isOpen)
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||||
|
|
||||||
|
const int bytesToRead = port.samples_num * port.sample_size * port.channels_num;
|
||||||
|
|
||||||
|
if (out_buffer == nullptr) {
|
||||||
|
int attempts = 0;
|
||||||
|
while (SDL_GetAudioStreamAvailable(port.stream) > 0) {
|
||||||
|
SDL_Delay(1);
|
||||||
|
if (++attempts > 1000) {
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; // done
|
||||||
|
}
|
||||||
|
|
||||||
|
int attempts = 0;
|
||||||
|
while (SDL_GetAudioStreamAvailable(port.stream) < bytesToRead) {
|
||||||
|
SDL_Delay(1);
|
||||||
|
if (++attempts > 1000) {
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int bytesRead = SDL_GetAudioStreamData(port.stream, out_buffer, bytesToRead);
|
||||||
|
if (bytesRead < 0) {
|
||||||
|
// SDL_GetAudioStreamData failed
|
||||||
|
LOG_ERROR(Lib_AudioIn, "AudioInInput error: {}", SDL_GetError());
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_STREAM_FAIL;
|
||||||
|
}
|
||||||
|
const int framesRead = bytesRead / (port.sample_size * port.channels_num);
|
||||||
|
return framesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDLAudioIn::AudioInClose(int handle) {
|
||||||
|
std::scoped_lock lock{m_mutex};
|
||||||
|
if (handle < 1 || handle > (int)portsIn.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto& port = portsIn[handle - 1];
|
||||||
|
if (!port.isOpen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_DestroyAudioStream(port.stream);
|
||||||
|
port = {};
|
||||||
|
}
|
42
src/core/libraries/audio/sdl_in.h
Normal file
42
src/core/libraries/audio/sdl_in.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 <array>
|
||||||
|
#include <mutex>
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
namespace Libraries::AudioIn {
|
||||||
|
enum OrbisAudioInParam {
|
||||||
|
ORBIS_AUDIO_IN_PARAM_FORMAT_S16_MONO = 0,
|
||||||
|
ORBIS_AUDIO_IN_PARAM_FORMAT_S16_STEREO = 2
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ORBIS_AUDIO_IN_ERROR_INVALID_PORT -1
|
||||||
|
#define ORBIS_AUDIO_IN_ERROR_TIMEOUT -2
|
||||||
|
#define ORBIS_AUDIO_IN_ERROR_STREAM_FAIL -3
|
||||||
|
|
||||||
|
class SDLAudioIn {
|
||||||
|
public:
|
||||||
|
int AudioInit();
|
||||||
|
int AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint32_t format);
|
||||||
|
int AudioInInput(int handle, void* out_buffer);
|
||||||
|
void AudioInClose(int handle);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct AudioInPort {
|
||||||
|
bool isOpen = false;
|
||||||
|
int type = 0;
|
||||||
|
uint32_t samples_num = 0;
|
||||||
|
uint32_t freq = 0;
|
||||||
|
int channels_num = 0;
|
||||||
|
int sample_size = 0;
|
||||||
|
uint32_t format = 0;
|
||||||
|
SDL_AudioStream* stream = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::array<AudioInPort, 8> portsIn;
|
||||||
|
std::mutex m_mutex;
|
||||||
|
};
|
@ -526,11 +526,18 @@ s32 PS4_SYSV_ABI sceAudio3dStrError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceAudio3dTerminate() {
|
s32 PS4_SYSV_ABI sceAudio3dTerminate() {
|
||||||
LOG_ERROR(Lib_Audio3d, "(STUBBED) called");
|
LOG_INFO(Lib_Audio3d, "called");
|
||||||
|
if (!state) {
|
||||||
|
return ORBIS_AUDIO3D_ERROR_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioOut::sceAudioOutOutput(state->audio_out_handle, nullptr);
|
||||||
|
AudioOut::sceAudioOutClose(state->audio_out_handle);
|
||||||
|
state.release();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("pZlOm1aF3aA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutClose);
|
LIB_FUNCTION("pZlOm1aF3aA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutClose);
|
||||||
LIB_FUNCTION("ucEsi62soTo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutOpen);
|
LIB_FUNCTION("ucEsi62soTo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutOpen);
|
||||||
LIB_FUNCTION("7NYEzJ9SJbM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1,
|
LIB_FUNCTION("7NYEzJ9SJbM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1,
|
||||||
|
@ -141,5 +141,5 @@ s32 PS4_SYSV_ABI sceAudio3dSetGpuRenderer();
|
|||||||
s32 PS4_SYSV_ABI sceAudio3dStrError();
|
s32 PS4_SYSV_ABI sceAudio3dStrError();
|
||||||
s32 PS4_SYSV_ABI sceAudio3dTerminate();
|
s32 PS4_SYSV_ABI sceAudio3dTerminate();
|
||||||
|
|
||||||
void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Audio3d
|
} // namespace Libraries::Audio3d
|
||||||
|
@ -278,7 +278,7 @@ s32 PS4_SYSV_ABI sceAvPlayerVprintf(const char* format, va_list args) {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceAvPlayer(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("KMcEa+rHsIo", "libSceAvPlayer", 1, "libSceAvPlayer", 1, 0, sceAvPlayerAddSource);
|
LIB_FUNCTION("KMcEa+rHsIo", "libSceAvPlayer", 1, "libSceAvPlayer", 1, 0, sceAvPlayerAddSource);
|
||||||
LIB_FUNCTION("x8uvuFOPZhU", "libSceAvPlayer", 1, "libSceAvPlayer", 1, 0,
|
LIB_FUNCTION("x8uvuFOPZhU", "libSceAvPlayer", 1, "libSceAvPlayer", 1, 0,
|
||||||
sceAvPlayerAddSourceEx);
|
sceAvPlayerAddSourceEx);
|
||||||
|
@ -290,6 +290,6 @@ enum class SceAvPlayerAvSyncMode {
|
|||||||
|
|
||||||
using SceAvPlayerLogCallback = int PS4_SYSV_ABI (*)(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 RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
} // namespace Libraries::AvPlayer
|
} // namespace Libraries::AvPlayer
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
FrameBuffer(const SceAvPlayerMemAllocator& memory_replacement, u32 align, u32 size) noexcept
|
FrameBuffer(const SceAvPlayerMemAllocator& memory_replacement, u32 align, u32 size) noexcept
|
||||||
: m_memory_replacement(memory_replacement),
|
: m_memory_replacement(memory_replacement),
|
||||||
m_data(Allocate(memory_replacement, align, size)) {
|
m_data(Allocate(memory_replacement, align, size)) {
|
||||||
ASSERT_MSG(m_data, "Could not allocated frame buffer.");
|
ASSERT_MSG(m_data, "Could not allocate frame buffer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
~FrameBuffer() {
|
~FrameBuffer() {
|
||||||
|
@ -410,7 +410,7 @@ s32 PS4_SYSV_ABI sceCameraStopByHandle() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceCamera(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("QhjrPkRPUZQ", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAccGetData);
|
LIB_FUNCTION("QhjrPkRPUZQ", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAccGetData);
|
||||||
LIB_FUNCTION("UFonL7xopFM", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAudioClose);
|
LIB_FUNCTION("UFonL7xopFM", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAudioClose);
|
||||||
LIB_FUNCTION("fkZE7Hup2ro", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAudioGetData);
|
LIB_FUNCTION("fkZE7Hup2ro", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAudioGetData);
|
||||||
|
@ -304,5 +304,5 @@ s32 PS4_SYSV_ABI sceCameraStartByHandle();
|
|||||||
s32 PS4_SYSV_ABI sceCameraStop(s32 handle);
|
s32 PS4_SYSV_ABI sceCameraStop(s32 handle);
|
||||||
s32 PS4_SYSV_ABI sceCameraStopByHandle();
|
s32 PS4_SYSV_ABI sceCameraStopByHandle();
|
||||||
|
|
||||||
void RegisterlibSceCamera(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Camera
|
} // namespace Libraries::Camera
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
// companion_httpd error codes
|
// companion_httpd error codes
|
||||||
constexpr int ORBIS_COMPANION_HTTPD_ERROR_UNKNOWN = 0x80E40001;
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_UNKNOWN = 0x80E40001;
|
||||||
constexpr int ORBIS_COMPANION_HTTPD_ERROR_FATAL = 0x80E40002;
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_FATAL = 0x80E40002;
|
||||||
@ -18,3 +20,8 @@ constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_STARTED = 0x80E4000B;
|
|||||||
constexpr int ORBIS_COMPANION_HTTPD_ERROR_ALREADY_REGISTERED = 0x80E4000;
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_ALREADY_REGISTERED = 0x80E4000;
|
||||||
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_CONNECTED = 0x80E4000D;
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_CONNECTED = 0x80E4000D;
|
||||||
constexpr int ORBIS_COMPANION_HTTPD_ERROR_USER_NOT_FOUND = 0x80E4000E;
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_USER_NOT_FOUND = 0x80E4000E;
|
||||||
|
|
||||||
|
// companion_util error codes
|
||||||
|
constexpr u32 ORBIS_COMPANION_UTIL_INVALID_ARGUMENT = 0x80AD0004;
|
||||||
|
constexpr u32 ORBIS_COMPANION_UTIL_INVALID_POINTER = 0x80AD0006;
|
||||||
|
constexpr u32 ORBIS_COMPANION_UTIL_NO_EVENT = 0x80AD0008;
|
@ -102,7 +102,7 @@ s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestCallback() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceCompanionHttpd(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("8pWltDG7h6A", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
LIB_FUNCTION("8pWltDG7h6A", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
sceCompanionHttpdAddHeader);
|
sceCompanionHttpdAddHeader);
|
||||||
LIB_FUNCTION("B-QBMeFdNgY", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
LIB_FUNCTION("B-QBMeFdNgY", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
@ -87,5 +87,5 @@ s32 PS4_SYSV_ABI sceCompanionHttpdTerminate();
|
|||||||
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestBodyReceptionCallback();
|
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestBodyReceptionCallback();
|
||||||
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestCallback();
|
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestCallback();
|
||||||
|
|
||||||
void RegisterlibSceCompanionHttpd(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::CompanionHttpd
|
} // namespace Libraries::CompanionHttpd
|
72
src/core/libraries/companion/companion_util.cpp
Normal file
72
src/core/libraries/companion/companion_util.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "companion_error.h"
|
||||||
|
#include "core/libraries/companion/companion_util.h"
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
|
namespace Libraries::CompanionUtil {
|
||||||
|
|
||||||
|
u32 PS4_SYSV_ABI getEvent(sceCompanionUtilContext* ctx, sceCompanionUtilEvent* outEvent,
|
||||||
|
s32 param_3) {
|
||||||
|
if (outEvent == 0) {
|
||||||
|
return ORBIS_COMPANION_UTIL_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx == nullptr) {
|
||||||
|
return ORBIS_COMPANION_UTIL_INVALID_POINTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* base = ctx->blob;
|
||||||
|
int flag = *reinterpret_cast<int*>(base + 0x178);
|
||||||
|
if (flag == 0) {
|
||||||
|
return ORBIS_COMPANION_UTIL_NO_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ORBIS_COMPANION_UTIL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilGetEvent(sceCompanionUtilEvent* outEvent) {
|
||||||
|
sceCompanionUtilContext* ctx = nullptr;
|
||||||
|
u32 ret = getEvent(ctx, outEvent, 1);
|
||||||
|
|
||||||
|
LOG_DEBUG(Lib_CompanionUtil, "(STUBBED) called ret: {}", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilGetRemoteOskEvent() {
|
||||||
|
LOG_ERROR(Lib_CompanionUtil, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilInitialize() {
|
||||||
|
LOG_ERROR(Lib_CompanionUtil, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilOptParamInitialize() {
|
||||||
|
LOG_ERROR(Lib_CompanionUtil, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilTerminate() {
|
||||||
|
LOG_ERROR(Lib_CompanionUtil, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
|
LIB_FUNCTION("cE5Msy11WhU", "libSceCompanionUtil", 1, "libSceCompanionUtil", 1, 1,
|
||||||
|
sceCompanionUtilGetEvent);
|
||||||
|
LIB_FUNCTION("MaVrz79mT5o", "libSceCompanionUtil", 1, "libSceCompanionUtil", 1, 1,
|
||||||
|
sceCompanionUtilGetRemoteOskEvent);
|
||||||
|
LIB_FUNCTION("xb1xlIhf0QY", "libSceCompanionUtil", 1, "libSceCompanionUtil", 1, 1,
|
||||||
|
sceCompanionUtilInitialize);
|
||||||
|
LIB_FUNCTION("IPN-FRSrafk", "libSceCompanionUtil", 1, "libSceCompanionUtil", 1, 1,
|
||||||
|
sceCompanionUtilOptParamInitialize);
|
||||||
|
LIB_FUNCTION("H1fYQd5lFAI", "libSceCompanionUtil", 1, "libSceCompanionUtil", 1, 1,
|
||||||
|
sceCompanionUtilTerminate);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Libraries::CompanionUtil
|
33
src/core/libraries/companion/companion_util.h
Normal file
33
src/core/libraries/companion/companion_util.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
|
namespace Core::Loader {
|
||||||
|
class SymbolsResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Libraries::CompanionUtil {
|
||||||
|
|
||||||
|
constexpr u32 ORBIS_COMPANION_UTIL_OK = 0;
|
||||||
|
|
||||||
|
struct sceCompanionUtilEvent {
|
||||||
|
std::uint8_t blob[0x104]{}; /// 0x104 bytes of data, dont know what it is exactly
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sceCompanionUtilContext {
|
||||||
|
std::uint8_t blob[0x27B]{}; /// 0x27B bytes of data, dont know what it is exactly
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 PS4_SYSV_ABI getEvent(sceCompanionUtilContext* ctx, sceCompanionUtilEvent* outEvent,
|
||||||
|
s32 param_3);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilGetEvent(sceCompanionUtilEvent* outEvent);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilGetRemoteOskEvent();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilInitialize();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilOptParamInitialize();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionUtilTerminate();
|
||||||
|
|
||||||
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
|
} // namespace Libraries::CompanionUtil
|
@ -34,7 +34,7 @@ int PS4_SYSV_ABI Func_E7EBCE96E92F91F8() {
|
|||||||
return ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO;
|
return ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceDiscMap(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("fl1eoDnwQ4s", "libSceDiscMap", 1, "libSceDiscMap", 1, 1,
|
LIB_FUNCTION("fl1eoDnwQ4s", "libSceDiscMap", 1, "libSceDiscMap", 1, 1,
|
||||||
sceDiscMapGetPackageSize);
|
sceDiscMapGetPackageSize);
|
||||||
LIB_FUNCTION("lbQKqsERhtE", "libSceDiscMap", 1, "libSceDiscMap", 1, 1,
|
LIB_FUNCTION("lbQKqsERhtE", "libSceDiscMap", 1, "libSceDiscMap", 1, 1,
|
||||||
|
@ -18,5 +18,5 @@ int PS4_SYSV_ABI Func_8A828CAEE7EDD5E9(char* path, s64 offset, s64 nbytes, int*
|
|||||||
int* ret2);
|
int* ret2);
|
||||||
int PS4_SYSV_ABI Func_E7EBCE96E92F91F8();
|
int PS4_SYSV_ABI Func_E7EBCE96E92F91F8();
|
||||||
|
|
||||||
void RegisterlibSceDiscMap(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::DiscMap
|
} // namespace Libraries::DiscMap
|
@ -545,7 +545,7 @@ s32 PS4_SYSV_ABI sceFiberSwitch(OrbisFiber* fiber, u64 arg_on_run_to, u64* arg_o
|
|||||||
return sceFiberSwitchImpl(fiber, nullptr, 0, arg_on_run_to, arg_on_run);
|
return sceFiberSwitchImpl(fiber, nullptr, 0, arg_on_run_to, arg_on_run);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceFiber(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("hVYD7Ou2pCQ", "libSceFiber", 1, "libSceFiber", 1, 1, sceFiberInitialize);
|
LIB_FUNCTION("hVYD7Ou2pCQ", "libSceFiber", 1, "libSceFiber", 1, 1, sceFiberInitialize);
|
||||||
LIB_FUNCTION("7+OJIpko9RY", "libSceFiber", 1, "libSceFiber", 1, 1,
|
LIB_FUNCTION("7+OJIpko9RY", "libSceFiber", 1, "libSceFiber", 1, 1,
|
||||||
sceFiberInitializeImpl); // _sceFiberInitializeWithInternalOptionImpl
|
sceFiberInitializeImpl); // _sceFiberInitializeWithInternalOptionImpl
|
||||||
|
@ -116,5 +116,5 @@ s32 PS4_SYSV_ABI sceFiberRename(OrbisFiber* fiber, const char* name);
|
|||||||
|
|
||||||
s32 PS4_SYSV_ABI sceFiberGetThreadFramePointerAddress(u64* addr_frame_pointer);
|
s32 PS4_SYSV_ABI sceFiberGetThreadFramePointerAddress(u64* addr_frame_pointer);
|
||||||
|
|
||||||
void RegisterlibSceFiber(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Fiber
|
} // namespace Libraries::Fiber
|
@ -246,7 +246,7 @@ int PS4_SYSV_ABI sceGameLiveStreamingUnregisterCallback() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceGameLiveStreaming(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("caqgDl+V9qA", "libSceGameLiveStreaming_debug", 1, "libSceGameLiveStreaming", 1, 1,
|
LIB_FUNCTION("caqgDl+V9qA", "libSceGameLiveStreaming_debug", 1, "libSceGameLiveStreaming", 1, 1,
|
||||||
sceGameLiveStreamingStartDebugBroadcast);
|
sceGameLiveStreamingStartDebugBroadcast);
|
||||||
LIB_FUNCTION("0i8Lrllxwow", "libSceGameLiveStreaming_debug", 1, "libSceGameLiveStreaming", 1, 1,
|
LIB_FUNCTION("0i8Lrllxwow", "libSceGameLiveStreaming_debug", 1, "libSceGameLiveStreaming", 1, 1,
|
||||||
|
@ -77,5 +77,5 @@ int PS4_SYSV_ABI sceGameLiveStreamingStopSocialFeedbackMessageFiltering();
|
|||||||
int PS4_SYSV_ABI sceGameLiveStreamingTerminate();
|
int PS4_SYSV_ABI sceGameLiveStreamingTerminate();
|
||||||
int PS4_SYSV_ABI sceGameLiveStreamingUnregisterCallback();
|
int PS4_SYSV_ABI sceGameLiveStreamingUnregisterCallback();
|
||||||
|
|
||||||
void RegisterlibSceGameLiveStreaming(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::GameLiveStreaming
|
} // namespace Libraries::GameLiveStreaming
|
@ -2823,7 +2823,7 @@ int PS4_SYSV_ABI Func_F916890425496553() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceGnmDriver(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LOG_INFO(Lib_GnmDriver, "Initializing presenter");
|
LOG_INFO(Lib_GnmDriver, "Initializing presenter");
|
||||||
liverpool = std::make_unique<AmdGpu::Liverpool>();
|
liverpool = std::make_unique<AmdGpu::Liverpool>();
|
||||||
presenter = std::make_unique<Vulkan::Presenter>(*g_window, liverpool.get());
|
presenter = std::make_unique<Vulkan::Presenter>(*g_window, liverpool.get());
|
||||||
@ -2834,7 +2834,7 @@ void RegisterlibSceGnmDriver(Core::Loader::SymbolsResolver* sym) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config::copyGPUCmdBuffers()) {
|
if (Config::copyGPUCmdBuffers()) {
|
||||||
liverpool->reserveCopyBufferSpace();
|
liverpool->ReserveCopyBufferSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform::IrqC::Instance()->Register(Platform::InterruptId::GpuIdle, ResetSubmissionLock,
|
Platform::IrqC::Instance()->Register(Platform::InterruptId::GpuIdle, ResetSubmissionLock,
|
||||||
|
@ -297,5 +297,5 @@ int PS4_SYSV_ABI Func_BFB41C057478F0BF();
|
|||||||
int PS4_SYSV_ABI Func_E51D44DB8151238C();
|
int PS4_SYSV_ABI Func_E51D44DB8151238C();
|
||||||
int PS4_SYSV_ABI Func_F916890425496553();
|
int PS4_SYSV_ABI Func_F916890425496553();
|
||||||
|
|
||||||
void RegisterlibSceGnmDriver(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::GnmDriver
|
} // namespace Libraries::GnmDriver
|
||||||
|
@ -939,7 +939,7 @@ s32 PS4_SYSV_ABI Func_FF2E0E53015FE231() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceHmd(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("8gH1aLgty5I", "libsceHmdReprojectionMultilayer", 1, "libSceHmd", 1, 1,
|
LIB_FUNCTION("8gH1aLgty5I", "libsceHmdReprojectionMultilayer", 1, "libSceHmd", 1, 1,
|
||||||
sceHmdReprojectionStartMultilayer);
|
sceHmdReprojectionStartMultilayer);
|
||||||
LIB_FUNCTION("gEokC+OGI8g", "libSceHmdDistortion", 1, "libSceHmd", 1, 1,
|
LIB_FUNCTION("gEokC+OGI8g", "libSceHmdDistortion", 1, "libSceHmd", 1, 1,
|
||||||
|
@ -199,5 +199,5 @@ s32 PS4_SYSV_ABI Func_B9A6FA0735EC7E49();
|
|||||||
s32 PS4_SYSV_ABI Func_FC193BD653F2AF2E();
|
s32 PS4_SYSV_ABI Func_FC193BD653F2AF2E();
|
||||||
s32 PS4_SYSV_ABI Func_FF2E0E53015FE231();
|
s32 PS4_SYSV_ABI Func_FF2E0E53015FE231();
|
||||||
|
|
||||||
void RegisterlibSceHmd(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::Hmd
|
} // namespace Libraries::Hmd
|
@ -190,7 +190,7 @@ Status PS4_SYSV_ABI sceErrorDialogUpdateStatus() {
|
|||||||
return g_status;
|
return g_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceErrorDialog(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("ekXHb1kDBl0", "libSceErrorDialog", 1, "libSceErrorDialog", 1, 1,
|
LIB_FUNCTION("ekXHb1kDBl0", "libSceErrorDialog", 1, "libSceErrorDialog", 1, 1,
|
||||||
sceErrorDialogClose);
|
sceErrorDialogClose);
|
||||||
LIB_FUNCTION("t2FvHRXzgqk", "libSceErrorDialog", 1, "libSceErrorDialog", 1, 1,
|
LIB_FUNCTION("t2FvHRXzgqk", "libSceErrorDialog", 1, "libSceErrorDialog", 1, 1,
|
||||||
|
@ -24,5 +24,5 @@ int PS4_SYSV_ABI sceErrorDialogOpenWithReport();
|
|||||||
CommonDialog::Error PS4_SYSV_ABI sceErrorDialogTerminate();
|
CommonDialog::Error PS4_SYSV_ABI sceErrorDialogTerminate();
|
||||||
CommonDialog::Status PS4_SYSV_ABI sceErrorDialogUpdateStatus();
|
CommonDialog::Status PS4_SYSV_ABI sceErrorDialogUpdateStatus();
|
||||||
|
|
||||||
void RegisterlibSceErrorDialog(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::ErrorDialog
|
} // namespace Libraries::ErrorDialog
|
@ -18,9 +18,11 @@ static ImeUi g_ime_ui;
|
|||||||
class ImeHandler {
|
class ImeHandler {
|
||||||
public:
|
public:
|
||||||
ImeHandler(const OrbisImeKeyboardParam* param) {
|
ImeHandler(const OrbisImeKeyboardParam* param) {
|
||||||
|
LOG_INFO(Lib_Ime, "Creating ImeHandler for keyboard");
|
||||||
Init(param, false);
|
Init(param, false);
|
||||||
}
|
}
|
||||||
ImeHandler(const OrbisImeParam* param) {
|
ImeHandler(const OrbisImeParam* param) {
|
||||||
|
LOG_INFO(Lib_Ime, "Creating ImeHandler for IME");
|
||||||
Init(param, true);
|
Init(param, true);
|
||||||
}
|
}
|
||||||
~ImeHandler() = default;
|
~ImeHandler() = default;
|
||||||
@ -38,13 +40,18 @@ public:
|
|||||||
openEvent.id = (ime_mode ? OrbisImeEventId::Open : OrbisImeEventId::KeyboardOpen);
|
openEvent.id = (ime_mode ? OrbisImeEventId::Open : OrbisImeEventId::KeyboardOpen);
|
||||||
|
|
||||||
if (ime_mode) {
|
if (ime_mode) {
|
||||||
sceImeGetPanelSize(&m_param.ime, &openEvent.param.rect.width,
|
LOG_INFO(Lib_Ime, "calling sceImeGetPanelSize");
|
||||||
&openEvent.param.rect.height);
|
Error e = sceImeGetPanelSize(&m_param.ime, &openEvent.param.rect.width,
|
||||||
|
&openEvent.param.rect.height);
|
||||||
|
if (e != Error::OK) {
|
||||||
|
LOG_ERROR(Lib_Ime, "sceImeGetPanelSize returned 0x{:X}", static_cast<u32>(e));
|
||||||
|
}
|
||||||
|
|
||||||
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.resource_id_array.userId = 1;
|
openEvent.param.resource_id_array.user_id = 1;
|
||||||
openEvent.param.resource_id_array.resourceId[0] = 1;
|
openEvent.param.resource_id_array.resource_id[0] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we supposed to call the event handler on init with
|
// Are we supposed to call the event handler on init with
|
||||||
@ -59,13 +66,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Update(OrbisImeEventHandler handler) {
|
Error Update(OrbisImeEventHandler handler) {
|
||||||
if (!m_ime_mode) {
|
if (!m_ime_mode) {
|
||||||
/* We don't handle any events for ImeKeyboard */
|
/* We don't handle any events for ImeKeyboard */
|
||||||
return ORBIS_OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock lock{g_ime_state.queue_mutex};
|
std::unique_lock<std::mutex> lock{g_ime_state.queue_mutex};
|
||||||
|
|
||||||
while (!g_ime_state.event_queue.empty()) {
|
while (!g_ime_state.event_queue.empty()) {
|
||||||
OrbisImeEvent event = g_ime_state.event_queue.front();
|
OrbisImeEvent event = g_ime_state.event_queue.front();
|
||||||
@ -73,7 +80,7 @@ public:
|
|||||||
Execute(handler, &event, false);
|
Execute(handler, &event, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ORBIS_OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Execute(OrbisImeEventHandler handler, OrbisImeEvent* event, bool use_param_handler) {
|
void Execute(OrbisImeEventHandler handler, OrbisImeEvent* event, bool use_param_handler) {
|
||||||
@ -94,14 +101,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 SetText(const char16_t* text, u32 length) {
|
Error SetText(const char16_t* text, u32 length) {
|
||||||
g_ime_state.SetText(text, length);
|
g_ime_state.SetText(text, length);
|
||||||
return ORBIS_OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 SetCaret(const OrbisImeCaret* caret) {
|
Error SetCaret(const OrbisImeCaret* caret) {
|
||||||
g_ime_state.SetCaret(caret->index);
|
g_ime_state.SetCaret(caret->index);
|
||||||
return ORBIS_OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsIme() {
|
bool IsIme() {
|
||||||
@ -144,17 +151,22 @@ int PS4_SYSV_ABI sceImeCheckUpdateTextInfo() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeClose() {
|
Error PS4_SYSV_ABI sceImeClose() {
|
||||||
LOG_INFO(Lib_Ime, "(STUBBED) called");
|
LOG_INFO(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!g_ime_handler) {
|
if (!g_ime_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return Error::NOT_OPENED;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_handler.release();
|
g_ime_handler.release();
|
||||||
|
if (g_keyboard_handler) {
|
||||||
|
return Error::INTERNAL;
|
||||||
|
}
|
||||||
g_ime_ui = ImeUi();
|
g_ime_ui = ImeUi();
|
||||||
g_ime_state = ImeState();
|
g_ime_state = ImeState();
|
||||||
return ORBIS_OK;
|
|
||||||
|
LOG_INFO(Lib_Ime, "IME closed successfully");
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeConfigGet() {
|
int PS4_SYSV_ABI sceImeConfigGet() {
|
||||||
@ -222,40 +234,87 @@ int PS4_SYSV_ABI sceImeGetPanelPositionAndForm() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32* height) {
|
Error PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32* height) {
|
||||||
LOG_INFO(Lib_Ime, "called");
|
LOG_INFO(Lib_Ime, "sceImeGetPanelSize called");
|
||||||
|
|
||||||
if (!width || !height) {
|
if (!param) {
|
||||||
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
LOG_ERROR(Lib_Ime, "Invalid param: NULL");
|
||||||
|
return Error::INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!width) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid *width: NULL");
|
||||||
|
return Error::INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
if (!height) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid *height: NULL");
|
||||||
|
return Error::INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (static_cast<u32>(param->option) & ~0x7BFF) { // Basic check for invalid options
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid option 0x{:X}", static_cast<u32>(param->option));
|
||||||
|
return Error::INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (param->type) {
|
switch (param->type) {
|
||||||
case OrbisImeType::Default:
|
case OrbisImeType::Default:
|
||||||
|
*width = 500; // dummy value
|
||||||
|
*height = 100; // dummy value
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->type: Default ({})", static_cast<u32>(param->type));
|
||||||
|
break;
|
||||||
case OrbisImeType::BasicLatin:
|
case OrbisImeType::BasicLatin:
|
||||||
|
*width = 500; // dummy value
|
||||||
|
*height = 100; // dummy value
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->type: BasicLatin ({})", static_cast<u32>(param->type));
|
||||||
|
break;
|
||||||
case OrbisImeType::Url:
|
case OrbisImeType::Url:
|
||||||
|
*width = 500; // dummy value
|
||||||
|
*height = 100; // dummy value
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->type: Url ({})", static_cast<u32>(param->type));
|
||||||
|
break;
|
||||||
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
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->type: Mail ({})", static_cast<u32>(param->type));
|
||||||
break;
|
break;
|
||||||
case OrbisImeType::Number:
|
case OrbisImeType::Number:
|
||||||
*width = 370;
|
*width = 370;
|
||||||
*height = 402;
|
*height = 402;
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->type: Number ({})", static_cast<u32>(param->type));
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid param->type: ({})", static_cast<u32>(param->type));
|
||||||
|
return Error::INVALID_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ORBIS_OK;
|
LOG_INFO(Lib_Ime, "IME panel size: width={}, height={}", *width, *height);
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeKeyboardClose(s32 userId) {
|
Error PS4_SYSV_ABI sceImeKeyboardClose(Libraries::UserService::OrbisUserServiceUserId userId) {
|
||||||
LOG_INFO(Lib_Ime, "(STUBBED) called");
|
LOG_INFO(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!g_keyboard_handler) {
|
if (!g_keyboard_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
LOG_ERROR(Lib_Ime, "No keyboard handler is open");
|
||||||
|
return Error::NOT_OPENED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((userId < 0 || userId > 4) &&
|
||||||
|
false) { // TODO: Check for valid user IDs. Disabled until user manager is ready.
|
||||||
|
// Maybe g_keyboard_handler should hold a user ID and I must compare it here?
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid userId: {}", userId);
|
||||||
|
return Error::INVALID_USER_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_keyboard_handler.release();
|
g_keyboard_handler.release();
|
||||||
return ORBIS_OK;
|
if (g_ime_handler) {
|
||||||
|
LOG_ERROR(Lib_Ime, "failed to close keyboard handler, IME handler is still open");
|
||||||
|
return Error::INTERNAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO(Lib_Ime, "Keyboard handler closed successfully for user ID: {}", userId);
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeKeyboardGetInfo() {
|
int PS4_SYSV_ABI sceImeKeyboardGetInfo() {
|
||||||
@ -268,25 +327,62 @@ int PS4_SYSV_ABI sceImeKeyboardGetResourceId() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeKeyboardOpen(s32 userId, const OrbisImeKeyboardParam* param) {
|
Error PS4_SYSV_ABI sceImeKeyboardOpen(Libraries::UserService::OrbisUserServiceUserId userId,
|
||||||
|
const OrbisImeKeyboardParam* param) {
|
||||||
LOG_INFO(Lib_Ime, "called");
|
LOG_INFO(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!param) {
|
if (!param) {
|
||||||
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
LOG_ERROR(Lib_Ime, "Invalid param: NULL");
|
||||||
}
|
return Error::INVALID_ADDRESS;
|
||||||
if (!param->arg) {
|
|
||||||
return ORBIS_IME_ERROR_INVALID_ARG;
|
|
||||||
}
|
}
|
||||||
if (!param->handler) {
|
if (!param->handler) {
|
||||||
return ORBIS_IME_ERROR_INVALID_HANDLER;
|
LOG_ERROR(Lib_Ime, "Invalid param->handler: NULL");
|
||||||
|
return Error::INVALID_HANDLER;
|
||||||
|
}
|
||||||
|
// seems like arg is optional, need to check if it is used in the handler
|
||||||
|
if (!param->arg && false) { // Todo: check if arg is used in the handler, temporarily disabled
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid param->arg: NULL");
|
||||||
|
return Error::INVALID_ARG;
|
||||||
|
}
|
||||||
|
if (static_cast<u32>(param->option) & ~kValidOrbisImeKeyboardOptionMask) {
|
||||||
|
LOG_ERROR(Lib_Ime,
|
||||||
|
"Invalid param->option\n"
|
||||||
|
"option: {:032b}\n"
|
||||||
|
"validMask: {:032b}",
|
||||||
|
static_cast<u32>(param->option), kValidOrbisImeKeyboardOptionMask);
|
||||||
|
return Error::INVALID_OPTION;
|
||||||
|
}
|
||||||
|
if ((userId < 0 || userId > 4) &&
|
||||||
|
false) { // TODO: Check for valid user IDs. Disabled until user manager is ready.
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid userId: {}", userId);
|
||||||
|
return Error::INVALID_USER_ID;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < sizeof(param->reserved1); ++i) {
|
||||||
|
if (param->reserved1[i] != 0) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid reserved1: not zeroed");
|
||||||
|
return Error::INVALID_RESERVED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < sizeof(param->reserved2); ++i) {
|
||||||
|
if (param->reserved2[i] != 0) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid reserved2: not zeroed");
|
||||||
|
return Error::INVALID_RESERVED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false) { // Todo: figure out what it is, always true for now
|
||||||
|
LOG_ERROR(Lib_Ime, "USB keyboard some special kind of failure");
|
||||||
|
return Error::CONNECTION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_keyboard_handler) {
|
if (g_keyboard_handler) {
|
||||||
return ORBIS_IME_ERROR_BUSY;
|
LOG_ERROR(Lib_Ime, "Keyboard handler is already open");
|
||||||
|
return Error::BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_keyboard_handler = std::make_unique<ImeHandler>(param);
|
g_keyboard_handler = std::make_unique<ImeHandler>(param);
|
||||||
return ORBIS_OK;
|
if (!g_keyboard_handler) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Failed to create keyboard handler");
|
||||||
|
return Error::INTERNAL; // or Error::NO_MEMORY;
|
||||||
|
}
|
||||||
|
LOG_INFO(Lib_Ime, "Keyboard handler created successfully for user ID: {}", userId);
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeKeyboardOpenInternal() {
|
int PS4_SYSV_ABI sceImeKeyboardOpenInternal() {
|
||||||
@ -304,18 +400,190 @@ int PS4_SYSV_ABI sceImeKeyboardUpdate() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const void* extended) {
|
Error PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const OrbisImeParamExtended* extended) {
|
||||||
LOG_INFO(Lib_Ime, "called");
|
LOG_INFO(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!param) {
|
if (!param) {
|
||||||
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
LOG_ERROR(Lib_Ime, "Invalid param: NULL");
|
||||||
|
return Error::INVALID_ADDRESS;
|
||||||
|
} else {
|
||||||
|
// LOG_DEBUG values for debugging purposes
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->user_id: {}", param->user_id);
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->type: {}", static_cast<u32>(param->type));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->supported_languages: {:064b}",
|
||||||
|
static_cast<u64>(param->supported_languages));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->enter_label: {}", static_cast<u32>(param->enter_label));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->input_method: {}", static_cast<u32>(param->input_method));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->filter: {:p}", reinterpret_cast<void*>(param->filter));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->option: {:032b}", static_cast<u32>(param->option));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->maxTextLength: {}", param->maxTextLength);
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->inputTextBuffer: {:p}",
|
||||||
|
static_cast<const void*>(param->inputTextBuffer));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->posx: {}", param->posx);
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->posy: {}", param->posy);
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->horizontal_alignment: {}",
|
||||||
|
static_cast<u32>(param->horizontal_alignment));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->vertical_alignment: {}",
|
||||||
|
static_cast<u32>(param->vertical_alignment));
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->work: {:p}", param->work);
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->arg: {:p}", param->arg);
|
||||||
|
LOG_DEBUG(Lib_Ime, "param->handler: {:p}", reinterpret_cast<void*>(param->handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!extended) {
|
||||||
|
LOG_INFO(Lib_Ime, "Not used extended: NULL");
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->option: {:032b}", static_cast<u32>(extended->option));
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_base: {{{},{},{},{}}}", extended->color_base.r,
|
||||||
|
extended->color_base.g, extended->color_base.b, extended->color_base.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_line: {{{},{},{},{}}}", extended->color_line.r,
|
||||||
|
extended->color_line.g, extended->color_line.b, extended->color_line.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_text_field: {{{},{},{},{}}}",
|
||||||
|
extended->color_text_field.r, extended->color_text_field.g,
|
||||||
|
extended->color_text_field.b, extended->color_text_field.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_preedit: {{{},{},{},{}}}", extended->color_preedit.r,
|
||||||
|
extended->color_preedit.g, extended->color_preedit.b, extended->color_preedit.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_button_default: {{{},{},{},{}}}",
|
||||||
|
extended->color_button_default.r, extended->color_button_default.g,
|
||||||
|
extended->color_button_default.b, extended->color_button_default.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_button_function: {{{},{},{},{}}}",
|
||||||
|
extended->color_button_function.r, extended->color_button_function.g,
|
||||||
|
extended->color_button_function.b, extended->color_button_function.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_button_symbol: {{{},{},{},{}}}",
|
||||||
|
extended->color_button_symbol.r, extended->color_button_symbol.g,
|
||||||
|
extended->color_button_symbol.b, extended->color_button_symbol.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_text: {{{},{},{},{}}}", extended->color_text.r,
|
||||||
|
extended->color_text.g, extended->color_text.b, extended->color_text.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->color_special: {{{},{},{},{}}}", extended->color_special.r,
|
||||||
|
extended->color_special.g, extended->color_special.b, extended->color_special.a);
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->priority: {}", static_cast<u32>(extended->priority));
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->additional_dictionary_path: {:p}",
|
||||||
|
static_cast<const void*>(extended->additional_dictionary_path));
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->ext_keyboard_filter: {:p}",
|
||||||
|
reinterpret_cast<void*>(extended->ext_keyboard_filter));
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->disable_device: {:032b}",
|
||||||
|
static_cast<u32>(extended->disable_device));
|
||||||
|
LOG_DEBUG(Lib_Ime, "extended->ext_keyboard_mode: {}", extended->ext_keyboard_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->user_id < 1 || param->user_id > 4) { // Todo: check valid user IDs
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid user_id: {}", static_cast<u32>(param->user_id));
|
||||||
|
return Error::INVALID_USER_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!magic_enum::enum_contains(param->type)) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid type: {}", static_cast<u32>(param->type));
|
||||||
|
return Error::INVALID_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (static_cast<u64>(param->supported_languages) & ~kValidOrbisImeLanguageMask) {
|
||||||
|
LOG_ERROR(Lib_Ime,
|
||||||
|
"Invalid supported_languages\n"
|
||||||
|
"supported_languages: {:064b}\n"
|
||||||
|
"valid_mask: {:064b}",
|
||||||
|
static_cast<u64>(param->supported_languages), kValidOrbisImeLanguageMask);
|
||||||
|
return Error::INVALID_SUPPORTED_LANGUAGES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!magic_enum::enum_contains(param->enter_label)) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid enter_label: {}", static_cast<u32>(param->enter_label));
|
||||||
|
return Error::INVALID_ENTER_LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!magic_enum::enum_contains(param->input_method)) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid input_method: {}", static_cast<u32>(param->input_method));
|
||||||
|
return Error::INVALID_INPUT_METHOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (static_cast<u32>(param->option) & ~kValidImeOptionMask) {
|
||||||
|
LOG_ERROR(Lib_Ime, "option has invalid bits set (0x{:X}), mask=(0x{:X})",
|
||||||
|
static_cast<u32>(param->option), kValidImeOptionMask);
|
||||||
|
return Error::INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->maxTextLength == 0 || param->maxTextLength > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid maxTextLength: {}", param->maxTextLength);
|
||||||
|
return Error::INVALID_MAX_TEXT_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!param->inputTextBuffer) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid inputTextBuffer: NULL");
|
||||||
|
return Error::INVALID_INPUT_TEXT_BUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool useHighRes = True(param->option & OrbisImeOption::USE_OVER_2K_COORDINATES);
|
||||||
|
const float maxWidth = useHighRes ? 3840.0f : 1920.0f;
|
||||||
|
const float maxHeight = useHighRes ? 2160.0f : 1080.0f;
|
||||||
|
|
||||||
|
if (param->posx < 0.0f || param->posx >= maxWidth) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid posx: {}, range: 0.0 - {}", param->posx, maxWidth);
|
||||||
|
return Error::INVALID_POSX;
|
||||||
|
}
|
||||||
|
if (param->posy < 0.0f || param->posy >= maxHeight) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid posy: {}, range: 0.0 - {}", param->posy, maxHeight);
|
||||||
|
return Error::INVALID_POSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!magic_enum::enum_contains(param->horizontal_alignment)) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid horizontal_alignment: {}",
|
||||||
|
static_cast<u32>(param->horizontal_alignment));
|
||||||
|
return Error::INVALID_HORIZONTALIGNMENT;
|
||||||
|
}
|
||||||
|
if (!magic_enum::enum_contains(param->vertical_alignment)) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid vertical_alignment: {}",
|
||||||
|
static_cast<u32>(param->vertical_alignment));
|
||||||
|
return Error::INVALID_VERTICALALIGNMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extended) {
|
||||||
|
u32 ext_option_value = static_cast<u32>(extended->option);
|
||||||
|
if (ext_option_value & ~kValidImeExtOptionMask) {
|
||||||
|
LOG_ERROR(Lib_Ime,
|
||||||
|
"Invalid extended->option\n"
|
||||||
|
"option: {:032b}\n"
|
||||||
|
"valid_mask: {:032b}",
|
||||||
|
ext_option_value, kValidImeExtOptionMask);
|
||||||
|
return Error::INVALID_EXTENDED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!param->work) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid work: NULL");
|
||||||
|
return Error::INVALID_WORK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todo: validate arg
|
||||||
|
if (false) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid arg: NULL");
|
||||||
|
return Error::INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todo: validate handler
|
||||||
|
if (false) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid handler: NULL");
|
||||||
|
return Error::INVALID_HANDLER;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sizeof(param->reserved); ++i) {
|
||||||
|
if (param->reserved[i] != 0) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Invalid reserved: not zeroed");
|
||||||
|
return Error::INVALID_RESERVED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (g_ime_handler) {
|
if (g_ime_handler) {
|
||||||
return ORBIS_IME_ERROR_BUSY;
|
LOG_ERROR(Lib_Ime, "IME handler is already open");
|
||||||
|
return Error::BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ime_handler = std::make_unique<ImeHandler>(param);
|
g_ime_handler = std::make_unique<ImeHandler>(param);
|
||||||
return ORBIS_OK;
|
if (!g_ime_handler) {
|
||||||
|
LOG_ERROR(Lib_Ime, "Failed to create IME handler");
|
||||||
|
return Error::NO_MEMORY; // or Error::INTERNAL
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO(Lib_Ime, "IME handler created successfully");
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeOpenInternal() {
|
int PS4_SYSV_ABI sceImeOpenInternal() {
|
||||||
@ -324,7 +592,7 @@ int PS4_SYSV_ABI sceImeOpenInternal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param) {
|
void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param) {
|
||||||
LOG_INFO(Lib_Ime, "called");
|
LOG_INFO(Lib_Ime, "sceImeParamInit called");
|
||||||
|
|
||||||
if (!param) {
|
if (!param) {
|
||||||
return;
|
return;
|
||||||
@ -339,27 +607,27 @@ int PS4_SYSV_ABI sceImeSetCandidateIndex() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret) {
|
Error PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret) {
|
||||||
LOG_TRACE(Lib_Ime, "called");
|
LOG_TRACE(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!g_ime_handler) {
|
if (!g_ime_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return Error::NOT_OPENED;
|
||||||
}
|
}
|
||||||
if (!caret) {
|
if (!caret) {
|
||||||
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
return Error::INVALID_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_ime_handler->SetCaret(caret);
|
return g_ime_handler->SetCaret(caret);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length) {
|
Error PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length) {
|
||||||
LOG_TRACE(Lib_Ime, "called");
|
LOG_TRACE(Lib_Ime, "called");
|
||||||
|
|
||||||
if (!g_ime_handler) {
|
if (!g_ime_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return Error::NOT_OPENED;
|
||||||
}
|
}
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return ORBIS_IME_ERROR_INVALID_ADDRESS;
|
return Error::INVALID_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_ime_handler->SetText(text, length);
|
return g_ime_handler->SetText(text, length);
|
||||||
@ -370,7 +638,7 @@ int PS4_SYSV_ABI sceImeSetTextGeometry() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler) {
|
Error PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler) {
|
||||||
if (g_ime_handler) {
|
if (g_ime_handler) {
|
||||||
g_ime_handler->Update(handler);
|
g_ime_handler->Update(handler);
|
||||||
}
|
}
|
||||||
@ -380,10 +648,10 @@ s32 PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!g_ime_handler || !g_keyboard_handler) {
|
if (!g_ime_handler || !g_keyboard_handler) {
|
||||||
return ORBIS_IME_ERROR_NOT_OPENED;
|
return Error::NOT_OPENED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ORBIS_OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceImeVshClearPreedit() {
|
int PS4_SYSV_ABI sceImeVshClearPreedit() {
|
||||||
@ -481,7 +749,7 @@ int PS4_SYSV_ABI sceImeVshUpdateContext2() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("mN+ZoSN-8hQ", "libSceIme", 1, "libSceIme", 1, 1, FinalizeImeModule);
|
LIB_FUNCTION("mN+ZoSN-8hQ", "libSceIme", 1, "libSceIme", 1, 1, FinalizeImeModule);
|
||||||
LIB_FUNCTION("uTW+63goeJs", "libSceIme", 1, "libSceIme", 1, 1, InitializeImeModule);
|
LIB_FUNCTION("uTW+63goeJs", "libSceIme", 1, "libSceIme", 1, 1, InitializeImeModule);
|
||||||
LIB_FUNCTION("Lf3DeGWC6xg", "libSceIme", 1, "libSceIme", 1, 1, sceImeCheckFilterText);
|
LIB_FUNCTION("Lf3DeGWC6xg", "libSceIme", 1, "libSceIme", 1, 1, sceImeCheckFilterText);
|
||||||
|
@ -13,78 +13,12 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::Ime {
|
namespace Libraries::Ime {
|
||||||
|
|
||||||
constexpr u32 ORBIS_IME_MAX_TEXT_LENGTH = 2048;
|
|
||||||
|
|
||||||
enum class OrbisImeKeyboardOption : u32 {
|
|
||||||
Default = 0,
|
|
||||||
Repeat = 1,
|
|
||||||
RepeatEachKey = 2,
|
|
||||||
AddOsk = 4,
|
|
||||||
EffectiveWithIme = 8,
|
|
||||||
DisableResume = 16,
|
|
||||||
DisableCapslockWithoutShift = 32,
|
|
||||||
};
|
|
||||||
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 {
|
|
||||||
OrbisImeKeyboardOption option;
|
|
||||||
s8 reserved1[4];
|
|
||||||
void* arg;
|
|
||||||
OrbisImeEventHandler handler;
|
|
||||||
s8 reserved2[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisImeParam {
|
|
||||||
s32 user_id;
|
|
||||||
OrbisImeType type;
|
|
||||||
u64 supported_languages;
|
|
||||||
OrbisImeEnterLabel enter_label;
|
|
||||||
OrbisImeInputMethod input_method;
|
|
||||||
OrbisImeTextFilter filter;
|
|
||||||
OrbisImeOption option;
|
|
||||||
u32 maxTextLength;
|
|
||||||
char16_t* inputTextBuffer;
|
|
||||||
float posx;
|
|
||||||
float posy;
|
|
||||||
OrbisImeHorizontalAlignment horizontal_alignment;
|
|
||||||
OrbisImeVerticalAlignment vertical_alignment;
|
|
||||||
void* work;
|
|
||||||
void* arg;
|
|
||||||
OrbisImeEventHandler handler;
|
|
||||||
s8 reserved[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisImeCaret {
|
|
||||||
f32 x;
|
|
||||||
f32 y;
|
|
||||||
u32 height;
|
|
||||||
u32 index;
|
|
||||||
};
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI FinalizeImeModule();
|
int PS4_SYSV_ABI FinalizeImeModule();
|
||||||
int PS4_SYSV_ABI InitializeImeModule();
|
int PS4_SYSV_ABI InitializeImeModule();
|
||||||
int PS4_SYSV_ABI sceImeCheckFilterText();
|
int PS4_SYSV_ABI sceImeCheckFilterText();
|
||||||
int PS4_SYSV_ABI sceImeCheckRemoteEventParam();
|
int PS4_SYSV_ABI sceImeCheckRemoteEventParam();
|
||||||
int PS4_SYSV_ABI sceImeCheckUpdateTextInfo();
|
int PS4_SYSV_ABI sceImeCheckUpdateTextInfo();
|
||||||
int PS4_SYSV_ABI sceImeClose();
|
Error PS4_SYSV_ABI sceImeClose();
|
||||||
int PS4_SYSV_ABI sceImeConfigGet();
|
int PS4_SYSV_ABI sceImeConfigGet();
|
||||||
int PS4_SYSV_ABI sceImeConfigSet();
|
int PS4_SYSV_ABI sceImeConfigSet();
|
||||||
int PS4_SYSV_ABI sceImeConfirmCandidate();
|
int PS4_SYSV_ABI sceImeConfirmCandidate();
|
||||||
@ -98,22 +32,23 @@ int PS4_SYSV_ABI sceImeDisableController();
|
|||||||
int PS4_SYSV_ABI sceImeFilterText();
|
int PS4_SYSV_ABI sceImeFilterText();
|
||||||
int PS4_SYSV_ABI sceImeForTestFunction();
|
int PS4_SYSV_ABI sceImeForTestFunction();
|
||||||
int PS4_SYSV_ABI sceImeGetPanelPositionAndForm();
|
int PS4_SYSV_ABI sceImeGetPanelPositionAndForm();
|
||||||
s32 PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32* height);
|
Error PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32* height);
|
||||||
s32 PS4_SYSV_ABI sceImeKeyboardClose(s32 userId);
|
Error PS4_SYSV_ABI sceImeKeyboardClose(Libraries::UserService::OrbisUserServiceUserId userId);
|
||||||
int PS4_SYSV_ABI sceImeKeyboardGetInfo();
|
int PS4_SYSV_ABI sceImeKeyboardGetInfo();
|
||||||
int PS4_SYSV_ABI sceImeKeyboardGetResourceId();
|
int PS4_SYSV_ABI sceImeKeyboardGetResourceId();
|
||||||
s32 PS4_SYSV_ABI sceImeKeyboardOpen(s32 userId, const OrbisImeKeyboardParam* param);
|
Error PS4_SYSV_ABI sceImeKeyboardOpen(Libraries::UserService::OrbisUserServiceUserId userId,
|
||||||
|
const OrbisImeKeyboardParam* param);
|
||||||
int PS4_SYSV_ABI sceImeKeyboardOpenInternal();
|
int PS4_SYSV_ABI sceImeKeyboardOpenInternal();
|
||||||
int PS4_SYSV_ABI sceImeKeyboardSetMode();
|
int PS4_SYSV_ABI sceImeKeyboardSetMode();
|
||||||
int PS4_SYSV_ABI sceImeKeyboardUpdate();
|
int PS4_SYSV_ABI sceImeKeyboardUpdate();
|
||||||
s32 PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const void* extended);
|
Error PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const OrbisImeParamExtended* extended);
|
||||||
int PS4_SYSV_ABI sceImeOpenInternal();
|
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);
|
Error PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret);
|
||||||
s32 PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length);
|
Error 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);
|
Error PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler);
|
||||||
int PS4_SYSV_ABI sceImeVshClearPreedit();
|
int PS4_SYSV_ABI sceImeVshClearPreedit();
|
||||||
int PS4_SYSV_ABI sceImeVshClose();
|
int PS4_SYSV_ABI sceImeVshClose();
|
||||||
int PS4_SYSV_ABI sceImeVshConfirmPreedit();
|
int PS4_SYSV_ABI sceImeVshConfirmPreedit();
|
||||||
@ -134,6 +69,6 @@ int PS4_SYSV_ABI sceImeVshUpdate();
|
|||||||
int PS4_SYSV_ABI sceImeVshUpdateContext();
|
int PS4_SYSV_ABI sceImeVshUpdateContext();
|
||||||
int PS4_SYSV_ABI sceImeVshUpdateContext2();
|
int PS4_SYSV_ABI sceImeVshUpdateContext2();
|
||||||
|
|
||||||
void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
} // namespace Libraries::Ime
|
} // namespace Libraries::Ime
|
||||||
|
@ -3,9 +3,273 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <core/libraries/system/userservice.h>
|
||||||
|
#include <magic_enum/magic_enum.hpp>
|
||||||
|
#include "common/enum.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/libraries/rtc/rtc.h"
|
#include "core/libraries/rtc/rtc.h"
|
||||||
|
|
||||||
|
constexpr u32 ORBIS_IME_MAX_TEXT_LENGTH = 2048;
|
||||||
|
constexpr u32 ORBIS_IME_DIALOG_MAX_TEXT_LENGTH = 2048;
|
||||||
|
|
||||||
|
template <typename E>
|
||||||
|
const std::underlying_type_t<E> generate_full_mask() {
|
||||||
|
static_assert(std::is_enum_v<E>, "E must be an enum type.");
|
||||||
|
static_assert(magic_enum::customize::enum_range<E>::is_flags,
|
||||||
|
"E must be marked as is_flags = true.");
|
||||||
|
|
||||||
|
using U = std::underlying_type_t<E>;
|
||||||
|
const auto values = magic_enum::enum_values<E>();
|
||||||
|
U mask = 0;
|
||||||
|
|
||||||
|
// Use index-based loop for better constexpr compatibility
|
||||||
|
for (std::size_t i = 0; i < values.size(); ++i) {
|
||||||
|
mask |= static_cast<U>(values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class Error : u32 {
|
||||||
|
OK = 0x0,
|
||||||
|
|
||||||
|
// ImeDialog library
|
||||||
|
BUSY = 0x80bc0001,
|
||||||
|
NOT_OPENED = 0x80bc0002,
|
||||||
|
NO_MEMORY = 0x80bc0003,
|
||||||
|
CONNECTION_FAILED = 0x80bc0004,
|
||||||
|
TOO_MANY_REQUESTS = 0x80bc0005,
|
||||||
|
INVALID_TEXT = 0x80bc0006,
|
||||||
|
EVENT_OVERFLOW = 0x80bc0007,
|
||||||
|
NOT_ACTIVE = 0x80bc0008,
|
||||||
|
IME_SUSPENDING = 0x80bc0009,
|
||||||
|
DEVICE_IN_USE = 0x80bc000a,
|
||||||
|
INVALID_USER_ID = 0x80bc0010,
|
||||||
|
INVALID_TYPE = 0x80bc0011,
|
||||||
|
INVALID_SUPPORTED_LANGUAGES = 0x80bc0012,
|
||||||
|
INVALID_ENTER_LABEL = 0x80bc0013,
|
||||||
|
INVALID_INPUT_METHOD = 0x80bc0014,
|
||||||
|
INVALID_OPTION = 0x80bc0015,
|
||||||
|
INVALID_MAX_TEXT_LENGTH = 0x80bc0016,
|
||||||
|
INVALID_INPUT_TEXT_BUFFER = 0x80bc0017,
|
||||||
|
INVALID_POSX = 0x80bc0018,
|
||||||
|
INVALID_POSY = 0x80bc0019,
|
||||||
|
INVALID_HORIZONTALIGNMENT = 0x80bc001a,
|
||||||
|
INVALID_VERTICALALIGNMENT = 0x80bc001b,
|
||||||
|
INVALID_EXTENDED = 0x80bc001c,
|
||||||
|
INVALID_KEYBOARD_TYPE = 0x80bc001d,
|
||||||
|
INVALID_WORK = 0x80bc0020,
|
||||||
|
INVALID_ARG = 0x80bc0021,
|
||||||
|
INVALID_HANDLER = 0x80bc0022,
|
||||||
|
NO_RESOURCE_ID = 0x80bc0023,
|
||||||
|
INVALID_MODE = 0x80bc0024,
|
||||||
|
INVALID_PARAM = 0x80bc0030,
|
||||||
|
INVALID_ADDRESS = 0x80bc0031,
|
||||||
|
INVALID_RESERVED = 0x80bc0032,
|
||||||
|
INVALID_TIMING = 0x80bc0033,
|
||||||
|
INTERNAL = 0x80bc00ff,
|
||||||
|
|
||||||
|
// Ime library
|
||||||
|
DIALOG_INVALID_TITLE = 0x80bc0101,
|
||||||
|
DIALOG_NOT_RUNNING = 0x80bc0105,
|
||||||
|
DIALOG_NOT_FINISHED = 0x80bc0106,
|
||||||
|
DIALOG_NOT_IN_USE = 0x80bc0107
|
||||||
|
};
|
||||||
|
|
||||||
|
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_COPY_PASTE = 128,
|
||||||
|
DISABLE_RESUME = 256,
|
||||||
|
DISABLE_AUTO_SPACE = 512,
|
||||||
|
DISABLE_POSITION_ADJUSTMENT = 2048,
|
||||||
|
EXPANDED_PREEDIT_BUFFER = 4096,
|
||||||
|
USE_JAPANESE_EISUU_KEY_AS_CAPSLOCK = 8192,
|
||||||
|
USE_OVER_2K_COORDINATES = 16384,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeOption);
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeOption> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidImeOptionMask = generate_full_mask<OrbisImeOption>();
|
||||||
|
|
||||||
|
enum class OrbisImeExtOption : u32 {
|
||||||
|
DEFAULT = 0x00000000,
|
||||||
|
SET_PRIORITY = 0x00000002,
|
||||||
|
PRIORITY_FULL_WIDTH = 0x00000008,
|
||||||
|
PRIORITY_FIXED_PANEL = 0x00000010,
|
||||||
|
DISABLE_POINTER = 0x00000040,
|
||||||
|
ENABLE_ADDITIONAL_DICTIONARY = 0x00000080,
|
||||||
|
DISABLE_STARTUP_SE = 0x00000100,
|
||||||
|
DISABLE_LIST_FOR_EXT_KEYBOARD = 0x00000200,
|
||||||
|
HIDE_KEYPANEL_IF_EXT_KEYBOARD = 0x00000400,
|
||||||
|
INIT_EXT_KEYBOARD_MODE = 0x00000800,
|
||||||
|
|
||||||
|
ENABLE_ACCESSIBILITY = 0x00001000, // ImeDialog unly
|
||||||
|
ADDITIONAL_DICTIONARY_PRIORITY_MODE = 0x00004000, // ImeDialog only
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeExtOption);
|
||||||
|
|
||||||
|
constexpr u32 kValidImeExtOptionMask = static_cast<u32>(
|
||||||
|
OrbisImeExtOption::SET_PRIORITY | OrbisImeExtOption::PRIORITY_FULL_WIDTH |
|
||||||
|
OrbisImeExtOption::PRIORITY_FIXED_PANEL | OrbisImeExtOption::DISABLE_POINTER |
|
||||||
|
OrbisImeExtOption::ENABLE_ADDITIONAL_DICTIONARY | OrbisImeExtOption::DISABLE_STARTUP_SE |
|
||||||
|
OrbisImeExtOption::DISABLE_LIST_FOR_EXT_KEYBOARD |
|
||||||
|
OrbisImeExtOption::HIDE_KEYPANEL_IF_EXT_KEYBOARD | OrbisImeExtOption::INIT_EXT_KEYBOARD_MODE);
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeExtOption> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidImeDialogExtOptionMask = generate_full_mask<OrbisImeExtOption>();
|
||||||
|
|
||||||
|
enum class OrbisImeLanguage : u64 {
|
||||||
|
DANISH = 0x0000000000000001,
|
||||||
|
GERMAN = 0x0000000000000002,
|
||||||
|
ENGLISH_US = 0x0000000000000004,
|
||||||
|
SPANISH = 0x0000000000000008,
|
||||||
|
FRENCH = 0x0000000000000010,
|
||||||
|
ITALIAN = 0x0000000000000020,
|
||||||
|
DUTCH = 0x0000000000000040,
|
||||||
|
NORWEGIAN = 0x0000000000000080,
|
||||||
|
POLISH = 0x0000000000000100,
|
||||||
|
PORTUGUESE_PT = 0x0000000000000200,
|
||||||
|
RUSSIAN = 0x0000000000000400,
|
||||||
|
FINNISH = 0x0000000000000800,
|
||||||
|
SWEDISH = 0x0000000000001000,
|
||||||
|
JAPANESE = 0x0000000000002000,
|
||||||
|
KOREAN = 0x0000000000004000,
|
||||||
|
SIMPLIFIED_CHINESE = 0x0000000000008000,
|
||||||
|
TRADITIONAL_CHINESE = 0x0000000000010000,
|
||||||
|
PORTUGUESE_BR = 0x0000000000020000,
|
||||||
|
ENGLISH_GB = 0x0000000000040000,
|
||||||
|
TURKISH = 0x0000000000080000,
|
||||||
|
SPANISH_LA = 0x0000000000100000,
|
||||||
|
ARABIC = 0x0000000001000000,
|
||||||
|
FRENCH_CA = 0x0000000002000000,
|
||||||
|
THAI = 0x0000000004000000,
|
||||||
|
CZECH = 0x0000000008000000,
|
||||||
|
GREEK = 0x0000000010000000,
|
||||||
|
INDONESIAN = 0x0000000020000000,
|
||||||
|
VIETNAMESE = 0x0000000040000000,
|
||||||
|
ROMANIAN = 0x0000000080000000,
|
||||||
|
HUNGARIAN = 0x0000000100000000,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeLanguage);
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeLanguage> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u64 kValidOrbisImeLanguageMask = generate_full_mask<OrbisImeLanguage>();
|
||||||
|
|
||||||
|
enum class OrbisImeDisableDevice : u32 {
|
||||||
|
DEFAULT = 0x00000000,
|
||||||
|
CONTROLLER = 0x00000001,
|
||||||
|
EXT_KEYBOARD = 0x00000002,
|
||||||
|
REMOTE_OSK = 0x00000004,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDisableDevice);
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeDisableDevice> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidOrbisImeDisableDeviceMask = generate_full_mask<OrbisImeDisableDevice>();
|
||||||
|
|
||||||
|
enum class OrbisImeInputMethodState : u32 {
|
||||||
|
PREEDIT = 0x01000000,
|
||||||
|
SELECTED = 0x02000000,
|
||||||
|
NATIVE = 0x04000000,
|
||||||
|
NATIVE2 = 0x08000000,
|
||||||
|
FULL_WIDTH = 0x10000000,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeInputMethodState);
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeInputMethodState> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidOrbisImeInputMethodStateMask = generate_full_mask<OrbisImeInputMethodState>();
|
||||||
|
|
||||||
|
enum class OrbisImeInitExtKeyboardMode : u32 {
|
||||||
|
ISABLE_ARABIC_INDIC_NUMERALS = 0x00000001,
|
||||||
|
ENABLE_FORMAT_CHARACTERS = 0x00000002,
|
||||||
|
INPUT_METHOD_STATE_NATIVE = 0x04000000,
|
||||||
|
INPUT_METHOD_STATE_NATIVE2 = 0x08000000,
|
||||||
|
INPUT_METHOD_STATE_FULL_WIDTH = 0x10000000,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeInitExtKeyboardMode);
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeInitExtKeyboardMode> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidOrbisImeInitExtKeyboardModeMask = generate_full_mask<OrbisImeInitExtKeyboardMode>();
|
||||||
|
|
||||||
|
enum class OrbisImeKeycodeState : u32 {
|
||||||
|
KEYCODE_VALID = 0x00000001,
|
||||||
|
CHARACTER_VALID = 0x00000002,
|
||||||
|
WITH_IME = 0x00000004,
|
||||||
|
FROM_OSK = 0x00000008,
|
||||||
|
FROM_OSK_SHORTCUT = 0x00000010,
|
||||||
|
FROM_IME_OPERATION = 0x00000020,
|
||||||
|
REPLACE_CHARACTER = 0x00000040,
|
||||||
|
CONTINUOUS_EVENT = 0x00000080,
|
||||||
|
MODIFIER_L_CTRL = 0x00000100,
|
||||||
|
MODIFIER_L_SHIFT = 0x00000200,
|
||||||
|
MODIFIER_L_ALT = 0x00000400,
|
||||||
|
MODIFIER_L_GUI = 0x00000800,
|
||||||
|
MODIFIER_R_CTRL = 0x00001000,
|
||||||
|
MODIFIER_R_SHIFT = 0x00002000,
|
||||||
|
MODIFIER_R_ALT = 0x00004000,
|
||||||
|
MODIFIER_R_GUI = 0x00008000,
|
||||||
|
LED_NUM_LOCK = 0x00010000,
|
||||||
|
LED_CAPS_LOCK = 0x00020000,
|
||||||
|
LED_SCROLL_LOCK = 0x00040000,
|
||||||
|
RESERVED1 = 0x00080000,
|
||||||
|
RESERVED2 = 0x00100000,
|
||||||
|
FROM_IME_INPUT = 0x00200000,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeKeycodeState);
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeKeycodeState> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidOrbisImeKeycodeStateMask = generate_full_mask<OrbisImeKeycodeState>();
|
||||||
|
|
||||||
|
enum class OrbisImeKeyboardOption : u32 {
|
||||||
|
Default = 0,
|
||||||
|
Repeat = 1,
|
||||||
|
RepeatEachKey = 2,
|
||||||
|
AddOsk = 4,
|
||||||
|
EffectiveWithIme = 8,
|
||||||
|
DisableResume = 16,
|
||||||
|
DisableCapslockWithoutShift = 32,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeKeyboardOption)
|
||||||
|
template <>
|
||||||
|
struct magic_enum::customize::enum_range<OrbisImeKeyboardOption> {
|
||||||
|
static constexpr bool is_flags = true;
|
||||||
|
};
|
||||||
|
const u32 kValidOrbisImeKeyboardOptionMask = generate_full_mask<OrbisImeKeyboardOption>();
|
||||||
|
|
||||||
|
enum class OrbisImeKeyboardMode : u32 {
|
||||||
|
Auto = 0,
|
||||||
|
Manual = 1,
|
||||||
|
Alphabet = 0,
|
||||||
|
Native = 2,
|
||||||
|
Part = 4,
|
||||||
|
Katakana = 8,
|
||||||
|
Hkana = 16,
|
||||||
|
ArabicIndicNumerals = 32,
|
||||||
|
DisableFormatCharacters = 64,
|
||||||
|
};
|
||||||
|
|
||||||
enum class OrbisImeType : u32 {
|
enum class OrbisImeType : u32 {
|
||||||
Default = 0,
|
Default = 0,
|
||||||
BasicLatin = 1,
|
BasicLatin = 1,
|
||||||
@ -41,6 +305,7 @@ enum class OrbisImeEventId : u32 {
|
|||||||
Open = 0,
|
Open = 0,
|
||||||
UpdateText = 1,
|
UpdateText = 1,
|
||||||
UpdateCaret = 2,
|
UpdateCaret = 2,
|
||||||
|
ChangeSize = 3,
|
||||||
PressClose = 4,
|
PressClose = 4,
|
||||||
PressEnter = 5,
|
PressEnter = 5,
|
||||||
Abort = 6,
|
Abort = 6,
|
||||||
@ -51,10 +316,14 @@ enum class OrbisImeEventId : u32 {
|
|||||||
CandidateDone = 11,
|
CandidateDone = 11,
|
||||||
CandidateCancel = 12,
|
CandidateCancel = 12,
|
||||||
ChangeDevice = 14,
|
ChangeDevice = 14,
|
||||||
|
JumpToNextObject = 15,
|
||||||
|
JumpToBeforeObject = 16,
|
||||||
|
ChangeWindowType = 17,
|
||||||
|
|
||||||
ChangeInputMethodState = 18,
|
ChangeInputMethodState = 18,
|
||||||
|
|
||||||
KeyboardOpen = 256,
|
KeyboardOpen = 256,
|
||||||
KeyboardKeycodeDoen = 257,
|
KeyboardKeycodeDown = 257,
|
||||||
KeyboardKeycodeUp = 258,
|
KeyboardKeycodeUp = 258,
|
||||||
KeyboardKeycodeRepeat = 259,
|
KeyboardKeycodeRepeat = 259,
|
||||||
KeyboardConnection = 260,
|
KeyboardConnection = 260,
|
||||||
@ -110,6 +379,13 @@ enum class OrbisImeDeviceType : u32 {
|
|||||||
RemoteOsk = 3,
|
RemoteOsk = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class OrbisImePanelPriority : u32 {
|
||||||
|
Default = 0,
|
||||||
|
Alphabet = 1,
|
||||||
|
Symbol = 2,
|
||||||
|
Accent = 3,
|
||||||
|
};
|
||||||
|
|
||||||
struct OrbisImeRect {
|
struct OrbisImeRect {
|
||||||
f32 x;
|
f32 x;
|
||||||
f32 y;
|
f32 y;
|
||||||
@ -117,8 +393,22 @@ struct OrbisImeRect {
|
|||||||
u32 height;
|
u32 height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OrbisImeColor {
|
||||||
|
u8 r;
|
||||||
|
u8 g;
|
||||||
|
u8 b;
|
||||||
|
u8 a;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class OrbisImeTextAreaMode : u32 {
|
||||||
|
Disable = 0,
|
||||||
|
Edit = 1,
|
||||||
|
Preedit = 2,
|
||||||
|
Select = 3,
|
||||||
|
};
|
||||||
|
|
||||||
struct OrbisImeTextAreaProperty {
|
struct OrbisImeTextAreaProperty {
|
||||||
u32 mode; // OrbisImeTextAreaMode
|
OrbisImeTextAreaMode mode;
|
||||||
u32 index;
|
u32 index;
|
||||||
s32 length;
|
s32 length;
|
||||||
};
|
};
|
||||||
@ -135,14 +425,14 @@ struct OrbisImeKeycode {
|
|||||||
char16_t character;
|
char16_t character;
|
||||||
u32 status;
|
u32 status;
|
||||||
OrbisImeKeyboardType type;
|
OrbisImeKeyboardType type;
|
||||||
s32 user_id;
|
Libraries::UserService::OrbisUserServiceUserId user_id;
|
||||||
u32 resource_id;
|
u32 resource_id;
|
||||||
Libraries::Rtc::OrbisRtcTick timestamp;
|
Libraries::Rtc::OrbisRtcTick timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeKeyboardResourceIdArray {
|
struct OrbisImeKeyboardResourceIdArray {
|
||||||
s32 userId;
|
Libraries::UserService::OrbisUserServiceUserId user_id;
|
||||||
u32 resourceId[5];
|
u32 resource_id[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeCaretMovementDirection : u32 {
|
enum class OrbisImeCaretMovementDirection : u32 {
|
||||||
@ -159,6 +449,16 @@ enum class OrbisImeCaretMovementDirection : u32 {
|
|||||||
Bottom = 10,
|
Bottom = 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class OrbisImePanelType : u32 {
|
||||||
|
Hide = 0,
|
||||||
|
Osk = 1,
|
||||||
|
Dialog = 2,
|
||||||
|
Candidate = 3,
|
||||||
|
Edit = 4,
|
||||||
|
EditAndCandidate = 5,
|
||||||
|
Accessibility = 6,
|
||||||
|
};
|
||||||
|
|
||||||
union OrbisImeEventParam {
|
union OrbisImeEventParam {
|
||||||
OrbisImeRect rect;
|
OrbisImeRect rect;
|
||||||
OrbisImeEditText text;
|
OrbisImeEditText text;
|
||||||
@ -168,6 +468,7 @@ union OrbisImeEventParam {
|
|||||||
char16_t* candidate_word;
|
char16_t* candidate_word;
|
||||||
s32 candidate_index;
|
s32 candidate_index;
|
||||||
OrbisImeDeviceType device_type;
|
OrbisImeDeviceType device_type;
|
||||||
|
OrbisImePanelType panel_type;
|
||||||
u32 input_method_state;
|
u32 input_method_state;
|
||||||
s8 reserved[64];
|
s8 reserved[64];
|
||||||
};
|
};
|
||||||
@ -177,7 +478,84 @@ struct OrbisImeEvent {
|
|||||||
OrbisImeEventParam param;
|
OrbisImeEventParam param;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using OrbisImeExtKeyboardFilter = PS4_SYSV_ABI int (*)(const OrbisImeKeycode* srcKeycode,
|
||||||
|
u16* outKeycode, u32* outStatus,
|
||||||
|
void* reserved);
|
||||||
|
|
||||||
using OrbisImeTextFilter = PS4_SYSV_ABI int (*)(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);
|
||||||
|
|
||||||
using OrbisImeEventHandler = PS4_SYSV_ABI void (*)(void* arg, const OrbisImeEvent* e);
|
using OrbisImeEventHandler = PS4_SYSV_ABI void (*)(void* arg, const OrbisImeEvent* e);
|
||||||
|
|
||||||
|
struct OrbisImeKeyboardParam {
|
||||||
|
OrbisImeKeyboardOption option;
|
||||||
|
s8 reserved1[4];
|
||||||
|
void* arg;
|
||||||
|
OrbisImeEventHandler handler;
|
||||||
|
s8 reserved2[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisImeParam {
|
||||||
|
Libraries::UserService::OrbisUserServiceUserId user_id;
|
||||||
|
OrbisImeType type;
|
||||||
|
OrbisImeLanguage supported_languages;
|
||||||
|
OrbisImeEnterLabel enter_label;
|
||||||
|
OrbisImeInputMethod input_method;
|
||||||
|
OrbisImeTextFilter filter;
|
||||||
|
OrbisImeOption option;
|
||||||
|
u32 maxTextLength;
|
||||||
|
char16_t* inputTextBuffer;
|
||||||
|
f32 posx;
|
||||||
|
f32 posy;
|
||||||
|
OrbisImeHorizontalAlignment horizontal_alignment;
|
||||||
|
OrbisImeVerticalAlignment vertical_alignment;
|
||||||
|
void* work;
|
||||||
|
void* arg;
|
||||||
|
OrbisImeEventHandler handler;
|
||||||
|
s8 reserved[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisImeCaret {
|
||||||
|
f32 x;
|
||||||
|
f32 y;
|
||||||
|
u32 height;
|
||||||
|
u32 index;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisImeDialogParam {
|
||||||
|
Libraries::UserService::OrbisUserServiceUserId user_id;
|
||||||
|
OrbisImeType type;
|
||||||
|
OrbisImeLanguage supported_languages;
|
||||||
|
OrbisImeEnterLabel enter_label;
|
||||||
|
OrbisImeInputMethod input_method;
|
||||||
|
OrbisImeTextFilter filter;
|
||||||
|
OrbisImeOption option;
|
||||||
|
u32 max_text_length;
|
||||||
|
char16_t* input_text_buffer;
|
||||||
|
f32 posx;
|
||||||
|
f32 posy;
|
||||||
|
OrbisImeHorizontalAlignment horizontal_alignment;
|
||||||
|
OrbisImeVerticalAlignment vertical_alignment;
|
||||||
|
const char16_t* placeholder;
|
||||||
|
const char16_t* title;
|
||||||
|
s8 reserved[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisImeParamExtended {
|
||||||
|
OrbisImeExtOption option;
|
||||||
|
OrbisImeColor color_base;
|
||||||
|
OrbisImeColor color_line;
|
||||||
|
OrbisImeColor color_text_field;
|
||||||
|
OrbisImeColor color_preedit;
|
||||||
|
OrbisImeColor color_button_default;
|
||||||
|
OrbisImeColor color_button_function;
|
||||||
|
OrbisImeColor color_button_symbol;
|
||||||
|
OrbisImeColor color_text;
|
||||||
|
OrbisImeColor color_special;
|
||||||
|
OrbisImePanelPriority priority;
|
||||||
|
char* additional_dictionary_path;
|
||||||
|
OrbisImeExtKeyboardFilter ext_keyboard_filter;
|
||||||
|
OrbisImeDisableDevice disable_device;
|
||||||
|
u32 ext_keyboard_mode;
|
||||||
|
s8 reserved[60];
|
||||||
|
};
|
||||||
|
@ -20,19 +20,19 @@ 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(OrbisImeOption option, OrbisImeType type) {
|
||||||
if (False(~option &
|
if (False(~option & (OrbisImeOption::MULTILINE |
|
||||||
(OrbisImeDialogOption::Multiline | OrbisImeDialogOption::NoAutoCompletion))) {
|
OrbisImeOption::NO_AUTO_CAPITALIZATION /* NoAutoCompletion */))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (True(option & OrbisImeDialogOption::Multiline) && type != OrbisImeType::Default &&
|
if (True(option & OrbisImeOption::MULTILINE) && type != OrbisImeType::Default &&
|
||||||
type != OrbisImeType::BasicLatin) {
|
type != OrbisImeType::BasicLatin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (True(option & OrbisImeDialogOption::NoAutoCompletion) && type != OrbisImeType::Number &&
|
if (True(option & OrbisImeOption::NO_AUTO_CAPITALIZATION /* NoAutoCompletion */) &&
|
||||||
type != OrbisImeType::BasicLatin) {
|
type != OrbisImeType::Number && type != OrbisImeType::BasicLatin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ Error PS4_SYSV_ABI sceImeDialogGetPanelSize(const OrbisImeDialogParam* param, u3
|
|||||||
case OrbisImeType::Url:
|
case OrbisImeType::Url:
|
||||||
case OrbisImeType::Mail:
|
case OrbisImeType::Mail:
|
||||||
*width = 500; // original: 793
|
*width = 500; // original: 793
|
||||||
if (True(param->option & OrbisImeDialogOption::Multiline)) {
|
if (True(param->option & OrbisImeOption::MULTILINE)) {
|
||||||
*height = 300; // original: 576
|
*height = 300; // original: 576
|
||||||
} else {
|
} else {
|
||||||
*height = 150; // original: 476
|
*height = 150; // original: 476
|
||||||
@ -149,18 +149,47 @@ OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) {
|
Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) {
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: entering, param={}, extended={}",
|
||||||
|
static_cast<void*>(param), static_cast<void*>(extended));
|
||||||
|
|
||||||
|
if (param == nullptr) {
|
||||||
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: param is null");
|
||||||
|
return Error::INVALID_ADDRESS;
|
||||||
|
} else {
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.user_id = {}",
|
||||||
|
static_cast<u32>(param->user_id));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.type = {}", static_cast<u32>(param->type));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.supported_languages = 0x{:X}",
|
||||||
|
static_cast<u64>(param->supported_languages));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.enter_label = {}",
|
||||||
|
static_cast<u32>(param->enter_label));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.input_method = {}",
|
||||||
|
static_cast<u32>(param->input_method));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.filter = {}", (void*)param->filter);
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.option = 0x{:X}",
|
||||||
|
static_cast<u32>(param->option));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.max_text_length = {}",
|
||||||
|
param->max_text_length);
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.input_text_buffer = {}",
|
||||||
|
(void*)param->input_text_buffer);
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.posx = {}", param->posx);
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.posy = {}", param->posy);
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.horizontal_alignment = {}",
|
||||||
|
static_cast<u32>(param->horizontal_alignment));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.vertical_alignment = {}",
|
||||||
|
static_cast<u32>(param->vertical_alignment));
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.placeholder = {}",
|
||||||
|
param->placeholder ? "<non-null>" : "NULL");
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: param.title = {}",
|
||||||
|
param->title ? "<non-null>" : "NULL");
|
||||||
|
}
|
||||||
if (g_ime_dlg_status != OrbisImeDialogStatus::None) {
|
if (g_ime_dlg_status != OrbisImeDialogStatus::None) {
|
||||||
LOG_INFO(Lib_ImeDialog, "IME dialog is already running");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: busy (status={})", (u32)g_ime_dlg_status);
|
||||||
return Error::BUSY;
|
return Error::BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param == nullptr) {
|
|
||||||
LOG_INFO(Lib_ImeDialog, "called with param (NULL)");
|
|
||||||
return Error::INVALID_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!magic_enum::enum_contains(param->type)) {
|
if (!magic_enum::enum_contains(param->type)) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->type");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: invalid param->type={}", (u32)param->type);
|
||||||
return Error::INVALID_ADDRESS;
|
return Error::INVALID_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,15 +198,15 @@ 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::LargeResolution)]) {
|
MAX_X_POSITIONS[False(param->option & OrbisImeOption::USE_OVER_2K_COORDINATES)]) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->posx");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: invalid posx={}", 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::LargeResolution)]) {
|
MAX_Y_POSITIONS[False(param->option & OrbisImeOption::USE_OVER_2K_COORDINATES)]) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->posy");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: invalid posy={}", param->posy);
|
||||||
return Error::INVALID_POSY;
|
return Error::INVALID_POSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,44 +221,55 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!IsValidOption(param->option, param->type)) {
|
if (!IsValidOption(param->option, param->type)) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->option");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: invalid option=0x{:X}for type={}",
|
||||||
|
static_cast<u32>(param->option), (u32)param->type);
|
||||||
return Error::INVALID_PARAM;
|
return Error::INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->input_text_buffer == nullptr) {
|
if (param->input_text_buffer == nullptr) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->inputTextBuffer");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: input_text_buffer is null");
|
||||||
return Error::INVALID_INPUT_TEXT_BUFFER;
|
return Error::INVALID_INPUT_TEXT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extended) {
|
if (extended) {
|
||||||
if (!magic_enum::enum_contains(extended->priority)) {
|
if (!magic_enum::enum_contains(extended->priority)) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->priority");
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: Invalid extended->priority");
|
||||||
return Error::INVALID_EXTENDED;
|
return Error::INVALID_EXTENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do correct extended->option validation
|
// TODO: do correct extended->option validation
|
||||||
|
|
||||||
if ((extended->ext_keyboard_mode & 0xe3fffffc) != 0) {
|
if ((extended->ext_keyboard_mode & 0xe3fffffc) != 0) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->extKeyboardMode");
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: Invalid extended->extKeyboardMode");
|
||||||
return Error::INVALID_EXTENDED;
|
return Error::INVALID_EXTENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extended->disable_device > 7) {
|
if (static_cast<u32>(extended->disable_device) & ~kValidOrbisImeDisableDeviceMask) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->disableDevice");
|
LOG_ERROR(Lib_ImeDialog,
|
||||||
|
"sceImeDialogInit: disable_device has invalid bits set (0x{:X})",
|
||||||
|
static_cast<u32>(extended->disable_device));
|
||||||
return Error::INVALID_EXTENDED;
|
return Error::INVALID_EXTENDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->max_text_length > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
|
if (param->max_text_length == 0 || param->max_text_length > ORBIS_IME_MAX_TEXT_LENGTH) {
|
||||||
LOG_INFO(Lib_ImeDialog, "Invalid param->maxTextLength");
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: invalid max_text_length={}",
|
||||||
|
param->max_text_length);
|
||||||
return Error::INVALID_MAX_TEXT_LENGTH;
|
return Error::INVALID_MAX_TEXT_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Title string validation
|
||||||
|
if (param->title != nullptr && !std::char_traits<char16_t>::length(param->title)) {
|
||||||
|
LOG_ERROR(Lib_ImeDialog, "sceImeDialogInit: title is empty");
|
||||||
|
return Error::INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
LOG_INFO(Lib_ImeDialog, "sceImeDialogInit: successful, status now=Running");
|
||||||
return Error::OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +311,7 @@ Error PS4_SYSV_ABI sceImeDialogTerm() {
|
|||||||
return Error::OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("oBmw4xrmfKs", "libSceImeDialog", 1, "libSceImeDialog", 1, 1, sceImeDialogAbort);
|
LIB_FUNCTION("oBmw4xrmfKs", "libSceImeDialog", 1, "libSceImeDialog", 1, 1, sceImeDialogAbort);
|
||||||
LIB_FUNCTION("bX4H+sxPI-o", "libSceImeDialog", 1, "libSceImeDialog", 1, 1,
|
LIB_FUNCTION("bX4H+sxPI-o", "libSceImeDialog", 1, "libSceImeDialog", 1, 1,
|
||||||
sceImeDialogForceClose);
|
sceImeDialogForceClose);
|
||||||
|
@ -13,50 +13,6 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::ImeDialog {
|
namespace Libraries::ImeDialog {
|
||||||
|
|
||||||
constexpr u32 ORBIS_IME_DIALOG_MAX_TEXT_LENGTH = 2048;
|
|
||||||
|
|
||||||
enum class Error : u32 {
|
|
||||||
OK = 0x0,
|
|
||||||
BUSY = 0x80bc0001,
|
|
||||||
NOT_OPENED = 0x80bc0002,
|
|
||||||
NO_MEMORY = 0x80bc0003,
|
|
||||||
CONNECTION_FAILED = 0x80bc0004,
|
|
||||||
TOO_MANY_REQUESTS = 0x80bc0005,
|
|
||||||
INVALID_TEXT = 0x80bc0006,
|
|
||||||
EVENT_OVERFLOW = 0x80bc0007,
|
|
||||||
NOT_ACTIVE = 0x80bc0008,
|
|
||||||
IME_SUSPENDING = 0x80bc0009,
|
|
||||||
DEVICE_IN_USE = 0x80bc000a,
|
|
||||||
INVALID_USER_ID = 0x80bc0010,
|
|
||||||
INVALID_TYPE = 0x80bc0011,
|
|
||||||
INVALID_SUPPORTED_LANGUAGES = 0x80bc0012,
|
|
||||||
INVALID_ENTER_LABEL = 0x80bc0013,
|
|
||||||
INVALID_INPUT_METHOD = 0x80bc0014,
|
|
||||||
INVALID_OPTION = 0x80bc0015,
|
|
||||||
INVALID_MAX_TEXT_LENGTH = 0x80bc0016,
|
|
||||||
INVALID_INPUT_TEXT_BUFFER = 0x80bc0017,
|
|
||||||
INVALID_POSX = 0x80bc0018,
|
|
||||||
INVALID_POSY = 0x80bc0019,
|
|
||||||
INVALID_HORIZONTALIGNMENT = 0x80bc001a,
|
|
||||||
INVALID_VERTICALALIGNMENT = 0x80bc001b,
|
|
||||||
INVALID_EXTENDED = 0x80bc001c,
|
|
||||||
INVALID_KEYBOARD_TYPE = 0x80bc001d,
|
|
||||||
INVALID_WORK = 0x80bc0020,
|
|
||||||
INVALID_ARG = 0x80bc0021,
|
|
||||||
INVALID_HANDLER = 0x80bc0022,
|
|
||||||
NO_RESOURCE_ID = 0x80bc0023,
|
|
||||||
INVALID_MODE = 0x80bc0024,
|
|
||||||
INVALID_PARAM = 0x80bc0030,
|
|
||||||
INVALID_ADDRESS = 0x80bc0031,
|
|
||||||
INVALID_RESERVED = 0x80bc0032,
|
|
||||||
INVALID_TIMING = 0x80bc0033,
|
|
||||||
INTERNAL = 0x80bc00ff,
|
|
||||||
DIALOG_INVALID_TITLE = 0x80bc0101,
|
|
||||||
DIALOG_NOT_RUNNING = 0x80bc0105,
|
|
||||||
DIALOG_NOT_FINISHED = 0x80bc0106,
|
|
||||||
DIALOG_NOT_IN_USE = 0x80bc0107,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class OrbisImeDialogStatus : u32 {
|
enum class OrbisImeDialogStatus : u32 {
|
||||||
None = 0,
|
None = 0,
|
||||||
Running = 1,
|
Running = 1,
|
||||||
@ -69,87 +25,11 @@ enum class OrbisImeDialogEndStatus : u32 {
|
|||||||
Aborted = 2,
|
Aborted = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisImeDialogOption : u32 {
|
|
||||||
Default = 0,
|
|
||||||
Multiline = 1,
|
|
||||||
NoAutoCorrection = 2,
|
|
||||||
NoAutoCompletion = 4,
|
|
||||||
// TODO: Document missing options
|
|
||||||
LargeResolution = 1024,
|
|
||||||
};
|
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDialogOption)
|
|
||||||
|
|
||||||
enum class OrbisImePanelPriority : u32 {
|
|
||||||
Default = 0,
|
|
||||||
Alphabet = 1,
|
|
||||||
Symbol = 2,
|
|
||||||
Accent = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisImeColor {
|
|
||||||
u8 r;
|
|
||||||
u8 g;
|
|
||||||
u8 b;
|
|
||||||
u8 a;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisImeDialogResult {
|
struct OrbisImeDialogResult {
|
||||||
OrbisImeDialogEndStatus endstatus;
|
OrbisImeDialogEndStatus endstatus;
|
||||||
s32 reserved[12];
|
s32 reserved[12];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisImeKeycode {
|
|
||||||
u16 keycode;
|
|
||||||
char16_t character;
|
|
||||||
u32 status;
|
|
||||||
OrbisImeKeyboardType type;
|
|
||||||
s32 user_id;
|
|
||||||
u32 resource_id;
|
|
||||||
u64 timestamp;
|
|
||||||
};
|
|
||||||
|
|
||||||
using OrbisImeExtKeyboardFilter = PS4_SYSV_ABI int (*)(const OrbisImeKeycode* srcKeycode,
|
|
||||||
u16* outKeycode, u32* outStatus,
|
|
||||||
void* reserved);
|
|
||||||
|
|
||||||
struct OrbisImeDialogParam {
|
|
||||||
s32 user_id;
|
|
||||||
OrbisImeType type;
|
|
||||||
u64 supported_languages;
|
|
||||||
OrbisImeEnterLabel enter_label;
|
|
||||||
OrbisImeInputMethod input_method;
|
|
||||||
OrbisImeTextFilter filter;
|
|
||||||
OrbisImeDialogOption option;
|
|
||||||
u32 max_text_length;
|
|
||||||
char16_t* input_text_buffer;
|
|
||||||
float posx;
|
|
||||||
float posy;
|
|
||||||
OrbisImeHorizontalAlignment horizontal_alignment;
|
|
||||||
OrbisImeVerticalAlignment vertical_alignment;
|
|
||||||
const char16_t* placeholder;
|
|
||||||
const char16_t* title;
|
|
||||||
s8 reserved[16];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisImeParamExtended {
|
|
||||||
u32 option; // OrbisImeDialogOptionExtended
|
|
||||||
OrbisImeColor color_base;
|
|
||||||
OrbisImeColor color_line;
|
|
||||||
OrbisImeColor color_text_field;
|
|
||||||
OrbisImeColor color_preedit;
|
|
||||||
OrbisImeColor color_button_default;
|
|
||||||
OrbisImeColor color_button_function;
|
|
||||||
OrbisImeColor color_button_symbol;
|
|
||||||
OrbisImeColor color_text;
|
|
||||||
OrbisImeColor color_special;
|
|
||||||
OrbisImePanelPriority priority;
|
|
||||||
char* additional_dictionary_path;
|
|
||||||
OrbisImeExtKeyboardFilter ext_keyboard_filter;
|
|
||||||
uint32_t disable_device;
|
|
||||||
uint32_t ext_keyboard_mode;
|
|
||||||
int8_t reserved[60];
|
|
||||||
};
|
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceImeDialogAbort();
|
Error PS4_SYSV_ABI sceImeDialogAbort();
|
||||||
Error PS4_SYSV_ABI sceImeDialogForceClose();
|
Error PS4_SYSV_ABI sceImeDialogForceClose();
|
||||||
Error PS4_SYSV_ABI sceImeDialogForTestFunction();
|
Error PS4_SYSV_ABI sceImeDialogForTestFunction();
|
||||||
@ -167,5 +47,5 @@ int PS4_SYSV_ABI sceImeDialogInitInternal3();
|
|||||||
int PS4_SYSV_ABI sceImeDialogSetPanelPosition();
|
int PS4_SYSV_ABI sceImeDialogSetPanelPosition();
|
||||||
Error PS4_SYSV_ABI sceImeDialogTerm();
|
Error PS4_SYSV_ABI sceImeDialogTerm();
|
||||||
|
|
||||||
void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::ImeDialog
|
} // namespace Libraries::ImeDialog
|
||||||
|
@ -21,12 +21,16 @@ namespace Libraries::ImeDialog {
|
|||||||
|
|
||||||
ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
||||||
const OrbisImeParamExtended* extended) {
|
const OrbisImeParamExtended* extended) {
|
||||||
|
LOG_INFO(Lib_ImeDialog, ">> ImeDialogState::Ctor: param={}, text_buffer={}",
|
||||||
|
static_cast<const void*>(param),
|
||||||
|
static_cast<void*>(param ? param->input_text_buffer : nullptr));
|
||||||
if (!param) {
|
if (!param) {
|
||||||
|
LOG_ERROR(Lib_ImeDialog, " param==nullptr, returning without init");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user_id = param->user_id;
|
user_id = param->user_id;
|
||||||
is_multi_line = True(param->option & OrbisImeDialogOption::Multiline);
|
is_multi_line = True(param->option & OrbisImeOption::MULTILINE);
|
||||||
is_numeric = param->type == OrbisImeType::Number;
|
is_numeric = param->type == OrbisImeType::Number;
|
||||||
type = param->type;
|
type = param->type;
|
||||||
enter_label = param->enter_label;
|
enter_label = param->enter_label;
|
||||||
@ -220,6 +224,7 @@ void ImeDialogUi::Free() {
|
|||||||
|
|
||||||
void ImeDialogUi::Draw() {
|
void ImeDialogUi::Draw() {
|
||||||
std::unique_lock lock{draw_mutex};
|
std::unique_lock lock{draw_mutex};
|
||||||
|
LOG_INFO(Lib_ImeDialog, ">> ImeDialogUi::Draw: first_render=%d", first_render);
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return;
|
return;
|
||||||
@ -259,9 +264,13 @@ void ImeDialogUi::Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state->is_multi_line) {
|
if (state->is_multi_line) {
|
||||||
|
LOG_INFO(Lib_ImeDialog, " Drawing multi-line widget…");
|
||||||
DrawMultiLineInputText();
|
DrawMultiLineInputText();
|
||||||
|
LOG_INFO(Lib_ImeDialog, " Done DrawMultiLineInputText");
|
||||||
} else {
|
} else {
|
||||||
|
LOG_INFO(Lib_ImeDialog, " Drawing input text widget…");
|
||||||
DrawInputText();
|
DrawInputText();
|
||||||
|
LOG_INFO(Lib_ImeDialog, " Done DrawInputText");
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCursorPosY(GetCursorPosY() + 10.0f);
|
SetCursorPosY(GetCursorPosY() + 10.0f);
|
||||||
@ -306,6 +315,7 @@ void ImeDialogUi::Draw() {
|
|||||||
End();
|
End();
|
||||||
|
|
||||||
first_render = false;
|
first_render = false;
|
||||||
|
LOG_INFO(Lib_ImeDialog, "<< ImeDialogUi::Draw complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImeDialogUi::DrawInputText() {
|
void ImeDialogUi::DrawInputText() {
|
||||||
@ -316,7 +326,7 @@ void ImeDialogUi::DrawInputText() {
|
|||||||
}
|
}
|
||||||
const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
||||||
if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(),
|
if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(),
|
||||||
state->max_text_length, input_size, ImGuiInputTextFlags_CallbackCharFilter,
|
state->max_text_length + 1, input_size, ImGuiInputTextFlags_CallbackCharFilter,
|
||||||
InputTextCallback, this)) {
|
InputTextCallback, this)) {
|
||||||
state->input_changed = true;
|
state->input_changed = true;
|
||||||
}
|
}
|
||||||
@ -332,7 +342,7 @@ void ImeDialogUi::DrawMultiLineInputText() {
|
|||||||
}
|
}
|
||||||
const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
||||||
if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(),
|
if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(),
|
||||||
state->max_text_length, input_size, flags, InputTextCallback, this)) {
|
state->max_text_length + 1, input_size, flags, InputTextCallback, this)) {
|
||||||
state->input_changed = true;
|
state->input_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,13 +351,19 @@ int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
ImeDialogUi* ui = static_cast<ImeDialogUi*>(data->UserData);
|
ImeDialogUi* ui = static_cast<ImeDialogUi*>(data->UserData);
|
||||||
ASSERT(ui);
|
ASSERT(ui);
|
||||||
|
|
||||||
|
LOG_DEBUG(Lib_ImeDialog, ">> InputTextCallback: EventFlag={}, EventChar={}", data->EventFlag,
|
||||||
|
data->EventChar);
|
||||||
|
|
||||||
// Should we filter punctuation?
|
// Should we filter punctuation?
|
||||||
if (ui->state->is_numeric && (data->EventChar < '0' || data->EventChar > '9') &&
|
if (ui->state->is_numeric && (data->EventChar < '0' || data->EventChar > '9') &&
|
||||||
data->EventChar != '\b' && data->EventChar != ',' && data->EventChar != '.') {
|
data->EventChar != '\b' && data->EventChar != ',' && data->EventChar != '.') {
|
||||||
|
LOG_INFO(Lib_ImeDialog, "InputTextCallback: rejecting non-digit char '{}'",
|
||||||
|
static_cast<char>(data->EventChar));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ui->state->keyboard_filter) {
|
if (!ui->state->keyboard_filter) {
|
||||||
|
LOG_DEBUG(Lib_ImeDialog, "InputTextCallback: no keyboard_filter, accepting char");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,20 +379,24 @@ int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
// the current language?)
|
// the current language?)
|
||||||
.user_id = ui->state->user_id,
|
.user_id = ui->state->user_id,
|
||||||
.resource_id = 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, "InputTextCallback: ConvertUTF8ToOrbis failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
LOG_DEBUG(Lib_ImeDialog, "InputTextCallback: converted to Orbis char={:#X}",
|
||||||
|
static_cast<uint16_t>(src_keycode.character));
|
||||||
src_keycode.keycode = src_keycode.character; // TODO set this to the correct value
|
src_keycode.keycode = src_keycode.character; // TODO set this to the correct value
|
||||||
|
|
||||||
u16 out_keycode;
|
u16 out_keycode;
|
||||||
u32 out_status;
|
u32 out_status;
|
||||||
|
|
||||||
ui->state->CallKeyboardFilter(&src_keycode, &out_keycode, &out_status);
|
bool keep = ui->state->CallKeyboardFilter(&src_keycode, &out_keycode, &out_status);
|
||||||
|
LOG_DEBUG(Lib_ImeDialog,
|
||||||
|
"InputTextCallback: CallKeyboardFilter returned %s (keycode=0x%X, status=0x%X)",
|
||||||
|
keep ? "true" : "false", out_keycode, out_status);
|
||||||
// TODO. set the keycode
|
// TODO. set the keycode
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -44,7 +44,7 @@ ImeState& ImeState::operator=(ImeState&& other) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImeState::SendEvent(OrbisImeEvent* event) {
|
void ImeState::SendEvent(OrbisImeEvent* event) {
|
||||||
std::unique_lock lock{queue_mutex};
|
std::unique_lock<std::mutex> lock{queue_mutex};
|
||||||
event_queue.push(*event);
|
event_queue.push(*event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ ImeUi& ImeUi::operator=(ImeUi&& other) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImeUi::Draw() {
|
void ImeUi::Draw() {
|
||||||
std::unique_lock lock{draw_mutex};
|
std::unique_lock<std::mutex> lock{draw_mutex};
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return;
|
return;
|
||||||
@ -199,7 +199,7 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
eventParam.caret_index = data->CursorPos;
|
eventParam.caret_index = data->CursorPos;
|
||||||
eventParam.area_num = 1;
|
eventParam.area_num = 1;
|
||||||
|
|
||||||
eventParam.text_area[0].mode = 1; // Edit mode
|
eventParam.text_area[0].mode = OrbisImeTextAreaMode::Edit;
|
||||||
eventParam.text_area[0].index = data->CursorPos;
|
eventParam.text_area[0].index = data->CursorPos;
|
||||||
eventParam.text_area[0].length = data->BufTextLen;
|
eventParam.text_area[0].length = data->BufTextLen;
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ s32 PS4_SYSV_ABI sceJpegEncQueryMemorySize(const OrbisJpegEncCreateParam* param)
|
|||||||
return ORBIS_JPEG_ENC_MINIMUM_MEMORY_SIZE;
|
return ORBIS_JPEG_ENC_MINIMUM_MEMORY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibSceJpegEnc(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("K+rocojkr-I", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncCreate);
|
LIB_FUNCTION("K+rocojkr-I", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncCreate);
|
||||||
LIB_FUNCTION("j1LyMdaM+C0", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncDelete);
|
LIB_FUNCTION("j1LyMdaM+C0", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncDelete);
|
||||||
LIB_FUNCTION("QbrU0cUghEM", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncEncode);
|
LIB_FUNCTION("QbrU0cUghEM", "libSceJpegEnc", 1, "libSceJpegEnc", 1, 1, sceJpegEncEncode);
|
||||||
|
@ -80,5 +80,5 @@ s32 PS4_SYSV_ABI sceJpegEncEncode(OrbisJpegEncHandle handle, const OrbisJpegEncE
|
|||||||
OrbisJpegEncOutputInfo* output_info);
|
OrbisJpegEncOutputInfo* output_info);
|
||||||
s32 PS4_SYSV_ABI sceJpegEncQueryMemorySize(const OrbisJpegEncCreateParam* param);
|
s32 PS4_SYSV_ABI sceJpegEncQueryMemorySize(const OrbisJpegEncCreateParam* param);
|
||||||
|
|
||||||
void RegisterlibSceJpegEnc(Core::Loader::SymbolsResolver* sym);
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::JpegEnc
|
} // namespace Libraries::JpegEnc
|
||||||
|
@ -98,6 +98,11 @@ bool EqueueInternal::RemoveEvent(u64 id, s16 filter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int EqueueInternal::WaitForEvents(SceKernelEvent* ev, int num, u32 micros) {
|
int EqueueInternal::WaitForEvents(SceKernelEvent* ev, int num, u32 micros) {
|
||||||
|
if (HasSmallTimer()) {
|
||||||
|
// If a small timer is set, just wait for it to expire.
|
||||||
|
return WaitForSmallTimer(ev, num, micros);
|
||||||
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
const auto predicate = [&] {
|
const auto predicate = [&] {
|
||||||
@ -120,7 +125,6 @@ int EqueueInternal::WaitForEvents(SceKernelEvent* ev, int num, u32 micros) {
|
|||||||
.count();
|
.count();
|
||||||
count = WaitForSmallTimer(ev, num, std::max(0l, long(micros - time_waited)));
|
count = WaitForSmallTimer(ev, num, std::max(0l, long(micros - time_waited)));
|
||||||
}
|
}
|
||||||
small_timer_event.event.data = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev->flags & SceKernelEvent::Flags::OneShot) {
|
if (ev->flags & SceKernelEvent::Flags::OneShot) {
|
||||||
@ -140,6 +144,8 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
|
|||||||
if (event.event.ident == ident && event.event.filter == filter) {
|
if (event.event.ident == ident && event.event.filter == filter) {
|
||||||
if (filter == SceKernelEvent::Filter::VideoOut) {
|
if (filter == SceKernelEvent::Filter::VideoOut) {
|
||||||
event.TriggerDisplay(trigger_data);
|
event.TriggerDisplay(trigger_data);
|
||||||
|
} else if (filter == SceKernelEvent::Filter::User) {
|
||||||
|
event.TriggerUser(trigger_data);
|
||||||
} else {
|
} else {
|
||||||
event.Trigger(trigger_data);
|
event.Trigger(trigger_data);
|
||||||
}
|
}
|
||||||
@ -172,38 +178,46 @@ int EqueueInternal::GetTriggeredEvents(SceKernelEvent* ev, int num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EqueueInternal::AddSmallTimer(EqueueEvent& ev) {
|
bool EqueueInternal::AddSmallTimer(EqueueEvent& ev) {
|
||||||
// We assume that only one timer event (with the same ident across calls)
|
SmallTimer st;
|
||||||
// can be posted to the queue, based on observations so far. In the opposite case,
|
st.event = ev.event;
|
||||||
// the small timer storage and wait logic should be reworked.
|
st.added = std::chrono::steady_clock::now();
|
||||||
ASSERT(!HasSmallTimer() || small_timer_event.event.ident == ev.event.ident);
|
st.interval = std::chrono::microseconds{ev.event.data};
|
||||||
ev.time_added = std::chrono::steady_clock::now();
|
{
|
||||||
small_timer_event = std::move(ev);
|
std::scoped_lock lock{m_mutex};
|
||||||
|
m_small_timers[st.event.ident] = std::move(st);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EqueueInternal::WaitForSmallTimer(SceKernelEvent* ev, int num, u32 micros) {
|
int EqueueInternal::WaitForSmallTimer(SceKernelEvent* ev, int num, u32 micros) {
|
||||||
int count{};
|
ASSERT(num >= 1);
|
||||||
|
|
||||||
ASSERT(num == 1);
|
|
||||||
|
|
||||||
auto curr_clock = std::chrono::steady_clock::now();
|
auto curr_clock = std::chrono::steady_clock::now();
|
||||||
const auto wait_end_us = curr_clock + std::chrono::microseconds{micros};
|
const auto wait_end_us = (micros == 0) ? std::chrono::steady_clock::time_point::max()
|
||||||
|
: curr_clock + std::chrono::microseconds{micros};
|
||||||
|
int count = 0;
|
||||||
do {
|
do {
|
||||||
curr_clock = std::chrono::steady_clock::now();
|
curr_clock = std::chrono::steady_clock::now();
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
if ((curr_clock - small_timer_event.time_added) >
|
for (auto it = m_small_timers.begin(); it != m_small_timers.end() && count < num;) {
|
||||||
std::chrono::microseconds{small_timer_event.event.data}) {
|
const SmallTimer& st = it->second;
|
||||||
ev[count++] = small_timer_event.event;
|
|
||||||
small_timer_event.event.data = 0;
|
if (curr_clock - st.added >= st.interval) {
|
||||||
break;
|
ev[count++] = st.event;
|
||||||
|
it = m_small_timers.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
} while (curr_clock < wait_end_us);
|
} while (curr_clock < wait_end_us);
|
||||||
|
|
||||||
return count;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EqueueInternal::EventExists(u64 id, s16 filter) {
|
bool EqueueInternal::EventExists(u64 id, s16 filter) {
|
||||||
@ -266,24 +280,15 @@ int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, SceKernelEvent* ev, int
|
|||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eq->HasSmallTimer()) {
|
if (timo == nullptr) {
|
||||||
ASSERT(timo && *timo);
|
// When the timeout is nullptr, we wait indefinitely
|
||||||
*out = eq->WaitForSmallTimer(ev, num, *timo);
|
*out = eq->WaitForEvents(ev, num, 0);
|
||||||
|
} else if (*timo == 0) {
|
||||||
|
// Only events that have already arrived at the time of this function call can be received
|
||||||
|
*out = eq->GetTriggeredEvents(ev, num);
|
||||||
} else {
|
} else {
|
||||||
if (timo == nullptr) { // wait until an event arrives without timing out
|
// Wait for up to the specified timeout value
|
||||||
*out = eq->WaitForEvents(ev, num, 0);
|
*out = eq->WaitForEvents(ev, num, *timo);
|
||||||
}
|
|
||||||
|
|
||||||
if (timo != nullptr) {
|
|
||||||
// Only events that have already arrived at the time of this function call can be
|
|
||||||
// received
|
|
||||||
if (*timo == 0) {
|
|
||||||
*out = eq->GetTriggeredEvents(ev, num);
|
|
||||||
} else {
|
|
||||||
// Wait until an event arrives with timing out
|
|
||||||
*out = eq->WaitForEvents(ev, num, *timo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*out == 0) {
|
if (*out == 0) {
|
||||||
@ -327,6 +332,11 @@ s32 PS4_SYSV_ABI sceKernelAddHRTimerEvent(SceKernelEqueue eq, int id, timespec*
|
|||||||
// `HrTimerSpinlockThresholdUs`) and fall back to boost asio timers if the time to tick is
|
// `HrTimerSpinlockThresholdUs`) and fall back to boost asio timers if the time to tick is
|
||||||
// large. Even for large delays, we truncate a small portion to complete the wait
|
// large. Even for large delays, we truncate a small portion to complete the wait
|
||||||
// using the spinlock, prioritizing precision.
|
// using the spinlock, prioritizing precision.
|
||||||
|
|
||||||
|
if (eq->EventExists(event.event.ident, event.event.filter)) {
|
||||||
|
eq->RemoveEvent(id, SceKernelEvent::Filter::HrTimer);
|
||||||
|
}
|
||||||
|
|
||||||
if (total_us < HrTimerSpinlockThresholdUs) {
|
if (total_us < HrTimerSpinlockThresholdUs) {
|
||||||
return eq->AddSmallTimer(event) ? ORBIS_OK : ORBIS_KERNEL_ERROR_ENOMEM;
|
return eq->AddSmallTimer(event) ? ORBIS_OK : ORBIS_KERNEL_ERROR_ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
#include "common/rdtsc.h"
|
#include "common/rdtsc.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
@ -98,6 +99,12 @@ struct EqueueEvent {
|
|||||||
event.data = reinterpret_cast<uintptr_t>(data);
|
event.data = reinterpret_cast<uintptr_t>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerUser(void* data) {
|
||||||
|
is_triggered = true;
|
||||||
|
event.fflags++;
|
||||||
|
event.udata = data;
|
||||||
|
}
|
||||||
|
|
||||||
void TriggerDisplay(void* data) {
|
void TriggerDisplay(void* data) {
|
||||||
is_triggered = true;
|
is_triggered = true;
|
||||||
if (data != nullptr) {
|
if (data != nullptr) {
|
||||||
@ -129,6 +136,12 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class EqueueInternal {
|
class EqueueInternal {
|
||||||
|
struct SmallTimer {
|
||||||
|
SceKernelEvent event;
|
||||||
|
std::chrono::steady_clock::time_point added;
|
||||||
|
std::chrono::microseconds interval;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EqueueInternal(std::string_view name) : m_name(name) {}
|
explicit EqueueInternal(std::string_view name) : m_name(name) {}
|
||||||
|
|
||||||
@ -145,13 +158,14 @@ public:
|
|||||||
int GetTriggeredEvents(SceKernelEvent* ev, int num);
|
int GetTriggeredEvents(SceKernelEvent* ev, int num);
|
||||||
|
|
||||||
bool AddSmallTimer(EqueueEvent& event);
|
bool AddSmallTimer(EqueueEvent& event);
|
||||||
bool HasSmallTimer() const {
|
bool HasSmallTimer() {
|
||||||
return small_timer_event.event.data != 0;
|
std::scoped_lock lock{m_mutex};
|
||||||
|
return !m_small_timers.empty();
|
||||||
}
|
}
|
||||||
bool RemoveSmallTimer(u64 id) {
|
bool RemoveSmallTimer(u64 id) {
|
||||||
if (HasSmallTimer() && small_timer_event.event.ident == id) {
|
if (HasSmallTimer()) {
|
||||||
small_timer_event = {};
|
std::scoped_lock lock{m_mutex};
|
||||||
return true;
|
return m_small_timers.erase(id) > 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -164,8 +178,8 @@ private:
|
|||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::vector<EqueueEvent> m_events;
|
std::vector<EqueueEvent> m_events;
|
||||||
EqueueEvent small_timer_event{};
|
|
||||||
std::condition_variable m_cond;
|
std::condition_variable m_cond;
|
||||||
|
std::unordered_map<u64, SmallTimer> m_small_timers;
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 PS4_SYSV_ABI sceKernelGetEventData(const SceKernelEvent* ev);
|
u64 PS4_SYSV_ABI sceKernelGetEventData(const SceKernelEvent* ev);
|
||||||
|
@ -118,14 +118,16 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_only) {
|
if (!exists) {
|
||||||
// Can't create files in a read only directory
|
if (read_only) {
|
||||||
h->DeleteHandle(handle);
|
// Can't create files in a read only directory
|
||||||
*__Error() = POSIX_EROFS;
|
h->DeleteHandle(handle);
|
||||||
return -1;
|
*__Error() = POSIX_EROFS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// Create a file if it doesn't exist
|
||||||
|
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
|
||||||
}
|
}
|
||||||
// Create a file if it doesn't exist
|
|
||||||
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
|
|
||||||
} else if (!exists) {
|
} else if (!exists) {
|
||||||
// If we're not creating a file, and it doesn't exist, return ENOENT
|
// If we're not creating a file, and it doesn't exist, return ENOENT
|
||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
@ -293,6 +295,7 @@ s64 PS4_SYSV_ABI write(s32 fd, const void* buf, size_t nbytes) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file->f.WriteRaw<u8>(buf, nbytes);
|
return file->f.WriteRaw<u8>(buf, nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +753,24 @@ s32 PS4_SYSV_ABI posix_rename(const char* from, const char* to) {
|
|||||||
*__Error() = POSIX_ENOTEMPTY;
|
*__Error() = POSIX_ENOTEMPTY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On Windows, std::filesystem::rename will error if the file has been opened before.
|
||||||
std::filesystem::copy(src_path, dst_path, std::filesystem::copy_options::overwrite_existing);
|
std::filesystem::copy(src_path, dst_path, std::filesystem::copy_options::overwrite_existing);
|
||||||
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
|
auto file = h->GetFile(src_path);
|
||||||
|
if (file) {
|
||||||
|
// We need to force ReadWrite if the file had Write access before
|
||||||
|
// Otherwise f.Open will clear the file contents.
|
||||||
|
auto access_mode = file->f.GetAccessMode() == Common::FS::FileAccessMode::Write
|
||||||
|
? Common::FS::FileAccessMode::ReadWrite
|
||||||
|
: file->f.GetAccessMode();
|
||||||
|
file->f.Close();
|
||||||
|
std::filesystem::remove(src_path);
|
||||||
|
file->f.Open(dst_path, access_mode);
|
||||||
|
} else {
|
||||||
|
std::filesystem::remove(src_path);
|
||||||
|
}
|
||||||
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1050,6 +1070,7 @@ void RegisterFileSystem(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite);
|
LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite);
|
||||||
LIB_FUNCTION("+WRlkKjZvag", "libkernel", 1, "libkernel", 1, 1, readv);
|
LIB_FUNCTION("+WRlkKjZvag", "libkernel", 1, "libkernel", 1, 1, readv);
|
||||||
LIB_FUNCTION("YSHRBRLn2pI", "libkernel", 1, "libkernel", 1, 1, writev);
|
LIB_FUNCTION("YSHRBRLn2pI", "libkernel", 1, "libkernel", 1, 1, writev);
|
||||||
|
LIB_FUNCTION("kAt6VDbHmro", "libkernel", 1, "libkernel", 1, 1, sceKernelWritev);
|
||||||
LIB_FUNCTION("Oy6IpwgtYOk", "libScePosix", 1, "libkernel", 1, 1, posix_lseek);
|
LIB_FUNCTION("Oy6IpwgtYOk", "libScePosix", 1, "libkernel", 1, 1, posix_lseek);
|
||||||
LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, posix_lseek);
|
LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, posix_lseek);
|
||||||
LIB_FUNCTION("oib76F-12fk", "libkernel", 1, "libkernel", 1, 1, sceKernelLseek);
|
LIB_FUNCTION("oib76F-12fk", "libkernel", 1, "libkernel", 1, 1, sceKernelLseek);
|
||||||
@ -1072,6 +1093,8 @@ void RegisterFileSystem(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("kBwCPsYX-m4", "libkernel", 1, "libkernel", 1, 1, sceKernelFstat);
|
LIB_FUNCTION("kBwCPsYX-m4", "libkernel", 1, "libkernel", 1, 1, sceKernelFstat);
|
||||||
LIB_FUNCTION("ih4CD9-gghM", "libkernel", 1, "libkernel", 1, 1, posix_ftruncate);
|
LIB_FUNCTION("ih4CD9-gghM", "libkernel", 1, "libkernel", 1, 1, posix_ftruncate);
|
||||||
LIB_FUNCTION("VW3TVZiM4-E", "libkernel", 1, "libkernel", 1, 1, sceKernelFtruncate);
|
LIB_FUNCTION("VW3TVZiM4-E", "libkernel", 1, "libkernel", 1, 1, sceKernelFtruncate);
|
||||||
|
LIB_FUNCTION("NN01qLRhiqU", "libScePosix", 1, "libkernel", 1, 1, posix_rename);
|
||||||
|
LIB_FUNCTION("NN01qLRhiqU", "libkernel", 1, "libkernel", 1, 1, posix_rename);
|
||||||
LIB_FUNCTION("52NcYU9+lEo", "libkernel", 1, "libkernel", 1, 1, sceKernelRename);
|
LIB_FUNCTION("52NcYU9+lEo", "libkernel", 1, "libkernel", 1, 1, sceKernelRename);
|
||||||
LIB_FUNCTION("yTj62I7kw4s", "libkernel", 1, "libkernel", 1, 1, sceKernelPreadv);
|
LIB_FUNCTION("yTj62I7kw4s", "libkernel", 1, "libkernel", 1, 1, sceKernelPreadv);
|
||||||
LIB_FUNCTION("ezv-RSBNKqI", "libScePosix", 1, "libkernel", 1, 1, posix_pread);
|
LIB_FUNCTION("ezv-RSBNKqI", "libScePosix", 1, "libkernel", 1, 1, posix_pread);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
|
#include "common/elf_info.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/polyfill_thread.h"
|
#include "common/polyfill_thread.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
@ -76,21 +77,28 @@ static PS4_SYSV_ABI void stack_chk_fail() {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
static thread_local int g_posix_errno = 0;
|
static thread_local s32 g_posix_errno = 0;
|
||||||
|
|
||||||
int* PS4_SYSV_ABI __Error() {
|
s32* PS4_SYSV_ABI __Error() {
|
||||||
return &g_posix_errno;
|
return &g_posix_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrSceToPosix(int error) {
|
void ErrSceToPosix(s32 error) {
|
||||||
g_posix_errno = error - ORBIS_KERNEL_ERROR_UNKNOWN;
|
g_posix_errno = error - ORBIS_KERNEL_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ErrnoToSceKernelError(int error) {
|
s32 ErrnoToSceKernelError(s32 error) {
|
||||||
return error + ORBIS_KERNEL_ERROR_UNKNOWN;
|
return error + ORBIS_KERNEL_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPosixErrno(int e) {
|
s32 PS4_SYSV_ABI sceKernelError(s32 posix_error) {
|
||||||
|
if (posix_error == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return posix_error + ORBIS_KERNEL_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPosixErrno(s32 e) {
|
||||||
// Some error numbers are different between supported OSes
|
// Some error numbers are different between supported OSes
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case EPERM:
|
case EPERM:
|
||||||
@ -132,15 +140,15 @@ void SetPosixErrno(int e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t g_mspace_atomic_id_mask = 0;
|
static u64 g_mspace_atomic_id_mask = 0;
|
||||||
static uint64_t g_mstate_table[64] = {0};
|
static u64 g_mstate_table[64] = {0};
|
||||||
|
|
||||||
struct HeapInfoInfo {
|
struct HeapInfoInfo {
|
||||||
uint64_t size = sizeof(HeapInfoInfo);
|
u64 size = sizeof(HeapInfoInfo);
|
||||||
uint32_t flag;
|
u32 flag;
|
||||||
uint32_t getSegmentInfo;
|
u32 getSegmentInfo;
|
||||||
uint64_t* mspace_atomic_id_mask;
|
u64* mspace_atomic_id_mask;
|
||||||
uint64_t* mstate_table;
|
u64* mstate_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PS4_SYSV_ABI sceLibcHeapGetTraceInfo(HeapInfoInfo* info) {
|
void PS4_SYSV_ABI sceLibcHeapGetTraceInfo(HeapInfoInfo* info) {
|
||||||
@ -159,7 +167,7 @@ struct OrbisKernelUuid {
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(OrbisKernelUuid) == 0x10);
|
static_assert(sizeof(OrbisKernelUuid) == 0x10);
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
|
s32 PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
|
||||||
if (!orbisUuid) {
|
if (!orbisUuid) {
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
@ -176,7 +184,7 @@ int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI kernel_ioctl(int fd, u64 cmd, VA_ARGS) {
|
s32 PS4_SYSV_ABI kernel_ioctl(s32 fd, u64 cmd, VA_ARGS) {
|
||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
auto* file = h->GetFile(fd);
|
auto* file = h->GetFile(fd);
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
@ -190,7 +198,7 @@ int PS4_SYSV_ABI kernel_ioctl(int fd, u64 cmd, VA_ARGS) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
VA_CTX(ctx);
|
VA_CTX(ctx);
|
||||||
int result = file->device->ioctl(cmd, &ctx);
|
s32 result = file->device->ioctl(cmd, &ctx);
|
||||||
LOG_TRACE(Lib_Kernel, "ioctl: fd = {:X} cmd = {:X} result = {}", fd, cmd, result);
|
LOG_TRACE(Lib_Kernel, "ioctl: fd = {:X} cmd = {:X} result = {}", fd, cmd, result);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
ErrSceToPosix(result);
|
ErrSceToPosix(result);
|
||||||
@ -204,15 +212,15 @@ const char* PS4_SYSV_ABI sceKernelGetFsSandboxRandomWord() {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI _sigprocmask() {
|
s32 PS4_SYSV_ABI _sigprocmask() {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_getpagesize() {
|
s32 PS4_SYSV_ABI posix_getpagesize() {
|
||||||
return 16_KB;
|
return 16_KB;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
|
s32 PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
|
||||||
Libraries::Net::OrbisNetSockaddr* addr, u32* paddrlen) {
|
Libraries::Net::OrbisNetSockaddr* addr, u32* paddrlen) {
|
||||||
auto* netcall = Common::Singleton<Libraries::Net::NetInternal>::Instance();
|
auto* netcall = Common::Singleton<Libraries::Net::NetInternal>::Instance();
|
||||||
auto sock = netcall->FindSocket(s);
|
auto sock = netcall->FindSocket(s);
|
||||||
@ -221,7 +229,7 @@ int PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
|
|||||||
LOG_ERROR(Lib_Net, "socket id is invalid = {}", s);
|
LOG_ERROR(Lib_Net, "socket id is invalid = {}", s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int returncode = sock->GetSocketAddress(addr, paddrlen);
|
s32 returncode = sock->GetSocketAddress(addr, paddrlen);
|
||||||
if (returncode >= 0) {
|
if (returncode >= 0) {
|
||||||
LOG_ERROR(Lib_Net, "return code : {:#x}", (u32)returncode);
|
LOG_ERROR(Lib_Net, "return code : {:#x}", (u32)returncode);
|
||||||
return 0;
|
return 0;
|
||||||
@ -230,7 +238,33 @@ int PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
|
|||||||
LOG_ERROR(Lib_Net, "error code returned : {:#x}", (u32)returncode);
|
LOG_ERROR(Lib_Net, "error code returned : {:#x}", (u32)returncode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
|
|
||||||
|
// stubbed on non-devkit consoles
|
||||||
|
s32 PS4_SYSV_ABI sceKernelGetGPI() {
|
||||||
|
LOG_DEBUG(Kernel, "called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stubbed on non-devkit consoles
|
||||||
|
s32 PS4_SYSV_ABI sceKernelSetGPO() {
|
||||||
|
LOG_DEBUG(Kernel, "called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceKernelGetSystemSwVersion(SwVersionStruct* ret) {
|
||||||
|
if (ret == nullptr) {
|
||||||
|
return ORBIS_OK; // but why?
|
||||||
|
}
|
||||||
|
ASSERT(ret->struct_size == 40);
|
||||||
|
u32 fake_fw = Common::ElfInfo::Instance().RawFirmwareVer();
|
||||||
|
ret->hex_representation = fake_fw;
|
||||||
|
std::snprintf(ret->text_representation, 28, "%2x.%03x.%03x", fake_fw >> 0x18,
|
||||||
|
fake_fw >> 0xc & 0xfff, fake_fw & 0xfff); // why %2x?
|
||||||
|
LOG_INFO(Lib_Kernel, "called, returned sw version: {}", ret->text_representation);
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
service_thread = std::jthread{KernelServiceThread};
|
service_thread = std::jthread{KernelServiceThread};
|
||||||
|
|
||||||
Libraries::Kernel::RegisterFileSystem(sym);
|
Libraries::Kernel::RegisterFileSystem(sym);
|
||||||
@ -245,6 +279,8 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
|
|||||||
Libraries::Kernel::RegisterDebug(sym);
|
Libraries::Kernel::RegisterDebug(sym);
|
||||||
|
|
||||||
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard);
|
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard);
|
||||||
|
LIB_FUNCTION("D4yla3vx4tY", "libkernel", 1, "libkernel", 1, 1, sceKernelError);
|
||||||
|
LIB_FUNCTION("Mv1zUObHvXI", "libkernel", 1, "libkernel", 1, 1, sceKernelGetSystemSwVersion);
|
||||||
LIB_FUNCTION("PfccT7qURYE", "libkernel", 1, "libkernel", 1, 1, kernel_ioctl);
|
LIB_FUNCTION("PfccT7qURYE", "libkernel", 1, "libkernel", 1, 1, kernel_ioctl);
|
||||||
LIB_FUNCTION("JGfTMBOdUJo", "libkernel", 1, "libkernel", 1, 1, sceKernelGetFsSandboxRandomWord);
|
LIB_FUNCTION("JGfTMBOdUJo", "libkernel", 1, "libkernel", 1, 1, sceKernelGetFsSandboxRandomWord);
|
||||||
LIB_FUNCTION("6xVpy0Fdq+I", "libkernel", 1, "libkernel", 1, 1, _sigprocmask);
|
LIB_FUNCTION("6xVpy0Fdq+I", "libkernel", 1, "libkernel", 1, 1, _sigprocmask);
|
||||||
@ -273,6 +309,13 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
|
|||||||
Libraries::Net::sceNetInetNtop); // TODO fix it to sys_ ...
|
Libraries::Net::sceNetInetNtop); // TODO fix it to sys_ ...
|
||||||
LIB_FUNCTION("4n51s0zEf0c", "libScePosix", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("4n51s0zEf0c", "libScePosix", 1, "libkernel", 1, 1,
|
||||||
Libraries::Net::sceNetInetPton); // TODO fix it to sys_ ...
|
Libraries::Net::sceNetInetPton); // TODO fix it to sys_ ...
|
||||||
|
LIB_FUNCTION("XVL8So3QJUk", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_connect);
|
||||||
|
LIB_FUNCTION("3e+4Iv7IJ8U", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_accept);
|
||||||
|
LIB_FUNCTION("aNeavPDNKzA", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_sendmsg);
|
||||||
|
LIB_FUNCTION("pxnCmagrtao", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_listen);
|
||||||
|
|
||||||
|
LIB_FUNCTION("4oXYe9Xmk0Q", "libkernel", 1, "libkernel", 1, 1, sceKernelGetGPI);
|
||||||
|
LIB_FUNCTION("ca7v6Cxulzs", "libkernel", 1, "libkernel", 1, 1, sceKernelSetGPO);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
||||||
|
@ -12,10 +12,10 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
|
||||||
void ErrSceToPosix(int result);
|
void ErrSceToPosix(s32 result);
|
||||||
int ErrnoToSceKernelError(int e);
|
s32 ErrnoToSceKernelError(s32 e);
|
||||||
void SetPosixErrno(int e);
|
void SetPosixErrno(s32 e);
|
||||||
int* PS4_SYSV_ABI __Error();
|
s32* PS4_SYSV_ABI __Error();
|
||||||
|
|
||||||
template <class F, F f>
|
template <class F, F f>
|
||||||
struct OrbisWrapperImpl;
|
struct OrbisWrapperImpl;
|
||||||
@ -33,8 +33,14 @@ struct OrbisWrapperImpl<PS4_SYSV_ABI R (*)(Args...), f> {
|
|||||||
|
|
||||||
#define ORBIS(func) (Libraries::Kernel::OrbisWrapperImpl<decltype(&(func)), func>::wrap)
|
#define ORBIS(func) (Libraries::Kernel::OrbisWrapperImpl<decltype(&(func)), func>::wrap)
|
||||||
|
|
||||||
int* PS4_SYSV_ABI __Error();
|
s32* PS4_SYSV_ABI __Error();
|
||||||
|
|
||||||
void RegisterKernel(Core::Loader::SymbolsResolver* sym);
|
struct SwVersionStruct {
|
||||||
|
u64 struct_size;
|
||||||
|
char text_representation[0x1c];
|
||||||
|
u32 hex_representation;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RegisterLib(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#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/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/orbis_error.h"
|
||||||
@ -24,8 +23,8 @@ u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize() {
|
|||||||
return memory->GetTotalDirectSize();
|
return memory->GetTotalDirectSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
s32 PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
||||||
u64 alignment, int memoryType, s64* physAddrOut) {
|
u64 alignment, s32 memoryType, s64* physAddrOut) {
|
||||||
if (searchStart < 0 || searchEnd < 0) {
|
if (searchStart < 0 || searchEnd < 0) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Invalid parameters!");
|
LOG_ERROR(Kernel_Vmm, "Invalid parameters!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -72,13 +71,13 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment, int memoryType,
|
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(u64 len, u64 alignment, s32 memoryType,
|
||||||
s64* physAddrOut) {
|
s64* physAddrOut) {
|
||||||
const auto searchEnd = static_cast<s64>(sceKernelGetDirectMemorySize());
|
const auto searchEnd = static_cast<s64>(sceKernelGetDirectMemorySize());
|
||||||
return sceKernelAllocateDirectMemory(0, searchEnd, len, alignment, memoryType, physAddrOut);
|
return sceKernelAllocateDirectMemory(0, searchEnd, len, alignment, memoryType, physAddrOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len) {
|
s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, u64 len) {
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -88,7 +87,7 @@ s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len) {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, size_t len) {
|
s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, u64 len) {
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -97,11 +96,10 @@ s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, size_t len) {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchEnd,
|
s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchEnd, u64 alignment,
|
||||||
size_t alignment, u64* physAddrOut,
|
u64* physAddrOut, u64* sizeOut) {
|
||||||
size_t* sizeOut) {
|
LOG_INFO(Kernel_Vmm, "called searchStart = {:#x}, searchEnd = {:#x}, alignment = {:#x}",
|
||||||
LOG_WARNING(Kernel_Vmm, "called searchStart = {:#x}, searchEnd = {:#x}, alignment = {:#x}",
|
searchStart, searchEnd, alignment);
|
||||||
searchStart, searchEnd, alignment);
|
|
||||||
|
|
||||||
if (physAddrOut == nullptr || sizeOut == nullptr) {
|
if (physAddrOut == nullptr || sizeOut == nullptr) {
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -110,7 +108,7 @@ s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchE
|
|||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
|
|
||||||
PAddr physAddr{};
|
PAddr physAddr{};
|
||||||
size_t size{};
|
u64 size{};
|
||||||
s32 result = memory->DirectQueryAvailable(searchStart, searchEnd, alignment, &physAddr, &size);
|
s32 result = memory->DirectQueryAvailable(searchStart, searchEnd, alignment, &physAddr, &size);
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
@ -123,14 +121,14 @@ s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchE
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, int flags, OrbisVirtualQueryInfo* info,
|
s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, s32 flags, OrbisVirtualQueryInfo* info,
|
||||||
size_t infoSize) {
|
u64 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);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u64 alignment) {
|
s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, s32 flags, u64 alignment) {
|
||||||
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, flags = {:#x}, alignment = {:#x}",
|
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, flags = {:#x}, alignment = {:#x}",
|
||||||
fmt::ptr(*addr), len, flags, alignment);
|
fmt::ptr(*addr), len, flags, alignment);
|
||||||
if (addr == nullptr) {
|
if (addr == nullptr) {
|
||||||
@ -152,14 +150,15 @@ s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u
|
|||||||
const VAddr in_addr = reinterpret_cast<VAddr>(*addr);
|
const VAddr in_addr = reinterpret_cast<VAddr>(*addr);
|
||||||
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
||||||
|
|
||||||
s32 result = memory->Reserve(addr, in_addr, len, map_flags, alignment);
|
s32 result = memory->MapMemory(addr, in_addr, len, Core::MemoryProt::NoAccess, map_flags,
|
||||||
|
Core::VMAType::Reserved, "anon", false, -1, alignment);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
LOG_INFO(Kernel_Vmm, "out_addr = {}", fmt::ptr(*addr));
|
LOG_INFO(Kernel_Vmm, "out_addr = {}", fmt::ptr(*addr));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, int flags,
|
s32 PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, s32 prot, s32 flags,
|
||||||
s64 directMemoryStart, u64 alignment,
|
s64 directMemoryStart, u64 alignment,
|
||||||
const char* name) {
|
const char* name) {
|
||||||
LOG_INFO(Kernel_Vmm,
|
LOG_INFO(Kernel_Vmm,
|
||||||
@ -202,7 +201,7 @@ int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, i
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int flags,
|
s32 PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, s32 prot, s32 flags,
|
||||||
s64 directMemoryStart, u64 alignment) {
|
s64 directMemoryStart, u64 alignment) {
|
||||||
LOG_INFO(Kernel_Vmm, "called, redirected to sceKernelMapNamedDirectMemory");
|
LOG_INFO(Kernel_Vmm, "called, redirected to sceKernelMapNamedDirectMemory");
|
||||||
return sceKernelMapNamedDirectMemory(addr, len, prot, flags, directMemoryStart, alignment,
|
return sceKernelMapNamedDirectMemory(addr, len, prot, flags, directMemoryStart, alignment,
|
||||||
@ -222,9 +221,10 @@ s32 PS4_SYSV_ABI sceKernelMapDirectMemory2(void** addr, u64 len, s32 type, s32 p
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, std::size_t len, int prot,
|
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, u64 len, s32 prot, s32 flags,
|
||||||
int flags, const char* name) {
|
const char* name) {
|
||||||
|
LOG_INFO(Kernel_Vmm, "in_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}, name = '{}'",
|
||||||
|
fmt::ptr(*addr_in_out), len, prot, flags, name);
|
||||||
if (len == 0 || !Common::Is16KBAligned(len)) {
|
if (len == 0 || !Common::Is16KBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "len is 0 or not 16kb multiple");
|
LOG_ERROR(Kernel_Vmm, "len is 0 or not 16kb multiple");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -243,46 +243,55 @@ s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, std::size_t
|
|||||||
const VAddr in_addr = reinterpret_cast<VAddr>(*addr_in_out);
|
const VAddr in_addr = reinterpret_cast<VAddr>(*addr_in_out);
|
||||||
const auto mem_prot = static_cast<Core::MemoryProt>(prot);
|
const auto mem_prot = static_cast<Core::MemoryProt>(prot);
|
||||||
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
||||||
SCOPE_EXIT {
|
|
||||||
LOG_INFO(Kernel_Vmm,
|
|
||||||
"in_addr = {:#x}, out_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}",
|
|
||||||
in_addr, fmt::ptr(*addr_in_out), len, prot, flags);
|
|
||||||
};
|
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
return memory->MapMemory(addr_in_out, in_addr, len, mem_prot, map_flags,
|
const auto ret = memory->MapMemory(addr_in_out, in_addr, len, mem_prot, map_flags,
|
||||||
Core::VMAType::Flexible, name);
|
Core::VMAType::Flexible, name);
|
||||||
|
LOG_INFO(Kernel_Vmm, "out_addr = {}", fmt::ptr(*addr_in_out));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMapFlexibleMemory(void** addr_in_out, std::size_t len, int prot,
|
s32 PS4_SYSV_ABI sceKernelMapFlexibleMemory(void** addr_in_out, u64 len, s32 prot, s32 flags) {
|
||||||
int flags) {
|
|
||||||
return sceKernelMapNamedFlexibleMemory(addr_in_out, len, prot, flags, "anon");
|
return sceKernelMapNamedFlexibleMemory(addr_in_out, len, prot, flags, "anon");
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelQueryMemoryProtection(void* addr, void** start, void** end, u32* prot) {
|
s32 PS4_SYSV_ABI sceKernelQueryMemoryProtection(void* addr, void** start, void** end, u32* prot) {
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
return memory->QueryProtection(std::bit_cast<VAddr>(addr), start, end, prot);
|
return memory->QueryProtection(std::bit_cast<VAddr>(addr), start, end, prot);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMProtect(const void* addr, size_t size, int prot) {
|
s32 PS4_SYSV_ABI sceKernelMprotect(const void* addr, u64 size, s32 prot) {
|
||||||
|
LOG_INFO(Kernel_Vmm, "called addr = {}, size = {:#x}, prot = {:#x}", fmt::ptr(addr), size,
|
||||||
|
prot);
|
||||||
Core::MemoryManager* memory_manager = Core::Memory::Instance();
|
Core::MemoryManager* memory_manager = Core::Memory::Instance();
|
||||||
Core::MemoryProt protection_flags = static_cast<Core::MemoryProt>(prot);
|
Core::MemoryProt protection_flags = static_cast<Core::MemoryProt>(prot);
|
||||||
return memory_manager->Protect(std::bit_cast<VAddr>(addr), size, protection_flags);
|
return memory_manager->Protect(std::bit_cast<VAddr>(addr), size, protection_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMTypeProtect(const void* addr, size_t size, int mtype, int prot) {
|
s32 PS4_SYSV_ABI posix_mprotect(const void* addr, u64 size, s32 prot) {
|
||||||
|
s32 result = sceKernelMprotect(addr, size, prot);
|
||||||
|
if (result < 0) {
|
||||||
|
ErrSceToPosix(result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceKernelMtypeprotect(const void* addr, u64 size, s32 mtype, s32 prot) {
|
||||||
|
LOG_INFO(Kernel_Vmm, "called addr = {}, size = {:#x}, prot = {:#x}", fmt::ptr(addr), size,
|
||||||
|
prot);
|
||||||
Core::MemoryManager* memory_manager = Core::Memory::Instance();
|
Core::MemoryManager* memory_manager = Core::Memory::Instance();
|
||||||
Core::MemoryProt protection_flags = static_cast<Core::MemoryProt>(prot);
|
Core::MemoryProt protection_flags = static_cast<Core::MemoryProt>(prot);
|
||||||
return memory_manager->Protect(std::bit_cast<VAddr>(addr), size, protection_flags);
|
return memory_manager->Protect(std::bit_cast<VAddr>(addr), size, protection_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelDirectMemoryQuery(u64 offset, int flags, OrbisQueryInfo* query_info,
|
s32 PS4_SYSV_ABI sceKernelDirectMemoryQuery(u64 offset, s32 flags, OrbisQueryInfo* query_info,
|
||||||
size_t infoSize) {
|
u64 infoSize) {
|
||||||
LOG_WARNING(Kernel_Vmm, "called offset = {:#x}, flags = {:#x}", offset, flags);
|
LOG_INFO(Kernel_Vmm, "called offset = {:#x}, flags = {:#x}", offset, flags);
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
return memory->DirectMemoryQuery(offset, flags == 1, query_info);
|
return memory->DirectMemoryQuery(offset, flags == 1, query_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelAvailableFlexibleMemorySize(size_t* out_size) {
|
s32 PS4_SYSV_ABI sceKernelAvailableFlexibleMemorySize(u64* out_size) {
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
*out_size = memory->GetAvailableFlexibleSize();
|
*out_size = memory->GetAvailableFlexibleSize();
|
||||||
LOG_INFO(Kernel_Vmm, "called size = {:#x}", *out_size);
|
LOG_INFO(Kernel_Vmm, "called size = {:#x}", *out_size);
|
||||||
@ -294,7 +303,7 @@ void PS4_SYSV_ABI _sceKernelRtldSetApplicationHeapAPI(void* func[]) {
|
|||||||
linker->SetHeapAPI(func);
|
linker->SetHeapAPI(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelGetDirectMemoryType(u64 addr, int* directMemoryTypeOut,
|
s32 PS4_SYSV_ABI sceKernelGetDirectMemoryType(u64 addr, s32* directMemoryTypeOut,
|
||||||
void** directMemoryStartOut,
|
void** directMemoryStartOut,
|
||||||
void** directMemoryEndOut) {
|
void** directMemoryEndOut) {
|
||||||
LOG_WARNING(Kernel_Vmm, "called, direct memory addr = {:#x}", addr);
|
LOG_WARNING(Kernel_Vmm, "called, direct memory addr = {:#x}", addr);
|
||||||
@ -303,23 +312,23 @@ int PS4_SYSV_ABI sceKernelGetDirectMemoryType(u64 addr, int* directMemoryTypeOut
|
|||||||
directMemoryEndOut);
|
directMemoryEndOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelIsStack(void* addr, void** start, void** end) {
|
s32 PS4_SYSV_ABI sceKernelIsStack(void* addr, void** start, void** end) {
|
||||||
LOG_DEBUG(Kernel_Vmm, "called, addr = {}", fmt::ptr(addr));
|
LOG_DEBUG(Kernel_Vmm, "called, addr = {}", fmt::ptr(addr));
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
return memory->IsStack(std::bit_cast<VAddr>(addr), start, end);
|
return memory->IsStack(std::bit_cast<VAddr>(addr), start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelBatchMap(OrbisKernelBatchMapEntry* entries, int numEntries,
|
s32 PS4_SYSV_ABI sceKernelBatchMap(OrbisKernelBatchMapEntry* entries, s32 numEntries,
|
||||||
int* numEntriesOut) {
|
s32* numEntriesOut) {
|
||||||
return sceKernelBatchMap2(entries, numEntries, numEntriesOut,
|
return sceKernelBatchMap2(entries, numEntries, numEntriesOut,
|
||||||
MemoryFlags::SCE_KERNEL_MAP_FIXED); // 0x10, 0x410?
|
MemoryFlags::SCE_KERNEL_MAP_FIXED); // 0x10, 0x410?
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEntries,
|
s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, s32 numEntries,
|
||||||
int* numEntriesOut, int flags) {
|
s32* numEntriesOut, s32 flags) {
|
||||||
int result = ORBIS_OK;
|
s32 result = ORBIS_OK;
|
||||||
int processed = 0;
|
s32 processed = 0;
|
||||||
for (int i = 0; i < numEntries; i++, processed++) {
|
for (s32 i = 0; i < numEntries; i++, processed++) {
|
||||||
if (entries == nullptr || entries[i].length == 0 || entries[i].operation > 4) {
|
if (entries == nullptr || entries[i].length == 0 || entries[i].operation > 4) {
|
||||||
result = ORBIS_KERNEL_ERROR_EINVAL;
|
result = ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
break; // break and assign a value to numEntriesOut.
|
break; // break and assign a value to numEntriesOut.
|
||||||
@ -344,7 +353,7 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_PROTECT: {
|
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_PROTECT: {
|
||||||
result = sceKernelMProtect(entries[i].start, entries[i].length, entries[i].protection);
|
result = sceKernelMprotect(entries[i].start, entries[i].length, entries[i].protection);
|
||||||
LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
|
LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
|
||||||
entries[i].operation, entries[i].length, result);
|
entries[i].operation, entries[i].length, result);
|
||||||
break;
|
break;
|
||||||
@ -359,7 +368,7 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_TYPE_PROTECT: {
|
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_TYPE_PROTECT: {
|
||||||
result = sceKernelMTypeProtect(entries[i].start, entries[i].length, entries[i].type,
|
result = sceKernelMtypeprotect(entries[i].start, entries[i].length, entries[i].type,
|
||||||
entries[i].protection);
|
entries[i].protection);
|
||||||
LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
|
LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
|
||||||
entries[i].operation, entries[i].length, result);
|
entries[i].operation, entries[i].length, result);
|
||||||
@ -380,7 +389,7 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelSetVirtualRangeName(const void* addr, size_t len, const char* name) {
|
s32 PS4_SYSV_ABI sceKernelSetVirtualRangeName(const void* addr, u64 len, const char* name) {
|
||||||
if (name == nullptr) {
|
if (name == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "name is invalid!");
|
LOG_ERROR(Kernel_Vmm, "name is invalid!");
|
||||||
return ORBIS_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
@ -396,8 +405,8 @@ s32 PS4_SYSV_ABI sceKernelSetVirtualRangeName(const void* addr, size_t len, cons
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, size_t len,
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, u64 len, u64 alignment,
|
||||||
size_t alignment, u64* physAddrOut) {
|
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 ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -439,10 +448,10 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, size_
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t alignment, int flags,
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addr_in, u64 len, u64 alignment, s32 flags,
|
||||||
void** addrOut) {
|
void** addr_out) {
|
||||||
LOG_INFO(Kernel_Vmm, "addrIn = {}, len = {:#x}, alignment = {:#x}, flags = {:#x}",
|
LOG_INFO(Kernel_Vmm, "addr_in = {}, len = {:#x}, alignment = {:#x}, flags = {:#x}",
|
||||||
fmt::ptr(addrIn), len, alignment, flags);
|
fmt::ptr(addr_in), len, alignment, flags);
|
||||||
|
|
||||||
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!");
|
||||||
@ -456,14 +465,16 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t ali
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
const VAddr in_addr = reinterpret_cast<VAddr>(addrIn);
|
const VAddr in_addr = reinterpret_cast<VAddr>(addr_in);
|
||||||
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
|
||||||
memory->PoolReserve(addrOut, in_addr, len, map_flags, alignment);
|
u64 map_alignment = alignment == 0 ? 2_MB : alignment;
|
||||||
|
|
||||||
return ORBIS_OK;
|
return memory->MapMemory(addr_out, std::bit_cast<VAddr>(addr_in), len,
|
||||||
|
Core::MemoryProt::NoAccess, map_flags, Core::VMAType::PoolReserved,
|
||||||
|
"anon", false, -1, map_alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int prot, int flags) {
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, u64 len, s32 type, s32 prot, s32 flags) {
|
||||||
if (addr == nullptr) {
|
if (addr == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -482,7 +493,7 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int
|
|||||||
return memory->PoolCommit(in_addr, len, mem_prot);
|
return memory->PoolCommit(in_addr, len, mem_prot);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, size_t len, int flags) {
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, u64 len, s32 flags) {
|
||||||
if (addr == nullptr) {
|
if (addr == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -523,12 +534,12 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolBatch(const OrbisKernelMemoryPoolBatchEntry*
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OrbisKernelMemoryPoolOpcode::Protect: {
|
case OrbisKernelMemoryPoolOpcode::Protect: {
|
||||||
result = sceKernelMProtect(entry.protect_params.addr, entry.protect_params.len,
|
result = sceKernelMprotect(entry.protect_params.addr, entry.protect_params.len,
|
||||||
entry.protect_params.prot);
|
entry.protect_params.prot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OrbisKernelMemoryPoolOpcode::TypeProtect: {
|
case OrbisKernelMemoryPoolOpcode::TypeProtect: {
|
||||||
result = sceKernelMTypeProtect(
|
result = sceKernelMtypeprotect(
|
||||||
entry.type_protect_params.addr, entry.type_protect_params.len,
|
entry.type_protect_params.addr, entry.type_protect_params.len,
|
||||||
entry.type_protect_params.type, entry.type_protect_params.prot);
|
entry.type_protect_params.type, entry.type_protect_params.prot);
|
||||||
break;
|
break;
|
||||||
@ -553,30 +564,49 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolBatch(const OrbisKernelMemoryPoolBatchEntry*
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd, size_t offset,
|
void* PS4_SYSV_ABI posix_mmap(void* addr, u64 len, s32 prot, s32 flags, s32 fd, s64 phys_addr) {
|
||||||
void** res) {
|
LOG_INFO(Kernel_Vmm,
|
||||||
LOG_INFO(Kernel_Vmm, "called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, offset = {}",
|
"called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, phys_addr = {}",
|
||||||
fmt::ptr(addr), len, prot, flags, fd, offset);
|
fmt::ptr(addr), len, prot, flags, fd, phys_addr);
|
||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
|
||||||
|
void* addr_out;
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
const auto mem_prot = static_cast<Core::MemoryProt>(prot);
|
const auto mem_prot = static_cast<Core::MemoryProt>(prot);
|
||||||
const auto mem_flags = static_cast<Core::MemoryMapFlags>(flags);
|
const auto mem_flags = static_cast<Core::MemoryMapFlags>(flags);
|
||||||
|
const auto is_exec = True(mem_prot & Core::MemoryProt::CpuExec);
|
||||||
|
|
||||||
|
s32 result = ORBIS_OK;
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return memory->MapMemory(res, std::bit_cast<VAddr>(addr), len, mem_prot, mem_flags,
|
result = memory->MapMemory(&addr_out, std::bit_cast<VAddr>(addr), len, mem_prot, mem_flags,
|
||||||
Core::VMAType::Flexible);
|
Core::VMAType::Flexible, "anon", is_exec);
|
||||||
} else {
|
} else {
|
||||||
const uintptr_t handle = h->GetFile(fd)->f.GetFileMapping();
|
result = memory->MapFile(&addr_out, std::bit_cast<VAddr>(addr), len, mem_prot, mem_flags,
|
||||||
return memory->MapFile(res, std::bit_cast<VAddr>(addr), len, mem_prot, mem_flags, handle,
|
fd, phys_addr);
|
||||||
offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result != ORBIS_OK) {
|
||||||
|
// If the memory mappings fail, mmap sets errno to the appropriate error code,
|
||||||
|
// then returns (void*)-1;
|
||||||
|
ErrSceToPosix(result);
|
||||||
|
return reinterpret_cast<void*>(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* PS4_SYSV_ABI posix_mmap(void* addr, u64 len, int prot, int flags, int fd, u64 offset) {
|
s32 PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, s32 prot, s32 flags, s32 fd, s64 phys_addr,
|
||||||
void* ptr;
|
void** res) {
|
||||||
LOG_INFO(Kernel_Vmm, "posix mmap redirect to sceKernelMmap");
|
void* addr_out = posix_mmap(addr, len, prot, flags, fd, phys_addr);
|
||||||
int result = sceKernelMmap(addr, len, prot, flags, fd, offset, &ptr);
|
|
||||||
ASSERT(result == 0);
|
if (addr_out == reinterpret_cast<void*>(-1)) {
|
||||||
return ptr;
|
// posix_mmap failed, calculate and return the appropriate kernel error code using errno.
|
||||||
|
LOG_ERROR(Kernel_Fs, "error = {}", *__Error());
|
||||||
|
return ErrnoToSceKernelError(*__Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the outputted address
|
||||||
|
*res = addr_out;
|
||||||
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelConfiguredFlexibleMemorySize(u64* sizeOut) {
|
s32 PS4_SYSV_ABI sceKernelConfiguredFlexibleMemorySize(u64* sizeOut) {
|
||||||
@ -589,7 +619,7 @@ s32 PS4_SYSV_ABI sceKernelConfiguredFlexibleMemorySize(u64* sizeOut) {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) {
|
s32 PS4_SYSV_ABI sceKernelMunmap(void* addr, u64 len) {
|
||||||
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}", fmt::ptr(addr), len);
|
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}", fmt::ptr(addr), len);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -598,8 +628,8 @@ int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) {
|
|||||||
return memory->UnmapMemory(std::bit_cast<VAddr>(addr), len);
|
return memory->UnmapMemory(std::bit_cast<VAddr>(addr), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_munmap(void* addr, size_t len) {
|
s32 PS4_SYSV_ABI posix_munmap(void* addr, u64 len) {
|
||||||
int result = sceKernelMunmap(addr, len);
|
s32 result = sceKernelMunmap(addr, len);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
LOG_ERROR(Kernel_Pthread, "posix_munmap: error = {}", result);
|
LOG_ERROR(Kernel_Pthread, "posix_munmap: error = {}", result);
|
||||||
ErrSceToPosix(result);
|
ErrSceToPosix(result);
|
||||||
@ -608,12 +638,12 @@ int PS4_SYSV_ABI posix_munmap(void* addr, size_t len) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int MAX_PRT_APERTURES = 3;
|
static constexpr s32 MAX_PRT_APERTURES = 3;
|
||||||
static constexpr VAddr PRT_AREA_START_ADDR = 0x1000000000;
|
static constexpr VAddr PRT_AREA_START_ADDR = 0x1000000000;
|
||||||
static constexpr size_t PRT_AREA_SIZE = 0xec00000000;
|
static constexpr u64 PRT_AREA_SIZE = 0xec00000000;
|
||||||
static std::array<std::pair<VAddr, size_t>, MAX_PRT_APERTURES> PrtApertures{};
|
static std::array<std::pair<VAddr, u64>, MAX_PRT_APERTURES> PrtApertures{};
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelSetPrtAperture(int id, VAddr address, size_t size) {
|
s32 PS4_SYSV_ABI sceKernelSetPrtAperture(s32 id, VAddr address, u64 size) {
|
||||||
if (id < 0 || id >= MAX_PRT_APERTURES) {
|
if (id < 0 || id >= MAX_PRT_APERTURES) {
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
@ -630,11 +660,14 @@ int PS4_SYSV_ABI sceKernelSetPrtAperture(int id, VAddr address, size_t size) {
|
|||||||
"PRT aperture id = {}, address = {:#x}, size = {:#x} is set but not used", id,
|
"PRT aperture id = {}, address = {:#x}, size = {:#x} is set but not used", id,
|
||||||
address, size);
|
address, size);
|
||||||
|
|
||||||
|
auto* memory = Core::Memory::Instance();
|
||||||
|
memory->SetPrtArea(id, address, size);
|
||||||
|
|
||||||
PrtApertures[id] = {address, size};
|
PrtApertures[id] = {address, size};
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelGetPrtAperture(int id, VAddr* address, size_t* size) {
|
s32 PS4_SYSV_ABI sceKernelGetPrtAperture(s32 id, VAddr* address, u64* size) {
|
||||||
if (id < 0 || id >= MAX_PRT_APERTURES) {
|
if (id < 0 || id >= MAX_PRT_APERTURES) {
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
@ -678,8 +711,10 @@ void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("n1-v6FgU7MQ", "libkernel", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("n1-v6FgU7MQ", "libkernel", 1, "libkernel", 1, 1,
|
||||||
sceKernelConfiguredFlexibleMemorySize);
|
sceKernelConfiguredFlexibleMemorySize);
|
||||||
|
|
||||||
LIB_FUNCTION("9bfdLIyuwCY", "libkernel", 1, "libkernel", 1, 1, sceKernelMTypeProtect);
|
LIB_FUNCTION("vSMAm3cxYTY", "libkernel", 1, "libkernel", 1, 1, sceKernelMprotect);
|
||||||
LIB_FUNCTION("vSMAm3cxYTY", "libkernel", 1, "libkernel", 1, 1, sceKernelMProtect);
|
LIB_FUNCTION("YQOfxL4QfeU", "libkernel", 1, "libkernel", 1, 1, posix_mprotect);
|
||||||
|
LIB_FUNCTION("YQOfxL4QfeU", "libScePosix", 1, "libkernel", 1, 1, posix_mprotect);
|
||||||
|
LIB_FUNCTION("9bfdLIyuwCY", "libkernel", 1, "libkernel", 1, 1, sceKernelMtypeprotect);
|
||||||
|
|
||||||
// Memory pool
|
// Memory pool
|
||||||
LIB_FUNCTION("qCSfqDILlns", "libkernel", 1, "libkernel", 1, 1, sceKernelMemoryPoolExpand);
|
LIB_FUNCTION("qCSfqDILlns", "libkernel", 1, "libkernel", 1, 1, sceKernelMemoryPoolExpand);
|
||||||
|
@ -52,13 +52,13 @@ constexpr u32 ORBIS_KERNEL_MAXIMUM_NAME_LENGTH = 32;
|
|||||||
struct OrbisQueryInfo {
|
struct OrbisQueryInfo {
|
||||||
uintptr_t start;
|
uintptr_t start;
|
||||||
uintptr_t end;
|
uintptr_t end;
|
||||||
int memoryType;
|
s32 memoryType;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisVirtualQueryInfo {
|
struct OrbisVirtualQueryInfo {
|
||||||
uintptr_t start;
|
uintptr_t start;
|
||||||
uintptr_t end;
|
uintptr_t end;
|
||||||
size_t offset;
|
u64 offset;
|
||||||
s32 protection;
|
s32 protection;
|
||||||
s32 memory_type;
|
s32 memory_type;
|
||||||
u8 is_flexible : 1;
|
u8 is_flexible : 1;
|
||||||
@ -73,12 +73,12 @@ static_assert(sizeof(OrbisVirtualQueryInfo) == 72,
|
|||||||
|
|
||||||
struct OrbisKernelBatchMapEntry {
|
struct OrbisKernelBatchMapEntry {
|
||||||
void* start;
|
void* start;
|
||||||
size_t offset;
|
u64 offset;
|
||||||
size_t length;
|
u64 length;
|
||||||
char protection;
|
char protection;
|
||||||
char type;
|
char type;
|
||||||
short reserved;
|
s16 reserved;
|
||||||
int operation;
|
s32 operation;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OrbisKernelMemoryPoolOpcode : u32 {
|
enum class OrbisKernelMemoryPoolOpcode : u32 {
|
||||||
@ -124,59 +124,57 @@ struct OrbisKernelMemoryPoolBatchEntry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize();
|
u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize();
|
||||||
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
s32 PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
||||||
u64 alignment, int memoryType, s64* physAddrOut);
|
u64 alignment, s32 memoryType, s64* physAddrOut);
|
||||||
int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, int flags,
|
s32 PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, s32 prot, s32 flags,
|
||||||
s64 directMemoryStart, u64 alignment,
|
s64 directMemoryStart, u64 alignment,
|
||||||
const char* name);
|
const char* name);
|
||||||
int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int flags,
|
s32 PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, s32 prot, s32 flags,
|
||||||
s64 directMemoryStart, u64 alignment);
|
s64 directMemoryStart, u64 alignment);
|
||||||
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment, int memoryType,
|
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(u64 len, u64 alignment, s32 memoryType,
|
||||||
s64* physAddrOut);
|
s64* physAddrOut);
|
||||||
s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, size_t len);
|
s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, u64 len);
|
||||||
s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len);
|
s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, u64 len);
|
||||||
s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchEnd,
|
s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchEnd, u64 alignment,
|
||||||
size_t alignment, u64* physAddrOut,
|
u64* physAddrOut, u64* sizeOut);
|
||||||
size_t* sizeOut);
|
s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, s32 flags, OrbisVirtualQueryInfo* info,
|
||||||
s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, int flags, OrbisVirtualQueryInfo* info,
|
u64 infoSize);
|
||||||
size_t infoSize);
|
s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, s32 flags, u64 alignment);
|
||||||
s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u64 alignment);
|
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, u64 len, s32 prot, s32 flags,
|
||||||
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addrInOut, std::size_t len, int prot,
|
const char* name);
|
||||||
int flags, const char* name);
|
s32 PS4_SYSV_ABI sceKernelMapFlexibleMemory(void** addr_in_out, u64 len, s32 prot, s32 flags);
|
||||||
s32 PS4_SYSV_ABI sceKernelMapFlexibleMemory(void** addr_in_out, std::size_t len, int prot,
|
s32 PS4_SYSV_ABI sceKernelQueryMemoryProtection(void* addr, void** start, void** end, u32* prot);
|
||||||
int flags);
|
|
||||||
int PS4_SYSV_ABI sceKernelQueryMemoryProtection(void* addr, void** start, void** end, u32* prot);
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMProtect(const void* addr, size_t size, int prot);
|
s32 PS4_SYSV_ABI sceKernelMprotect(const void* addr, u64 size, s32 prot);
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMTypeProtect(const void* addr, size_t size, int mtype, int prot);
|
s32 PS4_SYSV_ABI sceKernelMtypeprotect(const void* addr, u64 size, s32 mtype, s32 prot);
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelDirectMemoryQuery(u64 offset, int flags, OrbisQueryInfo* query_info,
|
s32 PS4_SYSV_ABI sceKernelDirectMemoryQuery(u64 offset, s32 flags, OrbisQueryInfo* query_info,
|
||||||
size_t infoSize);
|
u64 infoSize);
|
||||||
s32 PS4_SYSV_ABI sceKernelAvailableFlexibleMemorySize(size_t* sizeOut);
|
s32 PS4_SYSV_ABI sceKernelAvailableFlexibleMemorySize(u64* sizeOut);
|
||||||
void PS4_SYSV_ABI _sceKernelRtldSetApplicationHeapAPI(void* func[]);
|
void PS4_SYSV_ABI _sceKernelRtldSetApplicationHeapAPI(void* func[]);
|
||||||
int PS4_SYSV_ABI sceKernelGetDirectMemoryType(u64 addr, int* directMemoryTypeOut,
|
s32 PS4_SYSV_ABI sceKernelGetDirectMemoryType(u64 addr, s32* directMemoryTypeOut,
|
||||||
void** directMemoryStartOut,
|
void** directMemoryStartOut,
|
||||||
void** directMemoryEndOut);
|
void** directMemoryEndOut);
|
||||||
int PS4_SYSV_ABI sceKernelIsStack(void* addr, void** start, void** end);
|
s32 PS4_SYSV_ABI sceKernelIsStack(void* addr, void** start, void** end);
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelBatchMap(OrbisKernelBatchMapEntry* entries, int numEntries,
|
s32 PS4_SYSV_ABI sceKernelBatchMap(OrbisKernelBatchMapEntry* entries, s32 numEntries,
|
||||||
int* numEntriesOut);
|
s32* numEntriesOut);
|
||||||
s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEntries,
|
s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, s32 numEntries,
|
||||||
int* numEntriesOut, int flags);
|
s32* numEntriesOut, s32 flags);
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelSetVirtualRangeName(const void* addr, size_t len, const char* name);
|
s32 PS4_SYSV_ABI sceKernelSetVirtualRangeName(const void* addr, u64 len, const char* name);
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, size_t len,
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, u64 len, u64 alignment,
|
||||||
size_t alignment, u64* physAddrOut);
|
u64* physAddrOut);
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t alignment, int flags,
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addr_in, u64 len, u64 alignment, s32 flags,
|
||||||
void** addrOut);
|
void** addr_out);
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int prot, int flags);
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, u64 len, s32 type, s32 prot, s32 flags);
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, size_t len, int flags);
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, u64 len, s32 flags);
|
||||||
s32 PS4_SYSV_ABI sceKernelMemoryPoolBatch(const OrbisKernelMemoryPoolBatchEntry* entries, s32 count,
|
s32 PS4_SYSV_ABI sceKernelMemoryPoolBatch(const OrbisKernelMemoryPoolBatchEntry* entries, s32 count,
|
||||||
s32* num_processed, s32 flags);
|
s32* num_processed, s32 flags);
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len);
|
s32 PS4_SYSV_ABI sceKernelMunmap(void* addr, u64 len);
|
||||||
|
|
||||||
void RegisterMemory(Core::Loader::SymbolsResolver* sym);
|
void RegisterMemory(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags,
|
|||||||
auto* linker = Common::Singleton<Core::Linker>::Instance();
|
auto* linker = Common::Singleton<Core::Linker>::Instance();
|
||||||
auto* module = linker->FindByAddress(addr);
|
auto* module = linker->FindByAddress(addr);
|
||||||
if (!module) {
|
if (!module) {
|
||||||
return ORBIS_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_ESRCH;
|
||||||
}
|
}
|
||||||
const auto mod_info = module->GetModuleInfoEx();
|
const auto mod_info = module->GetModuleInfoEx();
|
||||||
|
|
||||||
@ -118,11 +118,23 @@ s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags,
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelGetModuleInfoFromAddr(VAddr addr, int flags,
|
s32 PS4_SYSV_ABI sceKernelGetModuleInfoFromAddr(VAddr addr, s32 flags,
|
||||||
Core::OrbisKernelModuleInfoEx* info) {
|
Core::OrbisKernelModuleInfoEx* info) {
|
||||||
|
if (flags >= 3) {
|
||||||
|
std::memset(info, 0, sizeof(Core::OrbisKernelModuleInfoEx));
|
||||||
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
|
}
|
||||||
|
if (info == nullptr) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO(Lib_Kernel, "called addr = {:#x}, flags = {:#x}", addr, flags);
|
LOG_INFO(Lib_Kernel, "called addr = {:#x}, flags = {:#x}", addr, flags);
|
||||||
auto* linker = Common::Singleton<Core::Linker>::Instance();
|
auto* linker = Common::Singleton<Core::Linker>::Instance();
|
||||||
auto* module = linker->FindByAddress(addr);
|
auto* module = linker->FindByAddress(addr);
|
||||||
|
if (!module) {
|
||||||
|
return ORBIS_KERNEL_ERROR_ESRCH;
|
||||||
|
}
|
||||||
|
|
||||||
*info = module->GetModuleInfoEx();
|
*info = module->GetModuleInfoEx();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
@ -426,6 +426,7 @@ void RegisterMutex(Core::Loader::SymbolsResolver* sym) {
|
|||||||
// Posix
|
// Posix
|
||||||
LIB_FUNCTION("ttHNfU+qDBU", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_init);
|
LIB_FUNCTION("ttHNfU+qDBU", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_init);
|
||||||
LIB_FUNCTION("7H0iTOciTLo", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_lock);
|
LIB_FUNCTION("7H0iTOciTLo", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_lock);
|
||||||
|
LIB_FUNCTION("Io9+nTKXZtA", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_timedlock);
|
||||||
LIB_FUNCTION("2Z+PpY6CaJg", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_unlock);
|
LIB_FUNCTION("2Z+PpY6CaJg", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_unlock);
|
||||||
LIB_FUNCTION("ltCfaGr2JGE", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_destroy);
|
LIB_FUNCTION("ltCfaGr2JGE", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_destroy);
|
||||||
LIB_FUNCTION("dQHWEsJtoE4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutexattr_init);
|
LIB_FUNCTION("dQHWEsJtoE4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutexattr_init);
|
||||||
|
@ -576,8 +576,19 @@ int PS4_SYSV_ABI posix_pthread_getaffinity_np(PthreadT thread, size_t cpusetsize
|
|||||||
if (thread == nullptr || cpusetp == nullptr) {
|
if (thread == nullptr || cpusetp == nullptr) {
|
||||||
return POSIX_EINVAL;
|
return POSIX_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto* thread_state = ThrState::Instance();
|
||||||
|
if (thread == g_curthread) {
|
||||||
|
g_curthread->lock.lock();
|
||||||
|
} else if (auto ret = thread_state->FindThread(thread, /*include dead*/ 0); ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
auto* attr_ptr = &thread->attr;
|
auto* attr_ptr = &thread->attr;
|
||||||
return posix_pthread_attr_getaffinity_np(&attr_ptr, cpusetsize, cpusetp);
|
auto ret = posix_pthread_attr_getaffinity_np(&attr_ptr, cpusetsize, cpusetp);
|
||||||
|
|
||||||
|
thread->lock.unlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_pthread_setaffinity_np(PthreadT thread, size_t cpusetsize,
|
int PS4_SYSV_ABI posix_pthread_setaffinity_np(PthreadT thread, size_t cpusetsize,
|
||||||
@ -585,11 +596,23 @@ int PS4_SYSV_ABI posix_pthread_setaffinity_np(PthreadT thread, size_t cpusetsize
|
|||||||
if (thread == nullptr || cpusetp == nullptr) {
|
if (thread == nullptr || cpusetp == nullptr) {
|
||||||
return POSIX_EINVAL;
|
return POSIX_EINVAL;
|
||||||
}
|
}
|
||||||
auto* attr_ptr = &thread->attr;
|
|
||||||
if (const auto ret = posix_pthread_attr_setaffinity_np(&attr_ptr, cpusetsize, cpusetp)) {
|
auto* thread_state = ThrState::Instance();
|
||||||
|
if (thread == g_curthread) {
|
||||||
|
g_curthread->lock.lock();
|
||||||
|
} else if (auto ret = thread_state->FindThread(thread, /*include dead*/ 0); ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return thread->SetAffinity(thread->attr.cpuset);
|
|
||||||
|
auto* attr_ptr = &thread->attr;
|
||||||
|
auto ret = posix_pthread_attr_setaffinity_np(&attr_ptr, cpusetsize, cpusetp);
|
||||||
|
|
||||||
|
if (ret == ORBIS_OK) {
|
||||||
|
ret = thread->SetAffinity(thread->attr.cpuset);
|
||||||
|
}
|
||||||
|
|
||||||
|
thread->lock.unlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePthreadGetaffinity(PthreadT thread, u64* mask) {
|
int PS4_SYSV_ABI scePthreadGetaffinity(PthreadT thread, u64* mask) {
|
||||||
|
@ -306,6 +306,8 @@ void RegisterThreadAttr(Core::Loader::SymbolsResolver* sym) {
|
|||||||
posix_pthread_attr_getdetachstate);
|
posix_pthread_attr_getdetachstate);
|
||||||
LIB_FUNCTION("JKyG3SWyA10", "libScePosix", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("JKyG3SWyA10", "libScePosix", 1, "libkernel", 1, 1,
|
||||||
posix_pthread_attr_setguardsize);
|
posix_pthread_attr_setguardsize);
|
||||||
|
LIB_FUNCTION("qlk9pSLsUmM", "libScePosix", 1, "libkernel", 1, 1,
|
||||||
|
posix_pthread_attr_getschedparam);
|
||||||
|
|
||||||
// Orbis
|
// Orbis
|
||||||
LIB_FUNCTION("4+h9EzwKF4I", "libkernel", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("4+h9EzwKF4I", "libkernel", 1, "libkernel", 1, 1,
|
||||||
|
@ -261,7 +261,7 @@ s32 PS4_SYSV_ABI scePngDecQueryMemorySize(const OrbisPngDecCreateParam* param) {
|
|||||||
return sizeof(PngHandler);
|
return sizeof(PngHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterlibScePngDec(Core::Loader::SymbolsResolver* sym) {
|
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("m0uW+8pFyaw", "libScePngDec", 1, "libScePngDec", 1, 1, scePngDecCreate);
|
LIB_FUNCTION("m0uW+8pFyaw", "libScePngDec", 1, "libScePngDec", 1, 1, scePngDecCreate);
|
||||||
LIB_FUNCTION("WC216DD3El4", "libScePngDec", 1, "libScePngDec", 1, 1, scePngDecDecode);
|
LIB_FUNCTION("WC216DD3El4", "libScePngDec", 1, "libScePngDec", 1, 1, scePngDecDecode);
|
||||||
LIB_FUNCTION("cJ--1xAbj-I", "libScePngDec", 1, "libScePngDec", 1, 1,
|
LIB_FUNCTION("cJ--1xAbj-I", "libScePngDec", 1, "libScePngDec", 1, 1,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user