diff options
119 files changed, 2090 insertions, 2198 deletions
diff --git a/.ci/scripts/android/eabuild.sh b/.ci/scripts/android/eabuild.sh new file mode 100644 index 000000000..1672f2948 --- /dev/null +++ b/.ci/scripts/android/eabuild.sh | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | # SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 4 | # SPDX-License-Identifier: GPL-3.0-or-later | ||
| 5 | |||
| 6 | export NDK_CCACHE="$(which ccache)" | ||
| 7 | ccache -s | ||
| 8 | |||
| 9 | export ANDROID_KEYSTORE_FILE="${GITHUB_WORKSPACE}/ks.jks" | ||
| 10 | base64 --decode <<< "${EA_PLAY_ANDROID_KEYSTORE_B64}" > "${ANDROID_KEYSTORE_FILE}" | ||
| 11 | export ANDROID_KEY_ALIAS="${PLAY_ANDROID_KEY_ALIAS}" | ||
| 12 | export ANDROID_KEYSTORE_PASS="${PLAY_ANDROID_KEYSTORE_PASS}" | ||
| 13 | export SERVICE_ACCOUNT_KEY_PATH="${GITHUB_WORKSPACE}/sa.json" | ||
| 14 | base64 --decode <<< "${EA_SERVICE_ACCOUNT_KEY_B64}" > "${SERVICE_ACCOUNT_KEY_PATH}" | ||
| 15 | ./gradlew "publishEaReleaseBundle" | ||
| 16 | |||
| 17 | ccache -s | ||
| 18 | |||
| 19 | if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then | ||
| 20 | rm "${ANDROID_KEYSTORE_FILE}" | ||
| 21 | fi | ||
diff --git a/.ci/scripts/android/mainlinebuild.sh b/.ci/scripts/android/mainlinebuild.sh new file mode 100644 index 000000000..f3b89ed1c --- /dev/null +++ b/.ci/scripts/android/mainlinebuild.sh | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | # SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 4 | # SPDX-License-Identifier: GPL-3.0-or-later | ||
| 5 | |||
| 6 | export NDK_CCACHE="$(which ccache)" | ||
| 7 | ccache -s | ||
| 8 | |||
| 9 | export ANDROID_KEYSTORE_FILE="${GITHUB_WORKSPACE}/ks.jks" | ||
| 10 | base64 --decode <<< "${MAINLINE_PLAY_ANDROID_KEYSTORE_B64}" > "${ANDROID_KEYSTORE_FILE}" | ||
| 11 | export ANDROID_KEY_ALIAS="${PLAY_ANDROID_KEY_ALIAS}" | ||
| 12 | export ANDROID_KEYSTORE_PASS="${PLAY_ANDROID_KEYSTORE_PASS}" | ||
| 13 | export SERVICE_ACCOUNT_KEY_PATH="${GITHUB_WORKSPACE}/sa.json" | ||
| 14 | base64 --decode <<< "${MAINLINE_SERVICE_ACCOUNT_KEY_B64}" > "${SERVICE_ACCOUNT_KEY_PATH}" | ||
| 15 | ./gradlew "publishMainlineReleaseBundle" | ||
| 16 | |||
| 17 | ccache -s | ||
| 18 | |||
| 19 | if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then | ||
| 20 | rm "${ANDROID_KEYSTORE_FILE}" | ||
| 21 | fi | ||
diff --git a/.github/workflows/android-ea-play-release.yml b/.github/workflows/android-ea-play-release.yml new file mode 100644 index 000000000..0cf78279c --- /dev/null +++ b/.github/workflows/android-ea-play-release.yml | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | name: yuzu-android-ea-play-release | ||
| 5 | |||
| 6 | on: | ||
| 7 | workflow_dispatch: | ||
| 8 | inputs: | ||
| 9 | release-track: | ||
| 10 | description: 'Play store release track (internal/alpha/beta/production)' | ||
| 11 | required: true | ||
| 12 | default: 'alpha' | ||
| 13 | |||
| 14 | jobs: | ||
| 15 | android: | ||
| 16 | runs-on: ubuntu-latest | ||
| 17 | if: ${{ github.repository == 'yuzu-emu/yuzu' }} | ||
| 18 | steps: | ||
| 19 | - uses: actions/checkout@v3 | ||
| 20 | name: Checkout | ||
| 21 | with: | ||
| 22 | fetch-depth: 0 | ||
| 23 | submodules: true | ||
| 24 | token: ${{ secrets.ALT_GITHUB_TOKEN }} | ||
| 25 | - run: npm install execa@5 | ||
| 26 | - uses: actions/github-script@v5 | ||
| 27 | name: 'Merge and publish Android EA changes' | ||
| 28 | env: | ||
| 29 | ALT_GITHUB_TOKEN: ${{ secrets.ALT_GITHUB_TOKEN }} | ||
| 30 | BUILD_EA: true | ||
| 31 | with: | ||
| 32 | script: | | ||
| 33 | const execa = require("execa"); | ||
| 34 | const mergebot = require('./.github/workflows/android-merge.js').mergebot; | ||
| 35 | process.chdir('${{ github.workspace }}'); | ||
| 36 | mergebot(github, context, execa); | ||
| 37 | - name: Get tag name | ||
| 38 | run: echo "GIT_TAG_NAME=$(cat tag-name.txt)" >> $GITHUB_ENV | ||
| 39 | - name: Set up JDK 17 | ||
| 40 | uses: actions/setup-java@v3 | ||
| 41 | with: | ||
| 42 | java-version: '17' | ||
| 43 | distribution: 'temurin' | ||
| 44 | - name: Install dependencies | ||
| 45 | run: | | ||
| 46 | sudo apt-get update | ||
| 47 | sudo apt-get install -y ccache apksigner glslang-dev glslang-tools | ||
| 48 | - name: Build | ||
| 49 | run: ./.ci/scripts/android/eabuild.sh | ||
| 50 | env: | ||
| 51 | EA_PLAY_ANDROID_KEYSTORE_B64: ${{ secrets.PLAY_ANDROID_KEYSTORE_B64 }} | ||
| 52 | PLAY_ANDROID_KEY_ALIAS: ${{ secrets.PLAY_ANDROID_KEY_ALIAS }} | ||
| 53 | PLAY_ANDROID_KEYSTORE_PASS: ${{ secrets.PLAY_ANDROID_KEYSTORE_PASS }} | ||
| 54 | EA_SERVICE_ACCOUNT_KEY_B64: ${{ secrets.EA_SERVICE_ACCOUNT_KEY_B64 }} | ||
| 55 | STORE_TRACK: ${{ github.event.inputs.release-track }} | ||
| 56 | AUTO_VERSIONED: true | ||
| 57 | BUILD_EA: true | ||
| 58 | - name: Create release | ||
| 59 | uses: softprops/action-gh-release@v1 | ||
| 60 | with: | ||
| 61 | tag_name: ${{ env.EA_TAG_NAME }} | ||
| 62 | name: ${{ env.EA_TAG_NAME }} | ||
| 63 | draft: false | ||
| 64 | prerelease: false | ||
| 65 | repository: yuzu/yuzu-android | ||
| 66 | token: ${{ secrets.ALT_GITHUB_TOKEN }} | ||
diff --git a/.github/workflows/android-mainline-play-release.yml b/.github/workflows/android-mainline-play-release.yml new file mode 100644 index 000000000..8255e0a40 --- /dev/null +++ b/.github/workflows/android-mainline-play-release.yml | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | name: yuzu-android-mainline-play-release | ||
| 5 | |||
| 6 | on: | ||
| 7 | workflow_dispatch: | ||
| 8 | inputs: | ||
| 9 | release-tag: | ||
| 10 | description: 'Tag # from yuzu-android that you want to build and publish' | ||
| 11 | required: true | ||
| 12 | default: '200' | ||
| 13 | release-track: | ||
| 14 | description: 'Play store release track (internal/alpha/beta/production)' | ||
| 15 | required: true | ||
| 16 | default: 'alpha' | ||
| 17 | |||
| 18 | jobs: | ||
| 19 | android: | ||
| 20 | runs-on: ubuntu-latest | ||
| 21 | if: ${{ github.repository == 'yuzu-emu/yuzu' }} | ||
| 22 | steps: | ||
| 23 | - uses: actions/checkout@v3 | ||
| 24 | name: Checkout | ||
| 25 | with: | ||
| 26 | fetch-depth: 0 | ||
| 27 | submodules: true | ||
| 28 | token: ${{ secrets.ALT_GITHUB_TOKEN }} | ||
| 29 | - run: npm install execa@5 | ||
| 30 | - uses: actions/github-script@v5 | ||
| 31 | name: 'Pull mainline tag' | ||
| 32 | env: | ||
| 33 | MAINLINE_TAG: ${{ github.event.inputs.release-tag }} | ||
| 34 | with: | ||
| 35 | script: | | ||
| 36 | const execa = require("execa"); | ||
| 37 | const mergebot = require('./.github/workflows/android-merge.js').getMainlineTag; | ||
| 38 | process.chdir('${{ github.workspace }}'); | ||
| 39 | mergebot(execa); | ||
| 40 | - name: Set up JDK 17 | ||
| 41 | uses: actions/setup-java@v3 | ||
| 42 | with: | ||
| 43 | java-version: '17' | ||
| 44 | distribution: 'temurin' | ||
| 45 | - name: Install dependencies | ||
| 46 | run: | | ||
| 47 | sudo apt-get update | ||
| 48 | sudo apt-get install -y ccache apksigner glslang-dev glslang-tools | ||
| 49 | - name: Build | ||
| 50 | run: | | ||
| 51 | echo "GIT_TAG_NAME=android-${{ github.event.inputs.releast-tag }}" >> $GITHUB_ENV | ||
| 52 | ./.ci/scripts/android/mainlinebuild.sh | ||
| 53 | env: | ||
| 54 | MAINLINE_PLAY_ANDROID_KEYSTORE_B64: ${{ secrets.PLAY_ANDROID_KEYSTORE_B64 }} | ||
| 55 | PLAY_ANDROID_KEY_ALIAS: ${{ secrets.PLAY_ANDROID_KEY_ALIAS }} | ||
| 56 | PLAY_ANDROID_KEYSTORE_PASS: ${{ secrets.PLAY_ANDROID_KEYSTORE_PASS }} | ||
| 57 | SERVICE_ACCOUNT_KEY_B64: ${{ secrets.MAINLINE_SERVICE_ACCOUNT_KEY_B64 }} | ||
| 58 | STORE_TRACK: ${{ github.event.inputs.release-track }} | ||
| 59 | AUTO_VERSIONED: true | ||
diff --git a/.github/workflows/android-merge.js b/.github/workflows/android-merge.js index 44ab56e44..315f81ba0 100644 --- a/.github/workflows/android-merge.js +++ b/.github/workflows/android-merge.js | |||
| @@ -6,9 +6,12 @@ | |||
| 6 | 6 | ||
| 7 | const fs = require("fs"); | 7 | const fs = require("fs"); |
| 8 | // which label to check for changes | 8 | // which label to check for changes |
| 9 | const CHANGE_LABEL = 'android-merge'; | 9 | const CHANGE_LABEL_MAINLINE = 'android-merge'; |
| 10 | const CHANGE_LABEL_EA = 'android-ea-merge'; | ||
| 10 | // how far back in time should we consider the changes are "recent"? (default: 24 hours) | 11 | // how far back in time should we consider the changes are "recent"? (default: 24 hours) |
| 11 | const DETECTION_TIME_FRAME = (parseInt(process.env.DETECTION_TIME_FRAME)) || (24 * 3600 * 1000); | 12 | const DETECTION_TIME_FRAME = (parseInt(process.env.DETECTION_TIME_FRAME)) || (24 * 3600 * 1000); |
| 13 | const BUILD_EA = process.env.BUILD_EA == 'true'; | ||
| 14 | const MAINLINE_TAG = process.env.MAINLINE_TAG; | ||
| 12 | 15 | ||
| 13 | async function checkBaseChanges(github) { | 16 | async function checkBaseChanges(github) { |
| 14 | // query the commit date of the latest commit on this branch | 17 | // query the commit date of the latest commit on this branch |
| @@ -40,20 +43,7 @@ async function checkBaseChanges(github) { | |||
| 40 | 43 | ||
| 41 | async function checkAndroidChanges(github) { | 44 | async function checkAndroidChanges(github) { |
| 42 | if (checkBaseChanges(github)) return true; | 45 | if (checkBaseChanges(github)) return true; |
| 43 | const query = `query($owner:String!, $name:String!, $label:String!) { | 46 | const pulls = getPulls(github, false); |
| 44 | repository(name:$name, owner:$owner) { | ||
| 45 | pullRequests(labels: [$label], states: OPEN, first: 100) { | ||
| 46 | nodes { number headRepository { pushedAt } } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | }`; | ||
| 50 | const variables = { | ||
| 51 | owner: 'yuzu-emu', | ||
| 52 | name: 'yuzu', | ||
| 53 | label: CHANGE_LABEL, | ||
| 54 | }; | ||
| 55 | const result = await github.graphql(query, variables); | ||
| 56 | const pulls = result.repository.pullRequests.nodes; | ||
| 57 | for (let i = 0; i < pulls.length; i++) { | 47 | for (let i = 0; i < pulls.length; i++) { |
| 58 | let pull = pulls[i]; | 48 | let pull = pulls[i]; |
| 59 | if (new Date() - new Date(pull.headRepository.pushedAt) <= DETECTION_TIME_FRAME) { | 49 | if (new Date() - new Date(pull.headRepository.pushedAt) <= DETECTION_TIME_FRAME) { |
| @@ -83,7 +73,13 @@ async function tagAndPush(github, owner, repo, execa, commit=false) { | |||
| 83 | }; | 73 | }; |
| 84 | const tags = await github.graphql(query, variables); | 74 | const tags = await github.graphql(query, variables); |
| 85 | const tagList = tags.repository.refs.nodes; | 75 | const tagList = tags.repository.refs.nodes; |
| 86 | const lastTag = tagList[0] ? tagList[0].name : 'dummy-0'; | 76 | let lastTag = 'android-1'; |
| 77 | for (let i = 0; i < tagList.length; ++i) { | ||
| 78 | if (tagList[i].name.includes('android-')) { | ||
| 79 | lastTag = tagList[i].name; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | } | ||
| 87 | const tagNumber = /\w+-(\d+)/.exec(lastTag)[1] | 0; | 83 | const tagNumber = /\w+-(\d+)/.exec(lastTag)[1] | 0; |
| 88 | const channel = repo.split('-')[1]; | 84 | const channel = repo.split('-')[1]; |
| 89 | const newTag = `${channel}-${tagNumber + 1}`; | 85 | const newTag = `${channel}-${tagNumber + 1}`; |
| @@ -101,6 +97,48 @@ async function tagAndPush(github, owner, repo, execa, commit=false) { | |||
| 101 | console.info('Successfully pushed new changes.'); | 97 | console.info('Successfully pushed new changes.'); |
| 102 | } | 98 | } |
| 103 | 99 | ||
| 100 | async function tagAndPushEA(github, owner, repo, execa) { | ||
| 101 | let altToken = process.env.ALT_GITHUB_TOKEN; | ||
| 102 | if (!altToken) { | ||
| 103 | throw `Please set ALT_GITHUB_TOKEN environment variable. This token should have write access to ${owner}/${repo}.`; | ||
| 104 | } | ||
| 105 | const query = `query ($owner:String!, $name:String!) { | ||
| 106 | repository(name:$name, owner:$owner) { | ||
| 107 | refs(refPrefix: "refs/tags/", orderBy: {field: TAG_COMMIT_DATE, direction: DESC}, first: 10) { | ||
| 108 | nodes { name } | ||
| 109 | } | ||
| 110 | } | ||
| 111 | }`; | ||
| 112 | const variables = { | ||
| 113 | owner: owner, | ||
| 114 | name: repo, | ||
| 115 | }; | ||
| 116 | const tags = await github.graphql(query, variables); | ||
| 117 | const tagList = tags.repository.refs.nodes; | ||
| 118 | let lastTag = 'ea-1'; | ||
| 119 | for (let i = 0; i < tagList.length; ++i) { | ||
| 120 | if (tagList[i].name.includes('ea-')) { | ||
| 121 | lastTag = tagList[i].name; | ||
| 122 | break; | ||
| 123 | } | ||
| 124 | } | ||
| 125 | const tagNumber = /\w+-(\d+)/.exec(lastTag)[1] | 0; | ||
| 126 | const newTag = `ea-${tagNumber + 1}`; | ||
| 127 | console.log(`New tag: ${newTag}`); | ||
| 128 | console.info('Pushing tags to GitHub ...'); | ||
| 129 | await execa("git", ["remote", "add", "android", "https://github.com/yuzu-emu/yuzu-android.git"]); | ||
| 130 | await execa("git", ["fetch", "android"]); | ||
| 131 | |||
| 132 | await execa("git", ['tag', newTag]); | ||
| 133 | await execa("git", ['push', 'android', `${newTag}`]); | ||
| 134 | |||
| 135 | fs.writeFile('tag-name.txt', newTag, (err) => { | ||
| 136 | if (err) throw 'Could not write tag name to file!' | ||
| 137 | }) | ||
| 138 | |||
| 139 | console.info('Successfully pushed new changes.'); | ||
| 140 | } | ||
| 141 | |||
| 104 | async function generateReadme(pulls, context, mergeResults, execa) { | 142 | async function generateReadme(pulls, context, mergeResults, execa) { |
| 105 | let baseUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/`; | 143 | let baseUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/`; |
| 106 | let output = | 144 | let output = |
| @@ -202,10 +240,7 @@ async function resetBranch(execa) { | |||
| 202 | } | 240 | } |
| 203 | } | 241 | } |
| 204 | 242 | ||
| 205 | async function mergebot(github, context, execa) { | 243 | async function getPulls(github) { |
| 206 | // Reset our local copy of master to what appears on yuzu-emu/yuzu - master | ||
| 207 | await resetBranch(execa); | ||
| 208 | |||
| 209 | const query = `query ($owner:String!, $name:String!, $label:String!) { | 244 | const query = `query ($owner:String!, $name:String!, $label:String!) { |
| 210 | repository(name:$name, owner:$owner) { | 245 | repository(name:$name, owner:$owner) { |
| 211 | pullRequests(labels: [$label], states: OPEN, first: 100) { | 246 | pullRequests(labels: [$label], states: OPEN, first: 100) { |
| @@ -215,13 +250,49 @@ async function mergebot(github, context, execa) { | |||
| 215 | } | 250 | } |
| 216 | } | 251 | } |
| 217 | }`; | 252 | }`; |
| 218 | const variables = { | 253 | const mainlineVariables = { |
| 219 | owner: 'yuzu-emu', | 254 | owner: 'yuzu-emu', |
| 220 | name: 'yuzu', | 255 | name: 'yuzu', |
| 221 | label: CHANGE_LABEL, | 256 | label: CHANGE_LABEL_MAINLINE, |
| 222 | }; | 257 | }; |
| 223 | const result = await github.graphql(query, variables); | 258 | const mainlineResult = await github.graphql(query, mainlineVariables); |
| 224 | const pulls = result.repository.pullRequests.nodes; | 259 | const pulls = mainlineResult.repository.pullRequests.nodes; |
| 260 | if (BUILD_EA) { | ||
| 261 | const eaVariables = { | ||
| 262 | owner: 'yuzu-emu', | ||
| 263 | name: 'yuzu', | ||
| 264 | label: CHANGE_LABEL_EA, | ||
| 265 | }; | ||
| 266 | const eaResult = await github.graphql(query, eaVariables); | ||
| 267 | const eaPulls = eaResult.repository.pullRequests.nodes; | ||
| 268 | return pulls.concat(eaPulls); | ||
| 269 | } | ||
| 270 | return pulls; | ||
| 271 | } | ||
| 272 | |||
| 273 | async function getMainlineTag(execa) { | ||
| 274 | console.log(`::group::Getting mainline tag android-${MAINLINE_TAG}`); | ||
| 275 | let hasFailed = false; | ||
| 276 | try { | ||
| 277 | await execa("git", ["remote", "add", "mainline", "https://github.com/yuzu-emu/yuzu-android.git"]); | ||
| 278 | await execa("git", ["fetch", "mainline", "--tags"]); | ||
| 279 | await execa("git", ["checkout", `tags/android-${MAINLINE_TAG}`]); | ||
| 280 | await execa("git", ["submodule", "update", "--init", "--recursive"]); | ||
| 281 | } catch (err) { | ||
| 282 | console.log('::error title=Failed pull tag'); | ||
| 283 | hasFailed = true; | ||
| 284 | } | ||
| 285 | console.log("::endgroup::"); | ||
| 286 | if (hasFailed) { | ||
| 287 | throw 'Failed pull mainline tag. Aborting!'; | ||
| 288 | } | ||
| 289 | } | ||
| 290 | |||
| 291 | async function mergebot(github, context, execa) { | ||
| 292 | // Reset our local copy of master to what appears on yuzu-emu/yuzu - master | ||
| 293 | await resetBranch(execa); | ||
| 294 | |||
| 295 | const pulls = await getPulls(github); | ||
| 225 | let displayList = []; | 296 | let displayList = []; |
| 226 | for (let i = 0; i < pulls.length; i++) { | 297 | for (let i = 0; i < pulls.length; i++) { |
| 227 | let pull = pulls[i]; | 298 | let pull = pulls[i]; |
| @@ -231,11 +302,17 @@ async function mergebot(github, context, execa) { | |||
| 231 | console.table(displayList); | 302 | console.table(displayList); |
| 232 | await fetchPullRequests(pulls, "https://github.com/yuzu-emu/yuzu", execa); | 303 | await fetchPullRequests(pulls, "https://github.com/yuzu-emu/yuzu", execa); |
| 233 | const mergeResults = await mergePullRequests(pulls, execa); | 304 | const mergeResults = await mergePullRequests(pulls, execa); |
| 234 | await generateReadme(pulls, context, mergeResults, execa); | 305 | |
| 235 | await tagAndPush(github, 'yuzu-emu', `yuzu-android`, execa, true); | 306 | if (BUILD_EA) { |
| 307 | await tagAndPushEA(github, 'yuzu-emu', `yuzu-android`, execa); | ||
| 308 | } else { | ||
| 309 | await generateReadme(pulls, context, mergeResults, execa); | ||
| 310 | await tagAndPush(github, 'yuzu-emu', `yuzu-android`, execa, true); | ||
| 311 | } | ||
| 236 | } | 312 | } |
| 237 | 313 | ||
| 238 | module.exports.mergebot = mergebot; | 314 | module.exports.mergebot = mergebot; |
| 239 | module.exports.checkAndroidChanges = checkAndroidChanges; | 315 | module.exports.checkAndroidChanges = checkAndroidChanges; |
| 240 | module.exports.tagAndPush = tagAndPush; | 316 | module.exports.tagAndPush = tagAndPush; |
| 241 | module.exports.checkBaseChanges = checkBaseChanges; | 317 | module.exports.checkBaseChanges = checkBaseChanges; |
| 318 | module.exports.getMainlineTag = getMainlineTag; | ||
diff --git a/.github/workflows/android-publish.yml b/.github/workflows/android-publish.yml index 68e21c2f2..61f739e96 100644 --- a/.github/workflows/android-publish.yml +++ b/.github/workflows/android-publish.yml | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2023 yuzu Emulator Project | 1 | # SPDX-FileCopyrightText: 2024 yuzu Emulator Project |
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later | 2 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | name: yuzu-android-publish | 4 | name: yuzu-android-publish |
| @@ -16,7 +16,7 @@ on: | |||
| 16 | jobs: | 16 | jobs: |
| 17 | android: | 17 | android: |
| 18 | runs-on: ubuntu-latest | 18 | runs-on: ubuntu-latest |
| 19 | if: ${{ github.event.inputs.android != 'false' && github.repository == 'yuzu-emu/yuzu-android' }} | 19 | if: ${{ github.event.inputs.android != 'false' && github.repository == 'yuzu-emu/yuzu' }} |
| 20 | steps: | 20 | steps: |
| 21 | # this checkout is required to make sure the GitHub Actions scripts are available | 21 | # this checkout is required to make sure the GitHub Actions scripts are available |
| 22 | - uses: actions/checkout@v3 | 22 | - uses: actions/checkout@v3 |
diff --git a/dist/languages/.tx/config b/dist/languages/.tx/config index cca7b3d67..fbdfbe017 100644 --- a/dist/languages/.tx/config +++ b/dist/languages/.tx/config | |||
| @@ -11,3 +11,4 @@ type = QT | |||
| 11 | file_filter = ../../src/android/app/src/main/res/values-<lang>/strings.xml | 11 | file_filter = ../../src/android/app/src/main/res/values-<lang>/strings.xml |
| 12 | source_file = ../../src/android/app/src/main/res/values/strings.xml | 12 | source_file = ../../src/android/app/src/main/res/values/strings.xml |
| 13 | type = ANDROID | 13 | type = ANDROID |
| 14 | lang_map = ja_JP:ja, ko_KR:ko, pt_BR:pt-rBR, pt_PT:pt-rPT, ru_RU:ru, vi_VN:vi, zh_CN:zh-rCN, zh_TW:zh-rTW | ||
diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 188ef9469..cb026211c 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | import android.annotation.SuppressLint | 4 | import android.annotation.SuppressLint |
| 5 | import kotlin.collections.setOf | 5 | import kotlin.collections.setOf |
| 6 | import org.jetbrains.kotlin.konan.properties.Properties | ||
| 7 | import org.jlleitschuh.gradle.ktlint.reporter.ReporterType | 6 | import org.jlleitschuh.gradle.ktlint.reporter.ReporterType |
| 7 | import com.github.triplet.gradle.androidpublisher.ReleaseStatus | ||
| 8 | 8 | ||
| 9 | plugins { | 9 | plugins { |
| 10 | id("com.android.application") | 10 | id("com.android.application") |
| @@ -13,6 +13,7 @@ plugins { | |||
| 13 | kotlin("plugin.serialization") version "1.9.20" | 13 | kotlin("plugin.serialization") version "1.9.20" |
| 14 | id("androidx.navigation.safeargs.kotlin") | 14 | id("androidx.navigation.safeargs.kotlin") |
| 15 | id("org.jlleitschuh.gradle.ktlint") version "11.4.0" | 15 | id("org.jlleitschuh.gradle.ktlint") version "11.4.0" |
| 16 | id("com.github.triplet.play") version "3.8.6" | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| @@ -58,15 +59,7 @@ android { | |||
| 58 | targetSdk = 34 | 59 | targetSdk = 34 |
| 59 | versionName = getGitVersion() | 60 | versionName = getGitVersion() |
| 60 | 61 | ||
| 61 | // If you want to use autoVersion for the versionCode, create a property in local.properties | 62 | versionCode = if (System.getenv("AUTO_VERSIONED") == "true") { |
| 62 | // named "autoVersioned" and set it to "true" | ||
| 63 | val properties = Properties() | ||
| 64 | val versionProperty = try { | ||
| 65 | properties.load(project.rootProject.file("local.properties").inputStream()) | ||
| 66 | properties.getProperty("autoVersioned") ?: "" | ||
| 67 | } catch (e: Exception) { "" } | ||
| 68 | |||
| 69 | versionCode = if (versionProperty == "true") { | ||
| 70 | autoVersion | 63 | autoVersion |
| 71 | } else { | 64 | } else { |
| 72 | 1 | 65 | 1 |
| @@ -221,6 +214,15 @@ ktlint { | |||
| 221 | } | 214 | } |
| 222 | } | 215 | } |
| 223 | 216 | ||
| 217 | play { | ||
| 218 | val keyPath = System.getenv("SERVICE_ACCOUNT_KEY_PATH") | ||
| 219 | if (keyPath != null) { | ||
| 220 | serviceAccountCredentials.set(File(keyPath)) | ||
| 221 | } | ||
| 222 | track.set(System.getenv("STORE_TRACK") ?: "internal") | ||
| 223 | releaseStatus.set(ReleaseStatus.COMPLETED) | ||
| 224 | } | ||
| 225 | |||
| 224 | dependencies { | 226 | dependencies { |
| 225 | implementation("androidx.core:core-ktx:1.12.0") | 227 | implementation("androidx.core:core-ktx:1.12.0") |
| 226 | implementation("androidx.appcompat:appcompat:1.6.1") | 228 | implementation("androidx.appcompat:appcompat:1.6.1") |
| @@ -257,12 +259,18 @@ fun runGitCommand(command: List<String>): String { | |||
| 257 | } | 259 | } |
| 258 | 260 | ||
| 259 | fun getGitVersion(): String { | 261 | fun getGitVersion(): String { |
| 262 | val gitVersion = runGitCommand( | ||
| 263 | listOf( | ||
| 264 | "git", | ||
| 265 | "describe", | ||
| 266 | "--always", | ||
| 267 | "--long" | ||
| 268 | ) | ||
| 269 | ).replace(Regex("(-0)?-[^-]+$"), "") | ||
| 260 | val versionName = if (System.getenv("GITHUB_ACTIONS") != null) { | 270 | val versionName = if (System.getenv("GITHUB_ACTIONS") != null) { |
| 261 | val gitTag = System.getenv("GIT_TAG_NAME") ?: "" | 271 | System.getenv("GIT_TAG_NAME") ?: gitVersion |
| 262 | gitTag | ||
| 263 | } else { | 272 | } else { |
| 264 | runGitCommand(listOf("git", "describe", "--always", "--long")) | 273 | gitVersion |
| 265 | .replace(Regex("(-0)?-[^-]+$"), "") | ||
| 266 | } | 274 | } |
| 267 | return versionName.ifEmpty { "0.0" } | 275 | return versionName.ifEmpty { "0.0" } |
| 268 | } | 276 | } |
diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index f011bd696..7890b30ca 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml | |||
| @@ -12,8 +12,6 @@ SPDX-License-Identifier: GPL-3.0-or-later | |||
| 12 | <uses-feature android:name="android.hardware.vulkan.version" android:version="0x401000" android:required="true" /> | 12 | <uses-feature android:name="android.hardware.vulkan.version" android:version="0x401000" android:required="true" /> |
| 13 | 13 | ||
| 14 | <uses-permission android:name="android.permission.INTERNET" /> | 14 | <uses-permission android:name="android.permission.INTERNET" /> |
| 15 | <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
| 16 | <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" /> | ||
| 17 | <uses-permission android:name="android.permission.NFC" /> | 15 | <uses-permission android:name="android.permission.NFC" /> |
| 18 | <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> | 16 | <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> |
| 19 | 17 | ||
| @@ -80,10 +78,6 @@ SPDX-License-Identifier: GPL-3.0-or-later | |||
| 80 | android:resource="@xml/nfc_tech_filter" /> | 78 | android:resource="@xml/nfc_tech_filter" /> |
| 81 | </activity> | 79 | </activity> |
| 82 | 80 | ||
| 83 | <service android:name="org.yuzu.yuzu_emu.utils.ForegroundService" android:foregroundServiceType="specialUse"> | ||
| 84 | <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="Keep emulation running in background"/> | ||
| 85 | </service> | ||
| 86 | |||
| 87 | <provider | 81 | <provider |
| 88 | android:name=".features.DocumentProvider" | 82 | android:name=".features.DocumentProvider" |
| 89 | android:authorities="${applicationId}.user" | 83 | android:authorities="${applicationId}.user" |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt index d114bd53d..76778c10a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt | |||
| @@ -17,17 +17,6 @@ fun Context.getPublicFilesDir(): File = getExternalFilesDir(null) ?: filesDir | |||
| 17 | 17 | ||
| 18 | class YuzuApplication : Application() { | 18 | class YuzuApplication : Application() { |
| 19 | private fun createNotificationChannels() { | 19 | private fun createNotificationChannels() { |
| 20 | val emulationChannel = NotificationChannel( | ||
| 21 | getString(R.string.emulation_notification_channel_id), | ||
| 22 | getString(R.string.emulation_notification_channel_name), | ||
| 23 | NotificationManager.IMPORTANCE_LOW | ||
| 24 | ) | ||
| 25 | emulationChannel.description = getString( | ||
| 26 | R.string.emulation_notification_channel_description | ||
| 27 | ) | ||
| 28 | emulationChannel.setSound(null, null) | ||
| 29 | emulationChannel.vibrationPattern = null | ||
| 30 | |||
| 31 | val noticeChannel = NotificationChannel( | 20 | val noticeChannel = NotificationChannel( |
| 32 | getString(R.string.notice_notification_channel_id), | 21 | getString(R.string.notice_notification_channel_id), |
| 33 | getString(R.string.notice_notification_channel_name), | 22 | getString(R.string.notice_notification_channel_name), |
| @@ -39,7 +28,6 @@ class YuzuApplication : Application() { | |||
| 39 | // Register the channel with the system; you can't change the importance | 28 | // Register the channel with the system; you can't change the importance |
| 40 | // or other notification behaviors after this | 29 | // or other notification behaviors after this |
| 41 | val notificationManager = getSystemService(NotificationManager::class.java) | 30 | val notificationManager = getSystemService(NotificationManager::class.java) |
| 42 | notificationManager.createNotificationChannel(emulationChannel) | ||
| 43 | notificationManager.createNotificationChannel(noticeChannel) | 31 | notificationManager.createNotificationChannel(noticeChannel) |
| 44 | } | 32 | } |
| 45 | 33 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index 564aaf305..7a8d03610 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | package org.yuzu.yuzu_emu.activities | 4 | package org.yuzu.yuzu_emu.activities |
| 5 | 5 | ||
| 6 | import android.annotation.SuppressLint | 6 | import android.annotation.SuppressLint |
| 7 | import android.app.Activity | ||
| 8 | import android.app.PendingIntent | 7 | import android.app.PendingIntent |
| 9 | import android.app.PictureInPictureParams | 8 | import android.app.PictureInPictureParams |
| 10 | import android.app.RemoteAction | 9 | import android.app.RemoteAction |
| @@ -45,7 +44,6 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting | |||
| 45 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 44 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 46 | import org.yuzu.yuzu_emu.model.EmulationViewModel | 45 | import org.yuzu.yuzu_emu.model.EmulationViewModel |
| 47 | import org.yuzu.yuzu_emu.model.Game | 46 | import org.yuzu.yuzu_emu.model.Game |
| 48 | import org.yuzu.yuzu_emu.utils.ForegroundService | ||
| 49 | import org.yuzu.yuzu_emu.utils.InputHandler | 47 | import org.yuzu.yuzu_emu.utils.InputHandler |
| 50 | import org.yuzu.yuzu_emu.utils.Log | 48 | import org.yuzu.yuzu_emu.utils.Log |
| 51 | import org.yuzu.yuzu_emu.utils.MemoryUtil | 49 | import org.yuzu.yuzu_emu.utils.MemoryUtil |
| @@ -74,11 +72,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 74 | 72 | ||
| 75 | private val emulationViewModel: EmulationViewModel by viewModels() | 73 | private val emulationViewModel: EmulationViewModel by viewModels() |
| 76 | 74 | ||
| 77 | override fun onDestroy() { | ||
| 78 | stopForegroundService(this) | ||
| 79 | super.onDestroy() | ||
| 80 | } | ||
| 81 | |||
| 82 | override fun onCreate(savedInstanceState: Bundle?) { | 75 | override fun onCreate(savedInstanceState: Bundle?) { |
| 83 | Log.gameLaunched = true | 76 | Log.gameLaunched = true |
| 84 | ThemeHelper.setTheme(this) | 77 | ThemeHelper.setTheme(this) |
| @@ -125,10 +118,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 125 | .apply() | 118 | .apply() |
| 126 | } | 119 | } |
| 127 | } | 120 | } |
| 128 | |||
| 129 | // Start a foreground service to prevent the app from getting killed in the background | ||
| 130 | val startIntent = Intent(this, ForegroundService::class.java) | ||
| 131 | startForegroundService(startIntent) | ||
| 132 | } | 121 | } |
| 133 | 122 | ||
| 134 | override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { | 123 | override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { |
| @@ -481,12 +470,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 481 | activity.startActivity(launcher) | 470 | activity.startActivity(launcher) |
| 482 | } | 471 | } |
| 483 | 472 | ||
| 484 | fun stopForegroundService(activity: Activity) { | ||
| 485 | val startIntent = Intent(activity, ForegroundService::class.java) | ||
| 486 | startIntent.action = ForegroundService.ACTION_STOP | ||
| 487 | activity.startForegroundService(startIntent) | ||
| 488 | } | ||
| 489 | |||
| 490 | private fun areCoordinatesOutside(view: View?, x: Float, y: Float): Boolean { | 473 | private fun areCoordinatesOutside(view: View?, x: Float, y: Float): Boolean { |
| 491 | if (view == null) { | 474 | if (view == null) { |
| 492 | return true | 475 | return true |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt index 86bd33672..664478472 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt | |||
| @@ -25,7 +25,8 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting { | |||
| 25 | HAPTIC_FEEDBACK("haptic_feedback"), | 25 | HAPTIC_FEEDBACK("haptic_feedback"), |
| 26 | SHOW_PERFORMANCE_OVERLAY("show_performance_overlay"), | 26 | SHOW_PERFORMANCE_OVERLAY("show_performance_overlay"), |
| 27 | SHOW_INPUT_OVERLAY("show_input_overlay"), | 27 | SHOW_INPUT_OVERLAY("show_input_overlay"), |
| 28 | TOUCHSCREEN("touchscreen"); | 28 | TOUCHSCREEN("touchscreen"), |
| 29 | SHOW_THERMAL_OVERLAY("show_thermal_overlay"); | ||
| 29 | 30 | ||
| 30 | override fun getBoolean(needsGlobal: Boolean): Boolean = | 31 | override fun getBoolean(needsGlobal: Boolean): Boolean = |
| 31 | NativeConfig.getBoolean(key, needsGlobal) | 32 | NativeConfig.getBoolean(key, needsGlobal) |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt index d7ab0b5d9..6f6e7be10 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt | |||
| @@ -8,7 +8,6 @@ import android.os.Bundle | |||
| 8 | import android.view.LayoutInflater | 8 | import android.view.LayoutInflater |
| 9 | import android.view.View | 9 | import android.view.View |
| 10 | import android.view.ViewGroup | 10 | import android.view.ViewGroup |
| 11 | import android.view.ViewGroup.MarginLayoutParams | ||
| 12 | import androidx.core.view.ViewCompat | 11 | import androidx.core.view.ViewCompat |
| 13 | import androidx.core.view.WindowInsetsCompat | 12 | import androidx.core.view.WindowInsetsCompat |
| 14 | import androidx.core.view.updatePadding | 13 | import androidx.core.view.updatePadding |
| @@ -27,6 +26,7 @@ import org.yuzu.yuzu_emu.R | |||
| 27 | import org.yuzu.yuzu_emu.databinding.FragmentSettingsBinding | 26 | import org.yuzu.yuzu_emu.databinding.FragmentSettingsBinding |
| 28 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 27 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 29 | import org.yuzu.yuzu_emu.model.SettingsViewModel | 28 | import org.yuzu.yuzu_emu.model.SettingsViewModel |
| 29 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 30 | 30 | ||
| 31 | class SettingsFragment : Fragment() { | 31 | class SettingsFragment : Fragment() { |
| 32 | private lateinit var presenter: SettingsFragmentPresenter | 32 | private lateinit var presenter: SettingsFragmentPresenter |
| @@ -125,18 +125,10 @@ class SettingsFragment : Fragment() { | |||
| 125 | val leftInsets = barInsets.left + cutoutInsets.left | 125 | val leftInsets = barInsets.left + cutoutInsets.left |
| 126 | val rightInsets = barInsets.right + cutoutInsets.right | 126 | val rightInsets = barInsets.right + cutoutInsets.right |
| 127 | 127 | ||
| 128 | val mlpSettingsList = binding.listSettings.layoutParams as MarginLayoutParams | 128 | binding.listSettings.updateMargins(left = leftInsets, right = rightInsets) |
| 129 | mlpSettingsList.leftMargin = leftInsets | 129 | binding.listSettings.updatePadding(bottom = barInsets.bottom) |
| 130 | mlpSettingsList.rightMargin = rightInsets | 130 | |
| 131 | binding.listSettings.layoutParams = mlpSettingsList | 131 | binding.appbarSettings.updateMargins(left = leftInsets, right = rightInsets) |
| 132 | binding.listSettings.updatePadding( | ||
| 133 | bottom = barInsets.bottom | ||
| 134 | ) | ||
| 135 | |||
| 136 | val mlpAppBar = binding.appbarSettings.layoutParams as MarginLayoutParams | ||
| 137 | mlpAppBar.leftMargin = leftInsets | ||
| 138 | mlpAppBar.rightMargin = rightInsets | ||
| 139 | binding.appbarSettings.layoutParams = mlpAppBar | ||
| 140 | windowInsets | 132 | windowInsets |
| 141 | } | 133 | } |
| 142 | } | 134 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt index 5ab38ffda..ff4f0e5df 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt | |||
| @@ -13,7 +13,6 @@ import android.os.Bundle | |||
| 13 | import android.view.LayoutInflater | 13 | import android.view.LayoutInflater |
| 14 | import android.view.View | 14 | import android.view.View |
| 15 | import android.view.ViewGroup | 15 | import android.view.ViewGroup |
| 16 | import android.view.ViewGroup.MarginLayoutParams | ||
| 17 | import android.widget.Toast | 16 | import android.widget.Toast |
| 18 | import androidx.core.view.ViewCompat | 17 | import androidx.core.view.ViewCompat |
| 19 | import androidx.core.view.WindowInsetsCompat | 18 | import androidx.core.view.WindowInsetsCompat |
| @@ -26,6 +25,7 @@ import org.yuzu.yuzu_emu.BuildConfig | |||
| 26 | import org.yuzu.yuzu_emu.R | 25 | import org.yuzu.yuzu_emu.R |
| 27 | import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding | 26 | import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding |
| 28 | import org.yuzu.yuzu_emu.model.HomeViewModel | 27 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 28 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 29 | 29 | ||
| 30 | class AboutFragment : Fragment() { | 30 | class AboutFragment : Fragment() { |
| 31 | private var _binding: FragmentAboutBinding? = null | 31 | private var _binding: FragmentAboutBinding? = null |
| @@ -114,15 +114,8 @@ class AboutFragment : Fragment() { | |||
| 114 | val leftInsets = barInsets.left + cutoutInsets.left | 114 | val leftInsets = barInsets.left + cutoutInsets.left |
| 115 | val rightInsets = barInsets.right + cutoutInsets.right | 115 | val rightInsets = barInsets.right + cutoutInsets.right |
| 116 | 116 | ||
| 117 | val mlpToolbar = binding.toolbarAbout.layoutParams as MarginLayoutParams | 117 | binding.toolbarAbout.updateMargins(left = leftInsets, right = rightInsets) |
| 118 | mlpToolbar.leftMargin = leftInsets | 118 | binding.scrollAbout.updateMargins(left = leftInsets, right = rightInsets) |
| 119 | mlpToolbar.rightMargin = rightInsets | ||
| 120 | binding.toolbarAbout.layoutParams = mlpToolbar | ||
| 121 | |||
| 122 | val mlpScrollAbout = binding.scrollAbout.layoutParams as MarginLayoutParams | ||
| 123 | mlpScrollAbout.leftMargin = leftInsets | ||
| 124 | mlpScrollAbout.rightMargin = rightInsets | ||
| 125 | binding.scrollAbout.layoutParams = mlpScrollAbout | ||
| 126 | 119 | ||
| 127 | binding.contentAbout.updatePadding(bottom = barInsets.bottom) | 120 | binding.contentAbout.updatePadding(bottom = barInsets.bottom) |
| 128 | 121 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt index adb65812c..f5647fa95 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt | |||
| @@ -31,6 +31,7 @@ import org.yuzu.yuzu_emu.model.AddonViewModel | |||
| 31 | import org.yuzu.yuzu_emu.model.HomeViewModel | 31 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 32 | import org.yuzu.yuzu_emu.utils.AddonUtil | 32 | import org.yuzu.yuzu_emu.utils.AddonUtil |
| 33 | import org.yuzu.yuzu_emu.utils.FileUtil.copyFilesTo | 33 | import org.yuzu.yuzu_emu.utils.FileUtil.copyFilesTo |
| 34 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 34 | import java.io.File | 35 | import java.io.File |
| 35 | 36 | ||
| 36 | class AddonsFragment : Fragment() { | 37 | class AddonsFragment : Fragment() { |
| @@ -202,27 +203,19 @@ class AddonsFragment : Fragment() { | |||
| 202 | val leftInsets = barInsets.left + cutoutInsets.left | 203 | val leftInsets = barInsets.left + cutoutInsets.left |
| 203 | val rightInsets = barInsets.right + cutoutInsets.right | 204 | val rightInsets = barInsets.right + cutoutInsets.right |
| 204 | 205 | ||
| 205 | val mlpToolbar = binding.toolbarAddons.layoutParams as ViewGroup.MarginLayoutParams | 206 | binding.toolbarAddons.updateMargins(left = leftInsets, right = rightInsets) |
| 206 | mlpToolbar.leftMargin = leftInsets | 207 | binding.listAddons.updateMargins(left = leftInsets, right = rightInsets) |
| 207 | mlpToolbar.rightMargin = rightInsets | ||
| 208 | binding.toolbarAddons.layoutParams = mlpToolbar | ||
| 209 | |||
| 210 | val mlpAddonsList = binding.listAddons.layoutParams as ViewGroup.MarginLayoutParams | ||
| 211 | mlpAddonsList.leftMargin = leftInsets | ||
| 212 | mlpAddonsList.rightMargin = rightInsets | ||
| 213 | binding.listAddons.layoutParams = mlpAddonsList | ||
| 214 | binding.listAddons.updatePadding( | 208 | binding.listAddons.updatePadding( |
| 215 | bottom = barInsets.bottom + | 209 | bottom = barInsets.bottom + |
| 216 | resources.getDimensionPixelSize(R.dimen.spacing_bottom_list_fab) | 210 | resources.getDimensionPixelSize(R.dimen.spacing_bottom_list_fab) |
| 217 | ) | 211 | ) |
| 218 | 212 | ||
| 219 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 213 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 220 | val mlpFab = | 214 | binding.buttonInstall.updateMargins( |
| 221 | binding.buttonInstall.layoutParams as ViewGroup.MarginLayoutParams | 215 | left = leftInsets + fabSpacing, |
| 222 | mlpFab.leftMargin = leftInsets + fabSpacing | 216 | right = rightInsets + fabSpacing, |
| 223 | mlpFab.rightMargin = rightInsets + fabSpacing | 217 | bottom = barInsets.bottom + fabSpacing |
| 224 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 218 | ) |
| 225 | binding.buttonInstall.layoutParams = mlpFab | ||
| 226 | 219 | ||
| 227 | windowInsets | 220 | windowInsets |
| 228 | } | 221 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt index 1f66b440d..73ca40484 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt | |||
| @@ -21,6 +21,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentAppletLauncherBinding | |||
| 21 | import org.yuzu.yuzu_emu.model.Applet | 21 | import org.yuzu.yuzu_emu.model.Applet |
| 22 | import org.yuzu.yuzu_emu.model.AppletInfo | 22 | import org.yuzu.yuzu_emu.model.AppletInfo |
| 23 | import org.yuzu.yuzu_emu.model.HomeViewModel | 23 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 24 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 24 | 25 | ||
| 25 | class AppletLauncherFragment : Fragment() { | 26 | class AppletLauncherFragment : Fragment() { |
| 26 | private var _binding: FragmentAppletLauncherBinding? = null | 27 | private var _binding: FragmentAppletLauncherBinding? = null |
| @@ -95,16 +96,8 @@ class AppletLauncherFragment : Fragment() { | |||
| 95 | val leftInsets = barInsets.left + cutoutInsets.left | 96 | val leftInsets = barInsets.left + cutoutInsets.left |
| 96 | val rightInsets = barInsets.right + cutoutInsets.right | 97 | val rightInsets = barInsets.right + cutoutInsets.right |
| 97 | 98 | ||
| 98 | val mlpAppBar = binding.toolbarApplets.layoutParams as ViewGroup.MarginLayoutParams | 99 | binding.toolbarApplets.updateMargins(left = leftInsets, right = rightInsets) |
| 99 | mlpAppBar.leftMargin = leftInsets | 100 | binding.listApplets.updateMargins(left = leftInsets, right = rightInsets) |
| 100 | mlpAppBar.rightMargin = rightInsets | ||
| 101 | binding.toolbarApplets.layoutParams = mlpAppBar | ||
| 102 | |||
| 103 | val mlpListApplets = | ||
| 104 | binding.listApplets.layoutParams as ViewGroup.MarginLayoutParams | ||
| 105 | mlpListApplets.leftMargin = leftInsets | ||
| 106 | mlpListApplets.rightMargin = rightInsets | ||
| 107 | binding.listApplets.layoutParams = mlpListApplets | ||
| 108 | 101 | ||
| 109 | binding.listApplets.updatePadding(bottom = barInsets.bottom) | 102 | binding.listApplets.updatePadding(bottom = barInsets.bottom) |
| 110 | 103 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt index bf017cd7c..41cff46c1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt | |||
| @@ -34,6 +34,7 @@ import org.yuzu.yuzu_emu.model.HomeViewModel | |||
| 34 | import org.yuzu.yuzu_emu.utils.FileUtil | 34 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 35 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 35 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 36 | import org.yuzu.yuzu_emu.utils.NativeConfig | 36 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| 37 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 37 | import java.io.File | 38 | import java.io.File |
| 38 | import java.io.IOException | 39 | import java.io.IOException |
| 39 | 40 | ||
| @@ -141,23 +142,15 @@ class DriverManagerFragment : Fragment() { | |||
| 141 | val leftInsets = barInsets.left + cutoutInsets.left | 142 | val leftInsets = barInsets.left + cutoutInsets.left |
| 142 | val rightInsets = barInsets.right + cutoutInsets.right | 143 | val rightInsets = barInsets.right + cutoutInsets.right |
| 143 | 144 | ||
| 144 | val mlpAppBar = binding.toolbarDrivers.layoutParams as ViewGroup.MarginLayoutParams | 145 | binding.toolbarDrivers.updateMargins(left = leftInsets, right = rightInsets) |
| 145 | mlpAppBar.leftMargin = leftInsets | 146 | binding.listDrivers.updateMargins(left = leftInsets, right = rightInsets) |
| 146 | mlpAppBar.rightMargin = rightInsets | ||
| 147 | binding.toolbarDrivers.layoutParams = mlpAppBar | ||
| 148 | |||
| 149 | val mlplistDrivers = binding.listDrivers.layoutParams as ViewGroup.MarginLayoutParams | ||
| 150 | mlplistDrivers.leftMargin = leftInsets | ||
| 151 | mlplistDrivers.rightMargin = rightInsets | ||
| 152 | binding.listDrivers.layoutParams = mlplistDrivers | ||
| 153 | 147 | ||
| 154 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 148 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 155 | val mlpFab = | 149 | binding.buttonInstall.updateMargins( |
| 156 | binding.buttonInstall.layoutParams as ViewGroup.MarginLayoutParams | 150 | left = leftInsets + fabSpacing, |
| 157 | mlpFab.leftMargin = leftInsets + fabSpacing | 151 | right = rightInsets + fabSpacing, |
| 158 | mlpFab.rightMargin = rightInsets + fabSpacing | 152 | bottom = barInsets.bottom + fabSpacing |
| 159 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 153 | ) |
| 160 | binding.buttonInstall.layoutParams = mlpFab | ||
| 161 | 154 | ||
| 162 | binding.listDrivers.updatePadding( | 155 | binding.listDrivers.updatePadding( |
| 163 | bottom = barInsets.bottom + | 156 | bottom = barInsets.bottom + |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt index dbc16da4a..0534b68ce 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt | |||
| @@ -19,6 +19,7 @@ import com.google.android.material.transition.MaterialSharedAxis | |||
| 19 | import org.yuzu.yuzu_emu.R | 19 | import org.yuzu.yuzu_emu.R |
| 20 | import org.yuzu.yuzu_emu.databinding.FragmentEarlyAccessBinding | 20 | import org.yuzu.yuzu_emu.databinding.FragmentEarlyAccessBinding |
| 21 | import org.yuzu.yuzu_emu.model.HomeViewModel | 21 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 22 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 22 | 23 | ||
| 23 | class EarlyAccessFragment : Fragment() { | 24 | class EarlyAccessFragment : Fragment() { |
| 24 | private var _binding: FragmentEarlyAccessBinding? = null | 25 | private var _binding: FragmentEarlyAccessBinding? = null |
| @@ -73,10 +74,7 @@ class EarlyAccessFragment : Fragment() { | |||
| 73 | val leftInsets = barInsets.left + cutoutInsets.left | 74 | val leftInsets = barInsets.left + cutoutInsets.left |
| 74 | val rightInsets = barInsets.right + cutoutInsets.right | 75 | val rightInsets = barInsets.right + cutoutInsets.right |
| 75 | 76 | ||
| 76 | val mlpAppBar = binding.appbarEa.layoutParams as ViewGroup.MarginLayoutParams | 77 | binding.appbarEa.updateMargins(left = leftInsets, right = rightInsets) |
| 77 | mlpAppBar.leftMargin = leftInsets | ||
| 78 | mlpAppBar.rightMargin = rightInsets | ||
| 79 | binding.appbarEa.layoutParams = mlpAppBar | ||
| 80 | 78 | ||
| 81 | binding.scrollEa.updatePadding( | 79 | binding.scrollEa.updatePadding( |
| 82 | left = leftInsets, | 80 | left = leftInsets, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 937b8faf1..44af896da 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -13,6 +13,7 @@ import android.net.Uri | |||
| 13 | import android.os.Bundle | 13 | import android.os.Bundle |
| 14 | import android.os.Handler | 14 | import android.os.Handler |
| 15 | import android.os.Looper | 15 | import android.os.Looper |
| 16 | import android.os.PowerManager | ||
| 16 | import android.os.SystemClock | 17 | import android.os.SystemClock |
| 17 | import android.view.* | 18 | import android.view.* |
| 18 | import android.widget.TextView | 19 | import android.widget.TextView |
| @@ -23,6 +24,7 @@ import androidx.core.content.res.ResourcesCompat | |||
| 23 | import androidx.core.graphics.Insets | 24 | import androidx.core.graphics.Insets |
| 24 | import androidx.core.view.ViewCompat | 25 | import androidx.core.view.ViewCompat |
| 25 | import androidx.core.view.WindowInsetsCompat | 26 | import androidx.core.view.WindowInsetsCompat |
| 27 | import androidx.core.view.updatePadding | ||
| 26 | import androidx.drawerlayout.widget.DrawerLayout | 28 | import androidx.drawerlayout.widget.DrawerLayout |
| 27 | import androidx.drawerlayout.widget.DrawerLayout.DrawerListener | 29 | import androidx.drawerlayout.widget.DrawerLayout.DrawerListener |
| 28 | import androidx.fragment.app.Fragment | 30 | import androidx.fragment.app.Fragment |
| @@ -38,7 +40,6 @@ import androidx.window.layout.WindowLayoutInfo | |||
| 38 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | 40 | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| 39 | import com.google.android.material.slider.Slider | 41 | import com.google.android.material.slider.Slider |
| 40 | import kotlinx.coroutines.Dispatchers | 42 | import kotlinx.coroutines.Dispatchers |
| 41 | import kotlinx.coroutines.flow.collect | ||
| 42 | import kotlinx.coroutines.flow.collectLatest | 43 | import kotlinx.coroutines.flow.collectLatest |
| 43 | import kotlinx.coroutines.launch | 44 | import kotlinx.coroutines.launch |
| 44 | import org.yuzu.yuzu_emu.HomeNavigationDirections | 45 | import org.yuzu.yuzu_emu.HomeNavigationDirections |
| @@ -64,6 +65,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 64 | private lateinit var emulationState: EmulationState | 65 | private lateinit var emulationState: EmulationState |
| 65 | private var emulationActivity: EmulationActivity? = null | 66 | private var emulationActivity: EmulationActivity? = null |
| 66 | private var perfStatsUpdater: (() -> Unit)? = null | 67 | private var perfStatsUpdater: (() -> Unit)? = null |
| 68 | private var thermalStatsUpdater: (() -> Unit)? = null | ||
| 67 | 69 | ||
| 68 | private var _binding: FragmentEmulationBinding? = null | 70 | private var _binding: FragmentEmulationBinding? = null |
| 69 | private val binding get() = _binding!! | 71 | private val binding get() = _binding!! |
| @@ -77,6 +79,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 77 | 79 | ||
| 78 | private var isInFoldableLayout = false | 80 | private var isInFoldableLayout = false |
| 79 | 81 | ||
| 82 | private lateinit var powerManager: PowerManager | ||
| 83 | |||
| 80 | override fun onAttach(context: Context) { | 84 | override fun onAttach(context: Context) { |
| 81 | super.onAttach(context) | 85 | super.onAttach(context) |
| 82 | if (context is EmulationActivity) { | 86 | if (context is EmulationActivity) { |
| @@ -102,6 +106,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 102 | super.onCreate(savedInstanceState) | 106 | super.onCreate(savedInstanceState) |
| 103 | updateOrientation() | 107 | updateOrientation() |
| 104 | 108 | ||
| 109 | powerManager = requireContext().getSystemService(Context.POWER_SERVICE) as PowerManager | ||
| 110 | |||
| 105 | val intentUri: Uri? = requireActivity().intent.data | 111 | val intentUri: Uri? = requireActivity().intent.data |
| 106 | var intentGame: Game? = null | 112 | var intentGame: Game? = null |
| 107 | if (intentUri != null) { | 113 | if (intentUri != null) { |
| @@ -394,8 +400,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 394 | 400 | ||
| 395 | emulationState.updateSurface() | 401 | emulationState.updateSurface() |
| 396 | 402 | ||
| 397 | // Setup overlay | 403 | // Setup overlays |
| 398 | updateShowFpsOverlay() | 404 | updateShowFpsOverlay() |
| 405 | updateThermalOverlay() | ||
| 399 | } | 406 | } |
| 400 | } | 407 | } |
| 401 | } | 408 | } |
| @@ -553,6 +560,38 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 553 | } | 560 | } |
| 554 | } | 561 | } |
| 555 | 562 | ||
| 563 | private fun updateThermalOverlay() { | ||
| 564 | if (BooleanSetting.SHOW_THERMAL_OVERLAY.getBoolean()) { | ||
| 565 | thermalStatsUpdater = { | ||
| 566 | if (emulationViewModel.emulationStarted.value && | ||
| 567 | !emulationViewModel.isEmulationStopping.value | ||
| 568 | ) { | ||
| 569 | val thermalStatus = when (powerManager.currentThermalStatus) { | ||
| 570 | PowerManager.THERMAL_STATUS_LIGHT -> "😥" | ||
| 571 | PowerManager.THERMAL_STATUS_MODERATE -> "🥵" | ||
| 572 | PowerManager.THERMAL_STATUS_SEVERE -> "🔥" | ||
| 573 | PowerManager.THERMAL_STATUS_CRITICAL, | ||
| 574 | PowerManager.THERMAL_STATUS_EMERGENCY, | ||
| 575 | PowerManager.THERMAL_STATUS_SHUTDOWN -> "☢️" | ||
| 576 | |||
| 577 | else -> "🙂" | ||
| 578 | } | ||
| 579 | if (_binding != null) { | ||
| 580 | binding.showThermalsText.text = thermalStatus | ||
| 581 | } | ||
| 582 | thermalStatsUpdateHandler.postDelayed(thermalStatsUpdater!!, 1000) | ||
| 583 | } | ||
| 584 | } | ||
| 585 | thermalStatsUpdateHandler.post(thermalStatsUpdater!!) | ||
| 586 | binding.showThermalsText.visibility = View.VISIBLE | ||
| 587 | } else { | ||
| 588 | if (thermalStatsUpdater != null) { | ||
| 589 | thermalStatsUpdateHandler.removeCallbacks(thermalStatsUpdater!!) | ||
| 590 | } | ||
| 591 | binding.showThermalsText.visibility = View.GONE | ||
| 592 | } | ||
| 593 | } | ||
| 594 | |||
| 556 | @SuppressLint("SourceLockedOrientationActivity") | 595 | @SuppressLint("SourceLockedOrientationActivity") |
| 557 | private fun updateOrientation() { | 596 | private fun updateOrientation() { |
| 558 | emulationActivity?.let { | 597 | emulationActivity?.let { |
| @@ -641,6 +680,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 641 | popup.menu.apply { | 680 | popup.menu.apply { |
| 642 | findItem(R.id.menu_toggle_fps).isChecked = | 681 | findItem(R.id.menu_toggle_fps).isChecked = |
| 643 | BooleanSetting.SHOW_PERFORMANCE_OVERLAY.getBoolean() | 682 | BooleanSetting.SHOW_PERFORMANCE_OVERLAY.getBoolean() |
| 683 | findItem(R.id.thermal_indicator).isChecked = | ||
| 684 | BooleanSetting.SHOW_THERMAL_OVERLAY.getBoolean() | ||
| 644 | findItem(R.id.menu_rel_stick_center).isChecked = | 685 | findItem(R.id.menu_rel_stick_center).isChecked = |
| 645 | BooleanSetting.JOYSTICK_REL_CENTER.getBoolean() | 686 | BooleanSetting.JOYSTICK_REL_CENTER.getBoolean() |
| 646 | findItem(R.id.menu_dpad_slide).isChecked = BooleanSetting.DPAD_SLIDE.getBoolean() | 687 | findItem(R.id.menu_dpad_slide).isChecked = BooleanSetting.DPAD_SLIDE.getBoolean() |
| @@ -660,6 +701,13 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 660 | true | 701 | true |
| 661 | } | 702 | } |
| 662 | 703 | ||
| 704 | R.id.thermal_indicator -> { | ||
| 705 | it.isChecked = !it.isChecked | ||
| 706 | BooleanSetting.SHOW_THERMAL_OVERLAY.setBoolean(it.isChecked) | ||
| 707 | updateThermalOverlay() | ||
| 708 | true | ||
| 709 | } | ||
| 710 | |||
| 663 | R.id.menu_edit_overlay -> { | 711 | R.id.menu_edit_overlay -> { |
| 664 | binding.drawerLayout.close() | 712 | binding.drawerLayout.close() |
| 665 | binding.surfaceInputOverlay.requestFocus() | 713 | binding.surfaceInputOverlay.requestFocus() |
| @@ -850,7 +898,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 850 | right = cutInsets.right | 898 | right = cutInsets.right |
| 851 | } | 899 | } |
| 852 | 900 | ||
| 853 | v.setPadding(left, cutInsets.top, right, 0) | 901 | v.updatePadding(left = left, top = cutInsets.top, right = right) |
| 854 | windowInsets | 902 | windowInsets |
| 855 | } | 903 | } |
| 856 | } | 904 | } |
| @@ -1003,5 +1051,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 1003 | 1051 | ||
| 1004 | companion object { | 1052 | companion object { |
| 1005 | private val perfStatsUpdateHandler = Handler(Looper.myLooper()!!) | 1053 | private val perfStatsUpdateHandler = Handler(Looper.myLooper()!!) |
| 1054 | private val thermalStatsUpdateHandler = Handler(Looper.myLooper()!!) | ||
| 1006 | } | 1055 | } |
| 1007 | } | 1056 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt index 341a37fdb..5c558b1a5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt | |||
| @@ -26,6 +26,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentFoldersBinding | |||
| 26 | import org.yuzu.yuzu_emu.model.GamesViewModel | 26 | import org.yuzu.yuzu_emu.model.GamesViewModel |
| 27 | import org.yuzu.yuzu_emu.model.HomeViewModel | 27 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 28 | import org.yuzu.yuzu_emu.ui.main.MainActivity | 28 | import org.yuzu.yuzu_emu.ui.main.MainActivity |
| 29 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 29 | 30 | ||
| 30 | class GameFoldersFragment : Fragment() { | 31 | class GameFoldersFragment : Fragment() { |
| 31 | private var _binding: FragmentFoldersBinding? = null | 32 | private var _binding: FragmentFoldersBinding? = null |
| @@ -100,23 +101,16 @@ class GameFoldersFragment : Fragment() { | |||
| 100 | val leftInsets = barInsets.left + cutoutInsets.left | 101 | val leftInsets = barInsets.left + cutoutInsets.left |
| 101 | val rightInsets = barInsets.right + cutoutInsets.right | 102 | val rightInsets = barInsets.right + cutoutInsets.right |
| 102 | 103 | ||
| 103 | val mlpToolbar = binding.toolbarFolders.layoutParams as ViewGroup.MarginLayoutParams | 104 | binding.toolbarFolders.updateMargins(left = leftInsets, right = rightInsets) |
| 104 | mlpToolbar.leftMargin = leftInsets | ||
| 105 | mlpToolbar.rightMargin = rightInsets | ||
| 106 | binding.toolbarFolders.layoutParams = mlpToolbar | ||
| 107 | 105 | ||
| 108 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 106 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 109 | val mlpFab = | 107 | binding.buttonAdd.updateMargins( |
| 110 | binding.buttonAdd.layoutParams as ViewGroup.MarginLayoutParams | 108 | left = leftInsets + fabSpacing, |
| 111 | mlpFab.leftMargin = leftInsets + fabSpacing | 109 | right = rightInsets + fabSpacing, |
| 112 | mlpFab.rightMargin = rightInsets + fabSpacing | 110 | bottom = barInsets.bottom + fabSpacing |
| 113 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 111 | ) |
| 114 | binding.buttonAdd.layoutParams = mlpFab | 112 | |
| 115 | 113 | binding.listFolders.updateMargins(left = leftInsets, right = rightInsets) | |
| 116 | val mlpListFolders = binding.listFolders.layoutParams as ViewGroup.MarginLayoutParams | ||
| 117 | mlpListFolders.leftMargin = leftInsets | ||
| 118 | mlpListFolders.rightMargin = rightInsets | ||
| 119 | binding.listFolders.layoutParams = mlpListFolders | ||
| 120 | 114 | ||
| 121 | binding.listFolders.updatePadding( | 115 | binding.listFolders.updatePadding( |
| 122 | bottom = barInsets.bottom + | 116 | bottom = barInsets.bottom + |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt index 5aa3f453f..dbd56e84f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt | |||
| @@ -27,6 +27,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentGameInfoBinding | |||
| 27 | import org.yuzu.yuzu_emu.model.GameVerificationResult | 27 | import org.yuzu.yuzu_emu.model.GameVerificationResult |
| 28 | import org.yuzu.yuzu_emu.model.HomeViewModel | 28 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 29 | import org.yuzu.yuzu_emu.utils.GameMetadata | 29 | import org.yuzu.yuzu_emu.utils.GameMetadata |
| 30 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 30 | 31 | ||
| 31 | class GameInfoFragment : Fragment() { | 32 | class GameInfoFragment : Fragment() { |
| 32 | private var _binding: FragmentGameInfoBinding? = null | 33 | private var _binding: FragmentGameInfoBinding? = null |
| @@ -122,11 +123,13 @@ class GameInfoFragment : Fragment() { | |||
| 122 | titleId = R.string.verify_success, | 123 | titleId = R.string.verify_success, |
| 123 | descriptionId = R.string.operation_completed_successfully | 124 | descriptionId = R.string.operation_completed_successfully |
| 124 | ) | 125 | ) |
| 126 | |||
| 125 | GameVerificationResult.Failed -> | 127 | GameVerificationResult.Failed -> |
| 126 | MessageDialogFragment.newInstance( | 128 | MessageDialogFragment.newInstance( |
| 127 | titleId = R.string.verify_failure, | 129 | titleId = R.string.verify_failure, |
| 128 | descriptionId = R.string.verify_failure_description | 130 | descriptionId = R.string.verify_failure_description |
| 129 | ) | 131 | ) |
| 132 | |||
| 130 | GameVerificationResult.NotImplemented -> | 133 | GameVerificationResult.NotImplemented -> |
| 131 | MessageDialogFragment.newInstance( | 134 | MessageDialogFragment.newInstance( |
| 132 | titleId = R.string.verify_no_result, | 135 | titleId = R.string.verify_no_result, |
| @@ -165,15 +168,8 @@ class GameInfoFragment : Fragment() { | |||
| 165 | val leftInsets = barInsets.left + cutoutInsets.left | 168 | val leftInsets = barInsets.left + cutoutInsets.left |
| 166 | val rightInsets = barInsets.right + cutoutInsets.right | 169 | val rightInsets = barInsets.right + cutoutInsets.right |
| 167 | 170 | ||
| 168 | val mlpToolbar = binding.toolbarInfo.layoutParams as ViewGroup.MarginLayoutParams | 171 | binding.toolbarInfo.updateMargins(left = leftInsets, right = rightInsets) |
| 169 | mlpToolbar.leftMargin = leftInsets | 172 | binding.scrollInfo.updateMargins(left = leftInsets, right = rightInsets) |
| 170 | mlpToolbar.rightMargin = rightInsets | ||
| 171 | binding.toolbarInfo.layoutParams = mlpToolbar | ||
| 172 | |||
| 173 | val mlpScrollAbout = binding.scrollInfo.layoutParams as ViewGroup.MarginLayoutParams | ||
| 174 | mlpScrollAbout.leftMargin = leftInsets | ||
| 175 | mlpScrollAbout.rightMargin = rightInsets | ||
| 176 | binding.scrollInfo.layoutParams = mlpScrollAbout | ||
| 177 | 173 | ||
| 178 | binding.contentInfo.updatePadding(bottom = barInsets.bottom) | 174 | binding.contentInfo.updatePadding(bottom = barInsets.bottom) |
| 179 | 175 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt index 582df0133..d14b2c634 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt | |||
| @@ -46,6 +46,7 @@ import org.yuzu.yuzu_emu.utils.FileUtil | |||
| 46 | import org.yuzu.yuzu_emu.utils.GameIconUtils | 46 | import org.yuzu.yuzu_emu.utils.GameIconUtils |
| 47 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 47 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 48 | import org.yuzu.yuzu_emu.utils.MemoryUtil | 48 | import org.yuzu.yuzu_emu.utils.MemoryUtil |
| 49 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 49 | import java.io.BufferedOutputStream | 50 | import java.io.BufferedOutputStream |
| 50 | import java.io.File | 51 | import java.io.File |
| 51 | 52 | ||
| @@ -320,46 +321,25 @@ class GamePropertiesFragment : Fragment() { | |||
| 320 | 321 | ||
| 321 | val smallLayout = resources.getBoolean(R.bool.small_layout) | 322 | val smallLayout = resources.getBoolean(R.bool.small_layout) |
| 322 | if (smallLayout) { | 323 | if (smallLayout) { |
| 323 | val mlpListAll = | 324 | binding.listAll.updateMargins(left = leftInsets, right = rightInsets) |
| 324 | binding.listAll.layoutParams as ViewGroup.MarginLayoutParams | ||
| 325 | mlpListAll.leftMargin = leftInsets | ||
| 326 | mlpListAll.rightMargin = rightInsets | ||
| 327 | binding.listAll.layoutParams = mlpListAll | ||
| 328 | } else { | 325 | } else { |
| 329 | if (ViewCompat.getLayoutDirection(binding.root) == | 326 | if (ViewCompat.getLayoutDirection(binding.root) == |
| 330 | ViewCompat.LAYOUT_DIRECTION_LTR | 327 | ViewCompat.LAYOUT_DIRECTION_LTR |
| 331 | ) { | 328 | ) { |
| 332 | val mlpListAll = | 329 | binding.listAll.updateMargins(right = rightInsets) |
| 333 | binding.listAll.layoutParams as ViewGroup.MarginLayoutParams | 330 | binding.iconLayout!!.updateMargins(top = barInsets.top, left = leftInsets) |
| 334 | mlpListAll.rightMargin = rightInsets | ||
| 335 | binding.listAll.layoutParams = mlpListAll | ||
| 336 | |||
| 337 | val mlpIconLayout = | ||
| 338 | binding.iconLayout!!.layoutParams as ViewGroup.MarginLayoutParams | ||
| 339 | mlpIconLayout.topMargin = barInsets.top | ||
| 340 | mlpIconLayout.leftMargin = leftInsets | ||
| 341 | binding.iconLayout!!.layoutParams = mlpIconLayout | ||
| 342 | } else { | 331 | } else { |
| 343 | val mlpListAll = | 332 | binding.listAll.updateMargins(left = leftInsets) |
| 344 | binding.listAll.layoutParams as ViewGroup.MarginLayoutParams | 333 | binding.iconLayout!!.updateMargins(top = barInsets.top, right = rightInsets) |
| 345 | mlpListAll.leftMargin = leftInsets | ||
| 346 | binding.listAll.layoutParams = mlpListAll | ||
| 347 | |||
| 348 | val mlpIconLayout = | ||
| 349 | binding.iconLayout!!.layoutParams as ViewGroup.MarginLayoutParams | ||
| 350 | mlpIconLayout.topMargin = barInsets.top | ||
| 351 | mlpIconLayout.rightMargin = rightInsets | ||
| 352 | binding.iconLayout!!.layoutParams = mlpIconLayout | ||
| 353 | } | 334 | } |
| 354 | } | 335 | } |
| 355 | 336 | ||
| 356 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 337 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 357 | val mlpFab = | 338 | binding.buttonStart.updateMargins( |
| 358 | binding.buttonStart.layoutParams as ViewGroup.MarginLayoutParams | 339 | left = leftInsets + fabSpacing, |
| 359 | mlpFab.leftMargin = leftInsets + fabSpacing | 340 | right = rightInsets + fabSpacing, |
| 360 | mlpFab.rightMargin = rightInsets + fabSpacing | 341 | bottom = barInsets.bottom + fabSpacing |
| 361 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 342 | ) |
| 362 | binding.buttonStart.layoutParams = mlpFab | ||
| 363 | 343 | ||
| 364 | binding.layoutAll.updatePadding( | 344 | binding.layoutAll.updatePadding( |
| 365 | top = barInsets.top, | 345 | top = barInsets.top, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index 1f3578b22..87e130d3e 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt | |||
| @@ -12,7 +12,6 @@ import android.provider.DocumentsContract | |||
| 12 | import android.view.LayoutInflater | 12 | import android.view.LayoutInflater |
| 13 | import android.view.View | 13 | import android.view.View |
| 14 | import android.view.ViewGroup | 14 | import android.view.ViewGroup |
| 15 | import android.view.ViewGroup.MarginLayoutParams | ||
| 16 | import android.widget.Toast | 15 | import android.widget.Toast |
| 17 | import androidx.appcompat.app.AppCompatActivity | 16 | import androidx.appcompat.app.AppCompatActivity |
| 18 | import androidx.core.app.ActivityCompat | 17 | import androidx.core.app.ActivityCompat |
| @@ -44,6 +43,7 @@ import org.yuzu.yuzu_emu.ui.main.MainActivity | |||
| 44 | import org.yuzu.yuzu_emu.utils.FileUtil | 43 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 45 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 44 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 46 | import org.yuzu.yuzu_emu.utils.Log | 45 | import org.yuzu.yuzu_emu.utils.Log |
| 46 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 47 | 47 | ||
| 48 | class HomeSettingsFragment : Fragment() { | 48 | class HomeSettingsFragment : Fragment() { |
| 49 | private var _binding: FragmentHomeSettingsBinding? = null | 49 | private var _binding: FragmentHomeSettingsBinding? = null |
| @@ -408,10 +408,7 @@ class HomeSettingsFragment : Fragment() { | |||
| 408 | bottom = barInsets.bottom | 408 | bottom = barInsets.bottom |
| 409 | ) | 409 | ) |
| 410 | 410 | ||
| 411 | val mlpScrollSettings = binding.scrollViewSettings.layoutParams as MarginLayoutParams | 411 | binding.scrollViewSettings.updateMargins(left = leftInsets, right = rightInsets) |
| 412 | mlpScrollSettings.leftMargin = leftInsets | ||
| 413 | mlpScrollSettings.rightMargin = rightInsets | ||
| 414 | binding.scrollViewSettings.layoutParams = mlpScrollSettings | ||
| 415 | 412 | ||
| 416 | binding.linearLayoutSettings.updatePadding(bottom = spacingNavigation) | 413 | binding.linearLayoutSettings.updatePadding(bottom = spacingNavigation) |
| 417 | 414 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt index 7df8e6bf4..63112dc6f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt | |||
| @@ -34,6 +34,7 @@ import org.yuzu.yuzu_emu.model.TaskState | |||
| 34 | import org.yuzu.yuzu_emu.ui.main.MainActivity | 34 | import org.yuzu.yuzu_emu.ui.main.MainActivity |
| 35 | import org.yuzu.yuzu_emu.utils.DirectoryInitialization | 35 | import org.yuzu.yuzu_emu.utils.DirectoryInitialization |
| 36 | import org.yuzu.yuzu_emu.utils.FileUtil | 36 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 37 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 37 | import java.io.BufferedOutputStream | 38 | import java.io.BufferedOutputStream |
| 38 | import java.io.File | 39 | import java.io.File |
| 39 | import java.math.BigInteger | 40 | import java.math.BigInteger |
| @@ -172,16 +173,8 @@ class InstallableFragment : Fragment() { | |||
| 172 | val leftInsets = barInsets.left + cutoutInsets.left | 173 | val leftInsets = barInsets.left + cutoutInsets.left |
| 173 | val rightInsets = barInsets.right + cutoutInsets.right | 174 | val rightInsets = barInsets.right + cutoutInsets.right |
| 174 | 175 | ||
| 175 | val mlpAppBar = binding.toolbarInstallables.layoutParams as ViewGroup.MarginLayoutParams | 176 | binding.toolbarInstallables.updateMargins(left = leftInsets, right = rightInsets) |
| 176 | mlpAppBar.leftMargin = leftInsets | 177 | binding.listInstallables.updateMargins(left = leftInsets, right = rightInsets) |
| 177 | mlpAppBar.rightMargin = rightInsets | ||
| 178 | binding.toolbarInstallables.layoutParams = mlpAppBar | ||
| 179 | |||
| 180 | val mlpScrollAbout = | ||
| 181 | binding.listInstallables.layoutParams as ViewGroup.MarginLayoutParams | ||
| 182 | mlpScrollAbout.leftMargin = leftInsets | ||
| 183 | mlpScrollAbout.rightMargin = rightInsets | ||
| 184 | binding.listInstallables.layoutParams = mlpScrollAbout | ||
| 185 | 178 | ||
| 186 | binding.listInstallables.updatePadding(bottom = barInsets.bottom) | 179 | binding.listInstallables.updatePadding(bottom = barInsets.bottom) |
| 187 | 180 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt index b6e9129f7..f17f621f8 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt | |||
| @@ -7,7 +7,6 @@ import android.os.Bundle | |||
| 7 | import android.view.LayoutInflater | 7 | import android.view.LayoutInflater |
| 8 | import android.view.View | 8 | import android.view.View |
| 9 | import android.view.ViewGroup | 9 | import android.view.ViewGroup |
| 10 | import android.view.ViewGroup.MarginLayoutParams | ||
| 11 | import androidx.appcompat.app.AppCompatActivity | 10 | import androidx.appcompat.app.AppCompatActivity |
| 12 | import androidx.core.view.ViewCompat | 11 | import androidx.core.view.ViewCompat |
| 13 | import androidx.core.view.WindowInsetsCompat | 12 | import androidx.core.view.WindowInsetsCompat |
| @@ -22,6 +21,7 @@ import org.yuzu.yuzu_emu.adapters.LicenseAdapter | |||
| 22 | import org.yuzu.yuzu_emu.databinding.FragmentLicensesBinding | 21 | import org.yuzu.yuzu_emu.databinding.FragmentLicensesBinding |
| 23 | import org.yuzu.yuzu_emu.model.HomeViewModel | 22 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 24 | import org.yuzu.yuzu_emu.model.License | 23 | import org.yuzu.yuzu_emu.model.License |
| 24 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 25 | 25 | ||
| 26 | class LicensesFragment : Fragment() { | 26 | class LicensesFragment : Fragment() { |
| 27 | private var _binding: FragmentLicensesBinding? = null | 27 | private var _binding: FragmentLicensesBinding? = null |
| @@ -122,15 +122,8 @@ class LicensesFragment : Fragment() { | |||
| 122 | val leftInsets = barInsets.left + cutoutInsets.left | 122 | val leftInsets = barInsets.left + cutoutInsets.left |
| 123 | val rightInsets = barInsets.right + cutoutInsets.right | 123 | val rightInsets = barInsets.right + cutoutInsets.right |
| 124 | 124 | ||
| 125 | val mlpAppBar = binding.appbarLicenses.layoutParams as MarginLayoutParams | 125 | binding.appbarLicenses.updateMargins(left = leftInsets, right = rightInsets) |
| 126 | mlpAppBar.leftMargin = leftInsets | 126 | binding.listLicenses.updateMargins(left = leftInsets, right = rightInsets) |
| 127 | mlpAppBar.rightMargin = rightInsets | ||
| 128 | binding.appbarLicenses.layoutParams = mlpAppBar | ||
| 129 | |||
| 130 | val mlpScrollAbout = binding.listLicenses.layoutParams as MarginLayoutParams | ||
| 131 | mlpScrollAbout.leftMargin = leftInsets | ||
| 132 | mlpScrollAbout.rightMargin = rightInsets | ||
| 133 | binding.listLicenses.layoutParams = mlpScrollAbout | ||
| 134 | 127 | ||
| 135 | binding.listLicenses.updatePadding(bottom = barInsets.bottom) | 128 | binding.listLicenses.updatePadding(bottom = barInsets.bottom) |
| 136 | 129 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt index f95d545bf..a135b80b4 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt | |||
| @@ -29,6 +29,7 @@ import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | |||
| 29 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | 29 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter |
| 30 | import org.yuzu.yuzu_emu.model.SettingsViewModel | 30 | import org.yuzu.yuzu_emu.model.SettingsViewModel |
| 31 | import org.yuzu.yuzu_emu.utils.NativeConfig | 31 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| 32 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 32 | 33 | ||
| 33 | class SettingsSearchFragment : Fragment() { | 34 | class SettingsSearchFragment : Fragment() { |
| 34 | private var _binding: FragmentSettingsSearchBinding? = null | 35 | private var _binding: FragmentSettingsSearchBinding? = null |
| @@ -174,15 +175,14 @@ class SettingsSearchFragment : Fragment() { | |||
| 174 | bottom = barInsets.bottom | 175 | bottom = barInsets.bottom |
| 175 | ) | 176 | ) |
| 176 | 177 | ||
| 177 | val mlpSettingsList = binding.settingsList.layoutParams as ViewGroup.MarginLayoutParams | 178 | binding.settingsList.updateMargins( |
| 178 | mlpSettingsList.leftMargin = leftInsets + sideMargin | 179 | left = leftInsets + sideMargin, |
| 179 | mlpSettingsList.rightMargin = rightInsets + sideMargin | 180 | right = rightInsets + sideMargin |
| 180 | binding.settingsList.layoutParams = mlpSettingsList | 181 | ) |
| 181 | 182 | binding.divider.updateMargins( | |
| 182 | val mlpDivider = binding.divider.layoutParams as ViewGroup.MarginLayoutParams | 183 | left = leftInsets + sideMargin, |
| 183 | mlpDivider.leftMargin = leftInsets + sideMargin | 184 | right = rightInsets + sideMargin |
| 184 | mlpDivider.rightMargin = rightInsets + sideMargin | 185 | ) |
| 185 | binding.divider.layoutParams = mlpDivider | ||
| 186 | 186 | ||
| 187 | windowInsets | 187 | windowInsets |
| 188 | } | 188 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt index 54380323e..23ca49b53 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt | |||
| @@ -8,7 +8,6 @@ import android.os.Bundle | |||
| 8 | import android.view.LayoutInflater | 8 | import android.view.LayoutInflater |
| 9 | import android.view.View | 9 | import android.view.View |
| 10 | import android.view.ViewGroup | 10 | import android.view.ViewGroup |
| 11 | import android.view.ViewGroup.MarginLayoutParams | ||
| 12 | import androidx.appcompat.app.AppCompatActivity | 11 | import androidx.appcompat.app.AppCompatActivity |
| 13 | import androidx.core.view.ViewCompat | 12 | import androidx.core.view.ViewCompat |
| 14 | import androidx.core.view.WindowInsetsCompat | 13 | import androidx.core.view.WindowInsetsCompat |
| @@ -27,6 +26,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentGamesBinding | |||
| 27 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager | 26 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager |
| 28 | import org.yuzu.yuzu_emu.model.GamesViewModel | 27 | import org.yuzu.yuzu_emu.model.GamesViewModel |
| 29 | import org.yuzu.yuzu_emu.model.HomeViewModel | 28 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 29 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 30 | 30 | ||
| 31 | class GamesFragment : Fragment() { | 31 | class GamesFragment : Fragment() { |
| 32 | private var _binding: FragmentGamesBinding? = null | 32 | private var _binding: FragmentGamesBinding? = null |
| @@ -169,15 +169,16 @@ class GamesFragment : Fragment() { | |||
| 169 | 169 | ||
| 170 | val leftInsets = barInsets.left + cutoutInsets.left | 170 | val leftInsets = barInsets.left + cutoutInsets.left |
| 171 | val rightInsets = barInsets.right + cutoutInsets.right | 171 | val rightInsets = barInsets.right + cutoutInsets.right |
| 172 | val mlpSwipe = binding.swipeRefresh.layoutParams as MarginLayoutParams | 172 | val left: Int |
| 173 | val right: Int | ||
| 173 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { | 174 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { |
| 174 | mlpSwipe.leftMargin = leftInsets + spacingNavigationRail | 175 | left = leftInsets + spacingNavigationRail |
| 175 | mlpSwipe.rightMargin = rightInsets | 176 | right = rightInsets |
| 176 | } else { | 177 | } else { |
| 177 | mlpSwipe.leftMargin = leftInsets | 178 | left = leftInsets |
| 178 | mlpSwipe.rightMargin = rightInsets + spacingNavigationRail | 179 | right = rightInsets + spacingNavigationRail |
| 179 | } | 180 | } |
| 180 | binding.swipeRefresh.layoutParams = mlpSwipe | 181 | binding.swipeRefresh.updateMargins(left = left, right = right) |
| 181 | 182 | ||
| 182 | binding.noticeText.updatePadding(bottom = spacingNavigation) | 183 | binding.noticeText.updatePadding(bottom = spacingNavigation) |
| 183 | 184 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index b3967d294..4df4ac4c6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt | |||
| @@ -34,7 +34,6 @@ import kotlinx.coroutines.launch | |||
| 34 | import org.yuzu.yuzu_emu.HomeNavigationDirections | 34 | import org.yuzu.yuzu_emu.HomeNavigationDirections |
| 35 | import org.yuzu.yuzu_emu.NativeLibrary | 35 | import org.yuzu.yuzu_emu.NativeLibrary |
| 36 | import org.yuzu.yuzu_emu.R | 36 | import org.yuzu.yuzu_emu.R |
| 37 | import org.yuzu.yuzu_emu.activities.EmulationActivity | ||
| 38 | import org.yuzu.yuzu_emu.databinding.ActivityMainBinding | 37 | import org.yuzu.yuzu_emu.databinding.ActivityMainBinding |
| 39 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 38 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 40 | import org.yuzu.yuzu_emu.fragments.AddGameFolderDialogFragment | 39 | import org.yuzu.yuzu_emu.fragments.AddGameFolderDialogFragment |
| @@ -177,9 +176,6 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 177 | } | 176 | } |
| 178 | } | 177 | } |
| 179 | 178 | ||
| 180 | // Dismiss previous notifications (should not happen unless a crash occurred) | ||
| 181 | EmulationActivity.stopForegroundService(this) | ||
| 182 | |||
| 183 | setInsets() | 179 | setInsets() |
| 184 | } | 180 | } |
| 185 | 181 | ||
| @@ -298,11 +294,6 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 298 | super.onResume() | 294 | super.onResume() |
| 299 | } | 295 | } |
| 300 | 296 | ||
| 301 | override fun onDestroy() { | ||
| 302 | EmulationActivity.stopForegroundService(this) | ||
| 303 | super.onDestroy() | ||
| 304 | } | ||
| 305 | |||
| 306 | private fun setInsets() = | 297 | private fun setInsets() = |
| 307 | ViewCompat.setOnApplyWindowInsetsListener( | 298 | ViewCompat.setOnApplyWindowInsetsListener( |
| 308 | binding.root | 299 | binding.root |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ForegroundService.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ForegroundService.kt deleted file mode 100644 index 086d17606..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ForegroundService.kt +++ /dev/null | |||
| @@ -1,70 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | package org.yuzu.yuzu_emu.utils | ||
| 5 | |||
| 6 | import android.app.PendingIntent | ||
| 7 | import android.app.Service | ||
| 8 | import android.content.Intent | ||
| 9 | import android.os.IBinder | ||
| 10 | import androidx.core.app.NotificationCompat | ||
| 11 | import androidx.core.app.NotificationManagerCompat | ||
| 12 | import org.yuzu.yuzu_emu.R | ||
| 13 | import org.yuzu.yuzu_emu.activities.EmulationActivity | ||
| 14 | |||
| 15 | /** | ||
| 16 | * A service that shows a permanent notification in the background to avoid the app getting | ||
| 17 | * cleared from memory by the system. | ||
| 18 | */ | ||
| 19 | class ForegroundService : Service() { | ||
| 20 | companion object { | ||
| 21 | const val EMULATION_RUNNING_NOTIFICATION = 0x1000 | ||
| 22 | |||
| 23 | const val ACTION_STOP = "stop" | ||
| 24 | } | ||
| 25 | |||
| 26 | private fun showRunningNotification() { | ||
| 27 | // Intent is used to resume emulation if the notification is clicked | ||
| 28 | val contentIntent = PendingIntent.getActivity( | ||
| 29 | this, | ||
| 30 | 0, | ||
| 31 | Intent(this, EmulationActivity::class.java), | ||
| 32 | PendingIntent.FLAG_IMMUTABLE | ||
| 33 | ) | ||
| 34 | val builder = | ||
| 35 | NotificationCompat.Builder(this, getString(R.string.emulation_notification_channel_id)) | ||
| 36 | .setSmallIcon(R.drawable.ic_stat_notification_logo) | ||
| 37 | .setContentTitle(getString(R.string.app_name)) | ||
| 38 | .setContentText(getString(R.string.emulation_notification_running)) | ||
| 39 | .setPriority(NotificationCompat.PRIORITY_LOW) | ||
| 40 | .setOngoing(true) | ||
| 41 | .setVibrate(null) | ||
| 42 | .setSound(null) | ||
| 43 | .setContentIntent(contentIntent) | ||
| 44 | startForeground(EMULATION_RUNNING_NOTIFICATION, builder.build()) | ||
| 45 | } | ||
| 46 | |||
| 47 | override fun onBind(intent: Intent): IBinder? { | ||
| 48 | return null | ||
| 49 | } | ||
| 50 | |||
| 51 | override fun onCreate() { | ||
| 52 | showRunningNotification() | ||
| 53 | } | ||
| 54 | |||
| 55 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||
| 56 | if (intent == null) { | ||
| 57 | return START_NOT_STICKY | ||
| 58 | } | ||
| 59 | if (intent.action == ACTION_STOP) { | ||
| 60 | NotificationManagerCompat.from(this).cancel(EMULATION_RUNNING_NOTIFICATION) | ||
| 61 | stopForeground(STOP_FOREGROUND_REMOVE) | ||
| 62 | stopSelfResult(startId) | ||
| 63 | } | ||
| 64 | return START_STICKY | ||
| 65 | } | ||
| 66 | |||
| 67 | override fun onDestroy() { | ||
| 68 | NotificationManagerCompat.from(this).cancel(EMULATION_RUNNING_NOTIFICATION) | ||
| 69 | } | ||
| 70 | } | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt index f9a3e4126..ffbfa9337 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | package org.yuzu.yuzu_emu.utils | 4 | package org.yuzu.yuzu_emu.utils |
| 5 | 5 | ||
| 6 | import android.view.View | 6 | import android.view.View |
| 7 | import android.view.ViewGroup | ||
| 7 | 8 | ||
| 8 | object ViewUtils { | 9 | object ViewUtils { |
| 9 | fun showView(view: View, length: Long = 300) { | 10 | fun showView(view: View, length: Long = 300) { |
| @@ -32,4 +33,28 @@ object ViewUtils { | |||
| 32 | view.visibility = View.INVISIBLE | 33 | view.visibility = View.INVISIBLE |
| 33 | }.start() | 34 | }.start() |
| 34 | } | 35 | } |
| 36 | |||
| 37 | fun View.updateMargins( | ||
| 38 | left: Int = -1, | ||
| 39 | top: Int = -1, | ||
| 40 | right: Int = -1, | ||
| 41 | bottom: Int = -1 | ||
| 42 | ) { | ||
| 43 | val layoutParams = this.layoutParams as ViewGroup.MarginLayoutParams | ||
| 44 | layoutParams.apply { | ||
| 45 | if (left != -1) { | ||
| 46 | leftMargin = left | ||
| 47 | } | ||
| 48 | if (top != -1) { | ||
| 49 | topMargin = top | ||
| 50 | } | ||
| 51 | if (right != -1) { | ||
| 52 | rightMargin = right | ||
| 53 | } | ||
| 54 | if (bottom != -1) { | ||
| 55 | bottomMargin = bottom | ||
| 56 | } | ||
| 57 | } | ||
| 58 | this.layoutParams = layoutParams | ||
| 59 | } | ||
| 35 | } | 60 | } |
diff --git a/src/android/app/src/main/jni/android_settings.h b/src/android/app/src/main/jni/android_settings.h index cf93304da..4a3bc8e53 100644 --- a/src/android/app/src/main/jni/android_settings.h +++ b/src/android/app/src/main/jni/android_settings.h | |||
| @@ -60,6 +60,8 @@ struct Values { | |||
| 60 | Settings::Category::Overlay}; | 60 | Settings::Category::Overlay}; |
| 61 | Settings::Setting<bool> show_performance_overlay{linkage, true, "show_performance_overlay", | 61 | Settings::Setting<bool> show_performance_overlay{linkage, true, "show_performance_overlay", |
| 62 | Settings::Category::Overlay}; | 62 | Settings::Category::Overlay}; |
| 63 | Settings::Setting<bool> show_thermal_overlay{linkage, false, "show_thermal_overlay", | ||
| 64 | Settings::Category::Overlay}; | ||
| 63 | Settings::Setting<bool> show_input_overlay{linkage, true, "show_input_overlay", | 65 | Settings::Setting<bool> show_input_overlay{linkage, true, "show_input_overlay", |
| 64 | Settings::Category::Overlay}; | 66 | Settings::Category::Overlay}; |
| 65 | Settings::Setting<bool> touchscreen{linkage, true, "touchscreen", Settings::Category::Overlay}; | 67 | Settings::Setting<bool> touchscreen{linkage, true, "touchscreen", Settings::Category::Overlay}; |
diff --git a/src/android/app/src/main/res/layout/fragment_emulation.xml b/src/android/app/src/main/res/layout/fragment_emulation.xml index 0d2bfe8d6..e99a15783 100644 --- a/src/android/app/src/main/res/layout/fragment_emulation.xml +++ b/src/android/app/src/main/res/layout/fragment_emulation.xml | |||
| @@ -140,6 +140,7 @@ | |||
| 140 | android:id="@+id/overlay_container" | 140 | android:id="@+id/overlay_container" |
| 141 | android:layout_width="match_parent" | 141 | android:layout_width="match_parent" |
| 142 | android:layout_height="match_parent" | 142 | android:layout_height="match_parent" |
| 143 | android:layout_marginHorizontal="20dp" | ||
| 143 | android:fitsSystemWindows="true"> | 144 | android:fitsSystemWindows="true"> |
| 144 | 145 | ||
| 145 | <com.google.android.material.textview.MaterialTextView | 146 | <com.google.android.material.textview.MaterialTextView |
| @@ -150,7 +151,19 @@ | |||
| 150 | android:layout_gravity="left" | 151 | android:layout_gravity="left" |
| 151 | android:clickable="false" | 152 | android:clickable="false" |
| 152 | android:focusable="false" | 153 | android:focusable="false" |
| 153 | android:paddingHorizontal="20dp" | 154 | android:textColor="@android:color/white" |
| 155 | android:shadowColor="@android:color/black" | ||
| 156 | android:shadowRadius="3" | ||
| 157 | tools:ignore="RtlHardcoded" /> | ||
| 158 | |||
| 159 | <com.google.android.material.textview.MaterialTextView | ||
| 160 | android:id="@+id/show_thermals_text" | ||
| 161 | style="@style/TextAppearance.Material3.BodySmall" | ||
| 162 | android:layout_width="wrap_content" | ||
| 163 | android:layout_height="wrap_content" | ||
| 164 | android:layout_gravity="right" | ||
| 165 | android:clickable="false" | ||
| 166 | android:focusable="false" | ||
| 154 | android:textColor="@android:color/white" | 167 | android:textColor="@android:color/white" |
| 155 | android:shadowColor="@android:color/black" | 168 | android:shadowColor="@android:color/black" |
| 156 | android:shadowRadius="3" | 169 | android:shadowRadius="3" |
diff --git a/src/android/app/src/main/res/menu/menu_overlay_options.xml b/src/android/app/src/main/res/menu/menu_overlay_options.xml index 363781652..a9e807427 100644 --- a/src/android/app/src/main/res/menu/menu_overlay_options.xml +++ b/src/android/app/src/main/res/menu/menu_overlay_options.xml | |||
| @@ -7,6 +7,11 @@ | |||
| 7 | android:checkable="true" /> | 7 | android:checkable="true" /> |
| 8 | 8 | ||
| 9 | <item | 9 | <item |
| 10 | android:id="@+id/thermal_indicator" | ||
| 11 | android:title="@string/emulation_thermal_indicator" | ||
| 12 | android:checkable="true" /> | ||
| 13 | |||
| 14 | <item | ||
| 10 | android:id="@+id/menu_edit_overlay" | 15 | android:id="@+id/menu_edit_overlay" |
| 11 | android:title="@string/emulation_touch_overlay_edit" /> | 16 | android:title="@string/emulation_touch_overlay_edit" /> |
| 12 | 17 | ||
diff --git a/src/android/app/src/main/res/values-ar/strings.xml b/src/android/app/src/main/res/values-ar/strings.xml index 53678f465..41d741847 100644 --- a/src/android/app/src/main/res/values-ar/strings.xml +++ b/src/android/app/src/main/res/values-ar/strings.xml | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="emulation_notification_channel_name">المحاكي نشط</string> | ||
| 5 | <string name="emulation_notification_channel_description">اظهار اشعار دائم عندما يكون المحاكي نشطاً</string> | ||
| 6 | <string name="emulation_notification_running">يوزو قيد التشغيل</string> | ||
| 7 | <string name="notice_notification_channel_name">الإشعارات والأخطاء</string> | 4 | <string name="notice_notification_channel_name">الإشعارات والأخطاء</string> |
| 8 | <string name="notice_notification_channel_description">اظهار اشعار عند حصول اي مشكلة.</string> | 5 | <string name="notice_notification_channel_description">اظهار اشعار عند حصول اي مشكلة.</string> |
| 9 | <string name="notification_permission_not_granted">لم يتم منح إذن الإشعار</string> | 6 | <string name="notification_permission_not_granted">لم يتم منح إذن الإشعار</string> |
diff --git a/src/android/app/src/main/res/values-ckb/strings.xml b/src/android/app/src/main/res/values-ckb/strings.xml index 7e1eb2b8d..827339505 100644 --- a/src/android/app/src/main/res/values-ckb/strings.xml +++ b/src/android/app/src/main/res/values-ckb/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">ئەم نەرمەکاڵایە یارییەکانی کۆنسۆلی نینتێندۆ سویچ کارپێدەکات. هیچ ناونیشانێکی یاری و کلیلی تێدا نییە..<br /><br />پێش ئەوەی دەست پێ بکەیت، تکایە شوێنی فایلی <![CDATA[<b> prod.keys </b>]]> دیاریبکە لە نێو کۆگای ئامێرەکەت.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">زیاتر فێربە</a>]]></string> | 4 | <string name="app_disclaimer">ئەم نەرمەکاڵایە یارییەکانی کۆنسۆلی نینتێندۆ سویچ کارپێدەکات. هیچ ناونیشانێکی یاری و کلیلی تێدا نییە..<br /><br />پێش ئەوەی دەست پێ بکەیت، تکایە شوێنی فایلی <![CDATA[<b> prod.keys </b>]]> دیاریبکە لە نێو کۆگای ئامێرەکەت.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">زیاتر فێربە</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">ئیمولەیشن کارایە</string> | ||
| 6 | <string name="emulation_notification_channel_description">ئاگادارکردنەوەیەکی بەردەوام نیشان دەدات کاتێک ئیمولەیشن کاردەکات.</string> | ||
| 7 | <string name="emulation_notification_running">یوزو کاردەکات</string> | ||
| 8 | <string name="notice_notification_channel_name">ئاگاداری و هەڵەکان</string> | 5 | <string name="notice_notification_channel_name">ئاگاداری و هەڵەکان</string> |
| 9 | <string name="notice_notification_channel_description">ئاگادارکردنەوەکان پیشان دەدات کاتێک شتێک بە هەڵەدا دەچێت.</string> | 6 | <string name="notice_notification_channel_description">ئاگادارکردنەوەکان پیشان دەدات کاتێک شتێک بە هەڵەدا دەچێت.</string> |
| 10 | <string name="notification_permission_not_granted">مۆڵەتی ئاگادارکردنەوە نەدراوە!</string> | 7 | <string name="notification_permission_not_granted">مۆڵەتی ئاگادارکردنەوە نەدراوە!</string> |
diff --git a/src/android/app/src/main/res/values-cs/strings.xml b/src/android/app/src/main/res/values-cs/strings.xml index b9a4a11e4..8f8e2848d 100644 --- a/src/android/app/src/main/res/values-cs/strings.xml +++ b/src/android/app/src/main/res/values-cs/strings.xml | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="emulation_notification_channel_name">Emulace je aktivní</string> | ||
| 5 | <string name="notice_notification_channel_name">Upozornění a chyby</string> | 4 | <string name="notice_notification_channel_name">Upozornění a chyby</string> |
| 6 | <string name="notice_notification_channel_description">Ukáže oznámení v případě chyby.</string> | 5 | <string name="notice_notification_channel_description">Ukáže oznámení v případě chyby.</string> |
| 7 | <string name="notification_permission_not_granted">Oznámení nejsou oprávněna!</string> | 6 | <string name="notification_permission_not_granted">Oznámení nejsou oprávněna!</string> |
diff --git a/src/android/app/src/main/res/values-de/strings.xml b/src/android/app/src/main/res/values-de/strings.xml index 483ea8c88..fb25b3c93 100644 --- a/src/android/app/src/main/res/values-de/strings.xml +++ b/src/android/app/src/main/res/values-de/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Diese Software kann Spiele für die Nintendo Switch abspielen. Keine Spiele oder Spielekeys sind enthalten.<br /><br />Bevor du beginnst, bitte halte deine <![CDATA[<b> prod.keys </b>]]> auf deinem Gerät bereit. .<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Mehr Infos</a>]]></string> | 4 | <string name="app_disclaimer">Diese Software kann Spiele für die Nintendo Switch abspielen. Keine Spiele oder Spielekeys sind enthalten.<br /><br />Bevor du beginnst, bitte halte deine <![CDATA[<b> prod.keys </b>]]> auf deinem Gerät bereit. .<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Mehr Infos</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Emulation ist aktiv</string> | ||
| 6 | <string name="emulation_notification_channel_description">Zeigt eine dauerhafte Benachrichtigung an, wenn die Emulation läuft.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu läuft</string> | ||
| 8 | <string name="notice_notification_channel_name">Hinweise und Fehler</string> | 5 | <string name="notice_notification_channel_name">Hinweise und Fehler</string> |
| 9 | <string name="notice_notification_channel_description">Zeigt Benachrichtigungen an, wenn etwas schief läuft.</string> | 6 | <string name="notice_notification_channel_description">Zeigt Benachrichtigungen an, wenn etwas schief läuft.</string> |
| 10 | <string name="notification_permission_not_granted">Berechtigung für Benachrichtigungen nicht erlaubt!</string> | 7 | <string name="notification_permission_not_granted">Berechtigung für Benachrichtigungen nicht erlaubt!</string> |
diff --git a/src/android/app/src/main/res/values-es/strings.xml b/src/android/app/src/main/res/values-es/strings.xml index c3825710b..7ecbeaba4 100644 --- a/src/android/app/src/main/res/values-es/strings.xml +++ b/src/android/app/src/main/res/values-es/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Este software ejecuta juegos para la videoconsola Nintendo Switch. Los videojuegos o claves no vienen incluidos.<br /><br />Antes de empezar, por favor, localice el archivo <![CDATA[<b> prod.keys </b>]]>en el almacenamiento de su dispositivo..<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Saber más</a>]]></string> | 4 | <string name="app_disclaimer">Este software ejecuta juegos para la videoconsola Nintendo Switch. Los videojuegos o claves no vienen incluidos.<br /><br />Antes de empezar, por favor, localice el archivo <![CDATA[<b> prod.keys </b>]]>en el almacenamiento de su dispositivo..<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Saber más</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Emulación activa</string> | ||
| 6 | <string name="emulation_notification_channel_description">Muestra una notificación persistente cuando la emulación está activa.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu está ejecutándose</string> | ||
| 8 | <string name="notice_notification_channel_name">Avisos y errores</string> | 5 | <string name="notice_notification_channel_name">Avisos y errores</string> |
| 9 | <string name="notice_notification_channel_description">Mostrar notificaciones cuándo algo vaya mal.</string> | 6 | <string name="notice_notification_channel_description">Mostrar notificaciones cuándo algo vaya mal.</string> |
| 10 | <string name="notification_permission_not_granted">¡Permisos de notificación no concedidos!</string> | 7 | <string name="notification_permission_not_granted">¡Permisos de notificación no concedidos!</string> |
diff --git a/src/android/app/src/main/res/values-fr/strings.xml b/src/android/app/src/main/res/values-fr/strings.xml index 667fe33cb..a848b9163 100644 --- a/src/android/app/src/main/res/values-fr/strings.xml +++ b/src/android/app/src/main/res/values-fr/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Ce logiciel exécutera des jeux pour la console de jeu Nintendo Switch. Aucun jeux ou clés n\'est inclus.<br /><br />Avant de commencer, veuillez localiser votre fichier <![CDATA[<b> prod.keys </b>]]> sur le stockage de votre appareil.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">En savoir plus</a>]]></string> | 4 | <string name="app_disclaimer">Ce logiciel exécutera des jeux pour la console de jeu Nintendo Switch. Aucun jeux ou clés n\'est inclus.<br /><br />Avant de commencer, veuillez localiser votre fichier <![CDATA[<b> prod.keys </b>]]> sur le stockage de votre appareil.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">En savoir plus</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">L\'émulation est active</string> | ||
| 6 | <string name="emulation_notification_channel_description">Affiche une notification persistante lorsque l\'émulation est en cours d\'exécution.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu est en cours d\'exécution</string> | ||
| 8 | <string name="notice_notification_channel_name">Avis et erreurs</string> | 5 | <string name="notice_notification_channel_name">Avis et erreurs</string> |
| 9 | <string name="notice_notification_channel_description">Affiche des notifications en cas de problème.</string> | 6 | <string name="notice_notification_channel_description">Affiche des notifications en cas de problème.</string> |
| 10 | <string name="notification_permission_not_granted">Permission de notification non accordée !</string> | 7 | <string name="notification_permission_not_granted">Permission de notification non accordée !</string> |
diff --git a/src/android/app/src/main/res/values-he/strings.xml b/src/android/app/src/main/res/values-he/strings.xml index 41e4450c6..6096605a9 100644 --- a/src/android/app/src/main/res/values-he/strings.xml +++ b/src/android/app/src/main/res/values-he/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">התוכנה תריץ משחקים לקונסולת ה Nintendo Switch. אף משחק או קבצים בעלי זכויות יוצרים נכללים.<br /><br /> לפני שאת/ה מתחיל בבקשה מצא את קובץ <![CDATA[<b>prod.keys</b>]]> על המכשיר.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">קרא עוד</a>]]></string> | 4 | <string name="app_disclaimer">התוכנה תריץ משחקים לקונסולת ה Nintendo Switch. אף משחק או קבצים בעלי זכויות יוצרים נכללים.<br /><br /> לפני שאת/ה מתחיל בבקשה מצא את קובץ <![CDATA[<b>prod.keys</b>]]> על המכשיר.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">קרא עוד</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">אמולציה פעילה</string> | ||
| 6 | <string name="emulation_notification_channel_description">מציג התראה מתמשכת כאשר האמולציה פועלת.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu רץ</string> | ||
| 8 | <string name="notice_notification_channel_name">התראות ותקלות</string> | 5 | <string name="notice_notification_channel_name">התראות ותקלות</string> |
| 9 | <string name="notice_notification_channel_description">מציג התראות כאשר משהו הולך לא כשורה.</string> | 6 | <string name="notice_notification_channel_description">מציג התראות כאשר משהו הולך לא כשורה.</string> |
| 10 | <string name="notification_permission_not_granted">הרשאות התראות לא ניתנה!</string> | 7 | <string name="notification_permission_not_granted">הרשאות התראות לא ניתנה!</string> |
diff --git a/src/android/app/src/main/res/values-hu/strings.xml b/src/android/app/src/main/res/values-hu/strings.xml index 554da0816..f3a29e0c3 100644 --- a/src/android/app/src/main/res/values-hu/strings.xml +++ b/src/android/app/src/main/res/values-hu/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Ez a szoftver Nintendo Switch játékkonzolhoz készült játékokat futtat. Nem tartalmaz játékokat vagy kulcsokat. .<br /><br />Mielőtt hozzákezdenél, kérjük, válaszd ki a <![CDATA[<b>prod.keys</b>]]> fájl helyét a készülék tárhelyén<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Tudj meg többet</a>]]></string> | 4 | <string name="app_disclaimer">Ez a szoftver Nintendo Switch játékkonzolhoz készült játékokat futtat. Nem tartalmaz játékokat vagy kulcsokat. .<br /><br />Mielőtt hozzákezdenél, kérjük, válaszd ki a <![CDATA[<b>prod.keys</b>]]> fájl helyét a készülék tárhelyén<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Tudj meg többet</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Emuláció aktív</string> | ||
| 6 | <string name="emulation_notification_channel_description">Állandó értesítést jelenít meg, amíg az emuláció fut.</string> | ||
| 7 | <string name="emulation_notification_running">A yuzu fut</string> | ||
| 8 | <string name="notice_notification_channel_name">Megjegyzések és hibák</string> | 5 | <string name="notice_notification_channel_name">Megjegyzések és hibák</string> |
| 9 | <string name="notice_notification_channel_description">Értesítések megjelenítése, ha valami rosszul sül el.</string> | 6 | <string name="notice_notification_channel_description">Értesítések megjelenítése, ha valami rosszul sül el.</string> |
| 10 | <string name="notification_permission_not_granted">Nincs engedély az értesítés megjelenítéséhez!</string> | 7 | <string name="notification_permission_not_granted">Nincs engedély az értesítés megjelenítéséhez!</string> |
diff --git a/src/android/app/src/main/res/values-it/strings.xml b/src/android/app/src/main/res/values-it/strings.xml index 61b39f57f..433d84f5c 100644 --- a/src/android/app/src/main/res/values-it/strings.xml +++ b/src/android/app/src/main/res/values-it/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Questo software permette di giocare ai giochi della console Nintendo Switch. Nessun gioco o chiave è inclusa.<br /><br />Prima di iniziare, perfavore individua il file <![CDATA[<b>prod.keys </b>]]> nella memoria del tuo dispositivo.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Scopri di più</a>]]></string> | 4 | <string name="app_disclaimer">Questo software permette di giocare ai giochi della console Nintendo Switch. Nessun gioco o chiave è inclusa.<br /><br />Prima di iniziare, perfavore individua il file <![CDATA[<b>prod.keys </b>]]> nella memoria del tuo dispositivo.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Scopri di più</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">L\'emulatore è attivo</string> | ||
| 6 | <string name="emulation_notification_channel_description">Mostra una notifica persistente quando l\'emulatore è in esecuzione.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu è in esecuzione</string> | ||
| 8 | <string name="notice_notification_channel_name">Avvisi ed errori</string> | 5 | <string name="notice_notification_channel_name">Avvisi ed errori</string> |
| 9 | <string name="notice_notification_channel_description">Mostra le notifiche quando qualcosa va storto.</string> | 6 | <string name="notice_notification_channel_description">Mostra le notifiche quando qualcosa va storto.</string> |
| 10 | <string name="notification_permission_not_granted">Autorizzazione di notifica non concessa!</string> | 7 | <string name="notification_permission_not_granted">Autorizzazione di notifica non concessa!</string> |
diff --git a/src/android/app/src/main/res/values-ja/strings.xml b/src/android/app/src/main/res/values-ja/strings.xml index 0cff40bb6..da73ad651 100644 --- a/src/android/app/src/main/res/values-ja/strings.xml +++ b/src/android/app/src/main/res/values-ja/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">このソフトウェアでは、Nintendo Switchのゲームを実行できます。 ゲームソフトやキーは含まれません。<br /><br />事前に、 <![CDATA[<b> prod.keys </b>]]> ファイルをストレージに配置しておいてください。<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">詳細</a>]]></string> | 4 | <string name="app_disclaimer">このソフトウェアでは、Nintendo Switchのゲームを実行できます。 ゲームソフトやキーは含まれません。<br /><br />事前に、 <![CDATA[<b> prod.keys </b>]]> ファイルをストレージに配置しておいてください。<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">詳細</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">エミュレーションが有効です</string> | ||
| 6 | <string name="emulation_notification_channel_description">エミュレーションの実行中に常設通知を表示します。</string> | ||
| 7 | <string name="emulation_notification_running">yuzu は実行中です</string> | ||
| 8 | <string name="notice_notification_channel_name">通知とエラー</string> | 5 | <string name="notice_notification_channel_name">通知とエラー</string> |
| 9 | <string name="notice_notification_channel_description">問題の発生時に通知を表示します。</string> | 6 | <string name="notice_notification_channel_description">問題の発生時に通知を表示します。</string> |
| 10 | <string name="notification_permission_not_granted">通知が許可されていません!</string> | 7 | <string name="notification_permission_not_granted">通知が許可されていません!</string> |
diff --git a/src/android/app/src/main/res/values-ko/strings.xml b/src/android/app/src/main/res/values-ko/strings.xml index eaa6c23ce..904353d34 100644 --- a/src/android/app/src/main/res/values-ko/strings.xml +++ b/src/android/app/src/main/res/values-ko/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">이 소프트웨어는 Nintendo Switch 게임을 실행합니다. 게임 타이틀이나 키는 포함되어 있지 않습니다.<br /><br />시작하기 전에 장치 저장소에서 <![CDATA[<b> prod.keys </b>]]> 파일을 찾아주세요.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">자세히 알아보기</a>]]></string> | 4 | <string name="app_disclaimer">이 소프트웨어는 Nintendo Switch 게임을 실행합니다. 게임 타이틀이나 키는 포함되어 있지 않습니다.<br /><br />시작하기 전에 장치 저장소에서 <![CDATA[<b> prod.keys </b>]]> 파일을 찾아주세요.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">자세히 알아보기</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">에뮬레이션이 활성화됨</string> | ||
| 6 | <string name="emulation_notification_channel_description">에뮬레이션이 실행 중일 때 지속적으로 알림을 표시합니다.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu가 실행 중입니다.</string> | ||
| 8 | <string name="notice_notification_channel_name">알림 및 오류</string> | 5 | <string name="notice_notification_channel_name">알림 및 오류</string> |
| 9 | <string name="notice_notification_channel_description">문제가 발생하면 알림을 표시합니다.</string> | 6 | <string name="notice_notification_channel_description">문제가 발생하면 알림을 표시합니다.</string> |
| 10 | <string name="notification_permission_not_granted">알림 권한이 부여되지 않았습니다!</string> | 7 | <string name="notification_permission_not_granted">알림 권한이 부여되지 않았습니다!</string> |
diff --git a/src/android/app/src/main/res/values-nb/strings.xml b/src/android/app/src/main/res/values-nb/strings.xml index e92dc62d9..fe3af5920 100644 --- a/src/android/app/src/main/res/values-nb/strings.xml +++ b/src/android/app/src/main/res/values-nb/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Denne programvaren vil kjøre spill for Nintendo Switch-spillkonsollen. Ingen spilltitler eller nøkler er inkludert.<br /><br />Før du begynner, må du finne <![CDATA[<b> prod.keys </b>]]> filen din på enhetslagringen.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Lær mer</a>]]></string> | 4 | <string name="app_disclaimer">Denne programvaren vil kjøre spill for Nintendo Switch-spillkonsollen. Ingen spilltitler eller nøkler er inkludert.<br /><br />Før du begynner, må du finne <![CDATA[<b> prod.keys </b>]]> filen din på enhetslagringen.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Lær mer</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Emulering er aktiv</string> | ||
| 6 | <string name="emulation_notification_channel_description">Viser et vedvarende varsel når emuleringen kjører.</string> | ||
| 7 | <string name="emulation_notification_running">Yuzu kjører</string> | ||
| 8 | <string name="notice_notification_channel_name">Merknader og feil</string> | 5 | <string name="notice_notification_channel_name">Merknader og feil</string> |
| 9 | <string name="notice_notification_channel_description">Viser varsler når noe går galt.</string> | 6 | <string name="notice_notification_channel_description">Viser varsler når noe går galt.</string> |
| 10 | <string name="notification_permission_not_granted">Varslingstillatelse ikke gitt!</string> | 7 | <string name="notification_permission_not_granted">Varslingstillatelse ikke gitt!</string> |
diff --git a/src/android/app/src/main/res/values-pl/strings.xml b/src/android/app/src/main/res/values-pl/strings.xml index fbd0ad7e9..2af7fd7b4 100644 --- a/src/android/app/src/main/res/values-pl/strings.xml +++ b/src/android/app/src/main/res/values-pl/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">To oprogramowanie umożliwia uruchomienie gier z konsoli Nintendo Switch. Nie zawiera gier ani wymaganych kluczy.<br /><br />Zanim zaczniesz, wybierz plik kluczy <![CDATA[<b> prod.keys </b>]]> z katalogu w pamięci masowej.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Dowiedz się więcej</a>]]></string> | 4 | <string name="app_disclaimer">To oprogramowanie umożliwia uruchomienie gier z konsoli Nintendo Switch. Nie zawiera gier ani wymaganych kluczy.<br /><br />Zanim zaczniesz, wybierz plik kluczy <![CDATA[<b> prod.keys </b>]]> z katalogu w pamięci masowej.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Dowiedz się więcej</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Emulacja jest uruchomiona</string> | ||
| 6 | <string name="emulation_notification_channel_description">Pokaż trwałe powiadomienie gdy emulacja jest uruchomiona.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu jest uruchomiony</string> | ||
| 8 | <string name="notice_notification_channel_name">Powiadomienia błędy</string> | 5 | <string name="notice_notification_channel_name">Powiadomienia błędy</string> |
| 9 | <string name="notice_notification_channel_description">Pokaż powiadomienie gdy coś pójdzie źle</string> | 6 | <string name="notice_notification_channel_description">Pokaż powiadomienie gdy coś pójdzie źle</string> |
| 10 | <string name="notification_permission_not_granted">Nie zezwolono na powiadomienia!</string> | 7 | <string name="notification_permission_not_granted">Nie zezwolono na powiadomienia!</string> |
diff --git a/src/android/app/src/main/res/values-pt-rBR/strings.xml b/src/android/app/src/main/res/values-pt-rBR/strings.xml index a87eb11e4..130252590 100644 --- a/src/android/app/src/main/res/values-pt-rBR/strings.xml +++ b/src/android/app/src/main/res/values-pt-rBR/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Este software executa jogos do console Nintendo Switch. Não estão inclusos nem jogos ou chaves.<br /><br />Antes de começar, por favor localize o arquivo <![CDATA[<b> prod.keys </b>]]> no armazenamento de seu dispositivo.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Saiba mais</a>]]></string> | 4 | <string name="app_disclaimer">Este software executa jogos do console Nintendo Switch. Não estão inclusos nem jogos ou chaves.<br /><br />Antes de começar, por favor localize o arquivo <![CDATA[<b> prod.keys </b>]]> no armazenamento de seu dispositivo.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Saiba mais</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">A emulação está Ativa</string> | ||
| 6 | <string name="emulation_notification_channel_description">Mostra uma notificação permanente enquanto a emulação estiver em andamento.</string> | ||
| 7 | <string name="emulation_notification_running">O Yuzu está em execução </string> | ||
| 8 | <string name="notice_notification_channel_name">Notificações e erros</string> | 5 | <string name="notice_notification_channel_name">Notificações e erros</string> |
| 9 | <string name="notice_notification_channel_description">Mostra notificações quando algo dá errado.</string> | 6 | <string name="notice_notification_channel_description">Mostra notificações quando algo dá errado.</string> |
| 10 | <string name="notification_permission_not_granted">Acesso às notificações não concedido!</string> | 7 | <string name="notification_permission_not_granted">Acesso às notificações não concedido!</string> |
diff --git a/src/android/app/src/main/res/values-pt-rPT/strings.xml b/src/android/app/src/main/res/values-pt-rPT/strings.xml index 684a71616..0fdbae4f8 100644 --- a/src/android/app/src/main/res/values-pt-rPT/strings.xml +++ b/src/android/app/src/main/res/values-pt-rPT/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Este software corre jogos para a consola Nintendo Switch. Não estão incluídas nem jogos ou chaves. <br /><br />Antes de começares, por favor localiza o ficheiro <![CDATA[1 prod.keys 1]]> no armazenamento do teu dispositivo.<br /><br /><![CDATA[2Learn more2]]></string> | 4 | <string name="app_disclaimer">Este software corre jogos para a consola Nintendo Switch. Não estão incluídas nem jogos ou chaves. <br /><br />Antes de começares, por favor localiza o ficheiro <![CDATA[1 prod.keys 1]]> no armazenamento do teu dispositivo.<br /><br /><![CDATA[2Learn more2]]></string> |
| 5 | <string name="emulation_notification_channel_name">Emulação está Ativa</string> | ||
| 6 | <string name="emulation_notification_channel_description">Mostra uma notificação permanente enquanto a emulação está a correr.</string> | ||
| 7 | <string name="emulation_notification_running">Yuzu está em execução </string> | ||
| 8 | <string name="notice_notification_channel_name">Notificações e erros</string> | 5 | <string name="notice_notification_channel_name">Notificações e erros</string> |
| 9 | <string name="notice_notification_channel_description">Mostra notificações quendo algo corre mal.</string> | 6 | <string name="notice_notification_channel_description">Mostra notificações quendo algo corre mal.</string> |
| 10 | <string name="notification_permission_not_granted">Permissões de notificação não permitidas </string> | 7 | <string name="notification_permission_not_granted">Permissões de notificação não permitidas </string> |
diff --git a/src/android/app/src/main/res/values-ru/strings.xml b/src/android/app/src/main/res/values-ru/strings.xml index 099b2c9eb..2dfd4a824 100644 --- a/src/android/app/src/main/res/values-ru/strings.xml +++ b/src/android/app/src/main/res/values-ru/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Это программное обеспечение позволяет запускать игры для игровой консоли Nintendo Switch. Мы не предоставляем сами игры или ключи.<br /><br />Перед началом работы найдите файл <![CDATA[<b> prod.keys </b>]]> в хранилище устройства..<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Узнать больше</a>]]></string> | 4 | <string name="app_disclaimer">Это программное обеспечение позволяет запускать игры для игровой консоли Nintendo Switch. Мы не предоставляем сами игры или ключи.<br /><br />Перед началом работы найдите файл <![CDATA[<b> prod.keys </b>]]> в хранилище устройства..<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Узнать больше</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Эмуляция активна</string> | ||
| 6 | <string name="emulation_notification_channel_description">Показывает постоянное уведомление, когда запущена эмуляция.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu запущен</string> | ||
| 8 | <string name="notice_notification_channel_name">Уведомления и ошибки</string> | 5 | <string name="notice_notification_channel_name">Уведомления и ошибки</string> |
| 9 | <string name="notice_notification_channel_description">Показывать уведомления, когда что-то пошло не так</string> | 6 | <string name="notice_notification_channel_description">Показывать уведомления, когда что-то пошло не так</string> |
| 10 | <string name="notification_permission_not_granted">Вы не предоставили разрешение на уведомления!</string> | 7 | <string name="notification_permission_not_granted">Вы не предоставили разрешение на уведомления!</string> |
diff --git a/src/android/app/src/main/res/values-uk/strings.xml b/src/android/app/src/main/res/values-uk/strings.xml index 361f0b726..9a2804a93 100644 --- a/src/android/app/src/main/res/values-uk/strings.xml +++ b/src/android/app/src/main/res/values-uk/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Це програмне забезпечення дозволяє запускати ігри для ігрової консолі Nintendo Switch. Ми не надаємо самі ігри або ключі.<br /><br />Перед початком роботи знайдіть ваш файл <![CDATA[<b> prod.keys </b>]]> у сховищі пристрою.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Дізнатися більше</a>]]></string> | 4 | <string name="app_disclaimer">Це програмне забезпечення дозволяє запускати ігри для ігрової консолі Nintendo Switch. Ми не надаємо самі ігри або ключі.<br /><br />Перед початком роботи знайдіть ваш файл <![CDATA[<b> prod.keys </b>]]> у сховищі пристрою.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Дізнатися більше</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Емуляція активна</string> | ||
| 6 | <string name="emulation_notification_channel_description">Показує постійне сповіщення, коли запущено емуляцію.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu запущено</string> | ||
| 8 | <string name="notice_notification_channel_name">Сповіщення та помилки</string> | 5 | <string name="notice_notification_channel_name">Сповіщення та помилки</string> |
| 9 | <string name="notice_notification_channel_description">Показувати сповіщення, коли щось пішло не так</string> | 6 | <string name="notice_notification_channel_description">Показувати сповіщення, коли щось пішло не так</string> |
| 10 | <string name="notification_permission_not_granted">Ви не надали дозвіл сповіщень!</string> | 7 | <string name="notification_permission_not_granted">Ви не надали дозвіл сповіщень!</string> |
diff --git a/src/android/app/src/main/res/values-vi/strings.xml b/src/android/app/src/main/res/values-vi/strings.xml index 0a722f329..dc06610c7 100644 --- a/src/android/app/src/main/res/values-vi/strings.xml +++ b/src/android/app/src/main/res/values-vi/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">Phần mềm này sẽ chạy các game cho máy chơi game Nintendo Switch. Không có title games hoặc keys được bao gồm.<br /><br />Trước khi bạn bắt đầu, hãy tìm tập tin <![CDATA[<b> prod.keys </b>]]> trên bộ nhớ thiết bị của bạn.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Tìm hiểu thêm</a>]]></string> | 4 | <string name="app_disclaimer">Phần mềm này sẽ chạy các game cho máy chơi game Nintendo Switch. Không có title games hoặc keys được bao gồm.<br /><br />Trước khi bạn bắt đầu, hãy tìm tập tin <![CDATA[<b> prod.keys </b>]]> trên bộ nhớ thiết bị của bạn.<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">Tìm hiểu thêm</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">Giả lập đang chạy</string> | ||
| 6 | <string name="emulation_notification_channel_description">Hiển thị thông báo liên tục khi giả lập đang chạy.</string> | ||
| 7 | <string name="emulation_notification_running">yuzu đang chạy</string> | ||
| 8 | <string name="notice_notification_channel_name">Thông báo và lỗi</string> | 5 | <string name="notice_notification_channel_name">Thông báo và lỗi</string> |
| 9 | <string name="notice_notification_channel_description">Hiển thị thông báo khi có sự cố xảy ra.</string> | 6 | <string name="notice_notification_channel_description">Hiển thị thông báo khi có sự cố xảy ra.</string> |
| 10 | <string name="notification_permission_not_granted">Ứng dụng không được cấp quyền thông báo!</string> | 7 | <string name="notification_permission_not_granted">Ứng dụng không được cấp quyền thông báo!</string> |
diff --git a/src/android/app/src/main/res/values-zh-rCN/strings.xml b/src/android/app/src/main/res/values-zh-rCN/strings.xml index b840591a4..6acf6f391 100644 --- a/src/android/app/src/main/res/values-zh-rCN/strings.xml +++ b/src/android/app/src/main/res/values-zh-rCN/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">此软件可以运行 Nintendo Switch 游戏,但不包含任何游戏和密钥文件。<br /><br />在开始前,请找到放置于设备存储中的 <![CDATA[<b> prod.keys </b>]]> 文件。<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">了解更多</a>]]></string> | 4 | <string name="app_disclaimer">此软件可以运行 Nintendo Switch 游戏,但不包含任何游戏和密钥文件。<br /><br />在开始前,请找到放置于设备存储中的 <![CDATA[<b> prod.keys </b>]]> 文件。<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">了解更多</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">正在进行模拟</string> | ||
| 6 | <string name="emulation_notification_channel_description">在模拟运行时显示持久通知。</string> | ||
| 7 | <string name="emulation_notification_running">yuzu 正在运行</string> | ||
| 8 | <string name="notice_notification_channel_name">通知及错误提醒</string> | 5 | <string name="notice_notification_channel_name">通知及错误提醒</string> |
| 9 | <string name="notice_notification_channel_description">当发生错误时显示通知。</string> | 6 | <string name="notice_notification_channel_description">当发生错误时显示通知。</string> |
| 10 | <string name="notification_permission_not_granted">未授予通知权限!</string> | 7 | <string name="notification_permission_not_granted">未授予通知权限!</string> |
diff --git a/src/android/app/src/main/res/values-zh-rTW/strings.xml b/src/android/app/src/main/res/values-zh-rTW/strings.xml index d39255714..411fc5947 100644 --- a/src/android/app/src/main/res/values-zh-rTW/strings.xml +++ b/src/android/app/src/main/res/values-zh-rTW/strings.xml | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> | 2 | <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> |
| 3 | 3 | ||
| 4 | <string name="app_disclaimer">此軟體可以執行 Nintendo Switch 主機遊戲,但不包含任何遊戲和金鑰。<br /><br />在您開始前,請找到放置於您的裝置儲存空間的 <![CDATA[<b> prod.keys </b>]]> 檔案。<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">深入瞭解</a>]]></string> | 4 | <string name="app_disclaimer">此軟體可以執行 Nintendo Switch 主機遊戲,但不包含任何遊戲和金鑰。<br /><br />在您開始前,請找到放置於您的裝置儲存空間的 <![CDATA[<b> prod.keys </b>]]> 檔案。<br /><br /><![CDATA[<a href=\"https://yuzu-emu.org/help/quickstart\">深入瞭解</a>]]></string> |
| 5 | <string name="emulation_notification_channel_name">模擬進行中</string> | ||
| 6 | <string name="emulation_notification_channel_description">在模擬執行時顯示持續通知。</string> | ||
| 7 | <string name="emulation_notification_running">yuzu 正在執行</string> | ||
| 8 | <string name="notice_notification_channel_name">通知和錯誤</string> | 5 | <string name="notice_notification_channel_name">通知和錯誤</string> |
| 9 | <string name="notice_notification_channel_description">發生錯誤時顯示通知。</string> | 6 | <string name="notice_notification_channel_description">發生錯誤時顯示通知。</string> |
| 10 | <string name="notification_permission_not_granted">未授予通知權限!</string> | 7 | <string name="notification_permission_not_granted">未授予通知權限!</string> |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 3cd1586fd..489e00107 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -4,10 +4,6 @@ | |||
| 4 | <!-- General application strings --> | 4 | <!-- General application strings --> |
| 5 | <string name="app_name" translatable="false">yuzu</string> | 5 | <string name="app_name" translatable="false">yuzu</string> |
| 6 | <string name="app_disclaimer">This software will run games for the Nintendo Switch game console. No game titles or keys are included.<br /><br />Before you begin, please locate your <![CDATA[<b> prod.keys </b>]]> file on your device storage.<br /><br /><![CDATA[<a href="https://yuzu-emu.org/help/quickstart">Learn more</a>]]></string> | 6 | <string name="app_disclaimer">This software will run games for the Nintendo Switch game console. No game titles or keys are included.<br /><br />Before you begin, please locate your <![CDATA[<b> prod.keys </b>]]> file on your device storage.<br /><br /><![CDATA[<a href="https://yuzu-emu.org/help/quickstart">Learn more</a>]]></string> |
| 7 | <string name="emulation_notification_channel_name">Emulation is Active</string> | ||
| 8 | <string name="emulation_notification_channel_id" translatable="false">emulationIsActive</string> | ||
| 9 | <string name="emulation_notification_channel_description">Shows a persistent notification when emulation is running.</string> | ||
| 10 | <string name="emulation_notification_running">yuzu is running</string> | ||
| 11 | <string name="notice_notification_channel_name">Notices and errors</string> | 7 | <string name="notice_notification_channel_name">Notices and errors</string> |
| 12 | <string name="notice_notification_channel_id" translatable="false">noticesAndErrors</string> | 8 | <string name="notice_notification_channel_id" translatable="false">noticesAndErrors</string> |
| 13 | <string name="notice_notification_channel_description">Shows notifications when something goes wrong.</string> | 9 | <string name="notice_notification_channel_description">Shows notifications when something goes wrong.</string> |
| @@ -380,6 +376,7 @@ | |||
| 380 | <string name="emulation_exit">Exit emulation</string> | 376 | <string name="emulation_exit">Exit emulation</string> |
| 381 | <string name="emulation_done">Done</string> | 377 | <string name="emulation_done">Done</string> |
| 382 | <string name="emulation_fps_counter">FPS counter</string> | 378 | <string name="emulation_fps_counter">FPS counter</string> |
| 379 | <string name="emulation_thermal_indicator">Thermal indicator</string> | ||
| 383 | <string name="emulation_toggle_controls">Toggle controls</string> | 380 | <string name="emulation_toggle_controls">Toggle controls</string> |
| 384 | <string name="emulation_rel_stick_center">Relative stick center</string> | 381 | <string name="emulation_rel_stick_center">Relative stick center</string> |
| 385 | <string name="emulation_dpad_slide">D-pad slide</string> | 382 | <string name="emulation_dpad_slide">D-pad slide</string> |
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 8ff1326f2..779be211e 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -107,6 +107,8 @@ add_library(common STATIC | |||
| 107 | quaternion.h | 107 | quaternion.h |
| 108 | range_map.h | 108 | range_map.h |
| 109 | range_mutex.h | 109 | range_mutex.h |
| 110 | range_sets.h | ||
| 111 | range_sets.inc | ||
| 110 | reader_writer_queue.h | 112 | reader_writer_queue.h |
| 111 | ring_buffer.h | 113 | ring_buffer.h |
| 112 | ${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp | 114 | ${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp |
| @@ -121,6 +123,7 @@ add_library(common STATIC | |||
| 121 | settings_input.cpp | 123 | settings_input.cpp |
| 122 | settings_input.h | 124 | settings_input.h |
| 123 | settings_setting.h | 125 | settings_setting.h |
| 126 | slot_vector.h | ||
| 124 | socket_types.h | 127 | socket_types.h |
| 125 | spin_lock.cpp | 128 | spin_lock.cpp |
| 126 | spin_lock.h | 129 | spin_lock.h |
diff --git a/src/common/range_sets.h b/src/common/range_sets.h new file mode 100644 index 000000000..f8fcee483 --- /dev/null +++ b/src/common/range_sets.h | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <memory> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Common { | ||
| 11 | |||
| 12 | template <typename AddressType> | ||
| 13 | class RangeSet { | ||
| 14 | public: | ||
| 15 | RangeSet(); | ||
| 16 | ~RangeSet(); | ||
| 17 | |||
| 18 | RangeSet(RangeSet const&) = delete; | ||
| 19 | RangeSet& operator=(RangeSet const&) = delete; | ||
| 20 | |||
| 21 | RangeSet(RangeSet&& other); | ||
| 22 | RangeSet& operator=(RangeSet&& other); | ||
| 23 | |||
| 24 | void Add(AddressType base_address, size_t size); | ||
| 25 | void Subtract(AddressType base_address, size_t size); | ||
| 26 | void Clear(); | ||
| 27 | bool Empty() const; | ||
| 28 | |||
| 29 | template <typename Func> | ||
| 30 | void ForEach(Func&& func) const; | ||
| 31 | |||
| 32 | template <typename Func> | ||
| 33 | void ForEachInRange(AddressType device_addr, size_t size, Func&& func) const; | ||
| 34 | |||
| 35 | private: | ||
| 36 | struct RangeSetImpl; | ||
| 37 | std::unique_ptr<RangeSetImpl> m_impl; | ||
| 38 | }; | ||
| 39 | |||
| 40 | template <typename AddressType> | ||
| 41 | class OverlapRangeSet { | ||
| 42 | public: | ||
| 43 | OverlapRangeSet(); | ||
| 44 | ~OverlapRangeSet(); | ||
| 45 | |||
| 46 | OverlapRangeSet(OverlapRangeSet const&) = delete; | ||
| 47 | OverlapRangeSet& operator=(OverlapRangeSet const&) = delete; | ||
| 48 | |||
| 49 | OverlapRangeSet(OverlapRangeSet&& other); | ||
| 50 | OverlapRangeSet& operator=(OverlapRangeSet&& other); | ||
| 51 | |||
| 52 | void Add(AddressType base_address, size_t size); | ||
| 53 | void Subtract(AddressType base_address, size_t size); | ||
| 54 | |||
| 55 | template <typename Func> | ||
| 56 | void Subtract(AddressType base_address, size_t size, Func&& on_delete); | ||
| 57 | |||
| 58 | void DeleteAll(AddressType base_address, size_t size); | ||
| 59 | void Clear(); | ||
| 60 | bool Empty() const; | ||
| 61 | |||
| 62 | template <typename Func> | ||
| 63 | void ForEach(Func&& func) const; | ||
| 64 | |||
| 65 | template <typename Func> | ||
| 66 | void ForEachInRange(AddressType device_addr, size_t size, Func&& func) const; | ||
| 67 | |||
| 68 | private: | ||
| 69 | struct OverlapRangeSetImpl; | ||
| 70 | std::unique_ptr<OverlapRangeSetImpl> m_impl; | ||
| 71 | }; | ||
| 72 | |||
| 73 | } // namespace Common | ||
diff --git a/src/common/range_sets.inc b/src/common/range_sets.inc new file mode 100644 index 000000000..b83eceb7b --- /dev/null +++ b/src/common/range_sets.inc | |||
| @@ -0,0 +1,304 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <limits> | ||
| 7 | #include <utility> | ||
| 8 | |||
| 9 | #include <boost/icl/interval.hpp> | ||
| 10 | #include <boost/icl/interval_base_set.hpp> | ||
| 11 | #include <boost/icl/interval_map.hpp> | ||
| 12 | #include <boost/icl/interval_set.hpp> | ||
| 13 | #include <boost/icl/split_interval_map.hpp> | ||
| 14 | #include <boost/pool/pool.hpp> | ||
| 15 | #include <boost/pool/pool_alloc.hpp> | ||
| 16 | #include <boost/pool/poolfwd.hpp> | ||
| 17 | |||
| 18 | #include "common/range_sets.h" | ||
| 19 | |||
| 20 | namespace Common { | ||
| 21 | |||
| 22 | namespace { | ||
| 23 | template <class T> | ||
| 24 | using RangeSetsAllocator = | ||
| 25 | boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete, | ||
| 26 | boost::details::pool::default_mutex, 1024, 2048>; | ||
| 27 | } | ||
| 28 | |||
| 29 | template <typename AddressType> | ||
| 30 | struct RangeSet<AddressType>::RangeSetImpl { | ||
| 31 | using IntervalSet = boost::icl::interval_set< | ||
| 32 | AddressType, std::less, ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), | ||
| 33 | RangeSetsAllocator>; | ||
| 34 | using IntervalType = typename IntervalSet::interval_type; | ||
| 35 | |||
| 36 | RangeSetImpl() = default; | ||
| 37 | ~RangeSetImpl() = default; | ||
| 38 | |||
| 39 | void Add(AddressType base_address, size_t size) { | ||
| 40 | AddressType end_address = base_address + static_cast<AddressType>(size); | ||
| 41 | IntervalType interval{base_address, end_address}; | ||
| 42 | m_ranges_set.add(interval); | ||
| 43 | } | ||
| 44 | |||
| 45 | void Subtract(AddressType base_address, size_t size) { | ||
| 46 | AddressType end_address = base_address + static_cast<AddressType>(size); | ||
| 47 | IntervalType interval{base_address, end_address}; | ||
| 48 | m_ranges_set.subtract(interval); | ||
| 49 | } | ||
| 50 | |||
| 51 | template <typename Func> | ||
| 52 | void ForEach(Func&& func) const { | ||
| 53 | if (m_ranges_set.empty()) { | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | auto it = m_ranges_set.begin(); | ||
| 57 | auto end_it = m_ranges_set.end(); | ||
| 58 | for (; it != end_it; it++) { | ||
| 59 | const AddressType inter_addr_end = it->upper(); | ||
| 60 | const AddressType inter_addr = it->lower(); | ||
| 61 | func(inter_addr, inter_addr_end); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | template <typename Func> | ||
| 66 | void ForEachInRange(AddressType base_addr, size_t size, Func&& func) const { | ||
| 67 | if (m_ranges_set.empty()) { | ||
| 68 | return; | ||
| 69 | } | ||
| 70 | const AddressType start_address = base_addr; | ||
| 71 | const AddressType end_address = start_address + size; | ||
| 72 | const RangeSetImpl::IntervalType search_interval{start_address, end_address}; | ||
| 73 | auto it = m_ranges_set.lower_bound(search_interval); | ||
| 74 | if (it == m_ranges_set.end()) { | ||
| 75 | return; | ||
| 76 | } | ||
| 77 | auto end_it = m_ranges_set.upper_bound(search_interval); | ||
| 78 | for (; it != end_it; it++) { | ||
| 79 | AddressType inter_addr_end = it->upper(); | ||
| 80 | AddressType inter_addr = it->lower(); | ||
| 81 | if (inter_addr_end > end_address) { | ||
| 82 | inter_addr_end = end_address; | ||
| 83 | } | ||
| 84 | if (inter_addr < start_address) { | ||
| 85 | inter_addr = start_address; | ||
| 86 | } | ||
| 87 | func(inter_addr, inter_addr_end); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | IntervalSet m_ranges_set; | ||
| 92 | }; | ||
| 93 | |||
| 94 | template <typename AddressType> | ||
| 95 | struct OverlapRangeSet<AddressType>::OverlapRangeSetImpl { | ||
| 96 | using IntervalSet = boost::icl::split_interval_map< | ||
| 97 | AddressType, s32, boost::icl::partial_enricher, std::less, boost::icl::inplace_plus, | ||
| 98 | boost::icl::inter_section, | ||
| 99 | ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), RangeSetsAllocator>; | ||
| 100 | using IntervalType = typename IntervalSet::interval_type; | ||
| 101 | |||
| 102 | OverlapRangeSetImpl() = default; | ||
| 103 | ~OverlapRangeSetImpl() = default; | ||
| 104 | |||
| 105 | void Add(AddressType base_address, size_t size) { | ||
| 106 | AddressType end_address = base_address + static_cast<AddressType>(size); | ||
| 107 | IntervalType interval{base_address, end_address}; | ||
| 108 | m_split_ranges_set += std::make_pair(interval, 1); | ||
| 109 | } | ||
| 110 | |||
| 111 | template <bool has_on_delete, typename Func> | ||
| 112 | void Subtract(AddressType base_address, size_t size, s32 amount, | ||
| 113 | [[maybe_unused]] Func&& on_delete) { | ||
| 114 | if (m_split_ranges_set.empty()) { | ||
| 115 | return; | ||
| 116 | } | ||
| 117 | AddressType end_address = base_address + static_cast<AddressType>(size); | ||
| 118 | IntervalType interval{base_address, end_address}; | ||
| 119 | bool any_removals = false; | ||
| 120 | m_split_ranges_set += std::make_pair(interval, -amount); | ||
| 121 | do { | ||
| 122 | any_removals = false; | ||
| 123 | auto it = m_split_ranges_set.lower_bound(interval); | ||
| 124 | if (it == m_split_ranges_set.end()) { | ||
| 125 | return; | ||
| 126 | } | ||
| 127 | auto end_it = m_split_ranges_set.upper_bound(interval); | ||
| 128 | for (; it != end_it; it++) { | ||
| 129 | if (it->second <= 0) { | ||
| 130 | if constexpr (has_on_delete) { | ||
| 131 | if (it->second == 0) { | ||
| 132 | on_delete(it->first.lower(), it->first.upper()); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | any_removals = true; | ||
| 136 | m_split_ranges_set.erase(it); | ||
| 137 | break; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } while (any_removals); | ||
| 141 | } | ||
| 142 | |||
| 143 | template <typename Func> | ||
| 144 | void ForEach(Func&& func) const { | ||
| 145 | if (m_split_ranges_set.empty()) { | ||
| 146 | return; | ||
| 147 | } | ||
| 148 | auto it = m_split_ranges_set.begin(); | ||
| 149 | auto end_it = m_split_ranges_set.end(); | ||
| 150 | for (; it != end_it; it++) { | ||
| 151 | const AddressType inter_addr_end = it->first.upper(); | ||
| 152 | const AddressType inter_addr = it->first.lower(); | ||
| 153 | func(inter_addr, inter_addr_end, it->second); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | template <typename Func> | ||
| 158 | void ForEachInRange(AddressType base_address, size_t size, Func&& func) const { | ||
| 159 | if (m_split_ranges_set.empty()) { | ||
| 160 | return; | ||
| 161 | } | ||
| 162 | const AddressType start_address = base_address; | ||
| 163 | const AddressType end_address = start_address + size; | ||
| 164 | const OverlapRangeSetImpl::IntervalType search_interval{start_address, end_address}; | ||
| 165 | auto it = m_split_ranges_set.lower_bound(search_interval); | ||
| 166 | if (it == m_split_ranges_set.end()) { | ||
| 167 | return; | ||
| 168 | } | ||
| 169 | auto end_it = m_split_ranges_set.upper_bound(search_interval); | ||
| 170 | for (; it != end_it; it++) { | ||
| 171 | auto& inter = it->first; | ||
| 172 | AddressType inter_addr_end = inter.upper(); | ||
| 173 | AddressType inter_addr = inter.lower(); | ||
| 174 | if (inter_addr_end > end_address) { | ||
| 175 | inter_addr_end = end_address; | ||
| 176 | } | ||
| 177 | if (inter_addr < start_address) { | ||
| 178 | inter_addr = start_address; | ||
| 179 | } | ||
| 180 | func(inter_addr, inter_addr_end, it->second); | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | IntervalSet m_split_ranges_set; | ||
| 185 | }; | ||
| 186 | |||
| 187 | template <typename AddressType> | ||
| 188 | RangeSet<AddressType>::RangeSet() { | ||
| 189 | m_impl = std::make_unique<RangeSet<AddressType>::RangeSetImpl>(); | ||
| 190 | } | ||
| 191 | |||
| 192 | template <typename AddressType> | ||
| 193 | RangeSet<AddressType>::~RangeSet() = default; | ||
| 194 | |||
| 195 | template <typename AddressType> | ||
| 196 | RangeSet<AddressType>::RangeSet(RangeSet&& other) { | ||
| 197 | m_impl = std::make_unique<RangeSet<AddressType>::RangeSetImpl>(); | ||
| 198 | m_impl->m_ranges_set = std::move(other.m_impl->m_ranges_set); | ||
| 199 | } | ||
| 200 | |||
| 201 | template <typename AddressType> | ||
| 202 | RangeSet<AddressType>& RangeSet<AddressType>::operator=(RangeSet&& other) { | ||
| 203 | m_impl->m_ranges_set = std::move(other.m_impl->m_ranges_set); | ||
| 204 | } | ||
| 205 | |||
| 206 | template <typename AddressType> | ||
| 207 | void RangeSet<AddressType>::Add(AddressType base_address, size_t size) { | ||
| 208 | m_impl->Add(base_address, size); | ||
| 209 | } | ||
| 210 | |||
| 211 | template <typename AddressType> | ||
| 212 | void RangeSet<AddressType>::Subtract(AddressType base_address, size_t size) { | ||
| 213 | m_impl->Subtract(base_address, size); | ||
| 214 | } | ||
| 215 | |||
| 216 | template <typename AddressType> | ||
| 217 | void RangeSet<AddressType>::Clear() { | ||
| 218 | m_impl->m_ranges_set.clear(); | ||
| 219 | } | ||
| 220 | |||
| 221 | template <typename AddressType> | ||
| 222 | bool RangeSet<AddressType>::Empty() const { | ||
| 223 | return m_impl->m_ranges_set.empty(); | ||
| 224 | } | ||
| 225 | |||
| 226 | template <typename AddressType> | ||
| 227 | template <typename Func> | ||
| 228 | void RangeSet<AddressType>::ForEach(Func&& func) const { | ||
| 229 | m_impl->ForEach(std::move(func)); | ||
| 230 | } | ||
| 231 | |||
| 232 | template <typename AddressType> | ||
| 233 | template <typename Func> | ||
| 234 | void RangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, | ||
| 235 | Func&& func) const { | ||
| 236 | m_impl->ForEachInRange(base_address, size, std::move(func)); | ||
| 237 | } | ||
| 238 | |||
| 239 | template <typename AddressType> | ||
| 240 | OverlapRangeSet<AddressType>::OverlapRangeSet() { | ||
| 241 | m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>(); | ||
| 242 | } | ||
| 243 | |||
| 244 | template <typename AddressType> | ||
| 245 | OverlapRangeSet<AddressType>::~OverlapRangeSet() = default; | ||
| 246 | |||
| 247 | template <typename AddressType> | ||
| 248 | OverlapRangeSet<AddressType>::OverlapRangeSet(OverlapRangeSet&& other) { | ||
| 249 | m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>(); | ||
| 250 | m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); | ||
| 251 | } | ||
| 252 | |||
| 253 | template <typename AddressType> | ||
| 254 | OverlapRangeSet<AddressType>& OverlapRangeSet<AddressType>::operator=(OverlapRangeSet&& other) { | ||
| 255 | m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); | ||
| 256 | } | ||
| 257 | |||
| 258 | template <typename AddressType> | ||
| 259 | void OverlapRangeSet<AddressType>::Add(AddressType base_address, size_t size) { | ||
| 260 | m_impl->Add(base_address, size); | ||
| 261 | } | ||
| 262 | |||
| 263 | template <typename AddressType> | ||
| 264 | void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t size) { | ||
| 265 | m_impl->template Subtract<false>(base_address, size, 1, [](AddressType, AddressType) {}); | ||
| 266 | } | ||
| 267 | |||
| 268 | template <typename AddressType> | ||
| 269 | template <typename Func> | ||
| 270 | void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t size, | ||
| 271 | Func&& on_delete) { | ||
| 272 | m_impl->template Subtract<true, Func>(base_address, size, 1, std::move(on_delete)); | ||
| 273 | } | ||
| 274 | |||
| 275 | template <typename AddressType> | ||
| 276 | void OverlapRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) { | ||
| 277 | m_impl->template Subtract<false>(base_address, size, std::numeric_limits<s32>::max(), | ||
| 278 | [](AddressType, AddressType) {}); | ||
| 279 | } | ||
| 280 | |||
| 281 | template <typename AddressType> | ||
| 282 | void OverlapRangeSet<AddressType>::Clear() { | ||
| 283 | m_impl->m_split_ranges_set.clear(); | ||
| 284 | } | ||
| 285 | |||
| 286 | template <typename AddressType> | ||
| 287 | bool OverlapRangeSet<AddressType>::Empty() const { | ||
| 288 | return m_impl->m_split_ranges_set.empty(); | ||
| 289 | } | ||
| 290 | |||
| 291 | template <typename AddressType> | ||
| 292 | template <typename Func> | ||
| 293 | void OverlapRangeSet<AddressType>::ForEach(Func&& func) const { | ||
| 294 | m_impl->ForEach(func); | ||
| 295 | } | ||
| 296 | |||
| 297 | template <typename AddressType> | ||
| 298 | template <typename Func> | ||
| 299 | void OverlapRangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, | ||
| 300 | Func&& func) const { | ||
| 301 | m_impl->ForEachInRange(base_address, size, std::move(func)); | ||
| 302 | } | ||
| 303 | |||
| 304 | } // namespace Common | ||
diff --git a/src/video_core/texture_cache/slot_vector.h b/src/common/slot_vector.h index 3ffa2a661..34ff7de94 100644 --- a/src/video_core/texture_cache/slot_vector.h +++ b/src/common/slot_vector.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/polyfill_ranges.h" | 15 | #include "common/polyfill_ranges.h" |
| 16 | 16 | ||
| 17 | namespace VideoCommon { | 17 | namespace Common { |
| 18 | 18 | ||
| 19 | struct SlotId { | 19 | struct SlotId { |
| 20 | static constexpr u32 INVALID_INDEX = std::numeric_limits<u32>::max(); | 20 | static constexpr u32 INVALID_INDEX = std::numeric_limits<u32>::max(); |
| @@ -217,11 +217,11 @@ private: | |||
| 217 | std::vector<u32> free_list; | 217 | std::vector<u32> free_list; |
| 218 | }; | 218 | }; |
| 219 | 219 | ||
| 220 | } // namespace VideoCommon | 220 | } // namespace Common |
| 221 | 221 | ||
| 222 | template <> | 222 | template <> |
| 223 | struct std::hash<VideoCommon::SlotId> { | 223 | struct std::hash<Common::SlotId> { |
| 224 | size_t operator()(const VideoCommon::SlotId& id) const noexcept { | 224 | size_t operator()(const Common::SlotId& id) const noexcept { |
| 225 | return std::hash<u32>{}(id.index); | 225 | return std::hash<u32>{}(id.index); |
| 226 | } | 226 | } |
| 227 | }; | 227 | }; |
diff --git a/src/common/typed_address.h b/src/common/typed_address.h index 64f4a07c2..d5e743583 100644 --- a/src/common/typed_address.h +++ b/src/common/typed_address.h | |||
| @@ -186,68 +186,68 @@ static_assert(std::is_trivially_destructible_v<PhysicalAddress>); | |||
| 186 | static_assert(std::is_trivially_destructible_v<VirtualAddress>); | 186 | static_assert(std::is_trivially_destructible_v<VirtualAddress>); |
| 187 | static_assert(std::is_trivially_destructible_v<ProcessAddress>); | 187 | static_assert(std::is_trivially_destructible_v<ProcessAddress>); |
| 188 | 188 | ||
| 189 | static_assert(Null<uint64_t> == 0); | 189 | static_assert(Null<uint64_t> == 0U); |
| 190 | static_assert(Null<PhysicalAddress> == Null<uint64_t>); | 190 | static_assert(Null<PhysicalAddress> == Null<uint64_t>); |
| 191 | static_assert(Null<VirtualAddress> == Null<uint64_t>); | 191 | static_assert(Null<VirtualAddress> == Null<uint64_t>); |
| 192 | static_assert(Null<ProcessAddress> == Null<uint64_t>); | 192 | static_assert(Null<ProcessAddress> == Null<uint64_t>); |
| 193 | 193 | ||
| 194 | // Constructor/assignment validations. | 194 | // Constructor/assignment validations. |
| 195 | static_assert([] { | 195 | static_assert([] { |
| 196 | const PhysicalAddress a(5); | 196 | const PhysicalAddress a(5U); |
| 197 | PhysicalAddress b(a); | 197 | PhysicalAddress b(a); |
| 198 | return b; | 198 | return b; |
| 199 | }() == PhysicalAddress(5)); | 199 | }() == PhysicalAddress(5U)); |
| 200 | static_assert([] { | 200 | static_assert([] { |
| 201 | const PhysicalAddress a(5); | 201 | const PhysicalAddress a(5U); |
| 202 | PhysicalAddress b(10); | 202 | PhysicalAddress b(10U); |
| 203 | b = a; | 203 | b = a; |
| 204 | return b; | 204 | return b; |
| 205 | }() == PhysicalAddress(5)); | 205 | }() == PhysicalAddress(5U)); |
| 206 | 206 | ||
| 207 | // Arithmetic validations. | 207 | // Arithmetic validations. |
| 208 | static_assert(PhysicalAddress(10) + 5 == PhysicalAddress(15)); | 208 | static_assert(PhysicalAddress(10U) + 5U == PhysicalAddress(15U)); |
| 209 | static_assert(PhysicalAddress(10) - 5 == PhysicalAddress(5)); | 209 | static_assert(PhysicalAddress(10U) - 5U == PhysicalAddress(5U)); |
| 210 | static_assert([] { | 210 | static_assert([] { |
| 211 | PhysicalAddress v(10); | 211 | PhysicalAddress v(10U); |
| 212 | v += 5; | 212 | v += 5U; |
| 213 | return v; | 213 | return v; |
| 214 | }() == PhysicalAddress(15)); | 214 | }() == PhysicalAddress(15U)); |
| 215 | static_assert([] { | 215 | static_assert([] { |
| 216 | PhysicalAddress v(10); | 216 | PhysicalAddress v(10U); |
| 217 | v -= 5; | 217 | v -= 5U; |
| 218 | return v; | 218 | return v; |
| 219 | }() == PhysicalAddress(5)); | 219 | }() == PhysicalAddress(5U)); |
| 220 | static_assert(PhysicalAddress(10)++ == PhysicalAddress(10)); | 220 | static_assert(PhysicalAddress(10U)++ == PhysicalAddress(10U)); |
| 221 | static_assert(++PhysicalAddress(10) == PhysicalAddress(11)); | 221 | static_assert(++PhysicalAddress(10U) == PhysicalAddress(11U)); |
| 222 | static_assert(PhysicalAddress(10)-- == PhysicalAddress(10)); | 222 | static_assert(PhysicalAddress(10U)-- == PhysicalAddress(10U)); |
| 223 | static_assert(--PhysicalAddress(10) == PhysicalAddress(9)); | 223 | static_assert(--PhysicalAddress(10U) == PhysicalAddress(9U)); |
| 224 | 224 | ||
| 225 | // Logical validations. | 225 | // Logical validations. |
| 226 | static_assert((PhysicalAddress(0b11111111) >> 1) == 0b01111111); | 226 | static_assert((PhysicalAddress(0b11111111U) >> 1) == 0b01111111U); |
| 227 | static_assert((PhysicalAddress(0b10101010) >> 1) == 0b01010101); | 227 | static_assert((PhysicalAddress(0b10101010U) >> 1) == 0b01010101U); |
| 228 | static_assert((PhysicalAddress(0b11111111) << 1) == 0b111111110); | 228 | static_assert((PhysicalAddress(0b11111111U) << 1) == 0b111111110U); |
| 229 | static_assert((PhysicalAddress(0b01010101) << 1) == 0b10101010); | 229 | static_assert((PhysicalAddress(0b01010101U) << 1) == 0b10101010U); |
| 230 | static_assert((PhysicalAddress(0b11111111) & 0b01010101) == 0b01010101); | 230 | static_assert((PhysicalAddress(0b11111111U) & 0b01010101U) == 0b01010101U); |
| 231 | static_assert((PhysicalAddress(0b11111111) & 0b10101010) == 0b10101010); | 231 | static_assert((PhysicalAddress(0b11111111U) & 0b10101010U) == 0b10101010U); |
| 232 | static_assert((PhysicalAddress(0b01010101) & 0b10101010) == 0b00000000); | 232 | static_assert((PhysicalAddress(0b01010101U) & 0b10101010U) == 0b00000000U); |
| 233 | static_assert((PhysicalAddress(0b00000000) | 0b01010101) == 0b01010101); | 233 | static_assert((PhysicalAddress(0b00000000U) | 0b01010101U) == 0b01010101U); |
| 234 | static_assert((PhysicalAddress(0b11111111) | 0b01010101) == 0b11111111); | 234 | static_assert((PhysicalAddress(0b11111111U) | 0b01010101U) == 0b11111111U); |
| 235 | static_assert((PhysicalAddress(0b10101010) | 0b01010101) == 0b11111111); | 235 | static_assert((PhysicalAddress(0b10101010U) | 0b01010101U) == 0b11111111U); |
| 236 | 236 | ||
| 237 | // Comparisons. | 237 | // Comparisons. |
| 238 | static_assert(PhysicalAddress(0) == PhysicalAddress(0)); | 238 | static_assert(PhysicalAddress(0U) == PhysicalAddress(0U)); |
| 239 | static_assert(PhysicalAddress(0) != PhysicalAddress(1)); | 239 | static_assert(PhysicalAddress(0U) != PhysicalAddress(1U)); |
| 240 | static_assert(PhysicalAddress(0) < PhysicalAddress(1)); | 240 | static_assert(PhysicalAddress(0U) < PhysicalAddress(1U)); |
| 241 | static_assert(PhysicalAddress(0) <= PhysicalAddress(1)); | 241 | static_assert(PhysicalAddress(0U) <= PhysicalAddress(1U)); |
| 242 | static_assert(PhysicalAddress(1) > PhysicalAddress(0)); | 242 | static_assert(PhysicalAddress(1U) > PhysicalAddress(0U)); |
| 243 | static_assert(PhysicalAddress(1) >= PhysicalAddress(0)); | 243 | static_assert(PhysicalAddress(1U) >= PhysicalAddress(0U)); |
| 244 | 244 | ||
| 245 | static_assert(!(PhysicalAddress(0) == PhysicalAddress(1))); | 245 | static_assert(!(PhysicalAddress(0U) == PhysicalAddress(1U))); |
| 246 | static_assert(!(PhysicalAddress(0) != PhysicalAddress(0))); | 246 | static_assert(!(PhysicalAddress(0U) != PhysicalAddress(0U))); |
| 247 | static_assert(!(PhysicalAddress(1) < PhysicalAddress(0))); | 247 | static_assert(!(PhysicalAddress(1U) < PhysicalAddress(0U))); |
| 248 | static_assert(!(PhysicalAddress(1) <= PhysicalAddress(0))); | 248 | static_assert(!(PhysicalAddress(1U) <= PhysicalAddress(0U))); |
| 249 | static_assert(!(PhysicalAddress(0) > PhysicalAddress(1))); | 249 | static_assert(!(PhysicalAddress(0U) > PhysicalAddress(1U))); |
| 250 | static_assert(!(PhysicalAddress(0) >= PhysicalAddress(1))); | 250 | static_assert(!(PhysicalAddress(0U) >= PhysicalAddress(1U))); |
| 251 | 251 | ||
| 252 | } // namespace Common | 252 | } // namespace Common |
| 253 | 253 | ||
diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index f2a407dc8..452f565be 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp | |||
| @@ -383,7 +383,7 @@ std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const | |||
| 383 | } else if (id == CPSR_REGISTER) { | 383 | } else if (id == CPSR_REGISTER) { |
| 384 | return ValueToHex(context.pstate); | 384 | return ValueToHex(context.pstate); |
| 385 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { | 385 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { |
| 386 | return ValueToHex(fprs[id - D0_REGISTER][0]); | 386 | return ValueToHex(fprs[(id - D0_REGISTER) / 2][(id - D0_REGISTER) % 2]); |
| 387 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { | 387 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { |
| 388 | return ValueToHex(fprs[id - Q0_REGISTER]); | 388 | return ValueToHex(fprs[id - Q0_REGISTER]); |
| 389 | } else if (id == FPSCR_REGISTER) { | 389 | } else if (id == FPSCR_REGISTER) { |
| @@ -406,7 +406,7 @@ void GDBStubA32::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 406 | } else if (id == CPSR_REGISTER) { | 406 | } else if (id == CPSR_REGISTER) { |
| 407 | context.pstate = HexToValue<u32>(value); | 407 | context.pstate = HexToValue<u32>(value); |
| 408 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { | 408 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { |
| 409 | fprs[id - D0_REGISTER] = {HexToValue<u64>(value), 0}; | 409 | fprs[(id - D0_REGISTER) / 2][(id - D0_REGISTER) % 2] = HexToValue<u64>(value); |
| 410 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { | 410 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { |
| 411 | fprs[id - Q0_REGISTER] = HexToValue<u128>(value); | 411 | fprs[id - Q0_REGISTER] = HexToValue<u128>(value); |
| 412 | } else if (id == FPSCR_REGISTER) { | 412 | } else if (id == FPSCR_REGISTER) { |
diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index b026f4220..6dfee806c 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc | |||
| @@ -532,6 +532,7 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size | |||
| 532 | cache_bytes = 0; | 532 | cache_bytes = 0; |
| 533 | } | 533 | } |
| 534 | }; | 534 | }; |
| 535 | size_t old_vpage = (base_vaddress >> Memory::YUZU_PAGEBITS) - 1; | ||
| 535 | for (; page != page_end; ++page) { | 536 | for (; page != page_end; ++page) { |
| 536 | CounterAtomicType& count = cached_pages->at(page >> subentries_shift).Count(page); | 537 | CounterAtomicType& count = cached_pages->at(page >> subentries_shift).Count(page); |
| 537 | auto [asid_2, vpage] = ExtractCPUBacking(page); | 538 | auto [asid_2, vpage] = ExtractCPUBacking(page); |
| @@ -547,6 +548,12 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size | |||
| 547 | memory_device_inter = registered_processes[asid_2.id]; | 548 | memory_device_inter = registered_processes[asid_2.id]; |
| 548 | } | 549 | } |
| 549 | 550 | ||
| 551 | if (vpage != old_vpage + 1) [[unlikely]] { | ||
| 552 | release_pending(); | ||
| 553 | } | ||
| 554 | |||
| 555 | old_vpage = vpage; | ||
| 556 | |||
| 550 | // Adds or subtracts 1, as count is a unsigned 8-bit value | 557 | // Adds or subtracts 1, as count is a unsigned 8-bit value |
| 551 | count.fetch_add(static_cast<CounterType>(delta), std::memory_order_release); | 558 | count.fetch_add(static_cast<CounterType>(delta), std::memory_order_release); |
| 552 | 559 | ||
diff --git a/src/core/hle/service/cmif_types.h b/src/core/hle/service/cmif_types.h index 84f4c2456..325304d5c 100644 --- a/src/core/hle/service/cmif_types.h +++ b/src/core/hle/service/cmif_types.h | |||
| @@ -262,7 +262,7 @@ class OutLargeData { | |||
| 262 | public: | 262 | public: |
| 263 | static_assert(std::is_trivially_copyable_v<T>, "LargeData type must be trivially copyable"); | 263 | static_assert(std::is_trivially_copyable_v<T>, "LargeData type must be trivially copyable"); |
| 264 | static_assert((A & BufferAttr_In) == 0, "OutLargeData attr must not be In"); | 264 | static_assert((A & BufferAttr_In) == 0, "OutLargeData attr must not be In"); |
| 265 | static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize); | 265 | static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_Out | BufferAttr_FixedSize); |
| 266 | using Type = T; | 266 | using Type = T; |
| 267 | 267 | ||
| 268 | /* implicit */ OutLargeData(const OutLargeData& t) : raw(t.raw) {} | 268 | /* implicit */ OutLargeData(const OutLargeData& t) : raw(t.raw) {} |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index b60fb9139..1fa9cfbfb 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -36,7 +36,7 @@ void LoopProcess(Core::System& system) { | |||
| 36 | server_manager->RegisterNamedService( | 36 | server_manager->RegisterNamedService( |
| 37 | "hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings)); | 37 | "hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings)); |
| 38 | 38 | ||
| 39 | server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system)); | 39 | server_manager->RegisterNamedService("hidbus", std::make_shared<Hidbus>(system)); |
| 40 | 40 | ||
| 41 | server_manager->RegisterNamedService("irs", std::make_shared<IRS::IRS>(system)); | 41 | server_manager->RegisterNamedService("irs", std::make_shared<IRS::IRS>(system)); |
| 42 | server_manager->RegisterNamedService("irs:sys", std::make_shared<IRS::IRS_SYS>(system)); | 42 | server_manager->RegisterNamedService("irs:sys", std::make_shared<IRS::IRS_SYS>(system)); |
diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp index 610af34dd..4e2663672 100644 --- a/src/core/hle/service/hid/hid_debug_server.cpp +++ b/src/core/hle/service/hid/hid_debug_server.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_serialization.h" | ||
| 6 | #include "core/hle/service/hid/hid_debug_server.h" | 7 | #include "core/hle/service/hid/hid_debug_server.h" |
| 7 | #include "core/hle/service/ipc_helpers.h" | 8 | #include "core/hle/service/ipc_helpers.h" |
| 8 | #include "hid_core/hid_types.h" | 9 | #include "hid_core/hid_types.h" |
| @@ -11,7 +12,6 @@ | |||
| 11 | 12 | ||
| 12 | #include "hid_core/resources/touch_screen/gesture.h" | 13 | #include "hid_core/resources/touch_screen/gesture.h" |
| 13 | #include "hid_core/resources/touch_screen/touch_screen.h" | 14 | #include "hid_core/resources/touch_screen/touch_screen.h" |
| 14 | #include "hid_core/resources/touch_screen/touch_types.h" | ||
| 15 | 15 | ||
| 16 | namespace Service::HID { | 16 | namespace Service::HID { |
| 17 | 17 | ||
| @@ -24,14 +24,14 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource | |||
| 24 | {0, nullptr, "DeactivateDebugPad"}, | 24 | {0, nullptr, "DeactivateDebugPad"}, |
| 25 | {1, nullptr, "SetDebugPadAutoPilotState"}, | 25 | {1, nullptr, "SetDebugPadAutoPilotState"}, |
| 26 | {2, nullptr, "UnsetDebugPadAutoPilotState"}, | 26 | {2, nullptr, "UnsetDebugPadAutoPilotState"}, |
| 27 | {10, &IHidDebugServer::DeactivateTouchScreen, "DeactivateTouchScreen"}, | 27 | {10, C<&IHidDebugServer::DeactivateTouchScreen>, "DeactivateTouchScreen"}, |
| 28 | {11, &IHidDebugServer::SetTouchScreenAutoPilotState, "SetTouchScreenAutoPilotState"}, | 28 | {11, C<&IHidDebugServer::SetTouchScreenAutoPilotState>, "SetTouchScreenAutoPilotState"}, |
| 29 | {12, &IHidDebugServer::UnsetTouchScreenAutoPilotState, "UnsetTouchScreenAutoPilotState"}, | 29 | {12, C<&IHidDebugServer::UnsetTouchScreenAutoPilotState>, "UnsetTouchScreenAutoPilotState"}, |
| 30 | {13, &IHidDebugServer::GetTouchScreenConfiguration, "GetTouchScreenConfiguration"}, | 30 | {13, C<&IHidDebugServer::GetTouchScreenConfiguration>, "GetTouchScreenConfiguration"}, |
| 31 | {14, &IHidDebugServer::ProcessTouchScreenAutoTune, "ProcessTouchScreenAutoTune"}, | 31 | {14, C<&IHidDebugServer::ProcessTouchScreenAutoTune>, "ProcessTouchScreenAutoTune"}, |
| 32 | {15, &IHidDebugServer::ForceStopTouchScreenManagement, "ForceStopTouchScreenManagement"}, | 32 | {15, C<&IHidDebugServer::ForceStopTouchScreenManagement>, "ForceStopTouchScreenManagement"}, |
| 33 | {16, &IHidDebugServer::ForceRestartTouchScreenManagement, "ForceRestartTouchScreenManagement"}, | 33 | {16, C<&IHidDebugServer::ForceRestartTouchScreenManagement>, "ForceRestartTouchScreenManagement"}, |
| 34 | {17, &IHidDebugServer::IsTouchScreenManaged, "IsTouchScreenManaged"}, | 34 | {17, C<&IHidDebugServer::IsTouchScreenManaged>, "IsTouchScreenManaged"}, |
| 35 | {20, nullptr, "DeactivateMouse"}, | 35 | {20, nullptr, "DeactivateMouse"}, |
| 36 | {21, nullptr, "SetMouseAutoPilotState"}, | 36 | {21, nullptr, "SetMouseAutoPilotState"}, |
| 37 | {22, nullptr, "UnsetMouseAutoPilotState"}, | 37 | {22, nullptr, "UnsetMouseAutoPilotState"}, |
| @@ -47,7 +47,7 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource | |||
| 47 | {60, nullptr, "ClearNpadSystemCommonPolicy"}, | 47 | {60, nullptr, "ClearNpadSystemCommonPolicy"}, |
| 48 | {61, nullptr, "DeactivateNpad"}, | 48 | {61, nullptr, "DeactivateNpad"}, |
| 49 | {62, nullptr, "ForceDisconnectNpad"}, | 49 | {62, nullptr, "ForceDisconnectNpad"}, |
| 50 | {91, &IHidDebugServer::DeactivateGesture, "DeactivateGesture"}, | 50 | {91, C<&IHidDebugServer::DeactivateGesture>, "DeactivateGesture"}, |
| 51 | {110, nullptr, "DeactivateHomeButton"}, | 51 | {110, nullptr, "DeactivateHomeButton"}, |
| 52 | {111, nullptr, "SetHomeButtonAutoPilotState"}, | 52 | {111, nullptr, "SetHomeButtonAutoPilotState"}, |
| 53 | {112, nullptr, "UnsetHomeButtonAutoPilotState"}, | 53 | {112, nullptr, "UnsetHomeButtonAutoPilotState"}, |
| @@ -160,169 +160,122 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | IHidDebugServer::~IHidDebugServer() = default; | 162 | IHidDebugServer::~IHidDebugServer() = default; |
| 163 | void IHidDebugServer::DeactivateTouchScreen(HLERequestContext& ctx) { | ||
| 164 | LOG_INFO(Service_HID, "called"); | ||
| 165 | 163 | ||
| 166 | Result result = ResultSuccess; | 164 | Result IHidDebugServer::DeactivateTouchScreen() { |
| 165 | LOG_INFO(Service_HID, "called"); | ||
| 167 | 166 | ||
| 168 | if (!firmware_settings->IsDeviceManaged()) { | 167 | if (!firmware_settings->IsDeviceManaged()) { |
| 169 | result = GetResourceManager()->GetTouchScreen()->Deactivate(); | 168 | R_RETURN(GetResourceManager()->GetTouchScreen()->Deactivate()); |
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | IPC::ResponseBuilder rb{ctx, 2}; | 171 | R_SUCCEED(); |
| 173 | rb.Push(result); | ||
| 174 | } | 172 | } |
| 175 | 173 | ||
| 176 | void IHidDebugServer::SetTouchScreenAutoPilotState(HLERequestContext& ctx) { | 174 | Result IHidDebugServer::SetTouchScreenAutoPilotState( |
| 175 | InArray<TouchState, BufferAttr_HipcMapAlias> auto_pilot_buffer) { | ||
| 177 | AutoPilotState auto_pilot{}; | 176 | AutoPilotState auto_pilot{}; |
| 178 | auto_pilot.count = ctx.GetReadBufferNumElements<TouchState>(); | ||
| 179 | const auto buffer = ctx.ReadBuffer(); | ||
| 180 | 177 | ||
| 181 | auto_pilot.count = std::min(auto_pilot.count, static_cast<u64>(auto_pilot.state.size())); | 178 | auto_pilot.count = |
| 182 | memcpy(auto_pilot.state.data(), buffer.data(), auto_pilot.count * sizeof(TouchState)); | 179 | static_cast<u64>(std::min(auto_pilot_buffer.size(), auto_pilot.state.size())); |
| 180 | memcpy(auto_pilot.state.data(), auto_pilot_buffer.data(), | ||
| 181 | auto_pilot.count * sizeof(TouchState)); | ||
| 183 | 182 | ||
| 184 | LOG_INFO(Service_HID, "called, auto_pilot_count={}", auto_pilot.count); | 183 | LOG_INFO(Service_HID, "called, auto_pilot_count={}", auto_pilot.count); |
| 185 | 184 | ||
| 186 | const Result result = | 185 | R_RETURN(GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot)); |
| 187 | GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot); | ||
| 188 | |||
| 189 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 190 | rb.Push(result); | ||
| 191 | } | 186 | } |
| 192 | 187 | ||
| 193 | void IHidDebugServer::UnsetTouchScreenAutoPilotState(HLERequestContext& ctx) { | 188 | Result IHidDebugServer::UnsetTouchScreenAutoPilotState() { |
| 194 | LOG_INFO(Service_HID, "called"); | 189 | LOG_INFO(Service_HID, "called"); |
| 195 | 190 | R_RETURN(GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState()); | |
| 196 | const Result result = GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState(); | ||
| 197 | |||
| 198 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 199 | rb.Push(result); | ||
| 200 | } | 191 | } |
| 201 | 192 | ||
| 202 | void IHidDebugServer::GetTouchScreenConfiguration(HLERequestContext& ctx) { | 193 | Result IHidDebugServer::GetTouchScreenConfiguration( |
| 203 | IPC::RequestParser rp{ctx}; | 194 | Out<Core::HID::TouchScreenConfigurationForNx> out_touchscreen_config, |
| 204 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 195 | ClientAppletResourceUserId aruid) { |
| 205 | 196 | LOG_INFO(Service_HID, "called, applet_resource_user_id={}", aruid.pid); | |
| 206 | LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 207 | 197 | ||
| 208 | Core::HID::TouchScreenConfigurationForNx touchscreen_config{}; | 198 | R_TRY(GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration( |
| 209 | const Result result = GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration( | 199 | *out_touchscreen_config, aruid.pid)); |
| 210 | touchscreen_config, applet_resource_user_id); | ||
| 211 | 200 | ||
| 212 | if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 && | 201 | if (out_touchscreen_config->mode != Core::HID::TouchScreenModeForNx::Heat2 && |
| 213 | touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) { | 202 | out_touchscreen_config->mode != Core::HID::TouchScreenModeForNx::Finger) { |
| 214 | touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting; | 203 | out_touchscreen_config->mode = Core::HID::TouchScreenModeForNx::UseSystemSetting; |
| 215 | } | 204 | } |
| 216 | 205 | ||
| 217 | IPC::ResponseBuilder rb{ctx, 6}; | 206 | R_SUCCEED(); |
| 218 | rb.Push(result); | ||
| 219 | rb.PushRaw(touchscreen_config); | ||
| 220 | } | 207 | } |
| 221 | 208 | ||
| 222 | void IHidDebugServer::ProcessTouchScreenAutoTune(HLERequestContext& ctx) { | 209 | Result IHidDebugServer::ProcessTouchScreenAutoTune() { |
| 223 | LOG_INFO(Service_HID, "called"); | 210 | LOG_INFO(Service_HID, "called"); |
| 224 | 211 | R_RETURN(GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune()); | |
| 225 | Result result = GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune(); | ||
| 226 | |||
| 227 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 228 | rb.Push(result); | ||
| 229 | } | 212 | } |
| 230 | 213 | ||
| 231 | void IHidDebugServer::ForceStopTouchScreenManagement(HLERequestContext& ctx) { | 214 | Result IHidDebugServer::ForceStopTouchScreenManagement() { |
| 232 | LOG_INFO(Service_HID, "called"); | 215 | LOG_INFO(Service_HID, "called"); |
| 233 | 216 | ||
| 234 | if (!firmware_settings->IsDeviceManaged()) { | 217 | if (!firmware_settings->IsDeviceManaged()) { |
| 235 | IPC::ResponseBuilder rb{ctx, 2}; | 218 | R_SUCCEED(); |
| 236 | rb.Push(ResultSuccess); | ||
| 237 | return; | ||
| 238 | } | 219 | } |
| 239 | 220 | ||
| 240 | Result result = ResultSuccess; | ||
| 241 | bool is_touch_active{}; | ||
| 242 | bool is_gesture_active{}; | ||
| 243 | auto touch_screen = GetResourceManager()->GetTouchScreen(); | 221 | auto touch_screen = GetResourceManager()->GetTouchScreen(); |
| 244 | auto gesture = GetResourceManager()->GetGesture(); | 222 | auto gesture = GetResourceManager()->GetGesture(); |
| 245 | 223 | ||
| 246 | if (firmware_settings->IsTouchI2cManaged()) { | 224 | if (firmware_settings->IsTouchI2cManaged()) { |
| 247 | result = touch_screen->IsActive(is_touch_active); | 225 | bool is_touch_active{}; |
| 248 | if (result.IsSuccess()) { | 226 | bool is_gesture_active{}; |
| 249 | result = gesture->IsActive(is_gesture_active); | 227 | R_TRY(touch_screen->IsActive(is_touch_active)); |
| 250 | } | 228 | R_TRY(gesture->IsActive(is_gesture_active)); |
| 251 | if (result.IsSuccess() && is_touch_active) { | 229 | |
| 252 | result = touch_screen->Deactivate(); | 230 | if (is_touch_active) { |
| 231 | R_TRY(touch_screen->Deactivate()); | ||
| 253 | } | 232 | } |
| 254 | if (result.IsSuccess() && is_gesture_active) { | 233 | if (is_gesture_active) { |
| 255 | result = gesture->Deactivate(); | 234 | R_TRY(gesture->Deactivate()); |
| 256 | } | 235 | } |
| 257 | } | 236 | } |
| 258 | 237 | ||
| 259 | IPC::ResponseBuilder rb{ctx, 2}; | 238 | R_SUCCEED(); |
| 260 | rb.Push(result); | ||
| 261 | } | 239 | } |
| 262 | 240 | ||
| 263 | void IHidDebugServer::ForceRestartTouchScreenManagement(HLERequestContext& ctx) { | 241 | Result IHidDebugServer::ForceRestartTouchScreenManagement(u32 basic_gesture_id, |
| 264 | IPC::RequestParser rp{ctx}; | 242 | ClientAppletResourceUserId aruid) { |
| 265 | struct Parameters { | ||
| 266 | u32 basic_gesture_id; | ||
| 267 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 268 | u64 applet_resource_user_id; | ||
| 269 | }; | ||
| 270 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 271 | |||
| 272 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 273 | |||
| 274 | LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}", | 243 | LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}", |
| 275 | parameters.basic_gesture_id, parameters.applet_resource_user_id); | 244 | basic_gesture_id, aruid.pid); |
| 276 | 245 | ||
| 277 | Result result = ResultSuccess; | ||
| 278 | auto touch_screen = GetResourceManager()->GetTouchScreen(); | 246 | auto touch_screen = GetResourceManager()->GetTouchScreen(); |
| 279 | auto gesture = GetResourceManager()->GetGesture(); | 247 | auto gesture = GetResourceManager()->GetGesture(); |
| 280 | 248 | ||
| 281 | if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) { | 249 | if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) { |
| 282 | result = gesture->Activate(); | 250 | R_TRY(gesture->Activate()); |
| 283 | if (result.IsSuccess()) { | 251 | R_TRY(gesture->Activate(aruid.pid, basic_gesture_id)); |
| 284 | result = | 252 | R_TRY(touch_screen->Activate()); |
| 285 | gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id); | 253 | R_TRY(touch_screen->Activate(aruid.pid)); |
| 286 | } | ||
| 287 | if (result.IsSuccess()) { | ||
| 288 | result = touch_screen->Activate(); | ||
| 289 | } | ||
| 290 | if (result.IsSuccess()) { | ||
| 291 | result = touch_screen->Activate(parameters.applet_resource_user_id); | ||
| 292 | } | ||
| 293 | } | 254 | } |
| 294 | 255 | ||
| 295 | IPC::ResponseBuilder rb{ctx, 2}; | 256 | R_SUCCEED(); |
| 296 | rb.Push(result); | ||
| 297 | } | 257 | } |
| 298 | 258 | ||
| 299 | void IHidDebugServer::IsTouchScreenManaged(HLERequestContext& ctx) { | 259 | Result IHidDebugServer::IsTouchScreenManaged(Out<bool> out_is_managed) { |
| 300 | LOG_INFO(Service_HID, "called"); | 260 | LOG_INFO(Service_HID, "called"); |
| 301 | 261 | ||
| 302 | bool is_touch_active{}; | 262 | bool is_touch_active{}; |
| 303 | bool is_gesture_active{}; | 263 | bool is_gesture_active{}; |
| 264 | R_TRY(GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active)); | ||
| 265 | R_TRY(GetResourceManager()->GetGesture()->IsActive(is_gesture_active)); | ||
| 304 | 266 | ||
| 305 | Result result = GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active); | 267 | *out_is_managed = is_touch_active || is_gesture_active; |
| 306 | if (result.IsSuccess()) { | 268 | R_SUCCEED(); |
| 307 | result = GetResourceManager()->GetGesture()->IsActive(is_gesture_active); | ||
| 308 | } | ||
| 309 | |||
| 310 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 311 | rb.Push(result); | ||
| 312 | rb.Push(is_touch_active | is_gesture_active); | ||
| 313 | } | 269 | } |
| 314 | 270 | ||
| 315 | void IHidDebugServer::DeactivateGesture(HLERequestContext& ctx) { | 271 | Result IHidDebugServer::DeactivateGesture() { |
| 316 | LOG_INFO(Service_HID, "called"); | 272 | LOG_INFO(Service_HID, "called"); |
| 317 | 273 | ||
| 318 | Result result = ResultSuccess; | ||
| 319 | |||
| 320 | if (!firmware_settings->IsDeviceManaged()) { | 274 | if (!firmware_settings->IsDeviceManaged()) { |
| 321 | result = GetResourceManager()->GetGesture()->Deactivate(); | 275 | R_RETURN(GetResourceManager()->GetGesture()->Deactivate()); |
| 322 | } | 276 | } |
| 323 | 277 | ||
| 324 | IPC::ResponseBuilder rb{ctx, 2}; | 278 | R_SUCCEED(); |
| 325 | rb.Push(result); | ||
| 326 | } | 279 | } |
| 327 | 280 | ||
| 328 | std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() { | 281 | std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() { |
diff --git a/src/core/hle/service/hid/hid_debug_server.h b/src/core/hle/service/hid/hid_debug_server.h index 7d5b082b3..3a483f07e 100644 --- a/src/core/hle/service/hid/hid_debug_server.h +++ b/src/core/hle/service/hid/hid_debug_server.h | |||
| @@ -3,7 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | #include "hid_core/resources/touch_screen/touch_types.h" | ||
| 7 | 9 | ||
| 8 | namespace Core { | 10 | namespace Core { |
| 9 | class System; | 11 | class System; |
| @@ -20,15 +22,19 @@ public: | |||
| 20 | ~IHidDebugServer() override; | 22 | ~IHidDebugServer() override; |
| 21 | 23 | ||
| 22 | private: | 24 | private: |
| 23 | void DeactivateTouchScreen(HLERequestContext& ctx); | 25 | Result DeactivateTouchScreen(); |
| 24 | void SetTouchScreenAutoPilotState(HLERequestContext& ctx); | 26 | Result SetTouchScreenAutoPilotState( |
| 25 | void UnsetTouchScreenAutoPilotState(HLERequestContext& ctx); | 27 | InArray<TouchState, BufferAttr_HipcMapAlias> auto_pilot_buffer); |
| 26 | void GetTouchScreenConfiguration(HLERequestContext& ctx); | 28 | Result UnsetTouchScreenAutoPilotState(); |
| 27 | void ProcessTouchScreenAutoTune(HLERequestContext& ctx); | 29 | Result GetTouchScreenConfiguration( |
| 28 | void ForceStopTouchScreenManagement(HLERequestContext& ctx); | 30 | Out<Core::HID::TouchScreenConfigurationForNx> out_touchscreen_config, |
| 29 | void ForceRestartTouchScreenManagement(HLERequestContext& ctx); | 31 | ClientAppletResourceUserId aruid); |
| 30 | void IsTouchScreenManaged(HLERequestContext& ctx); | 32 | Result ProcessTouchScreenAutoTune(); |
| 31 | void DeactivateGesture(HLERequestContext& ctx); | 33 | Result ForceStopTouchScreenManagement(); |
| 34 | Result ForceRestartTouchScreenManagement(u32 basic_gesture_id, | ||
| 35 | ClientAppletResourceUserId aruid); | ||
| 36 | Result IsTouchScreenManaged(Out<bool> out_is_managed); | ||
| 37 | Result DeactivateGesture(); | ||
| 32 | 38 | ||
| 33 | std::shared_ptr<ResourceManager> GetResourceManager(); | 39 | std::shared_ptr<ResourceManager> GetResourceManager(); |
| 34 | 40 | ||
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp index 22471e9e2..7126a1dcd 100644 --- a/src/core/hle/service/hid/hid_system_server.cpp +++ b/src/core/hle/service/hid/hid_system_server.cpp | |||
| @@ -508,13 +508,8 @@ void IHidSystemServer::RegisterAppletResourceUserId(HLERequestContext& ctx) { | |||
| 508 | Result result = GetResourceManager()->RegisterAppletResourceUserId( | 508 | Result result = GetResourceManager()->RegisterAppletResourceUserId( |
| 509 | parameters.applet_resource_user_id, parameters.enable_input); | 509 | parameters.applet_resource_user_id, parameters.enable_input); |
| 510 | 510 | ||
| 511 | if (result.IsSuccess()) { | ||
| 512 | // result = GetResourceManager()->GetNpad()->RegisterAppletResourceUserId( | ||
| 513 | // parameters.applet_resource_user_id); | ||
| 514 | } | ||
| 515 | |||
| 516 | IPC::ResponseBuilder rb{ctx, 2}; | 511 | IPC::ResponseBuilder rb{ctx, 2}; |
| 517 | rb.Push(ResultSuccess); | 512 | rb.Push(result); |
| 518 | } | 513 | } |
| 519 | 514 | ||
| 520 | void IHidSystemServer::UnregisterAppletResourceUserId(HLERequestContext& ctx) { | 515 | void IHidSystemServer::UnregisterAppletResourceUserId(HLERequestContext& ctx) { |
| @@ -524,8 +519,6 @@ void IHidSystemServer::UnregisterAppletResourceUserId(HLERequestContext& ctx) { | |||
| 524 | LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 519 | LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 525 | 520 | ||
| 526 | GetResourceManager()->UnregisterAppletResourceUserId(applet_resource_user_id); | 521 | GetResourceManager()->UnregisterAppletResourceUserId(applet_resource_user_id); |
| 527 | // GetResourceManager()->GetNpad()->UnregisterAppletResourceUserId(applet_resource_user_id); | ||
| 528 | // GetResourceManager()->GetPalma()->UnregisterAppletResourceUserId(applet_resource_user_id); | ||
| 529 | 522 | ||
| 530 | IPC::ResponseBuilder rb{ctx, 2}; | 523 | IPC::ResponseBuilder rb{ctx, 2}; |
| 531 | rb.Push(ResultSuccess); | 524 | rb.Push(ResultSuccess); |
diff --git a/src/core/hle/service/hid/hidbus.cpp b/src/core/hle/service/hid/hidbus.cpp index c903ee8b8..4fb002bc4 100644 --- a/src/core/hle/service/hid/hidbus.cpp +++ b/src/core/hle/service/hid/hidbus.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/hle/kernel/k_readable_event.h" | 9 | #include "core/hle/kernel/k_readable_event.h" |
| 10 | #include "core/hle/kernel/k_shared_memory.h" | 10 | #include "core/hle/kernel/k_shared_memory.h" |
| 11 | #include "core/hle/kernel/k_transfer_memory.h" | 11 | #include "core/hle/kernel/k_transfer_memory.h" |
| 12 | #include "core/hle/service/cmif_serialization.h" | ||
| 12 | #include "core/hle/service/hid/hidbus.h" | 13 | #include "core/hle/service/hid/hidbus.h" |
| 13 | #include "core/hle/service/ipc_helpers.h" | 14 | #include "core/hle/service/ipc_helpers.h" |
| 14 | #include "core/hle/service/service.h" | 15 | #include "core/hle/service/service.h" |
| @@ -22,25 +23,25 @@ namespace Service::HID { | |||
| 22 | // (15ms, 66Hz) | 23 | // (15ms, 66Hz) |
| 23 | constexpr auto hidbus_update_ns = std::chrono::nanoseconds{15 * 1000 * 1000}; | 24 | constexpr auto hidbus_update_ns = std::chrono::nanoseconds{15 * 1000 * 1000}; |
| 24 | 25 | ||
| 25 | HidBus::HidBus(Core::System& system_) | 26 | Hidbus::Hidbus(Core::System& system_) |
| 26 | : ServiceFramework{system_, "hidbus"}, service_context{system_, service_name} { | 27 | : ServiceFramework{system_, "hidbus"}, service_context{system_, service_name} { |
| 27 | 28 | ||
| 28 | // clang-format off | 29 | // clang-format off |
| 29 | static const FunctionInfo functions[] = { | 30 | static const FunctionInfo functions[] = { |
| 30 | {1, &HidBus::GetBusHandle, "GetBusHandle"}, | 31 | {1, C<&Hidbus::GetBusHandle>, "GetBusHandle"}, |
| 31 | {2, &HidBus::IsExternalDeviceConnected, "IsExternalDeviceConnected"}, | 32 | {2, C<&Hidbus::IsExternalDeviceConnected>, "IsExternalDeviceConnected"}, |
| 32 | {3, &HidBus::Initialize, "Initialize"}, | 33 | {3, C<&Hidbus::Initialize>, "Initialize"}, |
| 33 | {4, &HidBus::Finalize, "Finalize"}, | 34 | {4, C<&Hidbus::Finalize>, "Finalize"}, |
| 34 | {5, &HidBus::EnableExternalDevice, "EnableExternalDevice"}, | 35 | {5, C<&Hidbus::EnableExternalDevice>, "EnableExternalDevice"}, |
| 35 | {6, &HidBus::GetExternalDeviceId, "GetExternalDeviceId"}, | 36 | {6, C<&Hidbus::GetExternalDeviceId>, "GetExternalDeviceId"}, |
| 36 | {7, &HidBus::SendCommandAsync, "SendCommandAsync"}, | 37 | {7, C<&Hidbus::SendCommandAsync>, "SendCommandAsync"}, |
| 37 | {8, &HidBus::GetSendCommandAsynceResult, "GetSendCommandAsynceResult"}, | 38 | {8, C<&Hidbus::GetSendCommandAsynceResult>, "GetSendCommandAsynceResult"}, |
| 38 | {9, &HidBus::SetEventForSendCommandAsycResult, "SetEventForSendCommandAsycResult"}, | 39 | {9, C<&Hidbus::SetEventForSendCommandAsycResult>, "SetEventForSendCommandAsycResult"}, |
| 39 | {10, &HidBus::GetSharedMemoryHandle, "GetSharedMemoryHandle"}, | 40 | {10, C<&Hidbus::GetSharedMemoryHandle>, "GetSharedMemoryHandle"}, |
| 40 | {11, &HidBus::EnableJoyPollingReceiveMode, "EnableJoyPollingReceiveMode"}, | 41 | {11, C<&Hidbus::EnableJoyPollingReceiveMode>, "EnableJoyPollingReceiveMode"}, |
| 41 | {12, &HidBus::DisableJoyPollingReceiveMode, "DisableJoyPollingReceiveMode"}, | 42 | {12, C<&Hidbus::DisableJoyPollingReceiveMode>, "DisableJoyPollingReceiveMode"}, |
| 42 | {13, nullptr, "GetPollingData"}, | 43 | {13, nullptr, "GetPollingData"}, |
| 43 | {14, &HidBus::SetStatusManagerType, "SetStatusManagerType"}, | 44 | {14, C<&Hidbus::SetStatusManagerType>, "SetStatusManagerType"}, |
| 44 | }; | 45 | }; |
| 45 | // clang-format on | 46 | // clang-format on |
| 46 | 47 | ||
| @@ -60,11 +61,11 @@ HidBus::HidBus(Core::System& system_) | |||
| 60 | hidbus_update_event); | 61 | hidbus_update_event); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | HidBus::~HidBus() { | 64 | Hidbus::~Hidbus() { |
| 64 | system.CoreTiming().UnscheduleEvent(hidbus_update_event); | 65 | system.CoreTiming().UnscheduleEvent(hidbus_update_event); |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | void HidBus::UpdateHidbus(std::chrono::nanoseconds ns_late) { | 68 | void Hidbus::UpdateHidbus(std::chrono::nanoseconds ns_late) { |
| 68 | if (is_hidbus_enabled) { | 69 | if (is_hidbus_enabled) { |
| 69 | for (std::size_t i = 0; i < devices.size(); ++i) { | 70 | for (std::size_t i = 0; i < devices.size(); ++i) { |
| 70 | if (!devices[i].is_device_initialized) { | 71 | if (!devices[i].is_device_initialized) { |
| @@ -84,7 +85,7 @@ void HidBus::UpdateHidbus(std::chrono::nanoseconds ns_late) { | |||
| 84 | } | 85 | } |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | std::optional<std::size_t> HidBus::GetDeviceIndexFromHandle(BusHandle handle) const { | 88 | std::optional<std::size_t> Hidbus::GetDeviceIndexFromHandle(BusHandle handle) const { |
| 88 | for (std::size_t i = 0; i < devices.size(); ++i) { | 89 | for (std::size_t i = 0; i < devices.size(); ++i) { |
| 89 | const auto& device_handle = devices[i].handle; | 90 | const auto& device_handle = devices[i].handle; |
| 90 | if (handle.abstracted_pad_id == device_handle.abstracted_pad_id && | 91 | if (handle.abstracted_pad_id == device_handle.abstracted_pad_id && |
| @@ -98,20 +99,11 @@ std::optional<std::size_t> HidBus::GetDeviceIndexFromHandle(BusHandle handle) co | |||
| 98 | return std::nullopt; | 99 | return std::nullopt; |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | void HidBus::GetBusHandle(HLERequestContext& ctx) { | 102 | Result Hidbus::GetBusHandle(Out<bool> out_is_valid, Out<BusHandle> out_bus_handle, |
| 102 | IPC::RequestParser rp{ctx}; | 103 | Core::HID::NpadIdType npad_id, BusType bus_type, |
| 103 | struct Parameters { | 104 | AppletResourceUserId aruid) { |
| 104 | Core::HID::NpadIdType npad_id; | 105 | LOG_INFO(Service_HID, "called, npad_id={}, bus_type={}, applet_resource_user_id={}", npad_id, |
| 105 | INSERT_PADDING_WORDS_NOINIT(1); | 106 | bus_type, aruid.pid); |
| 106 | BusType bus_type; | ||
| 107 | u64 applet_resource_user_id; | ||
| 108 | }; | ||
| 109 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | ||
| 110 | |||
| 111 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 112 | |||
| 113 | LOG_INFO(Service_HID, "called, npad_id={}, bus_type={}, applet_resource_user_id={}", | ||
| 114 | parameters.npad_id, parameters.bus_type, parameters.applet_resource_user_id); | ||
| 115 | 107 | ||
| 116 | bool is_handle_found = 0; | 108 | bool is_handle_found = 0; |
| 117 | std::size_t handle_index = 0; | 109 | std::size_t handle_index = 0; |
| @@ -121,8 +113,8 @@ void HidBus::GetBusHandle(HLERequestContext& ctx) { | |||
| 121 | if (!handle.is_valid) { | 113 | if (!handle.is_valid) { |
| 122 | continue; | 114 | continue; |
| 123 | } | 115 | } |
| 124 | if (static_cast<Core::HID::NpadIdType>(handle.player_number) == parameters.npad_id && | 116 | if (handle.player_number.As<Core::HID::NpadIdType>() == npad_id && |
| 125 | handle.bus_type_id == static_cast<u8>(parameters.bus_type)) { | 117 | handle.bus_type_id == static_cast<u8>(bus_type)) { |
| 126 | is_handle_found = true; | 118 | is_handle_found = true; |
| 127 | handle_index = i; | 119 | handle_index = i; |
| 128 | break; | 120 | break; |
| @@ -135,388 +127,231 @@ void HidBus::GetBusHandle(HLERequestContext& ctx) { | |||
| 135 | if (devices[i].handle.is_valid) { | 127 | if (devices[i].handle.is_valid) { |
| 136 | continue; | 128 | continue; |
| 137 | } | 129 | } |
| 138 | devices[i].handle = { | 130 | devices[i].handle.raw = 0; |
| 139 | .abstracted_pad_id = static_cast<u8>(i), | 131 | devices[i].handle.abstracted_pad_id.Assign(i); |
| 140 | .internal_index = static_cast<u8>(i), | 132 | devices[i].handle.internal_index.Assign(i); |
| 141 | .player_number = static_cast<u8>(parameters.npad_id), | 133 | devices[i].handle.player_number.Assign(static_cast<u8>(npad_id)); |
| 142 | .bus_type_id = static_cast<u8>(parameters.bus_type), | 134 | devices[i].handle.bus_type_id.Assign(static_cast<u8>(bus_type)); |
| 143 | .is_valid = true, | 135 | devices[i].handle.is_valid.Assign(true); |
| 144 | }; | ||
| 145 | handle_index = i; | 136 | handle_index = i; |
| 146 | break; | 137 | break; |
| 147 | } | 138 | } |
| 148 | } | 139 | } |
| 149 | 140 | ||
| 150 | struct OutData { | 141 | *out_is_valid = true; |
| 151 | bool is_valid; | 142 | *out_bus_handle = devices[handle_index].handle; |
| 152 | INSERT_PADDING_BYTES(7); | 143 | R_SUCCEED(); |
| 153 | BusHandle handle; | ||
| 154 | }; | ||
| 155 | static_assert(sizeof(OutData) == 0x10, "OutData has incorrect size."); | ||
| 156 | |||
| 157 | const OutData out_data{ | ||
| 158 | .is_valid = true, | ||
| 159 | .handle = devices[handle_index].handle, | ||
| 160 | }; | ||
| 161 | |||
| 162 | IPC::ResponseBuilder rb{ctx, 6}; | ||
| 163 | rb.Push(ResultSuccess); | ||
| 164 | rb.PushRaw(out_data); | ||
| 165 | } | 144 | } |
| 166 | 145 | ||
| 167 | void HidBus::IsExternalDeviceConnected(HLERequestContext& ctx) { | 146 | Result Hidbus::IsExternalDeviceConnected(Out<bool> out_is_connected, BusHandle bus_handle) { |
| 168 | IPC::RequestParser rp{ctx}; | ||
| 169 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 170 | |||
| 171 | LOG_INFO(Service_HID, | 147 | LOG_INFO(Service_HID, |
| 172 | "Called, abstracted_pad_id={}, bus_type={}, internal_index={}, " | 148 | "Called, abstracted_pad_id={}, bus_type={}, internal_index={}, " |
| 173 | "player_number={}, is_valid={}", | 149 | "player_number={}, is_valid={}", |
| 174 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | 150 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 175 | bus_handle_.player_number, bus_handle_.is_valid); | 151 | bus_handle.player_number, bus_handle.is_valid); |
| 176 | 152 | ||
| 177 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | 153 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 178 | 154 | ||
| 179 | if (device_index) { | 155 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 180 | const auto& device = devices[device_index.value()].device; | ||
| 181 | const bool is_attached = device->IsDeviceActivated(); | ||
| 182 | 156 | ||
| 183 | IPC::ResponseBuilder rb{ctx, 3}; | 157 | *out_is_connected = devices[device_index.value()].device->IsDeviceActivated(); |
| 184 | rb.Push(ResultSuccess); | 158 | R_SUCCEED(); |
| 185 | rb.Push(is_attached); | ||
| 186 | return; | ||
| 187 | } | ||
| 188 | |||
| 189 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
| 190 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 191 | rb.Push(ResultUnknown); | ||
| 192 | return; | ||
| 193 | } | 159 | } |
| 194 | 160 | ||
| 195 | void HidBus::Initialize(HLERequestContext& ctx) { | 161 | Result Hidbus::Initialize(BusHandle bus_handle, AppletResourceUserId aruid) { |
| 196 | IPC::RequestParser rp{ctx}; | ||
| 197 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 198 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 199 | |||
| 200 | LOG_INFO(Service_HID, | 162 | LOG_INFO(Service_HID, |
| 201 | "called, abstracted_pad_id={} bus_type={} internal_index={} " | 163 | "called, abstracted_pad_id={} bus_type={} internal_index={} " |
| 202 | "player_number={} is_valid={}, applet_resource_user_id={}", | 164 | "player_number={} is_valid={}, applet_resource_user_id={}", |
| 203 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | 165 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 204 | bus_handle_.player_number, bus_handle_.is_valid, applet_resource_user_id); | 166 | bus_handle.player_number, bus_handle.is_valid, aruid.pid); |
| 205 | 167 | ||
| 206 | is_hidbus_enabled = true; | 168 | is_hidbus_enabled = true; |
| 207 | 169 | ||
| 208 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | 170 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 209 | |||
| 210 | if (device_index) { | ||
| 211 | const auto entry_index = devices[device_index.value()].handle.internal_index; | ||
| 212 | auto& cur_entry = hidbus_status.entries[entry_index]; | ||
| 213 | |||
| 214 | if (bus_handle_.internal_index == 0 && Settings::values.enable_ring_controller) { | ||
| 215 | MakeDevice<RingController>(bus_handle_); | ||
| 216 | devices[device_index.value()].is_device_initialized = true; | ||
| 217 | devices[device_index.value()].device->ActivateDevice(); | ||
| 218 | cur_entry.is_in_focus = true; | ||
| 219 | cur_entry.is_connected = true; | ||
| 220 | cur_entry.is_connected_result = ResultSuccess; | ||
| 221 | cur_entry.is_enabled = false; | ||
| 222 | cur_entry.is_polling_mode = false; | ||
| 223 | } else { | ||
| 224 | MakeDevice<HidbusStubbed>(bus_handle_); | ||
| 225 | devices[device_index.value()].is_device_initialized = true; | ||
| 226 | cur_entry.is_in_focus = true; | ||
| 227 | cur_entry.is_connected = false; | ||
| 228 | cur_entry.is_connected_result = ResultSuccess; | ||
| 229 | cur_entry.is_enabled = false; | ||
| 230 | cur_entry.is_polling_mode = false; | ||
| 231 | } | ||
| 232 | |||
| 233 | std::memcpy(system.Kernel().GetHidBusSharedMem().GetPointer(), &hidbus_status, | ||
| 234 | sizeof(hidbus_status)); | ||
| 235 | |||
| 236 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 237 | rb.Push(ResultSuccess); | ||
| 238 | return; | ||
| 239 | } | ||
| 240 | 171 | ||
| 241 | LOG_ERROR(Service_HID, "Invalid handle"); | 172 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 242 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 243 | rb.Push(ResultUnknown); | ||
| 244 | return; | ||
| 245 | } | ||
| 246 | 173 | ||
| 247 | void HidBus::Finalize(HLERequestContext& ctx) { | 174 | const auto entry_index = devices[device_index.value()].handle.internal_index; |
| 248 | IPC::RequestParser rp{ctx}; | 175 | auto& cur_entry = hidbus_status.entries[entry_index]; |
| 249 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 250 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 251 | |||
| 252 | LOG_INFO(Service_HID, | ||
| 253 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, " | ||
| 254 | "player_number={}, is_valid={}, applet_resource_user_id={}", | ||
| 255 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | ||
| 256 | bus_handle_.player_number, bus_handle_.is_valid, applet_resource_user_id); | ||
| 257 | |||
| 258 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | ||
| 259 | |||
| 260 | if (device_index) { | ||
| 261 | const auto entry_index = devices[device_index.value()].handle.internal_index; | ||
| 262 | auto& cur_entry = hidbus_status.entries[entry_index]; | ||
| 263 | auto& device = devices[device_index.value()].device; | ||
| 264 | devices[device_index.value()].is_device_initialized = false; | ||
| 265 | device->DeactivateDevice(); | ||
| 266 | 176 | ||
| 177 | if (bus_handle.internal_index == 0 && Settings::values.enable_ring_controller) { | ||
| 178 | MakeDevice<RingController>(bus_handle); | ||
| 179 | devices[device_index.value()].is_device_initialized = true; | ||
| 180 | devices[device_index.value()].device->ActivateDevice(); | ||
| 181 | cur_entry.is_in_focus = true; | ||
| 182 | cur_entry.is_connected = true; | ||
| 183 | cur_entry.is_connected_result = ResultSuccess; | ||
| 184 | cur_entry.is_enabled = false; | ||
| 185 | cur_entry.is_polling_mode = false; | ||
| 186 | } else { | ||
| 187 | MakeDevice<HidbusStubbed>(bus_handle); | ||
| 188 | devices[device_index.value()].is_device_initialized = true; | ||
| 267 | cur_entry.is_in_focus = true; | 189 | cur_entry.is_in_focus = true; |
| 268 | cur_entry.is_connected = false; | 190 | cur_entry.is_connected = false; |
| 269 | cur_entry.is_connected_result = ResultSuccess; | 191 | cur_entry.is_connected_result = ResultSuccess; |
| 270 | cur_entry.is_enabled = false; | 192 | cur_entry.is_enabled = false; |
| 271 | cur_entry.is_polling_mode = false; | 193 | cur_entry.is_polling_mode = false; |
| 272 | std::memcpy(system.Kernel().GetHidBusSharedMem().GetPointer(), &hidbus_status, | ||
| 273 | sizeof(hidbus_status)); | ||
| 274 | |||
| 275 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 276 | rb.Push(ResultSuccess); | ||
| 277 | return; | ||
| 278 | } | 194 | } |
| 279 | 195 | ||
| 280 | LOG_ERROR(Service_HID, "Invalid handle"); | 196 | std::memcpy(system.Kernel().GetHidBusSharedMem().GetPointer(), &hidbus_status, |
| 281 | IPC::ResponseBuilder rb{ctx, 2}; | 197 | sizeof(hidbus_status)); |
| 282 | rb.Push(ResultUnknown); | 198 | R_SUCCEED(); |
| 283 | return; | ||
| 284 | } | 199 | } |
| 285 | 200 | ||
| 286 | void HidBus::EnableExternalDevice(HLERequestContext& ctx) { | 201 | Result Hidbus::Finalize(BusHandle bus_handle, AppletResourceUserId aruid) { |
| 287 | IPC::RequestParser rp{ctx}; | 202 | LOG_INFO(Service_HID, |
| 288 | struct Parameters { | 203 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, " |
| 289 | bool enable; | 204 | "player_number={}, is_valid={}, applet_resource_user_id={}", |
| 290 | INSERT_PADDING_BYTES_NOINIT(7); | 205 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 291 | BusHandle bus_handle; | 206 | bus_handle.player_number, bus_handle.is_valid, aruid.pid); |
| 292 | u64 inval; | 207 | |
| 293 | u64 applet_resource_user_id; | 208 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 294 | }; | 209 | |
| 295 | static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size."); | 210 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 296 | 211 | ||
| 297 | const auto parameters{rp.PopRaw<Parameters>()}; | 212 | const auto entry_index = devices[device_index.value()].handle.internal_index; |
| 213 | auto& cur_entry = hidbus_status.entries[entry_index]; | ||
| 214 | auto& device = devices[device_index.value()].device; | ||
| 215 | devices[device_index.value()].is_device_initialized = false; | ||
| 216 | device->DeactivateDevice(); | ||
| 217 | |||
| 218 | cur_entry.is_in_focus = true; | ||
| 219 | cur_entry.is_connected = false; | ||
| 220 | cur_entry.is_connected_result = ResultSuccess; | ||
| 221 | cur_entry.is_enabled = false; | ||
| 222 | cur_entry.is_polling_mode = false; | ||
| 223 | std::memcpy(system.Kernel().GetHidBusSharedMem().GetPointer(), &hidbus_status, | ||
| 224 | sizeof(hidbus_status)); | ||
| 225 | R_SUCCEED(); | ||
| 226 | } | ||
| 298 | 227 | ||
| 228 | Result Hidbus::EnableExternalDevice(bool is_enabled, BusHandle bus_handle, u64 inval, | ||
| 229 | AppletResourceUserId aruid) { | ||
| 299 | LOG_DEBUG(Service_HID, | 230 | LOG_DEBUG(Service_HID, |
| 300 | "called, enable={}, abstracted_pad_id={}, bus_type={}, internal_index={}, " | 231 | "called, enable={}, abstracted_pad_id={}, bus_type={}, internal_index={}, " |
| 301 | "player_number={}, is_valid={}, inval={}, applet_resource_user_id{}", | 232 | "player_number={}, is_valid={}, inval={}, applet_resource_user_id{}", |
| 302 | parameters.enable, parameters.bus_handle.abstracted_pad_id, | 233 | is_enabled, bus_handle.abstracted_pad_id, bus_handle.bus_type_id, |
| 303 | parameters.bus_handle.bus_type_id, parameters.bus_handle.internal_index, | 234 | bus_handle.internal_index, bus_handle.player_number, bus_handle.is_valid, inval, |
| 304 | parameters.bus_handle.player_number, parameters.bus_handle.is_valid, parameters.inval, | 235 | aruid.pid); |
| 305 | parameters.applet_resource_user_id); | ||
| 306 | |||
| 307 | const auto device_index = GetDeviceIndexFromHandle(parameters.bus_handle); | ||
| 308 | |||
| 309 | if (device_index) { | ||
| 310 | auto& device = devices[device_index.value()].device; | ||
| 311 | device->Enable(parameters.enable); | ||
| 312 | 236 | ||
| 313 | IPC::ResponseBuilder rb{ctx, 2}; | 237 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 314 | rb.Push(ResultSuccess); | ||
| 315 | return; | ||
| 316 | } | ||
| 317 | 238 | ||
| 318 | LOG_ERROR(Service_HID, "Invalid handle"); | 239 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 319 | IPC::ResponseBuilder rb{ctx, 2}; | 240 | devices[device_index.value()].device->Enable(is_enabled); |
| 320 | rb.Push(ResultUnknown); | 241 | R_SUCCEED(); |
| 321 | return; | ||
| 322 | } | 242 | } |
| 323 | 243 | ||
| 324 | void HidBus::GetExternalDeviceId(HLERequestContext& ctx) { | 244 | Result Hidbus::GetExternalDeviceId(Out<u32> out_device_id, BusHandle bus_handle) { |
| 325 | IPC::RequestParser rp{ctx}; | ||
| 326 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 327 | |||
| 328 | LOG_DEBUG(Service_HID, | 245 | LOG_DEBUG(Service_HID, |
| 329 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " | 246 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " |
| 330 | "is_valid={}", | 247 | "is_valid={}", |
| 331 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | 248 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 332 | bus_handle_.player_number, bus_handle_.is_valid); | 249 | bus_handle.player_number, bus_handle.is_valid); |
| 333 | |||
| 334 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | ||
| 335 | |||
| 336 | if (device_index) { | ||
| 337 | const auto& device = devices[device_index.value()].device; | ||
| 338 | u32 device_id = device->GetDeviceId(); | ||
| 339 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 340 | rb.Push(ResultSuccess); | ||
| 341 | rb.Push<u32>(device_id); | ||
| 342 | return; | ||
| 343 | } | ||
| 344 | 250 | ||
| 345 | LOG_ERROR(Service_HID, "Invalid handle"); | 251 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 346 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 347 | rb.Push(ResultUnknown); | ||
| 348 | return; | ||
| 349 | } | ||
| 350 | 252 | ||
| 351 | void HidBus::SendCommandAsync(HLERequestContext& ctx) { | 253 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 352 | IPC::RequestParser rp{ctx}; | ||
| 353 | const auto data = ctx.ReadBuffer(); | ||
| 354 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 355 | 254 | ||
| 255 | *out_device_id = devices[device_index.value()].device->GetDeviceId(); | ||
| 256 | R_SUCCEED(); | ||
| 257 | } | ||
| 258 | |||
| 259 | Result Hidbus::SendCommandAsync(BusHandle bus_handle, | ||
| 260 | InBuffer<BufferAttr_HipcAutoSelect> buffer_data) { | ||
| 356 | LOG_DEBUG(Service_HID, | 261 | LOG_DEBUG(Service_HID, |
| 357 | "called, data_size={}, abstracted_pad_id={}, bus_type={}, internal_index={}, " | 262 | "called, data_size={}, abstracted_pad_id={}, bus_type={}, internal_index={}, " |
| 358 | "player_number={}, is_valid={}", | 263 | "player_number={}, is_valid={}", |
| 359 | data.size(), bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, | 264 | buffer_data.size(), bus_handle.abstracted_pad_id, bus_handle.bus_type_id, |
| 360 | bus_handle_.internal_index, bus_handle_.player_number, bus_handle_.is_valid); | 265 | bus_handle.internal_index, bus_handle.player_number, bus_handle.is_valid); |
| 361 | 266 | ||
| 362 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | 267 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 363 | 268 | ||
| 364 | if (device_index) { | 269 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 365 | auto& device = devices[device_index.value()].device; | ||
| 366 | device->SetCommand(data); | ||
| 367 | |||
| 368 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 369 | rb.Push(ResultSuccess); | ||
| 370 | return; | ||
| 371 | } | ||
| 372 | 270 | ||
| 373 | LOG_ERROR(Service_HID, "Invalid handle"); | 271 | devices[device_index.value()].device->SetCommand(buffer_data); |
| 374 | IPC::ResponseBuilder rb{ctx, 2}; | 272 | R_SUCCEED(); |
| 375 | rb.Push(ResultUnknown); | ||
| 376 | return; | ||
| 377 | }; | 273 | }; |
| 378 | 274 | ||
| 379 | void HidBus::GetSendCommandAsynceResult(HLERequestContext& ctx) { | 275 | Result Hidbus::GetSendCommandAsynceResult(Out<u64> out_data_size, BusHandle bus_handle, |
| 380 | IPC::RequestParser rp{ctx}; | 276 | OutBuffer<BufferAttr_HipcAutoSelect> out_buffer_data) { |
| 381 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 382 | |||
| 383 | LOG_DEBUG(Service_HID, | 277 | LOG_DEBUG(Service_HID, |
| 384 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " | 278 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " |
| 385 | "is_valid={}", | 279 | "is_valid={}", |
| 386 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | 280 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 387 | bus_handle_.player_number, bus_handle_.is_valid); | 281 | bus_handle.player_number, bus_handle.is_valid); |
| 388 | |||
| 389 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | ||
| 390 | 282 | ||
| 391 | if (device_index) { | 283 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 392 | const auto& device = devices[device_index.value()].device; | ||
| 393 | const std::vector<u8> data = device->GetReply(); | ||
| 394 | const u64 data_size = ctx.WriteBuffer(data); | ||
| 395 | 284 | ||
| 396 | IPC::ResponseBuilder rb{ctx, 4}; | 285 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 397 | rb.Push(ResultSuccess); | ||
| 398 | rb.Push<u64>(data_size); | ||
| 399 | return; | ||
| 400 | } | ||
| 401 | 286 | ||
| 402 | LOG_ERROR(Service_HID, "Invalid handle"); | 287 | *out_data_size = devices[device_index.value()].device->GetReply(out_buffer_data); |
| 403 | IPC::ResponseBuilder rb{ctx, 2}; | 288 | R_SUCCEED(); |
| 404 | rb.Push(ResultUnknown); | ||
| 405 | return; | ||
| 406 | }; | 289 | }; |
| 407 | 290 | ||
| 408 | void HidBus::SetEventForSendCommandAsycResult(HLERequestContext& ctx) { | 291 | Result Hidbus::SetEventForSendCommandAsycResult(OutCopyHandle<Kernel::KReadableEvent> out_event, |
| 409 | IPC::RequestParser rp{ctx}; | 292 | BusHandle bus_handle) { |
| 410 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 411 | |||
| 412 | LOG_INFO(Service_HID, | 293 | LOG_INFO(Service_HID, |
| 413 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " | 294 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " |
| 414 | "is_valid={}", | 295 | "is_valid={}", |
| 415 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | 296 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 416 | bus_handle_.player_number, bus_handle_.is_valid); | 297 | bus_handle.player_number, bus_handle.is_valid); |
| 417 | 298 | ||
| 418 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | 299 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 419 | 300 | ||
| 420 | if (device_index) { | 301 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 421 | const auto& device = devices[device_index.value()].device; | ||
| 422 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 423 | rb.Push(ResultSuccess); | ||
| 424 | rb.PushCopyObjects(device->GetSendCommandAsycEvent()); | ||
| 425 | return; | ||
| 426 | } | ||
| 427 | 302 | ||
| 428 | LOG_ERROR(Service_HID, "Invalid handle"); | 303 | *out_event = &devices[device_index.value()].device->GetSendCommandAsycEvent(); |
| 429 | IPC::ResponseBuilder rb{ctx, 2}; | 304 | R_SUCCEED(); |
| 430 | rb.Push(ResultUnknown); | ||
| 431 | return; | ||
| 432 | }; | 305 | }; |
| 433 | 306 | ||
| 434 | void HidBus::GetSharedMemoryHandle(HLERequestContext& ctx) { | 307 | Result Hidbus::GetSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory) { |
| 435 | LOG_DEBUG(Service_HID, "called"); | 308 | LOG_DEBUG(Service_HID, "called"); |
| 436 | 309 | ||
| 437 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 310 | *out_shared_memory = &system.Kernel().GetHidBusSharedMem(); |
| 438 | rb.Push(ResultSuccess); | 311 | R_SUCCEED(); |
| 439 | rb.PushCopyObjects(&system.Kernel().GetHidBusSharedMem()); | ||
| 440 | } | 312 | } |
| 441 | 313 | ||
| 442 | void HidBus::EnableJoyPollingReceiveMode(HLERequestContext& ctx) { | 314 | Result Hidbus::EnableJoyPollingReceiveMode(u32 t_mem_size, JoyPollingMode polling_mode, |
| 443 | IPC::RequestParser rp{ctx}; | 315 | BusHandle bus_handle, |
| 444 | const auto t_mem_size{rp.Pop<u32>()}; | 316 | InCopyHandle<Kernel::KTransferMemory> t_mem) { |
| 445 | const auto t_mem_handle{ctx.GetCopyHandle(0)}; | ||
| 446 | const auto polling_mode_{rp.PopEnum<JoyPollingMode>()}; | ||
| 447 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 448 | |||
| 449 | ASSERT_MSG(t_mem_size == 0x1000, "t_mem_size is not 0x1000 bytes"); | 317 | ASSERT_MSG(t_mem_size == 0x1000, "t_mem_size is not 0x1000 bytes"); |
| 450 | 318 | ASSERT_MSG(t_mem->GetSize() == t_mem_size, "t_mem has incorrect size"); | |
| 451 | auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle); | ||
| 452 | |||
| 453 | if (t_mem.IsNull()) { | ||
| 454 | LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); | ||
| 455 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 456 | rb.Push(ResultUnknown); | ||
| 457 | return; | ||
| 458 | } | ||
| 459 | |||
| 460 | ASSERT_MSG(t_mem->GetSize() == 0x1000, "t_mem has incorrect size"); | ||
| 461 | 319 | ||
| 462 | LOG_INFO(Service_HID, | 320 | LOG_INFO(Service_HID, |
| 463 | "called, t_mem_handle=0x{:08X}, polling_mode={}, abstracted_pad_id={}, bus_type={}, " | 321 | "called, polling_mode={}, abstracted_pad_id={}, bus_type={}, " |
| 464 | "internal_index={}, player_number={}, is_valid={}", | 322 | "internal_index={}, player_number={}, is_valid={}", |
| 465 | t_mem_handle, polling_mode_, bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, | 323 | polling_mode, bus_handle.abstracted_pad_id, bus_handle.bus_type_id, |
| 466 | bus_handle_.internal_index, bus_handle_.player_number, bus_handle_.is_valid); | 324 | bus_handle.internal_index, bus_handle.player_number, bus_handle.is_valid); |
| 467 | 325 | ||
| 468 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | 326 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 469 | 327 | ||
| 470 | if (device_index) { | 328 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 471 | auto& device = devices[device_index.value()].device; | ||
| 472 | device->SetPollingMode(polling_mode_); | ||
| 473 | device->SetTransferMemoryAddress(t_mem->GetSourceAddress()); | ||
| 474 | 329 | ||
| 475 | IPC::ResponseBuilder rb{ctx, 2}; | 330 | auto& device = devices[device_index.value()].device; |
| 476 | rb.Push(ResultSuccess); | 331 | device->SetPollingMode(polling_mode); |
| 477 | return; | 332 | device->SetTransferMemoryAddress(t_mem->GetSourceAddress()); |
| 478 | } | 333 | R_SUCCEED(); |
| 479 | |||
| 480 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
| 481 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 482 | rb.Push(ResultUnknown); | ||
| 483 | return; | ||
| 484 | } | 334 | } |
| 485 | 335 | ||
| 486 | void HidBus::DisableJoyPollingReceiveMode(HLERequestContext& ctx) { | 336 | Result Hidbus::DisableJoyPollingReceiveMode(BusHandle bus_handle) { |
| 487 | IPC::RequestParser rp{ctx}; | ||
| 488 | const auto bus_handle_{rp.PopRaw<BusHandle>()}; | ||
| 489 | |||
| 490 | LOG_INFO(Service_HID, | 337 | LOG_INFO(Service_HID, |
| 491 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " | 338 | "called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, " |
| 492 | "is_valid={}", | 339 | "is_valid={}", |
| 493 | bus_handle_.abstracted_pad_id, bus_handle_.bus_type_id, bus_handle_.internal_index, | 340 | bus_handle.abstracted_pad_id, bus_handle.bus_type_id, bus_handle.internal_index, |
| 494 | bus_handle_.player_number, bus_handle_.is_valid); | 341 | bus_handle.player_number, bus_handle.is_valid); |
| 495 | 342 | ||
| 496 | const auto device_index = GetDeviceIndexFromHandle(bus_handle_); | 343 | const auto device_index = GetDeviceIndexFromHandle(bus_handle); |
| 497 | 344 | ||
| 498 | if (device_index) { | 345 | R_UNLESS(device_index.has_value(), ResultUnknown); |
| 499 | auto& device = devices[device_index.value()].device; | ||
| 500 | device->DisablePollingMode(); | ||
| 501 | |||
| 502 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 503 | rb.Push(ResultSuccess); | ||
| 504 | return; | ||
| 505 | } | ||
| 506 | 346 | ||
| 507 | LOG_ERROR(Service_HID, "Invalid handle"); | 347 | auto& device = devices[device_index.value()].device; |
| 508 | IPC::ResponseBuilder rb{ctx, 2}; | 348 | device->DisablePollingMode(); |
| 509 | rb.Push(ResultUnknown); | 349 | R_SUCCEED(); |
| 510 | return; | ||
| 511 | } | 350 | } |
| 512 | 351 | ||
| 513 | void HidBus::SetStatusManagerType(HLERequestContext& ctx) { | 352 | Result Hidbus::SetStatusManagerType(StatusManagerType manager_type) { |
| 514 | IPC::RequestParser rp{ctx}; | ||
| 515 | const auto manager_type{rp.PopEnum<StatusManagerType>()}; | ||
| 516 | |||
| 517 | LOG_WARNING(Service_HID, "(STUBBED) called, manager_type={}", manager_type); | 353 | LOG_WARNING(Service_HID, "(STUBBED) called, manager_type={}", manager_type); |
| 518 | 354 | R_SUCCEED(); | |
| 519 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 520 | rb.Push(ResultSuccess); | ||
| 521 | }; | 355 | }; |
| 356 | |||
| 522 | } // namespace Service::HID | 357 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/hidbus.h b/src/core/hle/service/hid/hidbus.h index 03d9f6863..af4d95667 100644 --- a/src/core/hle/service/hid/hidbus.h +++ b/src/core/hle/service/hid/hidbus.h | |||
| @@ -5,8 +5,10 @@ | |||
| 5 | 5 | ||
| 6 | #include <functional> | 6 | #include <functional> |
| 7 | 7 | ||
| 8 | #include "core/hle/service/cmif_types.h" | ||
| 8 | #include "core/hle/service/kernel_helpers.h" | 9 | #include "core/hle/service/kernel_helpers.h" |
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 11 | #include "hid_core/hid_types.h" | ||
| 10 | #include "hid_core/hidbus/hidbus_base.h" | 12 | #include "hid_core/hidbus/hidbus_base.h" |
| 11 | 13 | ||
| 12 | namespace Core::Timing { | 14 | namespace Core::Timing { |
| @@ -19,10 +21,10 @@ class System; | |||
| 19 | 21 | ||
| 20 | namespace Service::HID { | 22 | namespace Service::HID { |
| 21 | 23 | ||
| 22 | class HidBus final : public ServiceFramework<HidBus> { | 24 | class Hidbus final : public ServiceFramework<Hidbus> { |
| 23 | public: | 25 | public: |
| 24 | explicit HidBus(Core::System& system_); | 26 | explicit Hidbus(Core::System& system_); |
| 25 | ~HidBus() override; | 27 | ~Hidbus() override; |
| 26 | 28 | ||
| 27 | private: | 29 | private: |
| 28 | static const std::size_t max_number_of_handles = 0x13; | 30 | static const std::size_t max_number_of_handles = 0x13; |
| @@ -41,7 +43,7 @@ private: | |||
| 41 | }; | 43 | }; |
| 42 | 44 | ||
| 43 | // This is nn::hidbus::BusType | 45 | // This is nn::hidbus::BusType |
| 44 | enum class BusType : u32 { | 46 | enum class BusType : u64 { |
| 45 | LeftJoyRail, | 47 | LeftJoyRail, |
| 46 | RightJoyRail, | 48 | RightJoyRail, |
| 47 | InternalBus, // Lark microphone | 49 | InternalBus, // Lark microphone |
| @@ -51,11 +53,15 @@ private: | |||
| 51 | 53 | ||
| 52 | // This is nn::hidbus::BusHandle | 54 | // This is nn::hidbus::BusHandle |
| 53 | struct BusHandle { | 55 | struct BusHandle { |
| 54 | u32 abstracted_pad_id; | 56 | union { |
| 55 | u8 internal_index; | 57 | u64 raw{}; |
| 56 | u8 player_number; | 58 | |
| 57 | u8 bus_type_id; | 59 | BitField<0, 32, u64> abstracted_pad_id; |
| 58 | bool is_valid; | 60 | BitField<32, 8, u64> internal_index; |
| 61 | BitField<40, 8, u64> player_number; | ||
| 62 | BitField<48, 8, u64> bus_type_id; | ||
| 63 | BitField<56, 1, u64> is_valid; | ||
| 64 | }; | ||
| 59 | }; | 65 | }; |
| 60 | static_assert(sizeof(BusHandle) == 0x8, "BusHandle is an invalid size"); | 66 | static_assert(sizeof(BusHandle) == 0x8, "BusHandle is an invalid size"); |
| 61 | 67 | ||
| @@ -94,19 +100,38 @@ private: | |||
| 94 | std::unique_ptr<HidbusBase> device{nullptr}; | 100 | std::unique_ptr<HidbusBase> device{nullptr}; |
| 95 | }; | 101 | }; |
| 96 | 102 | ||
| 97 | void GetBusHandle(HLERequestContext& ctx); | 103 | Result GetBusHandle(Out<bool> out_is_valid, Out<BusHandle> out_bus_handle, |
| 98 | void IsExternalDeviceConnected(HLERequestContext& ctx); | 104 | Core::HID::NpadIdType npad_id, BusType bus_type, |
| 99 | void Initialize(HLERequestContext& ctx); | 105 | AppletResourceUserId aruid); |
| 100 | void Finalize(HLERequestContext& ctx); | 106 | |
| 101 | void EnableExternalDevice(HLERequestContext& ctx); | 107 | Result IsExternalDeviceConnected(Out<bool> out_is_connected, BusHandle bus_handle); |
| 102 | void GetExternalDeviceId(HLERequestContext& ctx); | 108 | |
| 103 | void SendCommandAsync(HLERequestContext& ctx); | 109 | Result Initialize(BusHandle bus_handle, AppletResourceUserId aruid); |
| 104 | void GetSendCommandAsynceResult(HLERequestContext& ctx); | 110 | |
| 105 | void SetEventForSendCommandAsycResult(HLERequestContext& ctx); | 111 | Result Finalize(BusHandle bus_handle, AppletResourceUserId aruid); |
| 106 | void GetSharedMemoryHandle(HLERequestContext& ctx); | 112 | |
| 107 | void EnableJoyPollingReceiveMode(HLERequestContext& ctx); | 113 | Result EnableExternalDevice(bool is_enabled, BusHandle bus_handle, u64 inval, |
| 108 | void DisableJoyPollingReceiveMode(HLERequestContext& ctx); | 114 | AppletResourceUserId aruid); |
| 109 | void SetStatusManagerType(HLERequestContext& ctx); | 115 | |
| 116 | Result GetExternalDeviceId(Out<u32> out_device_id, BusHandle bus_handle); | ||
| 117 | |||
| 118 | Result SendCommandAsync(BusHandle bus_handle, InBuffer<BufferAttr_HipcAutoSelect> buffer_data); | ||
| 119 | |||
| 120 | Result GetSendCommandAsynceResult(Out<u64> out_data_size, BusHandle bus_handle, | ||
| 121 | OutBuffer<BufferAttr_HipcAutoSelect> out_buffer_data); | ||
| 122 | |||
| 123 | Result SetEventForSendCommandAsycResult(OutCopyHandle<Kernel::KReadableEvent> out_event, | ||
| 124 | BusHandle bus_handle); | ||
| 125 | |||
| 126 | Result GetSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory); | ||
| 127 | |||
| 128 | Result EnableJoyPollingReceiveMode(u32 t_mem_size, JoyPollingMode polling_mode, | ||
| 129 | BusHandle bus_handle, | ||
| 130 | InCopyHandle<Kernel::KTransferMemory> t_mem); | ||
| 131 | |||
| 132 | Result DisableJoyPollingReceiveMode(BusHandle bus_handle); | ||
| 133 | |||
| 134 | Result SetStatusManagerType(StatusManagerType manager_type); | ||
| 110 | 135 | ||
| 111 | void UpdateHidbus(std::chrono::nanoseconds ns_late); | 136 | void UpdateHidbus(std::chrono::nanoseconds ns_late); |
| 112 | std::optional<std::size_t> GetDeviceIndexFromHandle(BusHandle handle) const; | 137 | std::optional<std::size_t> GetDeviceIndexFromHandle(BusHandle handle) const; |
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp index 18e544f2f..7d7368ff9 100644 --- a/src/core/hle/service/hid/irs.cpp +++ b/src/core/hle/service/hid/irs.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/hle/kernel/k_shared_memory.h" | 9 | #include "core/hle/kernel/k_shared_memory.h" |
| 10 | #include "core/hle/kernel/k_transfer_memory.h" | 10 | #include "core/hle/kernel/k_transfer_memory.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/service/cmif_serialization.h" | ||
| 12 | #include "core/hle/service/hid/irs.h" | 13 | #include "core/hle/service/hid/irs.h" |
| 13 | #include "core/hle/service/ipc_helpers.h" | 14 | #include "core/hle/service/ipc_helpers.h" |
| 14 | #include "core/memory.h" | 15 | #include "core/memory.h" |
| @@ -28,24 +29,24 @@ namespace Service::IRS { | |||
| 28 | IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} { | 29 | IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} { |
| 29 | // clang-format off | 30 | // clang-format off |
| 30 | static const FunctionInfo functions[] = { | 31 | static const FunctionInfo functions[] = { |
| 31 | {302, &IRS::ActivateIrsensor, "ActivateIrsensor"}, | 32 | {302, C<&IRS::ActivateIrsensor>, "ActivateIrsensor"}, |
| 32 | {303, &IRS::DeactivateIrsensor, "DeactivateIrsensor"}, | 33 | {303, C<&IRS::DeactivateIrsensor>, "DeactivateIrsensor"}, |
| 33 | {304, &IRS::GetIrsensorSharedMemoryHandle, "GetIrsensorSharedMemoryHandle"}, | 34 | {304, C<&IRS::GetIrsensorSharedMemoryHandle>, "GetIrsensorSharedMemoryHandle"}, |
| 34 | {305, &IRS::StopImageProcessor, "StopImageProcessor"}, | 35 | {305, C<&IRS::StopImageProcessor>, "StopImageProcessor"}, |
| 35 | {306, &IRS::RunMomentProcessor, "RunMomentProcessor"}, | 36 | {306, C<&IRS::RunMomentProcessor>, "RunMomentProcessor"}, |
| 36 | {307, &IRS::RunClusteringProcessor, "RunClusteringProcessor"}, | 37 | {307, C<&IRS::RunClusteringProcessor>, "RunClusteringProcessor"}, |
| 37 | {308, &IRS::RunImageTransferProcessor, "RunImageTransferProcessor"}, | 38 | {308, C<&IRS::RunImageTransferProcessor>, "RunImageTransferProcessor"}, |
| 38 | {309, &IRS::GetImageTransferProcessorState, "GetImageTransferProcessorState"}, | 39 | {309, C<&IRS::GetImageTransferProcessorState>, "GetImageTransferProcessorState"}, |
| 39 | {310, &IRS::RunTeraPluginProcessor, "RunTeraPluginProcessor"}, | 40 | {310, C<&IRS::RunTeraPluginProcessor>, "RunTeraPluginProcessor"}, |
| 40 | {311, &IRS::GetNpadIrCameraHandle, "GetNpadIrCameraHandle"}, | 41 | {311, C<&IRS::GetNpadIrCameraHandle>, "GetNpadIrCameraHandle"}, |
| 41 | {312, &IRS::RunPointingProcessor, "RunPointingProcessor"}, | 42 | {312, C<&IRS::RunPointingProcessor>, "RunPointingProcessor"}, |
| 42 | {313, &IRS::SuspendImageProcessor, "SuspendImageProcessor"}, | 43 | {313, C<&IRS::SuspendImageProcessor>, "SuspendImageProcessor"}, |
| 43 | {314, &IRS::CheckFirmwareVersion, "CheckFirmwareVersion"}, | 44 | {314, C<&IRS::CheckFirmwareVersion>, "CheckFirmwareVersion"}, |
| 44 | {315, &IRS::SetFunctionLevel, "SetFunctionLevel"}, | 45 | {315, C<&IRS::SetFunctionLevel>, "SetFunctionLevel"}, |
| 45 | {316, &IRS::RunImageTransferExProcessor, "RunImageTransferExProcessor"}, | 46 | {316, C<&IRS::RunImageTransferExProcessor>, "RunImageTransferExProcessor"}, |
| 46 | {317, &IRS::RunIrLedProcessor, "RunIrLedProcessor"}, | 47 | {317, C<&IRS::RunIrLedProcessor>, "RunIrLedProcessor"}, |
| 47 | {318, &IRS::StopImageProcessorAsync, "StopImageProcessorAsync"}, | 48 | {318, C<&IRS::StopImageProcessorAsync>, "StopImageProcessorAsync"}, |
| 48 | {319, &IRS::ActivateIrsensorWithFunctionLevel, "ActivateIrsensorWithFunctionLevel"}, | 49 | {319, C<&IRS::ActivateIrsensorWithFunctionLevel>, "ActivateIrsensorWithFunctionLevel"}, |
| 49 | }; | 50 | }; |
| 50 | // clang-format on | 51 | // clang-format on |
| 51 | 52 | ||
| @@ -57,489 +58,292 @@ IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} { | |||
| 57 | } | 58 | } |
| 58 | IRS::~IRS() = default; | 59 | IRS::~IRS() = default; |
| 59 | 60 | ||
| 60 | void IRS::ActivateIrsensor(HLERequestContext& ctx) { | 61 | Result IRS::ActivateIrsensor(ClientAppletResourceUserId aruid) { |
| 61 | IPC::RequestParser rp{ctx}; | 62 | LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", aruid.pid); |
| 62 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 63 | R_SUCCEED(); |
| 63 | |||
| 64 | LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", | ||
| 65 | applet_resource_user_id); | ||
| 66 | |||
| 67 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 68 | rb.Push(ResultSuccess); | ||
| 69 | } | 64 | } |
| 70 | 65 | ||
| 71 | void IRS::DeactivateIrsensor(HLERequestContext& ctx) { | 66 | Result IRS::DeactivateIrsensor(ClientAppletResourceUserId aruid) { |
| 72 | IPC::RequestParser rp{ctx}; | 67 | LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", aruid.pid); |
| 73 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 68 | R_SUCCEED(); |
| 74 | |||
| 75 | LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", | ||
| 76 | applet_resource_user_id); | ||
| 77 | |||
| 78 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 79 | rb.Push(ResultSuccess); | ||
| 80 | } | 69 | } |
| 81 | 70 | ||
| 82 | void IRS::GetIrsensorSharedMemoryHandle(HLERequestContext& ctx) { | 71 | Result IRS::GetIrsensorSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory, |
| 83 | IPC::RequestParser rp{ctx}; | 72 | ClientAppletResourceUserId aruid) { |
| 84 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 73 | LOG_DEBUG(Service_IRS, "called, applet_resource_user_id={}", aruid.pid); |
| 85 | |||
| 86 | LOG_DEBUG(Service_IRS, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 87 | 74 | ||
| 88 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 75 | *out_shared_memory = &system.Kernel().GetIrsSharedMem(); |
| 89 | rb.Push(ResultSuccess); | 76 | R_SUCCEED(); |
| 90 | rb.PushCopyObjects(&system.Kernel().GetIrsSharedMem()); | ||
| 91 | } | 77 | } |
| 92 | 78 | ||
| 93 | void IRS::StopImageProcessor(HLERequestContext& ctx) { | 79 | Result IRS::StopImageProcessor(Core::IrSensor::IrCameraHandle camera_handle, |
| 94 | IPC::RequestParser rp{ctx}; | 80 | ClientAppletResourceUserId aruid) { |
| 95 | struct Parameters { | ||
| 96 | Core::IrSensor::IrCameraHandle camera_handle; | ||
| 97 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 98 | u64 applet_resource_user_id; | ||
| 99 | }; | ||
| 100 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 101 | |||
| 102 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 103 | |||
| 104 | LOG_WARNING(Service_IRS, | 81 | LOG_WARNING(Service_IRS, |
| 105 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", | 82 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", |
| 106 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 83 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid); |
| 107 | parameters.applet_resource_user_id); | ||
| 108 | |||
| 109 | auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 110 | if (result.IsSuccess()) { | ||
| 111 | // TODO: Stop Image processor | ||
| 112 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 113 | Common::Input::PollingMode::Active); | ||
| 114 | result = ResultSuccess; | ||
| 115 | } | ||
| 116 | 84 | ||
| 117 | IPC::ResponseBuilder rb{ctx, 2}; | 85 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 118 | rb.Push(result); | ||
| 119 | } | ||
| 120 | |||
| 121 | void IRS::RunMomentProcessor(HLERequestContext& ctx) { | ||
| 122 | IPC::RequestParser rp{ctx}; | ||
| 123 | struct Parameters { | ||
| 124 | Core::IrSensor::IrCameraHandle camera_handle; | ||
| 125 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 126 | u64 applet_resource_user_id; | ||
| 127 | Core::IrSensor::PackedMomentProcessorConfig processor_config; | ||
| 128 | }; | ||
| 129 | static_assert(sizeof(Parameters) == 0x30, "Parameters has incorrect size."); | ||
| 130 | 86 | ||
| 131 | const auto parameters{rp.PopRaw<Parameters>()}; | 87 | // TODO: Stop Image processor |
| 88 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 89 | Common::Input::PollingMode::Active); | ||
| 90 | R_SUCCEED(); | ||
| 91 | } | ||
| 132 | 92 | ||
| 93 | Result IRS::RunMomentProcessor( | ||
| 94 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 95 | const Core::IrSensor::PackedMomentProcessorConfig& processor_config) { | ||
| 133 | LOG_WARNING(Service_IRS, | 96 | LOG_WARNING(Service_IRS, |
| 134 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", | 97 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", |
| 135 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 98 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid); |
| 136 | parameters.applet_resource_user_id); | ||
| 137 | |||
| 138 | const auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 139 | |||
| 140 | if (result.IsSuccess()) { | ||
| 141 | auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle); | ||
| 142 | MakeProcessorWithCoreContext<MomentProcessor>(parameters.camera_handle, device); | ||
| 143 | auto& image_transfer_processor = GetProcessor<MomentProcessor>(parameters.camera_handle); | ||
| 144 | image_transfer_processor.SetConfig(parameters.processor_config); | ||
| 145 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 146 | Common::Input::PollingMode::IR); | ||
| 147 | } | ||
| 148 | 99 | ||
| 149 | IPC::ResponseBuilder rb{ctx, 2}; | 100 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 150 | rb.Push(result); | ||
| 151 | } | ||
| 152 | 101 | ||
| 153 | void IRS::RunClusteringProcessor(HLERequestContext& ctx) { | 102 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 154 | IPC::RequestParser rp{ctx}; | 103 | MakeProcessorWithCoreContext<MomentProcessor>(camera_handle, device); |
| 155 | struct Parameters { | 104 | auto& image_transfer_processor = GetProcessor<MomentProcessor>(camera_handle); |
| 156 | Core::IrSensor::IrCameraHandle camera_handle; | 105 | image_transfer_processor.SetConfig(processor_config); |
| 157 | INSERT_PADDING_WORDS_NOINIT(1); | 106 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 158 | u64 applet_resource_user_id; | 107 | Common::Input::PollingMode::IR); |
| 159 | Core::IrSensor::PackedClusteringProcessorConfig processor_config; | ||
| 160 | }; | ||
| 161 | static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size."); | ||
| 162 | 108 | ||
| 163 | const auto parameters{rp.PopRaw<Parameters>()}; | 109 | R_SUCCEED(); |
| 110 | } | ||
| 164 | 111 | ||
| 112 | Result IRS::RunClusteringProcessor( | ||
| 113 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 114 | const Core::IrSensor::PackedClusteringProcessorConfig& processor_config) { | ||
| 165 | LOG_WARNING(Service_IRS, | 115 | LOG_WARNING(Service_IRS, |
| 166 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", | 116 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", |
| 167 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 117 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid); |
| 168 | parameters.applet_resource_user_id); | ||
| 169 | |||
| 170 | auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 171 | |||
| 172 | if (result.IsSuccess()) { | ||
| 173 | auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle); | ||
| 174 | MakeProcessorWithCoreContext<ClusteringProcessor>(parameters.camera_handle, device); | ||
| 175 | auto& image_transfer_processor = | ||
| 176 | GetProcessor<ClusteringProcessor>(parameters.camera_handle); | ||
| 177 | image_transfer_processor.SetConfig(parameters.processor_config); | ||
| 178 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 179 | Common::Input::PollingMode::IR); | ||
| 180 | } | ||
| 181 | 118 | ||
| 182 | IPC::ResponseBuilder rb{ctx, 2}; | 119 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 183 | rb.Push(result); | ||
| 184 | } | ||
| 185 | 120 | ||
| 186 | void IRS::RunImageTransferProcessor(HLERequestContext& ctx) { | 121 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 187 | IPC::RequestParser rp{ctx}; | 122 | MakeProcessorWithCoreContext<ClusteringProcessor>(camera_handle, device); |
| 188 | struct Parameters { | 123 | auto& image_transfer_processor = GetProcessor<ClusteringProcessor>(camera_handle); |
| 189 | Core::IrSensor::IrCameraHandle camera_handle; | 124 | image_transfer_processor.SetConfig(processor_config); |
| 190 | INSERT_PADDING_WORDS_NOINIT(1); | 125 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 191 | u64 applet_resource_user_id; | 126 | Common::Input::PollingMode::IR); |
| 192 | Core::IrSensor::PackedImageTransferProcessorConfig processor_config; | ||
| 193 | u32 transfer_memory_size; | ||
| 194 | }; | ||
| 195 | static_assert(sizeof(Parameters) == 0x30, "Parameters has incorrect size."); | ||
| 196 | 127 | ||
| 197 | const auto parameters{rp.PopRaw<Parameters>()}; | 128 | R_SUCCEED(); |
| 198 | const auto t_mem_handle{ctx.GetCopyHandle(0)}; | 129 | } |
| 199 | 130 | ||
| 200 | auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle); | 131 | Result IRS::RunImageTransferProcessor( |
| 132 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 133 | const Core::IrSensor::PackedImageTransferProcessorConfig& processor_config, | ||
| 134 | u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem) { | ||
| 201 | 135 | ||
| 202 | if (t_mem.IsNull()) { | 136 | ASSERT_MSG(t_mem->GetSize() == transfer_memory_size, "t_mem has incorrect size"); |
| 203 | LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); | ||
| 204 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 205 | rb.Push(ResultUnknown); | ||
| 206 | return; | ||
| 207 | } | ||
| 208 | |||
| 209 | ASSERT_MSG(t_mem->GetSize() == parameters.transfer_memory_size, "t_mem has incorrect size"); | ||
| 210 | 137 | ||
| 211 | LOG_INFO(Service_IRS, | 138 | LOG_INFO(Service_IRS, |
| 212 | "called, npad_type={}, npad_id={}, transfer_memory_size={}, transfer_memory_size={}, " | 139 | "called, npad_type={}, npad_id={}, transfer_memory_size={}, transfer_memory_size={}, " |
| 213 | "applet_resource_user_id={}", | 140 | "applet_resource_user_id={}", |
| 214 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 141 | camera_handle.npad_type, camera_handle.npad_id, transfer_memory_size, t_mem->GetSize(), |
| 215 | parameters.transfer_memory_size, t_mem->GetSize(), parameters.applet_resource_user_id); | 142 | aruid.pid); |
| 216 | |||
| 217 | const auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 218 | |||
| 219 | if (result.IsSuccess()) { | ||
| 220 | auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle); | ||
| 221 | MakeProcessorWithCoreContext<ImageTransferProcessor>(parameters.camera_handle, device); | ||
| 222 | auto& image_transfer_processor = | ||
| 223 | GetProcessor<ImageTransferProcessor>(parameters.camera_handle); | ||
| 224 | image_transfer_processor.SetConfig(parameters.processor_config); | ||
| 225 | image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress()); | ||
| 226 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 227 | Common::Input::PollingMode::IR); | ||
| 228 | } | ||
| 229 | 143 | ||
| 230 | IPC::ResponseBuilder rb{ctx, 2}; | 144 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 231 | rb.Push(result); | ||
| 232 | } | ||
| 233 | 145 | ||
| 234 | void IRS::GetImageTransferProcessorState(HLERequestContext& ctx) { | 146 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 235 | IPC::RequestParser rp{ctx}; | 147 | MakeProcessorWithCoreContext<ImageTransferProcessor>(camera_handle, device); |
| 236 | struct Parameters { | 148 | auto& image_transfer_processor = GetProcessor<ImageTransferProcessor>(camera_handle); |
| 237 | Core::IrSensor::IrCameraHandle camera_handle; | 149 | image_transfer_processor.SetConfig(processor_config); |
| 238 | INSERT_PADDING_WORDS_NOINIT(1); | 150 | image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress()); |
| 239 | u64 applet_resource_user_id; | 151 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 240 | }; | 152 | Common::Input::PollingMode::IR); |
| 241 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 242 | 153 | ||
| 243 | const auto parameters{rp.PopRaw<Parameters>()}; | 154 | R_SUCCEED(); |
| 155 | } | ||
| 244 | 156 | ||
| 157 | Result IRS::GetImageTransferProcessorState( | ||
| 158 | Out<Core::IrSensor::ImageTransferProcessorState> out_state, | ||
| 159 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 160 | OutBuffer<BufferAttr_HipcMapAlias> out_buffer_data) { | ||
| 245 | LOG_DEBUG(Service_IRS, "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", | 161 | LOG_DEBUG(Service_IRS, "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", |
| 246 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 162 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid); |
| 247 | parameters.applet_resource_user_id); | ||
| 248 | |||
| 249 | const auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 250 | if (result.IsError()) { | ||
| 251 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 252 | rb.Push(result); | ||
| 253 | return; | ||
| 254 | } | ||
| 255 | 163 | ||
| 256 | const auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle); | 164 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 257 | 165 | ||
| 258 | if (device.mode != Core::IrSensor::IrSensorMode::ImageTransferProcessor) { | 166 | const auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 259 | IPC::ResponseBuilder rb{ctx, 2}; | 167 | |
| 260 | rb.Push(InvalidProcessorState); | 168 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 261 | return; | 169 | R_UNLESS(device.mode == Core::IrSensor::IrSensorMode::ImageTransferProcessor, |
| 262 | } | 170 | InvalidProcessorState); |
| 263 | 171 | ||
| 264 | std::vector<u8> data{}; | 172 | *out_state = GetProcessor<ImageTransferProcessor>(camera_handle).GetState(out_buffer_data); |
| 265 | const auto& image_transfer_processor = | ||
| 266 | GetProcessor<ImageTransferProcessor>(parameters.camera_handle); | ||
| 267 | const auto& state = image_transfer_processor.GetState(data); | ||
| 268 | 173 | ||
| 269 | ctx.WriteBuffer(data); | 174 | R_SUCCEED(); |
| 270 | IPC::ResponseBuilder rb{ctx, 6}; | ||
| 271 | rb.Push(ResultSuccess); | ||
| 272 | rb.PushRaw(state); | ||
| 273 | } | 175 | } |
| 274 | 176 | ||
| 275 | void IRS::RunTeraPluginProcessor(HLERequestContext& ctx) { | 177 | Result IRS::RunTeraPluginProcessor(Core::IrSensor::IrCameraHandle camera_handle, |
| 276 | IPC::RequestParser rp{ctx}; | 178 | Core::IrSensor::PackedTeraPluginProcessorConfig processor_config, |
| 277 | struct Parameters { | 179 | ClientAppletResourceUserId aruid) { |
| 278 | Core::IrSensor::IrCameraHandle camera_handle; | 180 | LOG_WARNING(Service_IRS, |
| 279 | Core::IrSensor::PackedTeraPluginProcessorConfig processor_config; | 181 | "(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, " |
| 280 | INSERT_PADDING_WORDS_NOINIT(1); | 182 | "applet_resource_user_id={}", |
| 281 | u64 applet_resource_user_id; | 183 | camera_handle.npad_type, camera_handle.npad_id, processor_config.mode, |
| 282 | }; | 184 | processor_config.required_mcu_version.major, |
| 283 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 185 | processor_config.required_mcu_version.minor, aruid.pid); |
| 284 | 186 | ||
| 285 | const auto parameters{rp.PopRaw<Parameters>()}; | 187 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 286 | 188 | ||
| 287 | LOG_WARNING( | 189 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 288 | Service_IRS, | 190 | MakeProcessor<TeraPluginProcessor>(camera_handle, device); |
| 289 | "(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, " | 191 | auto& image_transfer_processor = GetProcessor<TeraPluginProcessor>(camera_handle); |
| 290 | "applet_resource_user_id={}", | 192 | image_transfer_processor.SetConfig(processor_config); |
| 291 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 193 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 292 | parameters.processor_config.mode, parameters.processor_config.required_mcu_version.major, | 194 | Common::Input::PollingMode::IR); |
| 293 | parameters.processor_config.required_mcu_version.minor, parameters.applet_resource_user_id); | ||
| 294 | |||
| 295 | const auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 296 | |||
| 297 | if (result.IsSuccess()) { | ||
| 298 | auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle); | ||
| 299 | MakeProcessor<TeraPluginProcessor>(parameters.camera_handle, device); | ||
| 300 | auto& image_transfer_processor = | ||
| 301 | GetProcessor<TeraPluginProcessor>(parameters.camera_handle); | ||
| 302 | image_transfer_processor.SetConfig(parameters.processor_config); | ||
| 303 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 304 | Common::Input::PollingMode::IR); | ||
| 305 | } | ||
| 306 | 195 | ||
| 307 | IPC::ResponseBuilder rb{ctx, 2}; | 196 | R_SUCCEED(); |
| 308 | rb.Push(result); | ||
| 309 | } | 197 | } |
| 310 | 198 | ||
| 311 | void IRS::GetNpadIrCameraHandle(HLERequestContext& ctx) { | 199 | Result IRS::GetNpadIrCameraHandle(Out<Core::IrSensor::IrCameraHandle> out_camera_handle, |
| 312 | IPC::RequestParser rp{ctx}; | 200 | Core::HID::NpadIdType npad_id) { |
| 313 | const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; | 201 | R_UNLESS(HID::IsNpadIdValid(npad_id), HID::ResultInvalidNpadId); |
| 314 | |||
| 315 | if (npad_id > Core::HID::NpadIdType::Player8 && npad_id != Core::HID::NpadIdType::Invalid && | ||
| 316 | npad_id != Core::HID::NpadIdType::Handheld) { | ||
| 317 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 318 | rb.Push(Service::HID::ResultInvalidNpadId); | ||
| 319 | return; | ||
| 320 | } | ||
| 321 | 202 | ||
| 322 | Core::IrSensor::IrCameraHandle camera_handle{ | 203 | *out_camera_handle = { |
| 323 | .npad_id = static_cast<u8>(HID::NpadIdTypeToIndex(npad_id)), | 204 | .npad_id = static_cast<u8>(HID::NpadIdTypeToIndex(npad_id)), |
| 324 | .npad_type = Core::HID::NpadStyleIndex::None, | 205 | .npad_type = Core::HID::NpadStyleIndex::None, |
| 325 | }; | 206 | }; |
| 326 | 207 | ||
| 327 | LOG_INFO(Service_IRS, "called, npad_id={}, camera_npad_id={}, camera_npad_type={}", npad_id, | 208 | LOG_INFO(Service_IRS, "called, npad_id={}, camera_npad_id={}, camera_npad_type={}", npad_id, |
| 328 | camera_handle.npad_id, camera_handle.npad_type); | 209 | out_camera_handle->npad_id, out_camera_handle->npad_type); |
| 329 | 210 | ||
| 330 | IPC::ResponseBuilder rb{ctx, 3}; | 211 | R_SUCCEED(); |
| 331 | rb.Push(ResultSuccess); | ||
| 332 | rb.PushRaw(camera_handle); | ||
| 333 | } | 212 | } |
| 334 | 213 | ||
| 335 | void IRS::RunPointingProcessor(HLERequestContext& ctx) { | 214 | Result IRS::RunPointingProcessor( |
| 336 | IPC::RequestParser rp{ctx}; | 215 | Core::IrSensor::IrCameraHandle camera_handle, |
| 337 | const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; | 216 | const Core::IrSensor::PackedPointingProcessorConfig& processor_config, |
| 338 | const auto processor_config{rp.PopRaw<Core::IrSensor::PackedPointingProcessorConfig>()}; | 217 | ClientAppletResourceUserId aruid) { |
| 339 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 340 | |||
| 341 | LOG_WARNING( | 218 | LOG_WARNING( |
| 342 | Service_IRS, | 219 | Service_IRS, |
| 343 | "(STUBBED) called, npad_type={}, npad_id={}, mcu_version={}.{}, applet_resource_user_id={}", | 220 | "(STUBBED) called, npad_type={}, npad_id={}, mcu_version={}.{}, applet_resource_user_id={}", |
| 344 | camera_handle.npad_type, camera_handle.npad_id, processor_config.required_mcu_version.major, | 221 | camera_handle.npad_type, camera_handle.npad_id, processor_config.required_mcu_version.major, |
| 345 | processor_config.required_mcu_version.minor, applet_resource_user_id); | 222 | processor_config.required_mcu_version.minor, aruid.pid); |
| 346 | 223 | ||
| 347 | auto result = IsIrCameraHandleValid(camera_handle); | 224 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 348 | 225 | ||
| 349 | if (result.IsSuccess()) { | 226 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 350 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); | 227 | MakeProcessor<PointingProcessor>(camera_handle, device); |
| 351 | MakeProcessor<PointingProcessor>(camera_handle, device); | 228 | auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle); |
| 352 | auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle); | 229 | image_transfer_processor.SetConfig(processor_config); |
| 353 | image_transfer_processor.SetConfig(processor_config); | 230 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 354 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | 231 | Common::Input::PollingMode::IR); |
| 355 | Common::Input::PollingMode::IR); | ||
| 356 | } | ||
| 357 | 232 | ||
| 358 | IPC::ResponseBuilder rb{ctx, 2}; | 233 | R_SUCCEED(); |
| 359 | rb.Push(result); | ||
| 360 | } | 234 | } |
| 361 | 235 | ||
| 362 | void IRS::SuspendImageProcessor(HLERequestContext& ctx) { | 236 | Result IRS::SuspendImageProcessor(Core::IrSensor::IrCameraHandle camera_handle, |
| 363 | IPC::RequestParser rp{ctx}; | 237 | ClientAppletResourceUserId aruid) { |
| 364 | struct Parameters { | ||
| 365 | Core::IrSensor::IrCameraHandle camera_handle; | ||
| 366 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 367 | u64 applet_resource_user_id; | ||
| 368 | }; | ||
| 369 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 370 | |||
| 371 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 372 | |||
| 373 | LOG_WARNING(Service_IRS, | 238 | LOG_WARNING(Service_IRS, |
| 374 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", | 239 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", |
| 375 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 240 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid); |
| 376 | parameters.applet_resource_user_id); | ||
| 377 | 241 | ||
| 378 | auto result = IsIrCameraHandleValid(parameters.camera_handle); | 242 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 379 | if (result.IsSuccess()) { | ||
| 380 | // TODO: Suspend image processor | ||
| 381 | result = ResultSuccess; | ||
| 382 | } | ||
| 383 | 243 | ||
| 384 | IPC::ResponseBuilder rb{ctx, 2}; | 244 | // TODO: Suspend image processor |
| 385 | rb.Push(result); | ||
| 386 | } | ||
| 387 | 245 | ||
| 388 | void IRS::CheckFirmwareVersion(HLERequestContext& ctx) { | 246 | R_SUCCEED(); |
| 389 | IPC::RequestParser rp{ctx}; | 247 | } |
| 390 | const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; | ||
| 391 | const auto mcu_version{rp.PopRaw<Core::IrSensor::PackedMcuVersion>()}; | ||
| 392 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 393 | 248 | ||
| 249 | Result IRS::CheckFirmwareVersion(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 250 | Core::IrSensor::PackedMcuVersion mcu_version, | ||
| 251 | ClientAppletResourceUserId aruid) { | ||
| 394 | LOG_WARNING( | 252 | LOG_WARNING( |
| 395 | Service_IRS, | 253 | Service_IRS, |
| 396 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}, mcu_version={}.{}", | 254 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}, mcu_version={}.{}", |
| 397 | camera_handle.npad_type, camera_handle.npad_id, applet_resource_user_id, mcu_version.major, | 255 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid, mcu_version.major, |
| 398 | mcu_version.minor); | 256 | mcu_version.minor); |
| 399 | 257 | ||
| 400 | auto result = IsIrCameraHandleValid(camera_handle); | 258 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 401 | if (result.IsSuccess()) { | ||
| 402 | // TODO: Check firmware version | ||
| 403 | result = ResultSuccess; | ||
| 404 | } | ||
| 405 | 259 | ||
| 406 | IPC::ResponseBuilder rb{ctx, 2}; | 260 | // TODO: Check firmware version |
| 407 | rb.Push(result); | ||
| 408 | } | ||
| 409 | 261 | ||
| 410 | void IRS::SetFunctionLevel(HLERequestContext& ctx) { | 262 | R_SUCCEED(); |
| 411 | IPC::RequestParser rp{ctx}; | 263 | } |
| 412 | const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; | ||
| 413 | const auto function_level{rp.PopRaw<Core::IrSensor::PackedFunctionLevel>()}; | ||
| 414 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 415 | 264 | ||
| 265 | Result IRS::SetFunctionLevel(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 266 | Core::IrSensor::PackedFunctionLevel function_level, | ||
| 267 | ClientAppletResourceUserId aruid) { | ||
| 416 | LOG_WARNING( | 268 | LOG_WARNING( |
| 417 | Service_IRS, | 269 | Service_IRS, |
| 418 | "(STUBBED) called, npad_type={}, npad_id={}, function_level={}, applet_resource_user_id={}", | 270 | "(STUBBED) called, npad_type={}, npad_id={}, function_level={}, applet_resource_user_id={}", |
| 419 | camera_handle.npad_type, camera_handle.npad_id, function_level.function_level, | 271 | camera_handle.npad_type, camera_handle.npad_id, function_level.function_level, aruid.pid); |
| 420 | applet_resource_user_id); | ||
| 421 | 272 | ||
| 422 | auto result = IsIrCameraHandleValid(camera_handle); | 273 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 423 | if (result.IsSuccess()) { | ||
| 424 | // TODO: Set Function level | ||
| 425 | result = ResultSuccess; | ||
| 426 | } | ||
| 427 | 274 | ||
| 428 | IPC::ResponseBuilder rb{ctx, 2}; | 275 | // TODO: Set Function level |
| 429 | rb.Push(result); | ||
| 430 | } | ||
| 431 | 276 | ||
| 432 | void IRS::RunImageTransferExProcessor(HLERequestContext& ctx) { | 277 | R_SUCCEED(); |
| 433 | IPC::RequestParser rp{ctx}; | 278 | } |
| 434 | struct Parameters { | ||
| 435 | Core::IrSensor::IrCameraHandle camera_handle; | ||
| 436 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 437 | u64 applet_resource_user_id; | ||
| 438 | Core::IrSensor::PackedImageTransferProcessorExConfig processor_config; | ||
| 439 | u64 transfer_memory_size; | ||
| 440 | }; | ||
| 441 | static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size."); | ||
| 442 | 279 | ||
| 443 | const auto parameters{rp.PopRaw<Parameters>()}; | 280 | Result IRS::RunImageTransferExProcessor( |
| 444 | const auto t_mem_handle{ctx.GetCopyHandle(0)}; | 281 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, |
| 282 | const Core::IrSensor::PackedImageTransferProcessorExConfig& processor_config, | ||
| 283 | u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem) { | ||
| 445 | 284 | ||
| 446 | auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle); | 285 | ASSERT_MSG(t_mem->GetSize() == transfer_memory_size, "t_mem has incorrect size"); |
| 447 | 286 | ||
| 448 | LOG_INFO(Service_IRS, | 287 | LOG_INFO(Service_IRS, |
| 449 | "called, npad_type={}, npad_id={}, transfer_memory_size={}, " | 288 | "called, npad_type={}, npad_id={}, transfer_memory_size={}, " |
| 450 | "applet_resource_user_id={}", | 289 | "applet_resource_user_id={}", |
| 451 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 290 | camera_handle.npad_type, camera_handle.npad_id, transfer_memory_size, aruid.pid); |
| 452 | parameters.transfer_memory_size, parameters.applet_resource_user_id); | ||
| 453 | |||
| 454 | auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 455 | |||
| 456 | if (result.IsSuccess()) { | ||
| 457 | auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle); | ||
| 458 | MakeProcessorWithCoreContext<ImageTransferProcessor>(parameters.camera_handle, device); | ||
| 459 | auto& image_transfer_processor = | ||
| 460 | GetProcessor<ImageTransferProcessor>(parameters.camera_handle); | ||
| 461 | image_transfer_processor.SetConfig(parameters.processor_config); | ||
| 462 | image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress()); | ||
| 463 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 464 | Common::Input::PollingMode::IR); | ||
| 465 | } | ||
| 466 | 291 | ||
| 467 | IPC::ResponseBuilder rb{ctx, 2}; | 292 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 468 | rb.Push(result); | 293 | |
| 469 | } | 294 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 295 | MakeProcessorWithCoreContext<ImageTransferProcessor>(camera_handle, device); | ||
| 296 | auto& image_transfer_processor = GetProcessor<ImageTransferProcessor>(camera_handle); | ||
| 297 | image_transfer_processor.SetConfig(processor_config); | ||
| 298 | image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress()); | ||
| 299 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 300 | Common::Input::PollingMode::IR); | ||
| 470 | 301 | ||
| 471 | void IRS::RunIrLedProcessor(HLERequestContext& ctx) { | 302 | R_SUCCEED(); |
| 472 | IPC::RequestParser rp{ctx}; | 303 | } |
| 473 | const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; | ||
| 474 | const auto processor_config{rp.PopRaw<Core::IrSensor::PackedIrLedProcessorConfig>()}; | ||
| 475 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 476 | 304 | ||
| 305 | Result IRS::RunIrLedProcessor(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 306 | Core::IrSensor::PackedIrLedProcessorConfig processor_config, | ||
| 307 | ClientAppletResourceUserId aruid) { | ||
| 477 | LOG_WARNING(Service_IRS, | 308 | LOG_WARNING(Service_IRS, |
| 478 | "(STUBBED) called, npad_type={}, npad_id={}, light_target={}, mcu_version={}.{} " | 309 | "(STUBBED) called, npad_type={}, npad_id={}, light_target={}, mcu_version={}.{} " |
| 479 | "applet_resource_user_id={}", | 310 | "applet_resource_user_id={}", |
| 480 | camera_handle.npad_type, camera_handle.npad_id, processor_config.light_target, | 311 | camera_handle.npad_type, camera_handle.npad_id, processor_config.light_target, |
| 481 | processor_config.required_mcu_version.major, | 312 | processor_config.required_mcu_version.major, |
| 482 | processor_config.required_mcu_version.minor, applet_resource_user_id); | 313 | processor_config.required_mcu_version.minor, aruid.pid); |
| 483 | 314 | ||
| 484 | auto result = IsIrCameraHandleValid(camera_handle); | 315 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 485 | 316 | ||
| 486 | if (result.IsSuccess()) { | 317 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); |
| 487 | auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle); | 318 | MakeProcessor<IrLedProcessor>(camera_handle, device); |
| 488 | MakeProcessor<IrLedProcessor>(camera_handle, device); | 319 | auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle); |
| 489 | auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle); | 320 | image_transfer_processor.SetConfig(processor_config); |
| 490 | image_transfer_processor.SetConfig(processor_config); | 321 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 491 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | 322 | Common::Input::PollingMode::IR); |
| 492 | Common::Input::PollingMode::IR); | ||
| 493 | } | ||
| 494 | 323 | ||
| 495 | IPC::ResponseBuilder rb{ctx, 2}; | 324 | R_SUCCEED(); |
| 496 | rb.Push(result); | ||
| 497 | } | 325 | } |
| 498 | 326 | ||
| 499 | void IRS::StopImageProcessorAsync(HLERequestContext& ctx) { | 327 | Result IRS::StopImageProcessorAsync(Core::IrSensor::IrCameraHandle camera_handle, |
| 500 | IPC::RequestParser rp{ctx}; | 328 | ClientAppletResourceUserId aruid) { |
| 501 | struct Parameters { | ||
| 502 | Core::IrSensor::IrCameraHandle camera_handle; | ||
| 503 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 504 | u64 applet_resource_user_id; | ||
| 505 | }; | ||
| 506 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 507 | |||
| 508 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 509 | |||
| 510 | LOG_WARNING(Service_IRS, | 329 | LOG_WARNING(Service_IRS, |
| 511 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", | 330 | "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}", |
| 512 | parameters.camera_handle.npad_type, parameters.camera_handle.npad_id, | 331 | camera_handle.npad_type, camera_handle.npad_id, aruid.pid); |
| 513 | parameters.applet_resource_user_id); | ||
| 514 | |||
| 515 | auto result = IsIrCameraHandleValid(parameters.camera_handle); | ||
| 516 | if (result.IsSuccess()) { | ||
| 517 | // TODO: Stop image processor async | ||
| 518 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 519 | Common::Input::PollingMode::Active); | ||
| 520 | result = ResultSuccess; | ||
| 521 | } | ||
| 522 | 332 | ||
| 523 | IPC::ResponseBuilder rb{ctx, 2}; | 333 | R_TRY(IsIrCameraHandleValid(camera_handle)); |
| 524 | rb.Push(result); | ||
| 525 | } | ||
| 526 | 334 | ||
| 527 | void IRS::ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx) { | 335 | // TODO: Stop image processor async |
| 528 | IPC::RequestParser rp{ctx}; | 336 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, |
| 529 | struct Parameters { | 337 | Common::Input::PollingMode::Active); |
| 530 | Core::IrSensor::PackedFunctionLevel function_level; | ||
| 531 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 532 | u64 applet_resource_user_id; | ||
| 533 | }; | ||
| 534 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 535 | 338 | ||
| 536 | const auto parameters{rp.PopRaw<Parameters>()}; | 339 | R_SUCCEED(); |
| 340 | } | ||
| 537 | 341 | ||
| 342 | Result IRS::ActivateIrsensorWithFunctionLevel(Core::IrSensor::PackedFunctionLevel function_level, | ||
| 343 | ClientAppletResourceUserId aruid) { | ||
| 538 | LOG_WARNING(Service_IRS, "(STUBBED) called, function_level={}, applet_resource_user_id={}", | 344 | LOG_WARNING(Service_IRS, "(STUBBED) called, function_level={}, applet_resource_user_id={}", |
| 539 | parameters.function_level.function_level, parameters.applet_resource_user_id); | 345 | function_level.function_level, aruid.pid); |
| 540 | 346 | R_SUCCEED(); | |
| 541 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 542 | rb.Push(ResultSuccess); | ||
| 543 | } | 347 | } |
| 544 | 348 | ||
| 545 | Result IRS::IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const { | 349 | Result IRS::IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const { |
diff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.h index 06b7279ee..58dfee6c3 100644 --- a/src/core/hle/service/hid/irs.h +++ b/src/core/hle/service/hid/irs.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "hid_core/hid_types.h" | 9 | #include "hid_core/hid_types.h" |
| 9 | #include "hid_core/irsensor/irs_types.h" | 10 | #include "hid_core/irsensor/irs_types.h" |
| @@ -35,26 +36,73 @@ private: | |||
| 35 | }; | 36 | }; |
| 36 | static_assert(sizeof(StatusManager) == 0x8000, "StatusManager is an invalid size"); | 37 | static_assert(sizeof(StatusManager) == 0x8000, "StatusManager is an invalid size"); |
| 37 | 38 | ||
| 38 | void ActivateIrsensor(HLERequestContext& ctx); | 39 | Result ActivateIrsensor(ClientAppletResourceUserId aruid); |
| 39 | void DeactivateIrsensor(HLERequestContext& ctx); | 40 | |
| 40 | void GetIrsensorSharedMemoryHandle(HLERequestContext& ctx); | 41 | Result DeactivateIrsensor(ClientAppletResourceUserId aruid); |
| 41 | void StopImageProcessor(HLERequestContext& ctx); | 42 | |
| 42 | void RunMomentProcessor(HLERequestContext& ctx); | 43 | Result GetIrsensorSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory, |
| 43 | void RunClusteringProcessor(HLERequestContext& ctx); | 44 | ClientAppletResourceUserId aruid); |
| 44 | void RunImageTransferProcessor(HLERequestContext& ctx); | 45 | Result StopImageProcessor(Core::IrSensor::IrCameraHandle camera_handle, |
| 45 | void GetImageTransferProcessorState(HLERequestContext& ctx); | 46 | ClientAppletResourceUserId aruid); |
| 46 | void RunTeraPluginProcessor(HLERequestContext& ctx); | 47 | |
| 47 | void GetNpadIrCameraHandle(HLERequestContext& ctx); | 48 | Result RunMomentProcessor(Core::IrSensor::IrCameraHandle camera_handle, |
| 48 | void RunPointingProcessor(HLERequestContext& ctx); | 49 | ClientAppletResourceUserId aruid, |
| 49 | void SuspendImageProcessor(HLERequestContext& ctx); | 50 | const Core::IrSensor::PackedMomentProcessorConfig& processor_config); |
| 50 | void CheckFirmwareVersion(HLERequestContext& ctx); | 51 | |
| 51 | void SetFunctionLevel(HLERequestContext& ctx); | 52 | Result RunClusteringProcessor( |
| 52 | void RunImageTransferExProcessor(HLERequestContext& ctx); | 53 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, |
| 53 | void RunIrLedProcessor(HLERequestContext& ctx); | 54 | const Core::IrSensor::PackedClusteringProcessorConfig& processor_config); |
| 54 | void StopImageProcessorAsync(HLERequestContext& ctx); | 55 | |
| 55 | void ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx); | 56 | Result RunImageTransferProcessor( |
| 57 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 58 | const Core::IrSensor::PackedImageTransferProcessorConfig& processor_config, | ||
| 59 | u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem); | ||
| 60 | |||
| 61 | Result GetImageTransferProcessorState( | ||
| 62 | Out<Core::IrSensor::ImageTransferProcessorState> out_state, | ||
| 63 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 64 | OutBuffer<BufferAttr_HipcMapAlias> out_buffer_data); | ||
| 65 | |||
| 66 | Result RunTeraPluginProcessor(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 67 | Core::IrSensor::PackedTeraPluginProcessorConfig processor_config, | ||
| 68 | ClientAppletResourceUserId aruid); | ||
| 69 | |||
| 70 | Result GetNpadIrCameraHandle(Out<Core::IrSensor::IrCameraHandle> out_camera_handle, | ||
| 71 | Core::HID::NpadIdType npad_id); | ||
| 72 | |||
| 73 | Result RunPointingProcessor( | ||
| 74 | Core::IrSensor::IrCameraHandle camera_handle, | ||
| 75 | const Core::IrSensor::PackedPointingProcessorConfig& processor_config, | ||
| 76 | ClientAppletResourceUserId aruid); | ||
| 77 | |||
| 78 | Result SuspendImageProcessor(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 79 | ClientAppletResourceUserId aruid); | ||
| 80 | |||
| 81 | Result CheckFirmwareVersion(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 82 | Core::IrSensor::PackedMcuVersion mcu_version, | ||
| 83 | ClientAppletResourceUserId aruid); | ||
| 84 | |||
| 85 | Result SetFunctionLevel(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 86 | Core::IrSensor::PackedFunctionLevel function_level, | ||
| 87 | ClientAppletResourceUserId aruid); | ||
| 88 | |||
| 89 | Result RunImageTransferExProcessor( | ||
| 90 | Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid, | ||
| 91 | const Core::IrSensor::PackedImageTransferProcessorExConfig& processor_config, | ||
| 92 | u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem); | ||
| 93 | |||
| 94 | Result RunIrLedProcessor(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 95 | Core::IrSensor::PackedIrLedProcessorConfig processor_config, | ||
| 96 | ClientAppletResourceUserId aruid); | ||
| 97 | |||
| 98 | Result StopImageProcessorAsync(Core::IrSensor::IrCameraHandle camera_handle, | ||
| 99 | ClientAppletResourceUserId aruid); | ||
| 100 | |||
| 101 | Result ActivateIrsensorWithFunctionLevel(Core::IrSensor::PackedFunctionLevel function_level, | ||
| 102 | ClientAppletResourceUserId aruid); | ||
| 56 | 103 | ||
| 57 | Result IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const; | 104 | Result IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const; |
| 105 | |||
| 58 | Core::IrSensor::DeviceFormat& GetIrCameraSharedMemoryDeviceEntry( | 106 | Core::IrSensor::DeviceFormat& GetIrCameraSharedMemoryDeviceEntry( |
| 59 | const Core::IrSensor::IrCameraHandle& camera_handle); | 107 | const Core::IrSensor::IrCameraHandle& camera_handle); |
| 60 | 108 | ||
diff --git a/src/core/hle/service/nvdrv/core/heap_mapper.cpp b/src/core/hle/service/nvdrv/core/heap_mapper.cpp index 096dc5deb..af17e3e85 100644 --- a/src/core/hle/service/nvdrv/core/heap_mapper.cpp +++ b/src/core/hle/service/nvdrv/core/heap_mapper.cpp | |||
| @@ -3,110 +3,21 @@ | |||
| 3 | 3 | ||
| 4 | #include <mutex> | 4 | #include <mutex> |
| 5 | 5 | ||
| 6 | #include <boost/container/small_vector.hpp> | 6 | #include "common/range_sets.h" |
| 7 | #define BOOST_NO_MT | 7 | #include "common/range_sets.inc" |
| 8 | #include <boost/pool/detail/mutex.hpp> | ||
| 9 | #undef BOOST_NO_MT | ||
| 10 | #include <boost/icl/interval.hpp> | ||
| 11 | #include <boost/icl/interval_base_set.hpp> | ||
| 12 | #include <boost/icl/interval_set.hpp> | ||
| 13 | #include <boost/icl/split_interval_map.hpp> | ||
| 14 | #include <boost/pool/pool.hpp> | ||
| 15 | #include <boost/pool/pool_alloc.hpp> | ||
| 16 | #include <boost/pool/poolfwd.hpp> | ||
| 17 | |||
| 18 | #include "core/hle/service/nvdrv/core/heap_mapper.h" | 8 | #include "core/hle/service/nvdrv/core/heap_mapper.h" |
| 19 | #include "video_core/host1x/host1x.h" | 9 | #include "video_core/host1x/host1x.h" |
| 20 | 10 | ||
| 21 | namespace boost { | ||
| 22 | template <typename T> | ||
| 23 | class fast_pool_allocator<T, default_user_allocator_new_delete, details::pool::null_mutex, 4096, 0>; | ||
| 24 | } | ||
| 25 | |||
| 26 | namespace Service::Nvidia::NvCore { | 11 | namespace Service::Nvidia::NvCore { |
| 27 | 12 | ||
| 28 | using IntervalCompare = std::less<DAddr>; | ||
| 29 | using IntervalInstance = boost::icl::interval_type_default<DAddr, std::less>; | ||
| 30 | using IntervalAllocator = boost::fast_pool_allocator<DAddr>; | ||
| 31 | using IntervalSet = boost::icl::interval_set<DAddr>; | ||
| 32 | using IntervalType = typename IntervalSet::interval_type; | ||
| 33 | |||
| 34 | template <typename Type> | ||
| 35 | struct counter_add_functor : public boost::icl::identity_based_inplace_combine<Type> { | ||
| 36 | // types | ||
| 37 | typedef counter_add_functor<Type> type; | ||
| 38 | typedef boost::icl::identity_based_inplace_combine<Type> base_type; | ||
| 39 | |||
| 40 | // public member functions | ||
| 41 | void operator()(Type& current, const Type& added) const { | ||
| 42 | current += added; | ||
| 43 | if (current < base_type::identity_element()) { | ||
| 44 | current = base_type::identity_element(); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | // public static functions | ||
| 49 | static void version(Type&){}; | ||
| 50 | }; | ||
| 51 | |||
| 52 | using OverlapCombine = counter_add_functor<int>; | ||
| 53 | using OverlapSection = boost::icl::inter_section<int>; | ||
| 54 | using OverlapCounter = boost::icl::split_interval_map<DAddr, int>; | ||
| 55 | |||
| 56 | struct HeapMapper::HeapMapperInternal { | 13 | struct HeapMapper::HeapMapperInternal { |
| 57 | HeapMapperInternal(Tegra::Host1x::Host1x& host1x) : device_memory{host1x.MemoryManager()} {} | 14 | HeapMapperInternal(Tegra::Host1x::Host1x& host1x) : m_device_memory{host1x.MemoryManager()} {} |
| 58 | ~HeapMapperInternal() = default; | 15 | ~HeapMapperInternal() = default; |
| 59 | 16 | ||
| 60 | template <typename Func> | 17 | Common::RangeSet<VAddr> m_temporary_set; |
| 61 | void ForEachInOverlapCounter(OverlapCounter& current_range, VAddr cpu_addr, u64 size, | 18 | Common::OverlapRangeSet<VAddr> m_mapped_ranges; |
| 62 | Func&& func) { | 19 | Tegra::MaxwellDeviceMemoryManager& m_device_memory; |
| 63 | const DAddr start_address = cpu_addr; | 20 | std::mutex m_guard; |
| 64 | const DAddr end_address = start_address + size; | ||
| 65 | const IntervalType search_interval{start_address, end_address}; | ||
| 66 | auto it = current_range.lower_bound(search_interval); | ||
| 67 | if (it == current_range.end()) { | ||
| 68 | return; | ||
| 69 | } | ||
| 70 | auto end_it = current_range.upper_bound(search_interval); | ||
| 71 | for (; it != end_it; it++) { | ||
| 72 | auto& inter = it->first; | ||
| 73 | DAddr inter_addr_end = inter.upper(); | ||
| 74 | DAddr inter_addr = inter.lower(); | ||
| 75 | if (inter_addr_end > end_address) { | ||
| 76 | inter_addr_end = end_address; | ||
| 77 | } | ||
| 78 | if (inter_addr < start_address) { | ||
| 79 | inter_addr = start_address; | ||
| 80 | } | ||
| 81 | func(inter_addr, inter_addr_end, it->second); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | void RemoveEachInOverlapCounter(OverlapCounter& current_range, | ||
| 86 | const IntervalType search_interval, int subtract_value) { | ||
| 87 | bool any_removals = false; | ||
| 88 | current_range.add(std::make_pair(search_interval, subtract_value)); | ||
| 89 | do { | ||
| 90 | any_removals = false; | ||
| 91 | auto it = current_range.lower_bound(search_interval); | ||
| 92 | if (it == current_range.end()) { | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | auto end_it = current_range.upper_bound(search_interval); | ||
| 96 | for (; it != end_it; it++) { | ||
| 97 | if (it->second <= 0) { | ||
| 98 | any_removals = true; | ||
| 99 | current_range.erase(it); | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | } while (any_removals); | ||
| 104 | } | ||
| 105 | |||
| 106 | IntervalSet base_set; | ||
| 107 | OverlapCounter mapping_overlaps; | ||
| 108 | Tegra::MaxwellDeviceMemoryManager& device_memory; | ||
| 109 | std::mutex guard; | ||
| 110 | }; | 21 | }; |
| 111 | 22 | ||
| 112 | HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, Core::Asid asid, | 23 | HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, Core::Asid asid, |
| @@ -116,60 +27,48 @@ HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, | |||
| 116 | } | 27 | } |
| 117 | 28 | ||
| 118 | HeapMapper::~HeapMapper() { | 29 | HeapMapper::~HeapMapper() { |
| 119 | m_internal->device_memory.Unmap(m_daddress, m_size); | 30 | // Unmap whatever has been mapped. |
| 31 | m_internal->m_mapped_ranges.ForEach([this](VAddr start_addr, VAddr end_addr, s32 count) { | ||
| 32 | const size_t sub_size = end_addr - start_addr; | ||
| 33 | const size_t offset = start_addr - m_vaddress; | ||
| 34 | m_internal->m_device_memory.Unmap(m_daddress + offset, sub_size); | ||
| 35 | }); | ||
| 120 | } | 36 | } |
| 121 | 37 | ||
| 122 | DAddr HeapMapper::Map(VAddr start, size_t size) { | 38 | DAddr HeapMapper::Map(VAddr start, size_t size) { |
| 123 | std::scoped_lock lk(m_internal->guard); | 39 | std::scoped_lock lk(m_internal->m_guard); |
| 124 | m_internal->base_set.clear(); | 40 | // Add the mapping range to a temporary range set. |
| 125 | const IntervalType interval{start, start + size}; | 41 | m_internal->m_temporary_set.Clear(); |
| 126 | m_internal->base_set.insert(interval); | 42 | m_internal->m_temporary_set.Add(start, size); |
| 127 | m_internal->ForEachInOverlapCounter(m_internal->mapping_overlaps, start, size, | 43 | |
| 128 | [this](VAddr start_addr, VAddr end_addr, int) { | 44 | // Remove anything that's already mapped from the temporary range set. |
| 129 | const IntervalType other{start_addr, end_addr}; | 45 | m_internal->m_mapped_ranges.ForEachInRange( |
| 130 | m_internal->base_set.subtract(other); | 46 | start, size, [this](VAddr start_addr, VAddr end_addr, s32) { |
| 131 | }); | 47 | m_internal->m_temporary_set.Subtract(start_addr, end_addr - start_addr); |
| 132 | if (!m_internal->base_set.empty()) { | 48 | }); |
| 133 | auto it = m_internal->base_set.begin(); | 49 | |
| 134 | auto end_it = m_internal->base_set.end(); | 50 | // Map anything that has not been mapped yet. |
| 135 | for (; it != end_it; it++) { | 51 | m_internal->m_temporary_set.ForEach([this](VAddr start_addr, VAddr end_addr) { |
| 136 | const VAddr inter_addr_end = it->upper(); | 52 | const size_t sub_size = end_addr - start_addr; |
| 137 | const VAddr inter_addr = it->lower(); | 53 | const size_t offset = start_addr - m_vaddress; |
| 138 | const size_t offset = inter_addr - m_vaddress; | 54 | m_internal->m_device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size, m_asid); |
| 139 | const size_t sub_size = inter_addr_end - inter_addr; | 55 | }); |
| 140 | m_internal->device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size, | 56 | |
| 141 | m_asid); | 57 | // Add the mapping range to the split map, to register the map and overlaps. |
| 142 | } | 58 | m_internal->m_mapped_ranges.Add(start, size); |
| 143 | } | 59 | m_internal->m_temporary_set.Clear(); |
| 144 | m_internal->mapping_overlaps += std::make_pair(interval, 1); | 60 | return m_daddress + static_cast<DAddr>(start - m_vaddress); |
| 145 | m_internal->base_set.clear(); | ||
| 146 | return m_daddress + (start - m_vaddress); | ||
| 147 | } | 61 | } |
| 148 | 62 | ||
| 149 | void HeapMapper::Unmap(VAddr start, size_t size) { | 63 | void HeapMapper::Unmap(VAddr start, size_t size) { |
| 150 | std::scoped_lock lk(m_internal->guard); | 64 | std::scoped_lock lk(m_internal->m_guard); |
| 151 | m_internal->base_set.clear(); | 65 | |
| 152 | m_internal->ForEachInOverlapCounter(m_internal->mapping_overlaps, start, size, | 66 | // Just subtract the range and whatever is deleted, unmap it. |
| 153 | [this](VAddr start_addr, VAddr end_addr, int value) { | 67 | m_internal->m_mapped_ranges.Subtract(start, size, [this](VAddr start_addr, VAddr end_addr) { |
| 154 | if (value <= 1) { | 68 | const size_t sub_size = end_addr - start_addr; |
| 155 | const IntervalType other{start_addr, end_addr}; | 69 | const size_t offset = start_addr - m_vaddress; |
| 156 | m_internal->base_set.insert(other); | 70 | m_internal->m_device_memory.Unmap(m_daddress + offset, sub_size); |
| 157 | } | 71 | }); |
| 158 | }); | ||
| 159 | if (!m_internal->base_set.empty()) { | ||
| 160 | auto it = m_internal->base_set.begin(); | ||
| 161 | auto end_it = m_internal->base_set.end(); | ||
| 162 | for (; it != end_it; it++) { | ||
| 163 | const VAddr inter_addr_end = it->upper(); | ||
| 164 | const VAddr inter_addr = it->lower(); | ||
| 165 | const size_t offset = inter_addr - m_vaddress; | ||
| 166 | const size_t sub_size = inter_addr_end - inter_addr; | ||
| 167 | m_internal->device_memory.Unmap(m_daddress + offset, sub_size); | ||
| 168 | } | ||
| 169 | } | ||
| 170 | const IntervalType to_remove{start, start + size}; | ||
| 171 | m_internal->RemoveEachInOverlapCounter(m_internal->mapping_overlaps, to_remove, -1); | ||
| 172 | m_internal->base_set.clear(); | ||
| 173 | } | 72 | } |
| 174 | 73 | ||
| 175 | } // namespace Service::Nvidia::NvCore | 74 | } // namespace Service::Nvidia::NvCore |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index e6646ba04..68fe38874 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | |||
| @@ -123,6 +123,8 @@ NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) { | |||
| 123 | vm.va_range_end = params.va_range_end; | 123 | vm.va_range_end = params.va_range_end; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | const u64 max_big_page_bits = Common::Log2Ceil64(vm.va_range_end); | ||
| 127 | |||
| 126 | const auto start_pages{static_cast<u32>(vm.va_range_start >> VM::PAGE_SIZE_BITS)}; | 128 | const auto start_pages{static_cast<u32>(vm.va_range_start >> VM::PAGE_SIZE_BITS)}; |
| 127 | const auto end_pages{static_cast<u32>(vm.va_range_split >> VM::PAGE_SIZE_BITS)}; | 129 | const auto end_pages{static_cast<u32>(vm.va_range_split >> VM::PAGE_SIZE_BITS)}; |
| 128 | vm.small_page_allocator = std::make_shared<VM::Allocator>(start_pages, end_pages); | 130 | vm.small_page_allocator = std::make_shared<VM::Allocator>(start_pages, end_pages); |
| @@ -132,8 +134,8 @@ NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) { | |||
| 132 | static_cast<u32>((vm.va_range_end - vm.va_range_split) >> vm.big_page_size_bits)}; | 134 | static_cast<u32>((vm.va_range_end - vm.va_range_split) >> vm.big_page_size_bits)}; |
| 133 | vm.big_page_allocator = std::make_unique<VM::Allocator>(start_big_pages, end_big_pages); | 135 | vm.big_page_allocator = std::make_unique<VM::Allocator>(start_big_pages, end_big_pages); |
| 134 | 136 | ||
| 135 | gmmu = std::make_shared<Tegra::MemoryManager>(system, 40, vm.big_page_size_bits, | 137 | gmmu = std::make_shared<Tegra::MemoryManager>(system, max_big_page_bits, vm.va_range_split, |
| 136 | VM::PAGE_SIZE_BITS); | 138 | vm.big_page_size_bits, VM::PAGE_SIZE_BITS); |
| 137 | system.GPU().InitAddressSpace(*gmmu); | 139 | system.GPU().InitAddressSpace(*gmmu); |
| 138 | vm.initialised = true; | 140 | vm.initialised = true; |
| 139 | 141 | ||
diff --git a/src/core/hle/service/nvnflinger/hardware_composer.cpp b/src/core/hle/service/nvnflinger/hardware_composer.cpp index c720dd1f8..ba2b5c28c 100644 --- a/src/core/hle/service/nvnflinger/hardware_composer.cpp +++ b/src/core/hle/service/nvnflinger/hardware_composer.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" | 7 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" |
| 8 | #include "core/hle/service/nvnflinger/buffer_item.h" | 8 | #include "core/hle/service/nvnflinger/buffer_item.h" |
| 9 | #include "core/hle/service/nvnflinger/buffer_item_consumer.h" | 9 | #include "core/hle/service/nvnflinger/buffer_item_consumer.h" |
| 10 | #include "core/hle/service/nvnflinger/buffer_queue_producer.h" | ||
| 11 | #include "core/hle/service/nvnflinger/hardware_composer.h" | 10 | #include "core/hle/service/nvnflinger/hardware_composer.h" |
| 12 | #include "core/hle/service/nvnflinger/hwc_layer.h" | 11 | #include "core/hle/service/nvnflinger/hwc_layer.h" |
| 13 | #include "core/hle/service/nvnflinger/ui/graphic_buffer.h" | 12 | #include "core/hle/service/nvnflinger/ui/graphic_buffer.h" |
| @@ -46,31 +45,9 @@ HardwareComposer::HardwareComposer() = default; | |||
| 46 | HardwareComposer::~HardwareComposer() = default; | 45 | HardwareComposer::~HardwareComposer() = default; |
| 47 | 46 | ||
| 48 | u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display, | 47 | u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display, |
| 49 | Nvidia::Devices::nvdisp_disp0& nvdisp, u32 frame_advance) { | 48 | Nvidia::Devices::nvdisp_disp0& nvdisp) { |
| 50 | boost::container::small_vector<HwcLayer, 2> composition_stack; | 49 | boost::container::small_vector<HwcLayer, 2> composition_stack; |
| 51 | 50 | ||
| 52 | m_frame_number += frame_advance; | ||
| 53 | |||
| 54 | // Release any necessary framebuffers. | ||
| 55 | for (auto& [layer_id, framebuffer] : m_framebuffers) { | ||
| 56 | if (framebuffer.release_frame_number > m_frame_number) { | ||
| 57 | // Not yet ready to release this framebuffer. | ||
| 58 | continue; | ||
| 59 | } | ||
| 60 | |||
| 61 | if (!framebuffer.is_acquired) { | ||
| 62 | // Already released. | ||
| 63 | continue; | ||
| 64 | } | ||
| 65 | |||
| 66 | if (auto* layer = display.FindLayer(layer_id); layer != nullptr) { | ||
| 67 | // TODO: support release fence | ||
| 68 | // This is needed to prevent screen tearing | ||
| 69 | layer->GetConsumer().ReleaseBuffer(framebuffer.item, android::Fence::NoFence()); | ||
| 70 | framebuffer.is_acquired = false; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | // Set default speed limit to 100%. | 51 | // Set default speed limit to 100%. |
| 75 | *out_speed_scale = 1.0f; | 52 | *out_speed_scale = 1.0f; |
| 76 | 53 | ||
| @@ -142,7 +119,30 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display, | |||
| 142 | MicroProfileFlip(); | 119 | MicroProfileFlip(); |
| 143 | 120 | ||
| 144 | // Advance by at least one frame. | 121 | // Advance by at least one frame. |
| 145 | return swap_interval.value_or(1); | 122 | const u32 frame_advance = swap_interval.value_or(1); |
| 123 | m_frame_number += frame_advance; | ||
| 124 | |||
| 125 | // Release any necessary framebuffers. | ||
| 126 | for (auto& [layer_id, framebuffer] : m_framebuffers) { | ||
| 127 | if (framebuffer.release_frame_number > m_frame_number) { | ||
| 128 | // Not yet ready to release this framebuffer. | ||
| 129 | continue; | ||
| 130 | } | ||
| 131 | |||
| 132 | if (!framebuffer.is_acquired) { | ||
| 133 | // Already released. | ||
| 134 | continue; | ||
| 135 | } | ||
| 136 | |||
| 137 | if (auto* layer = display.FindLayer(layer_id); layer != nullptr) { | ||
| 138 | // TODO: support release fence | ||
| 139 | // This is needed to prevent screen tearing | ||
| 140 | layer->GetConsumer().ReleaseBuffer(framebuffer.item, android::Fence::NoFence()); | ||
| 141 | framebuffer.is_acquired = false; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | return frame_advance; | ||
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | void HardwareComposer::RemoveLayerLocked(VI::Display& display, LayerId layer_id) { | 148 | void HardwareComposer::RemoveLayerLocked(VI::Display& display, LayerId layer_id) { |
diff --git a/src/core/hle/service/nvnflinger/hardware_composer.h b/src/core/hle/service/nvnflinger/hardware_composer.h index ddab94ac9..28392c512 100644 --- a/src/core/hle/service/nvnflinger/hardware_composer.h +++ b/src/core/hle/service/nvnflinger/hardware_composer.h | |||
| @@ -27,7 +27,7 @@ public: | |||
| 27 | ~HardwareComposer(); | 27 | ~HardwareComposer(); |
| 28 | 28 | ||
| 29 | u32 ComposeLocked(f32* out_speed_scale, VI::Display& display, | 29 | u32 ComposeLocked(f32* out_speed_scale, VI::Display& display, |
| 30 | Nvidia::Devices::nvdisp_disp0& nvdisp, u32 frame_advance); | 30 | Nvidia::Devices::nvdisp_disp0& nvdisp); |
| 31 | void RemoveLayerLocked(VI::Display& display, LayerId layer_id); | 31 | void RemoveLayerLocked(VI::Display& display, LayerId layer_id); |
| 32 | 32 | ||
| 33 | private: | 33 | private: |
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index a4e848882..d8ba89d43 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp | |||
| @@ -291,8 +291,7 @@ void Nvnflinger::Compose() { | |||
| 291 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd); | 291 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd); |
| 292 | ASSERT(nvdisp); | 292 | ASSERT(nvdisp); |
| 293 | 293 | ||
| 294 | swap_interval = display.GetComposer().ComposeLocked(&compose_speed_scale, display, *nvdisp, | 294 | swap_interval = display.GetComposer().ComposeLocked(&compose_speed_scale, display, *nvdisp); |
| 295 | swap_interval); | ||
| 296 | } | 295 | } |
| 297 | } | 296 | } |
| 298 | 297 | ||
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index 96fa7fa3a..b84b57d92 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp | |||
| @@ -5,10 +5,13 @@ | |||
| 5 | #include "common/hex_util.h" | 5 | #include "common/hex_util.h" |
| 6 | #include "common/microprofile.h" | 6 | #include "common/microprofile.h" |
| 7 | #include "common/swap.h" | 7 | #include "common/swap.h" |
| 8 | #include "core/arm/debug.h" | ||
| 8 | #include "core/core.h" | 9 | #include "core/core.h" |
| 9 | #include "core/core_timing.h" | 10 | #include "core/core_timing.h" |
| 10 | #include "core/hle/kernel/k_page_table.h" | 11 | #include "core/hle/kernel/k_page_table.h" |
| 11 | #include "core/hle/kernel/k_process.h" | 12 | #include "core/hle/kernel/k_process.h" |
| 13 | #include "core/hle/kernel/k_process_page_table.h" | ||
| 14 | #include "core/hle/kernel/svc_types.h" | ||
| 12 | #include "core/hle/service/hid/hid_server.h" | 15 | #include "core/hle/service/hid/hid_server.h" |
| 13 | #include "core/hle/service/sm/sm.h" | 16 | #include "core/hle/service/sm/sm.h" |
| 14 | #include "core/memory.h" | 17 | #include "core/memory.h" |
| @@ -46,12 +49,25 @@ StandardVmCallbacks::StandardVmCallbacks(System& system_, const CheatProcessMeta | |||
| 46 | 49 | ||
| 47 | StandardVmCallbacks::~StandardVmCallbacks() = default; | 50 | StandardVmCallbacks::~StandardVmCallbacks() = default; |
| 48 | 51 | ||
| 49 | void StandardVmCallbacks::MemoryRead(VAddr address, void* data, u64 size) { | 52 | void StandardVmCallbacks::MemoryReadUnsafe(VAddr address, void* data, u64 size) { |
| 50 | system.ApplicationMemory().ReadBlock(SanitizeAddress(address), data, size); | 53 | // Return zero on invalid address |
| 54 | if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) { | ||
| 55 | std::memset(data, 0, size); | ||
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | system.ApplicationMemory().ReadBlock(address, data, size); | ||
| 51 | } | 60 | } |
| 52 | 61 | ||
| 53 | void StandardVmCallbacks::MemoryWrite(VAddr address, const void* data, u64 size) { | 62 | void StandardVmCallbacks::MemoryWriteUnsafe(VAddr address, const void* data, u64 size) { |
| 54 | system.ApplicationMemory().WriteBlock(SanitizeAddress(address), data, size); | 63 | // Skip invalid memory write address |
| 64 | if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) { | ||
| 65 | return; | ||
| 66 | } | ||
| 67 | |||
| 68 | if (system.ApplicationMemory().WriteBlock(address, data, size)) { | ||
| 69 | Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), address, size); | ||
| 70 | } | ||
| 55 | } | 71 | } |
| 56 | 72 | ||
| 57 | u64 StandardVmCallbacks::HidKeysDown() { | 73 | u64 StandardVmCallbacks::HidKeysDown() { |
| @@ -72,6 +88,20 @@ u64 StandardVmCallbacks::HidKeysDown() { | |||
| 72 | return static_cast<u64>(press_state & HID::NpadButton::All); | 88 | return static_cast<u64>(press_state & HID::NpadButton::All); |
| 73 | } | 89 | } |
| 74 | 90 | ||
| 91 | void StandardVmCallbacks::PauseProcess() { | ||
| 92 | if (system.ApplicationProcess()->IsSuspended()) { | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | system.ApplicationProcess()->SetActivity(Kernel::Svc::ProcessActivity::Paused); | ||
| 96 | } | ||
| 97 | |||
| 98 | void StandardVmCallbacks::ResumeProcess() { | ||
| 99 | if (!system.ApplicationProcess()->IsSuspended()) { | ||
| 100 | return; | ||
| 101 | } | ||
| 102 | system.ApplicationProcess()->SetActivity(Kernel::Svc::ProcessActivity::Runnable); | ||
| 103 | } | ||
| 104 | |||
| 75 | void StandardVmCallbacks::DebugLog(u8 id, u64 value) { | 105 | void StandardVmCallbacks::DebugLog(u8 id, u64 value) { |
| 76 | LOG_INFO(CheatEngine, "Cheat triggered DebugLog: ID '{:01X}' Value '{:016X}'", id, value); | 106 | LOG_INFO(CheatEngine, "Cheat triggered DebugLog: ID '{:01X}' Value '{:016X}'", id, value); |
| 77 | } | 107 | } |
| @@ -81,21 +111,25 @@ void StandardVmCallbacks::CommandLog(std::string_view data) { | |||
| 81 | data.back() == '\n' ? data.substr(0, data.size() - 1) : data); | 111 | data.back() == '\n' ? data.substr(0, data.size() - 1) : data); |
| 82 | } | 112 | } |
| 83 | 113 | ||
| 84 | VAddr StandardVmCallbacks::SanitizeAddress(VAddr in) const { | 114 | bool StandardVmCallbacks::IsAddressInRange(VAddr in) const { |
| 85 | if ((in < metadata.main_nso_extents.base || | 115 | if ((in < metadata.main_nso_extents.base || |
| 86 | in >= metadata.main_nso_extents.base + metadata.main_nso_extents.size) && | 116 | in >= metadata.main_nso_extents.base + metadata.main_nso_extents.size) && |
| 87 | (in < metadata.heap_extents.base || | 117 | (in < metadata.heap_extents.base || |
| 88 | in >= metadata.heap_extents.base + metadata.heap_extents.size)) { | 118 | in >= metadata.heap_extents.base + metadata.heap_extents.size) && |
| 89 | LOG_ERROR(CheatEngine, | 119 | (in < metadata.alias_extents.base || |
| 120 | in >= metadata.heap_extents.base + metadata.alias_extents.size) && | ||
| 121 | (in < metadata.aslr_extents.base || | ||
| 122 | in >= metadata.heap_extents.base + metadata.aslr_extents.size)) { | ||
| 123 | LOG_DEBUG(CheatEngine, | ||
| 90 | "Cheat attempting to access memory at invalid address={:016X}, if this " | 124 | "Cheat attempting to access memory at invalid address={:016X}, if this " |
| 91 | "persists, " | 125 | "persists, " |
| 92 | "the cheat may be incorrect. However, this may be normal early in execution if " | 126 | "the cheat may be incorrect. However, this may be normal early in execution if " |
| 93 | "the game has not properly set up yet.", | 127 | "the game has not properly set up yet.", |
| 94 | in); | 128 | in); |
| 95 | return 0; ///< Invalid addresses will hard crash | 129 | return false; ///< Invalid addresses will hard crash |
| 96 | } | 130 | } |
| 97 | 131 | ||
| 98 | return in; | 132 | return true; |
| 99 | } | 133 | } |
| 100 | 134 | ||
| 101 | CheatParser::~CheatParser() = default; | 135 | CheatParser::~CheatParser() = default; |
| @@ -211,16 +245,14 @@ void CheatEngine::Initialize() { | |||
| 211 | .base = GetInteger(page_table.GetHeapRegionStart()), | 245 | .base = GetInteger(page_table.GetHeapRegionStart()), |
| 212 | .size = page_table.GetHeapRegionSize(), | 246 | .size = page_table.GetHeapRegionSize(), |
| 213 | }; | 247 | }; |
| 214 | 248 | metadata.aslr_extents = { | |
| 215 | metadata.address_space_extents = { | ||
| 216 | .base = GetInteger(page_table.GetAddressSpaceStart()), | ||
| 217 | .size = page_table.GetAddressSpaceSize(), | ||
| 218 | }; | ||
| 219 | |||
| 220 | metadata.alias_extents = { | ||
| 221 | .base = GetInteger(page_table.GetAliasCodeRegionStart()), | 249 | .base = GetInteger(page_table.GetAliasCodeRegionStart()), |
| 222 | .size = page_table.GetAliasCodeRegionSize(), | 250 | .size = page_table.GetAliasCodeRegionSize(), |
| 223 | }; | 251 | }; |
| 252 | metadata.alias_extents = { | ||
| 253 | .base = GetInteger(page_table.GetAliasRegionStart()), | ||
| 254 | .size = page_table.GetAliasRegionSize(), | ||
| 255 | }; | ||
| 224 | 256 | ||
| 225 | is_pending_reload.exchange(true); | 257 | is_pending_reload.exchange(true); |
| 226 | } | 258 | } |
diff --git a/src/core/memory/cheat_engine.h b/src/core/memory/cheat_engine.h index ced2168d1..f52f2be7c 100644 --- a/src/core/memory/cheat_engine.h +++ b/src/core/memory/cheat_engine.h | |||
| @@ -27,17 +27,19 @@ public: | |||
| 27 | StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_); | 27 | StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_); |
| 28 | ~StandardVmCallbacks() override; | 28 | ~StandardVmCallbacks() override; |
| 29 | 29 | ||
| 30 | void MemoryRead(VAddr address, void* data, u64 size) override; | 30 | void MemoryReadUnsafe(VAddr address, void* data, u64 size) override; |
| 31 | void MemoryWrite(VAddr address, const void* data, u64 size) override; | 31 | void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) override; |
| 32 | u64 HidKeysDown() override; | 32 | u64 HidKeysDown() override; |
| 33 | void PauseProcess() override; | ||
| 34 | void ResumeProcess() override; | ||
| 33 | void DebugLog(u8 id, u64 value) override; | 35 | void DebugLog(u8 id, u64 value) override; |
| 34 | void CommandLog(std::string_view data) override; | 36 | void CommandLog(std::string_view data) override; |
| 35 | 37 | ||
| 36 | private: | 38 | private: |
| 37 | VAddr SanitizeAddress(VAddr address) const; | 39 | bool IsAddressInRange(VAddr address) const; |
| 38 | 40 | ||
| 39 | const CheatProcessMetadata& metadata; | 41 | const CheatProcessMetadata& metadata; |
| 40 | System& system; | 42 | Core::System& system; |
| 41 | }; | 43 | }; |
| 42 | 44 | ||
| 43 | // Intermediary class that parses a text file or other disk format for storing cheats into a | 45 | // Intermediary class that parses a text file or other disk format for storing cheats into a |
diff --git a/src/core/memory/dmnt_cheat_types.h b/src/core/memory/dmnt_cheat_types.h index c6b40e505..64c072d3d 100644 --- a/src/core/memory/dmnt_cheat_types.h +++ b/src/core/memory/dmnt_cheat_types.h | |||
| @@ -18,7 +18,7 @@ struct CheatProcessMetadata { | |||
| 18 | MemoryRegionExtents main_nso_extents{}; | 18 | MemoryRegionExtents main_nso_extents{}; |
| 19 | MemoryRegionExtents heap_extents{}; | 19 | MemoryRegionExtents heap_extents{}; |
| 20 | MemoryRegionExtents alias_extents{}; | 20 | MemoryRegionExtents alias_extents{}; |
| 21 | MemoryRegionExtents address_space_extents{}; | 21 | MemoryRegionExtents aslr_extents{}; |
| 22 | std::array<u8, 0x20> main_nso_build_id{}; | 22 | std::array<u8, 0x20> main_nso_build_id{}; |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp index 31ffc4fbb..f7097d01d 100644 --- a/src/core/memory/dmnt_cheat_vm.cpp +++ b/src/core/memory/dmnt_cheat_vm.cpp | |||
| @@ -322,8 +322,9 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) { | |||
| 322 | } break; | 322 | } break; |
| 323 | case CheatVmOpcodeType::EndConditionalBlock: { | 323 | case CheatVmOpcodeType::EndConditionalBlock: { |
| 324 | // 20000000 | 324 | // 20000000 |
| 325 | // There's actually nothing left to process here! | 325 | opcode.opcode = EndConditionalOpcode{ |
| 326 | opcode.opcode = EndConditionalOpcode{}; | 326 | .is_else = ((first_dword >> 24) & 0xf) == 1, |
| 327 | }; | ||
| 327 | } break; | 328 | } break; |
| 328 | case CheatVmOpcodeType::ControlLoop: { | 329 | case CheatVmOpcodeType::ControlLoop: { |
| 329 | // 300R0000 VVVVVVVV | 330 | // 300R0000 VVVVVVVV |
| @@ -555,6 +556,18 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) { | |||
| 555 | .idx = first_dword & 0xF, | 556 | .idx = first_dword & 0xF, |
| 556 | }; | 557 | }; |
| 557 | } break; | 558 | } break; |
| 559 | case CheatVmOpcodeType::PauseProcess: { | ||
| 560 | /* FF0????? */ | ||
| 561 | /* FF0 = opcode 0xFF0 */ | ||
| 562 | /* Pauses the current process. */ | ||
| 563 | opcode.opcode = PauseProcessOpcode{}; | ||
| 564 | } break; | ||
| 565 | case CheatVmOpcodeType::ResumeProcess: { | ||
| 566 | /* FF0????? */ | ||
| 567 | /* FF0 = opcode 0xFF0 */ | ||
| 568 | /* Pauses the current process. */ | ||
| 569 | opcode.opcode = ResumeProcessOpcode{}; | ||
| 570 | } break; | ||
| 558 | case CheatVmOpcodeType::DebugLog: { | 571 | case CheatVmOpcodeType::DebugLog: { |
| 559 | // FFFTIX## | 572 | // FFFTIX## |
| 560 | // FFFTI0Ma aaaaaaaa | 573 | // FFFTI0Ma aaaaaaaa |
| @@ -621,7 +634,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) { | |||
| 621 | return valid; | 634 | return valid; |
| 622 | } | 635 | } |
| 623 | 636 | ||
| 624 | void DmntCheatVm::SkipConditionalBlock() { | 637 | void DmntCheatVm::SkipConditionalBlock(bool is_if) { |
| 625 | if (condition_depth > 0) { | 638 | if (condition_depth > 0) { |
| 626 | // We want to continue until we're out of the current block. | 639 | // We want to continue until we're out of the current block. |
| 627 | const std::size_t desired_depth = condition_depth - 1; | 640 | const std::size_t desired_depth = condition_depth - 1; |
| @@ -637,8 +650,12 @@ void DmntCheatVm::SkipConditionalBlock() { | |||
| 637 | // We also support nesting of conditional blocks, and Gateway does not. | 650 | // We also support nesting of conditional blocks, and Gateway does not. |
| 638 | if (skip_opcode.begin_conditional_block) { | 651 | if (skip_opcode.begin_conditional_block) { |
| 639 | condition_depth++; | 652 | condition_depth++; |
| 640 | } else if (std::holds_alternative<EndConditionalOpcode>(skip_opcode.opcode)) { | 653 | } else if (auto end_cond = std::get_if<EndConditionalOpcode>(&skip_opcode.opcode)) { |
| 641 | condition_depth--; | 654 | if (!end_cond->is_else) { |
| 655 | condition_depth--; | ||
| 656 | } else if (is_if && condition_depth - 1 == desired_depth) { | ||
| 657 | break; | ||
| 658 | } | ||
| 642 | } | 659 | } |
| 643 | } | 660 | } |
| 644 | } else { | 661 | } else { |
| @@ -675,6 +692,10 @@ u64 DmntCheatVm::GetCheatProcessAddress(const CheatProcessMetadata& metadata, | |||
| 675 | return metadata.main_nso_extents.base + rel_address; | 692 | return metadata.main_nso_extents.base + rel_address; |
| 676 | case MemoryAccessType::Heap: | 693 | case MemoryAccessType::Heap: |
| 677 | return metadata.heap_extents.base + rel_address; | 694 | return metadata.heap_extents.base + rel_address; |
| 695 | case MemoryAccessType::Alias: | ||
| 696 | return metadata.alias_extents.base + rel_address; | ||
| 697 | case MemoryAccessType::Aslr: | ||
| 698 | return metadata.aslr_extents.base + rel_address; | ||
| 678 | } | 699 | } |
| 679 | } | 700 | } |
| 680 | 701 | ||
| @@ -682,7 +703,6 @@ void DmntCheatVm::ResetState() { | |||
| 682 | registers.fill(0); | 703 | registers.fill(0); |
| 683 | saved_values.fill(0); | 704 | saved_values.fill(0); |
| 684 | loop_tops.fill(0); | 705 | loop_tops.fill(0); |
| 685 | static_registers.fill(0); | ||
| 686 | instruction_ptr = 0; | 706 | instruction_ptr = 0; |
| 687 | condition_depth = 0; | 707 | condition_depth = 0; |
| 688 | decode_success = true; | 708 | decode_success = true; |
| @@ -753,7 +773,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 753 | case 2: | 773 | case 2: |
| 754 | case 4: | 774 | case 4: |
| 755 | case 8: | 775 | case 8: |
| 756 | callbacks->MemoryWrite(dst_address, &dst_value, store_static->bit_width); | 776 | callbacks->MemoryWriteUnsafe(dst_address, &dst_value, store_static->bit_width); |
| 757 | break; | 777 | break; |
| 758 | } | 778 | } |
| 759 | } else if (auto begin_cond = std::get_if<BeginConditionalOpcode>(&cur_opcode.opcode)) { | 779 | } else if (auto begin_cond = std::get_if<BeginConditionalOpcode>(&cur_opcode.opcode)) { |
| @@ -766,7 +786,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 766 | case 2: | 786 | case 2: |
| 767 | case 4: | 787 | case 4: |
| 768 | case 8: | 788 | case 8: |
| 769 | callbacks->MemoryRead(src_address, &src_value, begin_cond->bit_width); | 789 | callbacks->MemoryReadUnsafe(src_address, &src_value, begin_cond->bit_width); |
| 770 | break; | 790 | break; |
| 771 | } | 791 | } |
| 772 | // Check against condition. | 792 | // Check against condition. |
| @@ -794,13 +814,18 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 794 | } | 814 | } |
| 795 | // Skip conditional block if condition not met. | 815 | // Skip conditional block if condition not met. |
| 796 | if (!cond_met) { | 816 | if (!cond_met) { |
| 797 | SkipConditionalBlock(); | 817 | SkipConditionalBlock(true); |
| 798 | } | 818 | } |
| 799 | } else if (std::holds_alternative<EndConditionalOpcode>(cur_opcode.opcode)) { | 819 | } else if (auto end_cond = std::get_if<EndConditionalOpcode>(&cur_opcode.opcode)) { |
| 800 | // Decrement the condition depth. | 820 | if (end_cond->is_else) { |
| 801 | // We will assume, graciously, that mismatched conditional block ends are a nop. | 821 | /* Skip to the end of the conditional block. */ |
| 802 | if (condition_depth > 0) { | 822 | this->SkipConditionalBlock(false); |
| 803 | condition_depth--; | 823 | } else { |
| 824 | /* Decrement the condition depth. */ | ||
| 825 | /* We will assume, graciously, that mismatched conditional block ends are a nop. */ | ||
| 826 | if (condition_depth > 0) { | ||
| 827 | condition_depth--; | ||
| 828 | } | ||
| 804 | } | 829 | } |
| 805 | } else if (auto ctrl_loop = std::get_if<ControlLoopOpcode>(&cur_opcode.opcode)) { | 830 | } else if (auto ctrl_loop = std::get_if<ControlLoopOpcode>(&cur_opcode.opcode)) { |
| 806 | if (ctrl_loop->start_loop) { | 831 | if (ctrl_loop->start_loop) { |
| @@ -832,8 +857,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 832 | case 2: | 857 | case 2: |
| 833 | case 4: | 858 | case 4: |
| 834 | case 8: | 859 | case 8: |
| 835 | callbacks->MemoryRead(src_address, ®isters[ldr_memory->reg_index], | 860 | callbacks->MemoryReadUnsafe(src_address, ®isters[ldr_memory->reg_index], |
| 836 | ldr_memory->bit_width); | 861 | ldr_memory->bit_width); |
| 837 | break; | 862 | break; |
| 838 | } | 863 | } |
| 839 | } else if (auto str_static = std::get_if<StoreStaticToAddressOpcode>(&cur_opcode.opcode)) { | 864 | } else if (auto str_static = std::get_if<StoreStaticToAddressOpcode>(&cur_opcode.opcode)) { |
| @@ -849,7 +874,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 849 | case 2: | 874 | case 2: |
| 850 | case 4: | 875 | case 4: |
| 851 | case 8: | 876 | case 8: |
| 852 | callbacks->MemoryWrite(dst_address, &dst_value, str_static->bit_width); | 877 | callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_static->bit_width); |
| 853 | break; | 878 | break; |
| 854 | } | 879 | } |
| 855 | // Increment register if relevant. | 880 | // Increment register if relevant. |
| @@ -908,7 +933,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 908 | // Check for keypress. | 933 | // Check for keypress. |
| 909 | if ((begin_keypress_cond->key_mask & kDown) != begin_keypress_cond->key_mask) { | 934 | if ((begin_keypress_cond->key_mask & kDown) != begin_keypress_cond->key_mask) { |
| 910 | // Keys not pressed. Skip conditional block. | 935 | // Keys not pressed. Skip conditional block. |
| 911 | SkipConditionalBlock(); | 936 | SkipConditionalBlock(true); |
| 912 | } | 937 | } |
| 913 | } else if (auto perform_math_reg = | 938 | } else if (auto perform_math_reg = |
| 914 | std::get_if<PerformArithmeticRegisterOpcode>(&cur_opcode.opcode)) { | 939 | std::get_if<PerformArithmeticRegisterOpcode>(&cur_opcode.opcode)) { |
| @@ -1007,7 +1032,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 1007 | case 2: | 1032 | case 2: |
| 1008 | case 4: | 1033 | case 4: |
| 1009 | case 8: | 1034 | case 8: |
| 1010 | callbacks->MemoryWrite(dst_address, &dst_value, str_register->bit_width); | 1035 | callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_register->bit_width); |
| 1011 | break; | 1036 | break; |
| 1012 | } | 1037 | } |
| 1013 | 1038 | ||
| @@ -1086,7 +1111,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 1086 | case 2: | 1111 | case 2: |
| 1087 | case 4: | 1112 | case 4: |
| 1088 | case 8: | 1113 | case 8: |
| 1089 | callbacks->MemoryRead(cond_address, &cond_value, begin_reg_cond->bit_width); | 1114 | callbacks->MemoryReadUnsafe(cond_address, &cond_value, |
| 1115 | begin_reg_cond->bit_width); | ||
| 1090 | break; | 1116 | break; |
| 1091 | } | 1117 | } |
| 1092 | } | 1118 | } |
| @@ -1116,7 +1142,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 1116 | 1142 | ||
| 1117 | // Skip conditional block if condition not met. | 1143 | // Skip conditional block if condition not met. |
| 1118 | if (!cond_met) { | 1144 | if (!cond_met) { |
| 1119 | SkipConditionalBlock(); | 1145 | SkipConditionalBlock(true); |
| 1120 | } | 1146 | } |
| 1121 | } else if (auto save_restore_reg = | 1147 | } else if (auto save_restore_reg = |
| 1122 | std::get_if<SaveRestoreRegisterOpcode>(&cur_opcode.opcode)) { | 1148 | std::get_if<SaveRestoreRegisterOpcode>(&cur_opcode.opcode)) { |
| @@ -1178,6 +1204,10 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 1178 | // Store a register to a static register. | 1204 | // Store a register to a static register. |
| 1179 | static_registers[rw_static_reg->static_idx] = registers[rw_static_reg->idx]; | 1205 | static_registers[rw_static_reg->static_idx] = registers[rw_static_reg->idx]; |
| 1180 | } | 1206 | } |
| 1207 | } else if (std::holds_alternative<PauseProcessOpcode>(cur_opcode.opcode)) { | ||
| 1208 | callbacks->PauseProcess(); | ||
| 1209 | } else if (std::holds_alternative<ResumeProcessOpcode>(cur_opcode.opcode)) { | ||
| 1210 | callbacks->ResumeProcess(); | ||
| 1181 | } else if (auto debug_log = std::get_if<DebugLogOpcode>(&cur_opcode.opcode)) { | 1211 | } else if (auto debug_log = std::get_if<DebugLogOpcode>(&cur_opcode.opcode)) { |
| 1182 | // Read value from memory. | 1212 | // Read value from memory. |
| 1183 | u64 log_value = 0; | 1213 | u64 log_value = 0; |
| @@ -1224,7 +1254,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { | |||
| 1224 | case 2: | 1254 | case 2: |
| 1225 | case 4: | 1255 | case 4: |
| 1226 | case 8: | 1256 | case 8: |
| 1227 | callbacks->MemoryRead(val_address, &log_value, debug_log->bit_width); | 1257 | callbacks->MemoryReadUnsafe(val_address, &log_value, debug_log->bit_width); |
| 1228 | break; | 1258 | break; |
| 1229 | } | 1259 | } |
| 1230 | } | 1260 | } |
diff --git a/src/core/memory/dmnt_cheat_vm.h b/src/core/memory/dmnt_cheat_vm.h index 641cb09c4..1c1ed1259 100644 --- a/src/core/memory/dmnt_cheat_vm.h +++ b/src/core/memory/dmnt_cheat_vm.h | |||
| @@ -42,12 +42,16 @@ enum class CheatVmOpcodeType : u32 { | |||
| 42 | DoubleExtendedWidth = 0xF0, | 42 | DoubleExtendedWidth = 0xF0, |
| 43 | 43 | ||
| 44 | // Double-extended width opcodes. | 44 | // Double-extended width opcodes. |
| 45 | PauseProcess = 0xFF0, | ||
| 46 | ResumeProcess = 0xFF1, | ||
| 45 | DebugLog = 0xFFF, | 47 | DebugLog = 0xFFF, |
| 46 | }; | 48 | }; |
| 47 | 49 | ||
| 48 | enum class MemoryAccessType : u32 { | 50 | enum class MemoryAccessType : u32 { |
| 49 | MainNso = 0, | 51 | MainNso = 0, |
| 50 | Heap = 1, | 52 | Heap = 1, |
| 53 | Alias = 2, | ||
| 54 | Aslr = 3, | ||
| 51 | }; | 55 | }; |
| 52 | 56 | ||
| 53 | enum class ConditionalComparisonType : u32 { | 57 | enum class ConditionalComparisonType : u32 { |
| @@ -131,7 +135,9 @@ struct BeginConditionalOpcode { | |||
| 131 | VmInt value{}; | 135 | VmInt value{}; |
| 132 | }; | 136 | }; |
| 133 | 137 | ||
| 134 | struct EndConditionalOpcode {}; | 138 | struct EndConditionalOpcode { |
| 139 | bool is_else; | ||
| 140 | }; | ||
| 135 | 141 | ||
| 136 | struct ControlLoopOpcode { | 142 | struct ControlLoopOpcode { |
| 137 | bool start_loop{}; | 143 | bool start_loop{}; |
| @@ -222,6 +228,10 @@ struct ReadWriteStaticRegisterOpcode { | |||
| 222 | u32 idx{}; | 228 | u32 idx{}; |
| 223 | }; | 229 | }; |
| 224 | 230 | ||
| 231 | struct PauseProcessOpcode {}; | ||
| 232 | |||
| 233 | struct ResumeProcessOpcode {}; | ||
| 234 | |||
| 225 | struct DebugLogOpcode { | 235 | struct DebugLogOpcode { |
| 226 | u32 bit_width{}; | 236 | u32 bit_width{}; |
| 227 | u32 log_id{}; | 237 | u32 log_id{}; |
| @@ -244,8 +254,8 @@ struct CheatVmOpcode { | |||
| 244 | PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode, | 254 | PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode, |
| 245 | PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode, | 255 | PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode, |
| 246 | BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode, | 256 | BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode, |
| 247 | SaveRestoreRegisterMaskOpcode, ReadWriteStaticRegisterOpcode, DebugLogOpcode, | 257 | SaveRestoreRegisterMaskOpcode, ReadWriteStaticRegisterOpcode, PauseProcessOpcode, |
| 248 | UnrecognizedInstruction> | 258 | ResumeProcessOpcode, DebugLogOpcode, UnrecognizedInstruction> |
| 249 | opcode{}; | 259 | opcode{}; |
| 250 | }; | 260 | }; |
| 251 | 261 | ||
| @@ -256,11 +266,14 @@ public: | |||
| 256 | public: | 266 | public: |
| 257 | virtual ~Callbacks(); | 267 | virtual ~Callbacks(); |
| 258 | 268 | ||
| 259 | virtual void MemoryRead(VAddr address, void* data, u64 size) = 0; | 269 | virtual void MemoryReadUnsafe(VAddr address, void* data, u64 size) = 0; |
| 260 | virtual void MemoryWrite(VAddr address, const void* data, u64 size) = 0; | 270 | virtual void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) = 0; |
| 261 | 271 | ||
| 262 | virtual u64 HidKeysDown() = 0; | 272 | virtual u64 HidKeysDown() = 0; |
| 263 | 273 | ||
| 274 | virtual void PauseProcess() = 0; | ||
| 275 | virtual void ResumeProcess() = 0; | ||
| 276 | |||
| 264 | virtual void DebugLog(u8 id, u64 value) = 0; | 277 | virtual void DebugLog(u8 id, u64 value) = 0; |
| 265 | virtual void CommandLog(std::string_view data) = 0; | 278 | virtual void CommandLog(std::string_view data) = 0; |
| 266 | }; | 279 | }; |
| @@ -296,7 +309,7 @@ private: | |||
| 296 | std::array<std::size_t, NumRegisters> loop_tops{}; | 309 | std::array<std::size_t, NumRegisters> loop_tops{}; |
| 297 | 310 | ||
| 298 | bool DecodeNextOpcode(CheatVmOpcode& out); | 311 | bool DecodeNextOpcode(CheatVmOpcode& out); |
| 299 | void SkipConditionalBlock(); | 312 | void SkipConditionalBlock(bool is_if); |
| 300 | void ResetState(); | 313 | void ResetState(); |
| 301 | 314 | ||
| 302 | // For implementing the DebugLog opcode. | 315 | // For implementing the DebugLog opcode. |
diff --git a/src/hid_core/hidbus/hidbus_base.h b/src/hid_core/hidbus/hidbus_base.h index ec41684e1..c948606e4 100644 --- a/src/hid_core/hidbus/hidbus_base.h +++ b/src/hid_core/hidbus/hidbus_base.h | |||
| @@ -160,7 +160,7 @@ public: | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | // Returns a reply from a command | 162 | // Returns a reply from a command |
| 163 | virtual std::vector<u8> GetReply() const { | 163 | virtual u64 GetReply(std::span<u8> out_data) const { |
| 164 | return {}; | 164 | return {}; |
| 165 | } | 165 | } |
| 166 | 166 | ||
diff --git a/src/hid_core/hidbus/ringcon.cpp b/src/hid_core/hidbus/ringcon.cpp index cedf25c16..4f5eaa505 100644 --- a/src/hid_core/hidbus/ringcon.cpp +++ b/src/hid_core/hidbus/ringcon.cpp | |||
| @@ -90,32 +90,32 @@ u8 RingController::GetDeviceId() const { | |||
| 90 | return device_id; | 90 | return device_id; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | std::vector<u8> RingController::GetReply() const { | 93 | u64 RingController::GetReply(std::span<u8> out_data) const { |
| 94 | const RingConCommands current_command = command; | 94 | const RingConCommands current_command = command; |
| 95 | 95 | ||
| 96 | switch (current_command) { | 96 | switch (current_command) { |
| 97 | case RingConCommands::GetFirmwareVersion: | 97 | case RingConCommands::GetFirmwareVersion: |
| 98 | return GetFirmwareVersionReply(); | 98 | return GetFirmwareVersionReply(out_data); |
| 99 | case RingConCommands::ReadId: | 99 | case RingConCommands::ReadId: |
| 100 | return GetReadIdReply(); | 100 | return GetReadIdReply(out_data); |
| 101 | case RingConCommands::c20105: | 101 | case RingConCommands::c20105: |
| 102 | return GetC020105Reply(); | 102 | return GetC020105Reply(out_data); |
| 103 | case RingConCommands::ReadUnkCal: | 103 | case RingConCommands::ReadUnkCal: |
| 104 | return GetReadUnkCalReply(); | 104 | return GetReadUnkCalReply(out_data); |
| 105 | case RingConCommands::ReadFactoryCal: | 105 | case RingConCommands::ReadFactoryCal: |
| 106 | return GetReadFactoryCalReply(); | 106 | return GetReadFactoryCalReply(out_data); |
| 107 | case RingConCommands::ReadUserCal: | 107 | case RingConCommands::ReadUserCal: |
| 108 | return GetReadUserCalReply(); | 108 | return GetReadUserCalReply(out_data); |
| 109 | case RingConCommands::ReadRepCount: | 109 | case RingConCommands::ReadRepCount: |
| 110 | return GetReadRepCountReply(); | 110 | return GetReadRepCountReply(out_data); |
| 111 | case RingConCommands::ReadTotalPushCount: | 111 | case RingConCommands::ReadTotalPushCount: |
| 112 | return GetReadTotalPushCountReply(); | 112 | return GetReadTotalPushCountReply(out_data); |
| 113 | case RingConCommands::ResetRepCount: | 113 | case RingConCommands::ResetRepCount: |
| 114 | return GetResetRepCountReply(); | 114 | return GetResetRepCountReply(out_data); |
| 115 | case RingConCommands::SaveCalData: | 115 | case RingConCommands::SaveCalData: |
| 116 | return GetSaveDataReply(); | 116 | return GetSaveDataReply(out_data); |
| 117 | default: | 117 | default: |
| 118 | return GetErrorReply(); | 118 | return GetErrorReply(out_data); |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | 121 | ||
| @@ -163,16 +163,16 @@ bool RingController::SetCommand(std::span<const u8> data) { | |||
| 163 | } | 163 | } |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | std::vector<u8> RingController::GetFirmwareVersionReply() const { | 166 | u64 RingController::GetFirmwareVersionReply(std::span<u8> out_data) const { |
| 167 | const FirmwareVersionReply reply{ | 167 | const FirmwareVersionReply reply{ |
| 168 | .status = DataValid::Valid, | 168 | .status = DataValid::Valid, |
| 169 | .firmware = version, | 169 | .firmware = version, |
| 170 | }; | 170 | }; |
| 171 | 171 | ||
| 172 | return GetDataVector(reply); | 172 | return GetData(reply, out_data); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | std::vector<u8> RingController::GetReadIdReply() const { | 175 | u64 RingController::GetReadIdReply(std::span<u8> out_data) const { |
| 176 | // The values are hardcoded from a real joycon | 176 | // The values are hardcoded from a real joycon |
| 177 | const ReadIdReply reply{ | 177 | const ReadIdReply reply{ |
| 178 | .status = DataValid::Valid, | 178 | .status = DataValid::Valid, |
| @@ -184,83 +184,83 @@ std::vector<u8> RingController::GetReadIdReply() const { | |||
| 184 | .id_h_x4 = 8245, | 184 | .id_h_x4 = 8245, |
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | return GetDataVector(reply); | 187 | return GetData(reply, out_data); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | std::vector<u8> RingController::GetC020105Reply() const { | 190 | u64 RingController::GetC020105Reply(std::span<u8> out_data) const { |
| 191 | const Cmd020105Reply reply{ | 191 | const Cmd020105Reply reply{ |
| 192 | .status = DataValid::Valid, | 192 | .status = DataValid::Valid, |
| 193 | .data = 1, | 193 | .data = 1, |
| 194 | }; | 194 | }; |
| 195 | 195 | ||
| 196 | return GetDataVector(reply); | 196 | return GetData(reply, out_data); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | std::vector<u8> RingController::GetReadUnkCalReply() const { | 199 | u64 RingController::GetReadUnkCalReply(std::span<u8> out_data) const { |
| 200 | const ReadUnkCalReply reply{ | 200 | const ReadUnkCalReply reply{ |
| 201 | .status = DataValid::Valid, | 201 | .status = DataValid::Valid, |
| 202 | .data = 0, | 202 | .data = 0, |
| 203 | }; | 203 | }; |
| 204 | 204 | ||
| 205 | return GetDataVector(reply); | 205 | return GetData(reply, out_data); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | std::vector<u8> RingController::GetReadFactoryCalReply() const { | 208 | u64 RingController::GetReadFactoryCalReply(std::span<u8> out_data) const { |
| 209 | const ReadFactoryCalReply reply{ | 209 | const ReadFactoryCalReply reply{ |
| 210 | .status = DataValid::Valid, | 210 | .status = DataValid::Valid, |
| 211 | .calibration = factory_calibration, | 211 | .calibration = factory_calibration, |
| 212 | }; | 212 | }; |
| 213 | 213 | ||
| 214 | return GetDataVector(reply); | 214 | return GetData(reply, out_data); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | std::vector<u8> RingController::GetReadUserCalReply() const { | 217 | u64 RingController::GetReadUserCalReply(std::span<u8> out_data) const { |
| 218 | const ReadUserCalReply reply{ | 218 | const ReadUserCalReply reply{ |
| 219 | .status = DataValid::Valid, | 219 | .status = DataValid::Valid, |
| 220 | .calibration = user_calibration, | 220 | .calibration = user_calibration, |
| 221 | }; | 221 | }; |
| 222 | 222 | ||
| 223 | return GetDataVector(reply); | 223 | return GetData(reply, out_data); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | std::vector<u8> RingController::GetReadRepCountReply() const { | 226 | u64 RingController::GetReadRepCountReply(std::span<u8> out_data) const { |
| 227 | const GetThreeByteReply reply{ | 227 | const GetThreeByteReply reply{ |
| 228 | .status = DataValid::Valid, | 228 | .status = DataValid::Valid, |
| 229 | .data = {total_rep_count, 0, 0}, | 229 | .data = {total_rep_count, 0, 0}, |
| 230 | .crc = GetCrcValue({total_rep_count, 0, 0, 0}), | 230 | .crc = GetCrcValue({total_rep_count, 0, 0, 0}), |
| 231 | }; | 231 | }; |
| 232 | 232 | ||
| 233 | return GetDataVector(reply); | 233 | return GetData(reply, out_data); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | std::vector<u8> RingController::GetReadTotalPushCountReply() const { | 236 | u64 RingController::GetReadTotalPushCountReply(std::span<u8> out_data) const { |
| 237 | const GetThreeByteReply reply{ | 237 | const GetThreeByteReply reply{ |
| 238 | .status = DataValid::Valid, | 238 | .status = DataValid::Valid, |
| 239 | .data = {total_push_count, 0, 0}, | 239 | .data = {total_push_count, 0, 0}, |
| 240 | .crc = GetCrcValue({total_push_count, 0, 0, 0}), | 240 | .crc = GetCrcValue({total_push_count, 0, 0, 0}), |
| 241 | }; | 241 | }; |
| 242 | 242 | ||
| 243 | return GetDataVector(reply); | 243 | return GetData(reply, out_data); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | std::vector<u8> RingController::GetResetRepCountReply() const { | 246 | u64 RingController::GetResetRepCountReply(std::span<u8> out_data) const { |
| 247 | return GetReadRepCountReply(); | 247 | return GetReadRepCountReply(out_data); |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | std::vector<u8> RingController::GetSaveDataReply() const { | 250 | u64 RingController::GetSaveDataReply(std::span<u8> out_data) const { |
| 251 | const StatusReply reply{ | 251 | const StatusReply reply{ |
| 252 | .status = DataValid::Valid, | 252 | .status = DataValid::Valid, |
| 253 | }; | 253 | }; |
| 254 | 254 | ||
| 255 | return GetDataVector(reply); | 255 | return GetData(reply, out_data); |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | std::vector<u8> RingController::GetErrorReply() const { | 258 | u64 RingController::GetErrorReply(std::span<u8> out_data) const { |
| 259 | const ErrorReply reply{ | 259 | const ErrorReply reply{ |
| 260 | .status = DataValid::BadCRC, | 260 | .status = DataValid::BadCRC, |
| 261 | }; | 261 | }; |
| 262 | 262 | ||
| 263 | return GetDataVector(reply); | 263 | return GetData(reply, out_data); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | u8 RingController::GetCrcValue(const std::vector<u8>& data) const { | 266 | u8 RingController::GetCrcValue(const std::vector<u8>& data) const { |
| @@ -281,12 +281,11 @@ u8 RingController::GetCrcValue(const std::vector<u8>& data) const { | |||
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | template <typename T> | 283 | template <typename T> |
| 284 | std::vector<u8> RingController::GetDataVector(const T& reply) const { | 284 | u64 RingController::GetData(const T& reply, std::span<u8> out_data) const { |
| 285 | static_assert(std::is_trivially_copyable_v<T>); | 285 | static_assert(std::is_trivially_copyable_v<T>); |
| 286 | std::vector<u8> data; | 286 | const auto data_size = static_cast<u64>(std::min(sizeof(reply), out_data.size())); |
| 287 | data.resize(sizeof(reply)); | 287 | std::memcpy(out_data.data(), &reply, data_size); |
| 288 | std::memcpy(data.data(), &reply, sizeof(reply)); | 288 | return data_size; |
| 289 | return data; | ||
| 290 | } | 289 | } |
| 291 | 290 | ||
| 292 | } // namespace Service::HID | 291 | } // namespace Service::HID |
diff --git a/src/hid_core/hidbus/ringcon.h b/src/hid_core/hidbus/ringcon.h index 0953e8100..a48eeed45 100644 --- a/src/hid_core/hidbus/ringcon.h +++ b/src/hid_core/hidbus/ringcon.h | |||
| @@ -34,7 +34,7 @@ public: | |||
| 34 | bool SetCommand(std::span<const u8> data) override; | 34 | bool SetCommand(std::span<const u8> data) override; |
| 35 | 35 | ||
| 36 | // Returns a reply from a command | 36 | // Returns a reply from a command |
| 37 | std::vector<u8> GetReply() const override; | 37 | u64 GetReply(std::span<u8> data) const override; |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
| 40 | // These values are obtained from a real ring controller | 40 | // These values are obtained from a real ring controller |
| @@ -184,44 +184,44 @@ private: | |||
| 184 | RingConData GetSensorValue() const; | 184 | RingConData GetSensorValue() const; |
| 185 | 185 | ||
| 186 | // Returns 8 byte reply with firmware version | 186 | // Returns 8 byte reply with firmware version |
| 187 | std::vector<u8> GetFirmwareVersionReply() const; | 187 | u64 GetFirmwareVersionReply(std::span<u8> out_data) const; |
| 188 | 188 | ||
| 189 | // Returns 16 byte reply with ID values | 189 | // Returns 16 byte reply with ID values |
| 190 | std::vector<u8> GetReadIdReply() const; | 190 | u64 GetReadIdReply(std::span<u8> out_data) const; |
| 191 | 191 | ||
| 192 | // (STUBBED) Returns 8 byte reply | 192 | // (STUBBED) Returns 8 byte reply |
| 193 | std::vector<u8> GetC020105Reply() const; | 193 | u64 GetC020105Reply(std::span<u8> out_data) const; |
| 194 | 194 | ||
| 195 | // (STUBBED) Returns 8 byte empty reply | 195 | // (STUBBED) Returns 8 byte empty reply |
| 196 | std::vector<u8> GetReadUnkCalReply() const; | 196 | u64 GetReadUnkCalReply(std::span<u8> out_data) const; |
| 197 | 197 | ||
| 198 | // Returns 20 byte reply with factory calibration values | 198 | // Returns 20 byte reply with factory calibration values |
| 199 | std::vector<u8> GetReadFactoryCalReply() const; | 199 | u64 GetReadFactoryCalReply(std::span<u8> out_data) const; |
| 200 | 200 | ||
| 201 | // Returns 20 byte reply with user calibration values | 201 | // Returns 20 byte reply with user calibration values |
| 202 | std::vector<u8> GetReadUserCalReply() const; | 202 | u64 GetReadUserCalReply(std::span<u8> out_data) const; |
| 203 | 203 | ||
| 204 | // Returns 8 byte reply | 204 | // Returns 8 byte reply |
| 205 | std::vector<u8> GetReadRepCountReply() const; | 205 | u64 GetReadRepCountReply(std::span<u8> out_data) const; |
| 206 | 206 | ||
| 207 | // Returns 8 byte reply | 207 | // Returns 8 byte reply |
| 208 | std::vector<u8> GetReadTotalPushCountReply() const; | 208 | u64 GetReadTotalPushCountReply(std::span<u8> out_data) const; |
| 209 | 209 | ||
| 210 | // Returns 8 byte reply | 210 | // Returns 8 byte reply |
| 211 | std::vector<u8> GetResetRepCountReply() const; | 211 | u64 GetResetRepCountReply(std::span<u8> out_data) const; |
| 212 | 212 | ||
| 213 | // Returns 4 byte save data reply | 213 | // Returns 4 byte save data reply |
| 214 | std::vector<u8> GetSaveDataReply() const; | 214 | u64 GetSaveDataReply(std::span<u8> out_data) const; |
| 215 | 215 | ||
| 216 | // Returns 8 byte error reply | 216 | // Returns 8 byte error reply |
| 217 | std::vector<u8> GetErrorReply() const; | 217 | u64 GetErrorReply(std::span<u8> out_data) const; |
| 218 | 218 | ||
| 219 | // Returns 8 bit redundancy check from provided data | 219 | // Returns 8 bit redundancy check from provided data |
| 220 | u8 GetCrcValue(const std::vector<u8>& data) const; | 220 | u8 GetCrcValue(const std::vector<u8>& data) const; |
| 221 | 221 | ||
| 222 | // Converts structs to an u8 vector equivalent | 222 | // Converts structs to an u8 vector equivalent |
| 223 | template <typename T> | 223 | template <typename T> |
| 224 | std::vector<u8> GetDataVector(const T& reply) const; | 224 | u64 GetData(const T& reply, std::span<u8> out_data) const; |
| 225 | 225 | ||
| 226 | RingConCommands command{RingConCommands::Error}; | 226 | RingConCommands command{RingConCommands::Error}; |
| 227 | 227 | ||
diff --git a/src/hid_core/hidbus/starlink.cpp b/src/hid_core/hidbus/starlink.cpp index 31b263aa1..1c4df1d8c 100644 --- a/src/hid_core/hidbus/starlink.cpp +++ b/src/hid_core/hidbus/starlink.cpp | |||
| @@ -38,7 +38,7 @@ u8 Starlink::GetDeviceId() const { | |||
| 38 | return DEVICE_ID; | 38 | return DEVICE_ID; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | std::vector<u8> Starlink::GetReply() const { | 41 | u64 Starlink::GetReply(std::span<u8> out_data) const { |
| 42 | return {}; | 42 | return {}; |
| 43 | } | 43 | } |
| 44 | 44 | ||
diff --git a/src/hid_core/hidbus/starlink.h b/src/hid_core/hidbus/starlink.h index ee37763b4..695b69748 100644 --- a/src/hid_core/hidbus/starlink.h +++ b/src/hid_core/hidbus/starlink.h | |||
| @@ -31,7 +31,7 @@ public: | |||
| 31 | bool SetCommand(std::span<const u8> data) override; | 31 | bool SetCommand(std::span<const u8> data) override; |
| 32 | 32 | ||
| 33 | // Returns a reply from a command | 33 | // Returns a reply from a command |
| 34 | std::vector<u8> GetReply() const override; | 34 | u64 GetReply(std::span<u8> out_data) const override; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | } // namespace Service::HID | 37 | } // namespace Service::HID |
diff --git a/src/hid_core/hidbus/stubbed.cpp b/src/hid_core/hidbus/stubbed.cpp index f16051aa9..658922a4f 100644 --- a/src/hid_core/hidbus/stubbed.cpp +++ b/src/hid_core/hidbus/stubbed.cpp | |||
| @@ -38,7 +38,7 @@ u8 HidbusStubbed::GetDeviceId() const { | |||
| 38 | return DEVICE_ID; | 38 | return DEVICE_ID; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | std::vector<u8> HidbusStubbed::GetReply() const { | 41 | u64 HidbusStubbed::GetReply(std::span<u8> out_data) const { |
| 42 | return {}; | 42 | return {}; |
| 43 | } | 43 | } |
| 44 | 44 | ||
diff --git a/src/hid_core/hidbus/stubbed.h b/src/hid_core/hidbus/stubbed.h index 7a711cea0..f05280b3a 100644 --- a/src/hid_core/hidbus/stubbed.h +++ b/src/hid_core/hidbus/stubbed.h | |||
| @@ -31,7 +31,7 @@ public: | |||
| 31 | bool SetCommand(std::span<const u8> data) override; | 31 | bool SetCommand(std::span<const u8> data) override; |
| 32 | 32 | ||
| 33 | // Returns a reply from a command | 33 | // Returns a reply from a command |
| 34 | std::vector<u8> GetReply() const override; | 34 | u64 GetReply(std::span<u8> out_data) const override; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | } // namespace Service::HID | 37 | } // namespace Service::HID |
diff --git a/src/hid_core/irsensor/image_transfer_processor.cpp b/src/hid_core/irsensor/image_transfer_processor.cpp index d6573f8dc..2b5a50ef6 100644 --- a/src/hid_core/irsensor/image_transfer_processor.cpp +++ b/src/hid_core/irsensor/image_transfer_processor.cpp | |||
| @@ -145,9 +145,8 @@ void ImageTransferProcessor::SetTransferMemoryAddress(Common::ProcessAddress t_m | |||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | Core::IrSensor::ImageTransferProcessorState ImageTransferProcessor::GetState( | 147 | Core::IrSensor::ImageTransferProcessorState ImageTransferProcessor::GetState( |
| 148 | std::vector<u8>& data) const { | 148 | std::span<u8> data) const { |
| 149 | const auto size = GetDataSize(current_config.trimming_format); | 149 | const auto size = std::min(GetDataSize(current_config.trimming_format), data.size()); |
| 150 | data.resize(size); | ||
| 151 | system.ApplicationMemory().ReadBlock(transfer_memory, data.data(), size); | 150 | system.ApplicationMemory().ReadBlock(transfer_memory, data.data(), size); |
| 152 | return processor_state; | 151 | return processor_state; |
| 153 | } | 152 | } |
diff --git a/src/hid_core/irsensor/image_transfer_processor.h b/src/hid_core/irsensor/image_transfer_processor.h index 4e0117084..df1c9d920 100644 --- a/src/hid_core/irsensor/image_transfer_processor.h +++ b/src/hid_core/irsensor/image_transfer_processor.h | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <span> | ||
| 7 | |||
| 6 | #include "common/typed_address.h" | 8 | #include "common/typed_address.h" |
| 7 | #include "hid_core/irsensor/irs_types.h" | 9 | #include "hid_core/irsensor/irs_types.h" |
| 8 | #include "hid_core/irsensor/processor_base.h" | 10 | #include "hid_core/irsensor/processor_base.h" |
| @@ -39,7 +41,7 @@ public: | |||
| 39 | // Transfer memory where the image data will be stored | 41 | // Transfer memory where the image data will be stored |
| 40 | void SetTransferMemoryAddress(Common::ProcessAddress t_mem); | 42 | void SetTransferMemoryAddress(Common::ProcessAddress t_mem); |
| 41 | 43 | ||
| 42 | Core::IrSensor::ImageTransferProcessorState GetState(std::vector<u8>& data) const; | 44 | Core::IrSensor::ImageTransferProcessorState GetState(std::span<u8> data) const; |
| 43 | 45 | ||
| 44 | private: | 46 | private: |
| 45 | // This is nn::irsensor::ImageTransferProcessorConfig | 47 | // This is nn::irsensor::ImageTransferProcessorConfig |
diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index 245da582e..01261ba97 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp | |||
| @@ -314,6 +314,7 @@ void ResourceManager::UnregisterAppletResourceUserId(u64 aruid) { | |||
| 314 | std::scoped_lock lock{shared_mutex}; | 314 | std::scoped_lock lock{shared_mutex}; |
| 315 | applet_resource->UnregisterAppletResourceUserId(aruid); | 315 | applet_resource->UnregisterAppletResourceUserId(aruid); |
| 316 | npad->UnregisterAppletResourceUserId(aruid); | 316 | npad->UnregisterAppletResourceUserId(aruid); |
| 317 | // palma->UnregisterAppletResourceUserId(aruid); | ||
| 317 | } | 318 | } |
| 318 | 319 | ||
| 319 | Result ResourceManager::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid) { | 320 | Result ResourceManager::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid) { |
| @@ -324,6 +325,7 @@ Result ResourceManager::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle | |||
| 324 | void ResourceManager::FreeAppletResourceId(u64 aruid) { | 325 | void ResourceManager::FreeAppletResourceId(u64 aruid) { |
| 325 | std::scoped_lock lock{shared_mutex}; | 326 | std::scoped_lock lock{shared_mutex}; |
| 326 | applet_resource->FreeAppletResourceId(aruid); | 327 | applet_resource->FreeAppletResourceId(aruid); |
| 328 | npad->FreeAppletResourceId(aruid); | ||
| 327 | } | 329 | } |
| 328 | 330 | ||
| 329 | void ResourceManager::EnableInput(u64 aruid, bool is_enabled) { | 331 | void ResourceManager::EnableInput(u64 aruid, bool is_enabled) { |
diff --git a/src/hid_core/resources/abstracted_pad/abstract_sixaxis_handler.cpp b/src/hid_core/resources/abstracted_pad/abstract_sixaxis_handler.cpp index 6d759298e..0dde244ef 100644 --- a/src/hid_core/resources/abstracted_pad/abstract_sixaxis_handler.cpp +++ b/src/hid_core/resources/abstracted_pad/abstract_sixaxis_handler.cpp | |||
| @@ -57,7 +57,7 @@ Result NpadAbstractSixAxisHandler::UpdateSixAxisState() { | |||
| 57 | Core::HID::NpadIdType npad_id = properties_handler->GetNpadId(); | 57 | Core::HID::NpadIdType npad_id = properties_handler->GetNpadId(); |
| 58 | for (std::size_t i = 0; i < AruidIndexMax; i++) { | 58 | for (std::size_t i = 0; i < AruidIndexMax; i++) { |
| 59 | auto* data = applet_resource_holder->applet_resource->GetAruidDataByIndex(i); | 59 | auto* data = applet_resource_holder->applet_resource->GetAruidDataByIndex(i); |
| 60 | if (data->flag.is_assigned) { | 60 | if (data == nullptr || !data->flag.is_assigned) { |
| 61 | continue; | 61 | continue; |
| 62 | } | 62 | } |
| 63 | auto& npad_entry = data->shared_memory_format->npad.npad_entry[NpadIdTypeToIndex(npad_id)]; | 63 | auto& npad_entry = data->shared_memory_format->npad.npad_entry[NpadIdTypeToIndex(npad_id)]; |
diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index fe3fdc5cd..e10e97e1c 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp | |||
| @@ -117,6 +117,10 @@ Result NPad::ActivateNpadResource(u64 aruid) { | |||
| 117 | return npad_resource.Activate(aruid); | 117 | return npad_resource.Activate(aruid); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | void NPad::FreeAppletResourceId(u64 aruid) { | ||
| 121 | return npad_resource.FreeAppletResourceId(aruid); | ||
| 122 | } | ||
| 123 | |||
| 120 | void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx) { | 124 | void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx) { |
| 121 | if (type == Core::HID::ControllerTriggerType::All) { | 125 | if (type == Core::HID::ControllerTriggerType::All) { |
| 122 | ControllerUpdate(Core::HID::ControllerTriggerType::Connected, controller_idx); | 126 | ControllerUpdate(Core::HID::ControllerTriggerType::Connected, controller_idx); |
| @@ -131,7 +135,7 @@ void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t c | |||
| 131 | 135 | ||
| 132 | auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index); | 136 | auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index); |
| 133 | 137 | ||
| 134 | if (!data->flag.is_assigned) { | 138 | if (data == nullptr || !data->flag.is_assigned) { |
| 135 | continue; | 139 | continue; |
| 136 | } | 140 | } |
| 137 | 141 | ||
| @@ -463,13 +467,13 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 463 | std::scoped_lock lock{*applet_resource_holder.shared_mutex}; | 467 | std::scoped_lock lock{*applet_resource_holder.shared_mutex}; |
| 464 | for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { | 468 | for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { |
| 465 | const auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index); | 469 | const auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index); |
| 466 | const auto aruid = data->aruid; | ||
| 467 | 470 | ||
| 468 | if (!data->flag.is_assigned) { | 471 | if (data == nullptr || !data->flag.is_assigned) { |
| 469 | continue; | 472 | continue; |
| 470 | } | 473 | } |
| 471 | 474 | ||
| 472 | bool is_set{}; | 475 | bool is_set{}; |
| 476 | const auto aruid = data->aruid; | ||
| 473 | npad_resource.IsSupportedNpadStyleSet(is_set, aruid); | 477 | npad_resource.IsSupportedNpadStyleSet(is_set, aruid); |
| 474 | // Wait until style is defined | 478 | // Wait until style is defined |
| 475 | if (!is_set) { | 479 | if (!is_set) { |
diff --git a/src/hid_core/resources/npad/npad.h b/src/hid_core/resources/npad/npad.h index c63488346..99e761127 100644 --- a/src/hid_core/resources/npad/npad.h +++ b/src/hid_core/resources/npad/npad.h | |||
| @@ -58,6 +58,8 @@ public: | |||
| 58 | Result ActivateNpadResource(); | 58 | Result ActivateNpadResource(); |
| 59 | Result ActivateNpadResource(u64 aruid); | 59 | Result ActivateNpadResource(u64 aruid); |
| 60 | 60 | ||
| 61 | void FreeAppletResourceId(u64 aruid); | ||
| 62 | |||
| 61 | // When the controller is requesting an update for the shared memory | 63 | // When the controller is requesting an update for the shared memory |
| 62 | void OnUpdate(const Core::Timing::CoreTiming& core_timing); | 64 | void OnUpdate(const Core::Timing::CoreTiming& core_timing); |
| 63 | 65 | ||
diff --git a/src/hid_core/resources/npad/npad_resource.cpp b/src/hid_core/resources/npad/npad_resource.cpp index 8dd86b58e..79f7d74c0 100644 --- a/src/hid_core/resources/npad/npad_resource.cpp +++ b/src/hid_core/resources/npad/npad_resource.cpp | |||
| @@ -67,7 +67,7 @@ Result NPadResource::RegisterAppletResourceUserId(u64 aruid) { | |||
| 67 | void NPadResource::UnregisterAppletResourceUserId(u64 aruid) { | 67 | void NPadResource::UnregisterAppletResourceUserId(u64 aruid) { |
| 68 | const u64 aruid_index = GetIndexFromAruid(aruid); | 68 | const u64 aruid_index = GetIndexFromAruid(aruid); |
| 69 | 69 | ||
| 70 | DestroyStyleSetUpdateEvents(aruid); | 70 | FreeAppletResourceId(aruid); |
| 71 | if (aruid_index < AruidIndexMax) { | 71 | if (aruid_index < AruidIndexMax) { |
| 72 | state[aruid_index] = {}; | 72 | state[aruid_index] = {}; |
| 73 | registration_list.flag[aruid_index] = RegistrationStatus::PendingDelete; | 73 | registration_list.flag[aruid_index] = RegistrationStatus::PendingDelete; |
| @@ -80,14 +80,18 @@ void NPadResource::UnregisterAppletResourceUserId(u64 aruid) { | |||
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void NPadResource::DestroyStyleSetUpdateEvents(u64 aruid) { | 83 | void NPadResource::FreeAppletResourceId(u64 aruid) { |
| 84 | const u64 aruid_index = GetIndexFromAruid(aruid); | 84 | const u64 aruid_index = GetIndexFromAruid(aruid); |
| 85 | 85 | ||
| 86 | if (aruid_index >= AruidIndexMax) { | 86 | if (aruid_index >= AruidIndexMax) { |
| 87 | return; | 87 | return; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | for (auto& controller_state : state[aruid_index].controller_state) { | 90 | auto& aruid_data = state[aruid_index]; |
| 91 | |||
| 92 | aruid_data.flag.is_assigned.Assign(false); | ||
| 93 | |||
| 94 | for (auto& controller_state : aruid_data.controller_state) { | ||
| 91 | if (!controller_state.is_styleset_update_event_initialized) { | 95 | if (!controller_state.is_styleset_update_event_initialized) { |
| 92 | continue; | 96 | continue; |
| 93 | } | 97 | } |
diff --git a/src/hid_core/resources/npad/npad_resource.h b/src/hid_core/resources/npad/npad_resource.h index aed89eec6..8ee5702fd 100644 --- a/src/hid_core/resources/npad/npad_resource.h +++ b/src/hid_core/resources/npad/npad_resource.h | |||
| @@ -55,7 +55,7 @@ public: | |||
| 55 | Result RegisterAppletResourceUserId(u64 aruid); | 55 | Result RegisterAppletResourceUserId(u64 aruid); |
| 56 | void UnregisterAppletResourceUserId(u64 aruid); | 56 | void UnregisterAppletResourceUserId(u64 aruid); |
| 57 | 57 | ||
| 58 | void DestroyStyleSetUpdateEvents(u64 aruid); | 58 | void FreeAppletResourceId(u64 aruid); |
| 59 | 59 | ||
| 60 | Result Activate(u64 aruid); | 60 | Result Activate(u64 aruid); |
| 61 | Result Activate(); | 61 | Result Activate(); |
diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index abb6fd152..b407a5c76 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp | |||
| @@ -28,142 +28,148 @@ void SixAxis::OnRelease() {} | |||
| 28 | 28 | ||
| 29 | void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 29 | void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
| 30 | std::scoped_lock shared_lock{*shared_mutex}; | 30 | std::scoped_lock shared_lock{*shared_mutex}; |
| 31 | const u64 aruid = applet_resource->GetActiveAruid(); | ||
| 32 | auto* data = applet_resource->GetAruidData(aruid); | ||
| 33 | 31 | ||
| 34 | if (data == nullptr || !data->flag.is_assigned) { | 32 | for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { |
| 35 | return; | 33 | const auto* data = applet_resource->GetAruidDataByIndex(aruid_index); |
| 36 | } | ||
| 37 | |||
| 38 | if (!IsControllerActivated()) { | ||
| 39 | return; | ||
| 40 | } | ||
| 41 | 34 | ||
| 42 | for (std::size_t i = 0; i < controller_data.size(); ++i) { | 35 | if (data == nullptr || !data->flag.is_assigned) { |
| 43 | NpadSharedMemoryEntry& shared_memory = data->shared_memory_format->npad.npad_entry[i]; | ||
| 44 | auto& controller = controller_data[i]; | ||
| 45 | const auto& controller_type = controller.device->GetNpadStyleIndex(); | ||
| 46 | |||
| 47 | if (controller_type == Core::HID::NpadStyleIndex::None || | ||
| 48 | !controller.device->IsConnected()) { | ||
| 49 | continue; | 36 | continue; |
| 50 | } | 37 | } |
| 51 | 38 | ||
| 52 | const auto& motion_state = controller.device->GetMotions(); | 39 | if (!IsControllerActivated()) { |
| 53 | auto& sixaxis_fullkey_state = controller.sixaxis_fullkey_state; | 40 | return; |
| 54 | auto& sixaxis_handheld_state = controller.sixaxis_handheld_state; | ||
| 55 | auto& sixaxis_dual_left_state = controller.sixaxis_dual_left_state; | ||
| 56 | auto& sixaxis_dual_right_state = controller.sixaxis_dual_right_state; | ||
| 57 | auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state; | ||
| 58 | auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state; | ||
| 59 | |||
| 60 | auto& sixaxis_fullkey_lifo = shared_memory.internal_state.sixaxis_fullkey_lifo; | ||
| 61 | auto& sixaxis_handheld_lifo = shared_memory.internal_state.sixaxis_handheld_lifo; | ||
| 62 | auto& sixaxis_dual_left_lifo = shared_memory.internal_state.sixaxis_dual_left_lifo; | ||
| 63 | auto& sixaxis_dual_right_lifo = shared_memory.internal_state.sixaxis_dual_right_lifo; | ||
| 64 | auto& sixaxis_left_lifo = shared_memory.internal_state.sixaxis_left_lifo; | ||
| 65 | auto& sixaxis_right_lifo = shared_memory.internal_state.sixaxis_right_lifo; | ||
| 66 | |||
| 67 | // Clear previous state | ||
| 68 | sixaxis_fullkey_state = {}; | ||
| 69 | sixaxis_handheld_state = {}; | ||
| 70 | sixaxis_dual_left_state = {}; | ||
| 71 | sixaxis_dual_right_state = {}; | ||
| 72 | sixaxis_left_lifo_state = {}; | ||
| 73 | sixaxis_right_lifo_state = {}; | ||
| 74 | |||
| 75 | if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) { | ||
| 76 | controller.sixaxis_at_rest = true; | ||
| 77 | for (std::size_t e = 0; e < motion_state.size(); ++e) { | ||
| 78 | controller.sixaxis_at_rest = | ||
| 79 | controller.sixaxis_at_rest && motion_state[e].is_at_rest; | ||
| 80 | } | ||
| 81 | } | 41 | } |
| 82 | 42 | ||
| 83 | const auto set_motion_state = [&](Core::HID::SixAxisSensorState& state, | 43 | for (std::size_t i = 0; i < controller_data.size(); ++i) { |
| 84 | const Core::HID::ControllerMotion& hid_state) { | 44 | NpadSharedMemoryEntry& shared_memory = data->shared_memory_format->npad.npad_entry[i]; |
| 85 | using namespace std::literals::chrono_literals; | 45 | auto& controller = controller_data[i]; |
| 86 | static constexpr Core::HID::SixAxisSensorState default_motion_state = { | 46 | const auto& controller_type = controller.device->GetNpadStyleIndex(); |
| 87 | .delta_time = std::chrono::nanoseconds(5ms).count(), | 47 | |
| 88 | .accel = {0, 0, -1.0f}, | 48 | if (!data->flag.enable_six_axis_sensor) { |
| 89 | .orientation = | 49 | continue; |
| 90 | { | 50 | } |
| 91 | Common::Vec3f{1.0f, 0, 0}, | 51 | |
| 92 | Common::Vec3f{0, 1.0f, 0}, | 52 | if (controller_type == Core::HID::NpadStyleIndex::None || |
| 93 | Common::Vec3f{0, 0, 1.0f}, | 53 | !controller.device->IsConnected()) { |
| 94 | }, | 54 | continue; |
| 95 | .attribute = {1}, | 55 | } |
| 56 | |||
| 57 | const auto& motion_state = controller.device->GetMotions(); | ||
| 58 | auto& sixaxis_fullkey_state = controller.sixaxis_fullkey_state; | ||
| 59 | auto& sixaxis_handheld_state = controller.sixaxis_handheld_state; | ||
| 60 | auto& sixaxis_dual_left_state = controller.sixaxis_dual_left_state; | ||
| 61 | auto& sixaxis_dual_right_state = controller.sixaxis_dual_right_state; | ||
| 62 | auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state; | ||
| 63 | auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state; | ||
| 64 | |||
| 65 | auto& sixaxis_fullkey_lifo = shared_memory.internal_state.sixaxis_fullkey_lifo; | ||
| 66 | auto& sixaxis_handheld_lifo = shared_memory.internal_state.sixaxis_handheld_lifo; | ||
| 67 | auto& sixaxis_dual_left_lifo = shared_memory.internal_state.sixaxis_dual_left_lifo; | ||
| 68 | auto& sixaxis_dual_right_lifo = shared_memory.internal_state.sixaxis_dual_right_lifo; | ||
| 69 | auto& sixaxis_left_lifo = shared_memory.internal_state.sixaxis_left_lifo; | ||
| 70 | auto& sixaxis_right_lifo = shared_memory.internal_state.sixaxis_right_lifo; | ||
| 71 | |||
| 72 | // Clear previous state | ||
| 73 | sixaxis_fullkey_state = {}; | ||
| 74 | sixaxis_handheld_state = {}; | ||
| 75 | sixaxis_dual_left_state = {}; | ||
| 76 | sixaxis_dual_right_state = {}; | ||
| 77 | sixaxis_left_lifo_state = {}; | ||
| 78 | sixaxis_right_lifo_state = {}; | ||
| 79 | |||
| 80 | if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) { | ||
| 81 | controller.sixaxis_at_rest = true; | ||
| 82 | for (std::size_t e = 0; e < motion_state.size(); ++e) { | ||
| 83 | controller.sixaxis_at_rest = | ||
| 84 | controller.sixaxis_at_rest && motion_state[e].is_at_rest; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | const auto set_motion_state = [&](Core::HID::SixAxisSensorState& state, | ||
| 89 | const Core::HID::ControllerMotion& hid_state) { | ||
| 90 | using namespace std::literals::chrono_literals; | ||
| 91 | static constexpr Core::HID::SixAxisSensorState default_motion_state = { | ||
| 92 | .delta_time = std::chrono::nanoseconds(5ms).count(), | ||
| 93 | .accel = {0, 0, -1.0f}, | ||
| 94 | .orientation = | ||
| 95 | { | ||
| 96 | Common::Vec3f{1.0f, 0, 0}, | ||
| 97 | Common::Vec3f{0, 1.0f, 0}, | ||
| 98 | Common::Vec3f{0, 0, 1.0f}, | ||
| 99 | }, | ||
| 100 | .attribute = {1}, | ||
| 101 | }; | ||
| 102 | if (!controller.sixaxis_sensor_enabled) { | ||
| 103 | state = default_motion_state; | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | if (!Settings::values.motion_enabled.GetValue()) { | ||
| 107 | state = default_motion_state; | ||
| 108 | return; | ||
| 109 | } | ||
| 110 | state.attribute.is_connected.Assign(1); | ||
| 111 | state.delta_time = std::chrono::nanoseconds(5ms).count(); | ||
| 112 | state.accel = hid_state.accel; | ||
| 113 | state.gyro = hid_state.gyro; | ||
| 114 | state.rotation = hid_state.rotation; | ||
| 115 | state.orientation = hid_state.orientation; | ||
| 96 | }; | 116 | }; |
| 97 | if (!controller.sixaxis_sensor_enabled) { | 117 | |
| 98 | state = default_motion_state; | 118 | switch (controller_type) { |
| 99 | return; | 119 | case Core::HID::NpadStyleIndex::None: |
| 120 | ASSERT(false); | ||
| 121 | break; | ||
| 122 | case Core::HID::NpadStyleIndex::Fullkey: | ||
| 123 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | ||
| 124 | break; | ||
| 125 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 126 | set_motion_state(sixaxis_handheld_state, motion_state[0]); | ||
| 127 | break; | ||
| 128 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 129 | set_motion_state(sixaxis_dual_left_state, motion_state[0]); | ||
| 130 | set_motion_state(sixaxis_dual_right_state, motion_state[1]); | ||
| 131 | break; | ||
| 132 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 133 | set_motion_state(sixaxis_left_lifo_state, motion_state[0]); | ||
| 134 | break; | ||
| 135 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 136 | set_motion_state(sixaxis_right_lifo_state, motion_state[1]); | ||
| 137 | break; | ||
| 138 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 139 | using namespace std::literals::chrono_literals; | ||
| 140 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | ||
| 141 | sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count(); | ||
| 142 | break; | ||
| 143 | default: | ||
| 144 | break; | ||
| 100 | } | 145 | } |
| 101 | if (!Settings::values.motion_enabled.GetValue()) { | 146 | |
| 102 | state = default_motion_state; | 147 | sixaxis_fullkey_state.sampling_number = |
| 103 | return; | 148 | sixaxis_fullkey_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 149 | sixaxis_handheld_state.sampling_number = | ||
| 150 | sixaxis_handheld_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 151 | sixaxis_dual_left_state.sampling_number = | ||
| 152 | sixaxis_dual_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 153 | sixaxis_dual_right_state.sampling_number = | ||
| 154 | sixaxis_dual_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 155 | sixaxis_left_lifo_state.sampling_number = | ||
| 156 | sixaxis_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 157 | sixaxis_right_lifo_state.sampling_number = | ||
| 158 | sixaxis_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 159 | |||
| 160 | if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) { | ||
| 161 | // This buffer only is updated on handheld on HW | ||
| 162 | sixaxis_handheld_lifo.lifo.WriteNextEntry(sixaxis_handheld_state); | ||
| 163 | } else { | ||
| 164 | // Handheld doesn't update this buffer on HW | ||
| 165 | sixaxis_fullkey_lifo.lifo.WriteNextEntry(sixaxis_fullkey_state); | ||
| 104 | } | 166 | } |
| 105 | state.attribute.is_connected.Assign(1); | ||
| 106 | state.delta_time = std::chrono::nanoseconds(5ms).count(); | ||
| 107 | state.accel = hid_state.accel; | ||
| 108 | state.gyro = hid_state.gyro; | ||
| 109 | state.rotation = hid_state.rotation; | ||
| 110 | state.orientation = hid_state.orientation; | ||
| 111 | }; | ||
| 112 | |||
| 113 | switch (controller_type) { | ||
| 114 | case Core::HID::NpadStyleIndex::None: | ||
| 115 | ASSERT(false); | ||
| 116 | break; | ||
| 117 | case Core::HID::NpadStyleIndex::Fullkey: | ||
| 118 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | ||
| 119 | break; | ||
| 120 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 121 | set_motion_state(sixaxis_handheld_state, motion_state[0]); | ||
| 122 | break; | ||
| 123 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 124 | set_motion_state(sixaxis_dual_left_state, motion_state[0]); | ||
| 125 | set_motion_state(sixaxis_dual_right_state, motion_state[1]); | ||
| 126 | break; | ||
| 127 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 128 | set_motion_state(sixaxis_left_lifo_state, motion_state[0]); | ||
| 129 | break; | ||
| 130 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 131 | set_motion_state(sixaxis_right_lifo_state, motion_state[1]); | ||
| 132 | break; | ||
| 133 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 134 | using namespace std::literals::chrono_literals; | ||
| 135 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | ||
| 136 | sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count(); | ||
| 137 | break; | ||
| 138 | default: | ||
| 139 | break; | ||
| 140 | } | ||
| 141 | 167 | ||
| 142 | sixaxis_fullkey_state.sampling_number = | 168 | sixaxis_dual_left_lifo.lifo.WriteNextEntry(sixaxis_dual_left_state); |
| 143 | sixaxis_fullkey_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | 169 | sixaxis_dual_right_lifo.lifo.WriteNextEntry(sixaxis_dual_right_state); |
| 144 | sixaxis_handheld_state.sampling_number = | 170 | sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state); |
| 145 | sixaxis_handheld_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | 171 | sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state); |
| 146 | sixaxis_dual_left_state.sampling_number = | ||
| 147 | sixaxis_dual_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 148 | sixaxis_dual_right_state.sampling_number = | ||
| 149 | sixaxis_dual_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 150 | sixaxis_left_lifo_state.sampling_number = | ||
| 151 | sixaxis_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 152 | sixaxis_right_lifo_state.sampling_number = | ||
| 153 | sixaxis_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; | ||
| 154 | |||
| 155 | if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) { | ||
| 156 | // This buffer only is updated on handheld on HW | ||
| 157 | sixaxis_handheld_lifo.lifo.WriteNextEntry(sixaxis_handheld_state); | ||
| 158 | } else { | ||
| 159 | // Handheld doesn't update this buffer on HW | ||
| 160 | sixaxis_fullkey_lifo.lifo.WriteNextEntry(sixaxis_fullkey_state); | ||
| 161 | } | 172 | } |
| 162 | |||
| 163 | sixaxis_dual_left_lifo.lifo.WriteNextEntry(sixaxis_dual_left_state); | ||
| 164 | sixaxis_dual_right_lifo.lifo.WriteNextEntry(sixaxis_dual_right_state); | ||
| 165 | sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state); | ||
| 166 | sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state); | ||
| 167 | } | 173 | } |
| 168 | } | 174 | } |
| 169 | 175 | ||
diff --git a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp index 56e8e8e51..c39321915 100644 --- a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp +++ b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp | |||
| @@ -63,7 +63,7 @@ Result TouchResource::ActivateTouch(u64 aruid) { | |||
| 63 | auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); | 63 | auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); |
| 64 | TouchAruidData& touch_data = aruid_data[aruid_index]; | 64 | TouchAruidData& touch_data = aruid_data[aruid_index]; |
| 65 | 65 | ||
| 66 | if (!applet_data->flag.is_assigned) { | 66 | if (applet_data == nullptr || !applet_data->flag.is_assigned) { |
| 67 | touch_data = {}; | 67 | touch_data = {}; |
| 68 | continue; | 68 | continue; |
| 69 | } | 69 | } |
| @@ -124,7 +124,7 @@ Result TouchResource::ActivateGesture(u64 aruid, u32 basic_gesture_id) { | |||
| 124 | auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); | 124 | auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); |
| 125 | TouchAruidData& touch_data = aruid_data[aruid_index]; | 125 | TouchAruidData& touch_data = aruid_data[aruid_index]; |
| 126 | 126 | ||
| 127 | if (!applet_data->flag.is_assigned) { | 127 | if (applet_data == nullptr || !applet_data->flag.is_assigned) { |
| 128 | touch_data = {}; | 128 | touch_data = {}; |
| 129 | continue; | 129 | continue; |
| 130 | } | 130 | } |
| @@ -324,7 +324,7 @@ Result TouchResource::SetTouchScreenConfiguration( | |||
| 324 | const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); | 324 | const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); |
| 325 | TouchAruidData& data = aruid_data[aruid_index]; | 325 | TouchAruidData& data = aruid_data[aruid_index]; |
| 326 | 326 | ||
| 327 | if (!applet_data->flag.is_assigned) { | 327 | if (applet_data == nullptr || !applet_data->flag.is_assigned) { |
| 328 | continue; | 328 | continue; |
| 329 | } | 329 | } |
| 330 | if (aruid != data.aruid) { | 330 | if (aruid != data.aruid) { |
| @@ -344,7 +344,7 @@ Result TouchResource::GetTouchScreenConfiguration( | |||
| 344 | const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); | 344 | const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); |
| 345 | const TouchAruidData& data = aruid_data[aruid_index]; | 345 | const TouchAruidData& data = aruid_data[aruid_index]; |
| 346 | 346 | ||
| 347 | if (!applet_data->flag.is_assigned) { | 347 | if (applet_data == nullptr || !applet_data->flag.is_assigned) { |
| 348 | continue; | 348 | continue; |
| 349 | } | 349 | } |
| 350 | if (aruid != data.aruid) { | 350 | if (aruid != data.aruid) { |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 64a4e0e55..44281e407 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -60,10 +60,11 @@ public: | |||
| 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); | 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | explicit ImageOperands(Id lod, Id ms) { | 63 | explicit ImageOperands(EmitContext& ctx, const IR::Value& offset, Id lod, Id ms) { |
| 64 | if (Sirit::ValidId(lod)) { | 64 | if (Sirit::ValidId(lod)) { |
| 65 | Add(spv::ImageOperandsMask::Lod, lod); | 65 | Add(spv::ImageOperandsMask::Lod, lod); |
| 66 | } | 66 | } |
| 67 | AddOffset(ctx, offset, ImageFetchOffsetAllowed); | ||
| 67 | if (Sirit::ValidId(ms)) { | 68 | if (Sirit::ValidId(ms)) { |
| 68 | Add(spv::ImageOperandsMask::Sample, ms); | 69 | Add(spv::ImageOperandsMask::Sample, ms); |
| 69 | } | 70 | } |
| @@ -311,37 +312,6 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info, | |||
| 311 | return coords; | 312 | return coords; |
| 312 | } | 313 | } |
| 313 | } | 314 | } |
| 314 | |||
| 315 | void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords, | ||
| 316 | Id offset) { | ||
| 317 | if (!Sirit::ValidId(offset)) { | ||
| 318 | return; | ||
| 319 | } | ||
| 320 | |||
| 321 | Id result_type{}; | ||
| 322 | switch (info.type) { | ||
| 323 | case TextureType::Buffer: | ||
| 324 | case TextureType::Color1D: | ||
| 325 | case TextureType::ColorArray1D: { | ||
| 326 | result_type = ctx.U32[1]; | ||
| 327 | break; | ||
| 328 | } | ||
| 329 | case TextureType::Color2D: | ||
| 330 | case TextureType::Color2DRect: | ||
| 331 | case TextureType::ColorArray2D: { | ||
| 332 | result_type = ctx.U32[2]; | ||
| 333 | break; | ||
| 334 | } | ||
| 335 | case TextureType::Color3D: { | ||
| 336 | result_type = ctx.U32[3]; | ||
| 337 | break; | ||
| 338 | } | ||
| 339 | case TextureType::ColorCube: | ||
| 340 | case TextureType::ColorArrayCube: | ||
| 341 | return; | ||
| 342 | } | ||
| 343 | coords = ctx.OpIAdd(result_type, coords, offset); | ||
| 344 | } | ||
| 345 | } // Anonymous namespace | 315 | } // Anonymous namespace |
| 346 | 316 | ||
| 347 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { | 317 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| @@ -524,10 +494,9 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, | |||
| 524 | operands.Span()); | 494 | operands.Span()); |
| 525 | } | 495 | } |
| 526 | 496 | ||
| 527 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, | 497 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 528 | Id lod, Id ms) { | 498 | const IR::Value& offset, Id lod, Id ms) { |
| 529 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 499 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 530 | AddOffsetToCoordinates(ctx, info, coords, offset); | ||
| 531 | if (info.type == TextureType::Buffer) { | 500 | if (info.type == TextureType::Buffer) { |
| 532 | lod = Id{}; | 501 | lod = Id{}; |
| 533 | } | 502 | } |
| @@ -535,7 +504,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c | |||
| 535 | // This image is multisampled, lod must be implicit | 504 | // This image is multisampled, lod must be implicit |
| 536 | lod = Id{}; | 505 | lod = Id{}; |
| 537 | } | 506 | } |
| 538 | const ImageOperands operands(lod, ms); | 507 | const ImageOperands operands(ctx, offset, lod, ms); |
| 539 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], | 508 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], |
| 540 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); | 509 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); |
| 541 | } | 510 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 5c01b1012..08fcabd58 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -537,8 +537,8 @@ Id EmitImageGather(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id | |||
| 537 | const IR::Value& offset, const IR::Value& offset2); | 537 | const IR::Value& offset, const IR::Value& offset2); |
| 538 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 538 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); | 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); |
| 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, | 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 541 | Id lod, Id ms); | 541 | const IR::Value& offset, Id lod, Id ms); |
| 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, | 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, |
| 543 | const IR::Value& skip_mips); | 543 | const IR::Value& skip_mips); |
| 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); | 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 16c905db9..55180f4b5 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -274,7 +274,6 @@ add_library(video_core STATIC | |||
| 274 | texture_cache/image_view_info.h | 274 | texture_cache/image_view_info.h |
| 275 | texture_cache/render_targets.h | 275 | texture_cache/render_targets.h |
| 276 | texture_cache/samples_helper.h | 276 | texture_cache/samples_helper.h |
| 277 | texture_cache/slot_vector.h | ||
| 278 | texture_cache/texture_cache.cpp | 277 | texture_cache/texture_cache.cpp |
| 279 | texture_cache/texture_cache.h | 278 | texture_cache/texture_cache.h |
| 280 | texture_cache/texture_cache_base.h | 279 | texture_cache/texture_cache_base.h |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index b4bf369d1..6d3d933c5 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <numeric> | 8 | #include <numeric> |
| 9 | 9 | ||
| 10 | #include "common/range_sets.inc" | ||
| 10 | #include "video_core/buffer_cache/buffer_cache_base.h" | 11 | #include "video_core/buffer_cache/buffer_cache_base.h" |
| 11 | #include "video_core/guest_memory.h" | 12 | #include "video_core/guest_memory.h" |
| 12 | #include "video_core/host1x/gpu_device_memory_manager.h" | 13 | #include "video_core/host1x/gpu_device_memory_manager.h" |
| @@ -20,7 +21,7 @@ BufferCache<P>::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, R | |||
| 20 | : runtime{runtime_}, device_memory{device_memory_}, memory_tracker{device_memory} { | 21 | : runtime{runtime_}, device_memory{device_memory_}, memory_tracker{device_memory} { |
| 21 | // Ensure the first slot is used for the null buffer | 22 | // Ensure the first slot is used for the null buffer |
| 22 | void(slot_buffers.insert(runtime, NullBufferParams{})); | 23 | void(slot_buffers.insert(runtime, NullBufferParams{})); |
| 23 | common_ranges.clear(); | 24 | gpu_modified_ranges.Clear(); |
| 24 | inline_buffer_id = NULL_BUFFER_ID; | 25 | inline_buffer_id = NULL_BUFFER_ID; |
| 25 | 26 | ||
| 26 | if (!runtime.CanReportMemoryUsage()) { | 27 | if (!runtime.CanReportMemoryUsage()) { |
| @@ -44,6 +45,9 @@ BufferCache<P>::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, R | |||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | template <class P> | 47 | template <class P> |
| 48 | BufferCache<P>::~BufferCache() = default; | ||
| 49 | |||
| 50 | template <class P> | ||
| 47 | void BufferCache<P>::RunGarbageCollector() { | 51 | void BufferCache<P>::RunGarbageCollector() { |
| 48 | const bool aggressive_gc = total_used_memory >= critical_memory; | 52 | const bool aggressive_gc = total_used_memory >= critical_memory; |
| 49 | const u64 ticks_to_destroy = aggressive_gc ? 60 : 120; | 53 | const u64 ticks_to_destroy = aggressive_gc ? 60 : 120; |
| @@ -96,20 +100,17 @@ void BufferCache<P>::TickFrame() { | |||
| 96 | ++frame_tick; | 100 | ++frame_tick; |
| 97 | delayed_destruction_ring.Tick(); | 101 | delayed_destruction_ring.Tick(); |
| 98 | 102 | ||
| 99 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 103 | for (auto& buffer : async_buffers_death_ring) { |
| 100 | for (auto& buffer : async_buffers_death_ring) { | 104 | runtime.FreeDeferredStagingBuffer(buffer); |
| 101 | runtime.FreeDeferredStagingBuffer(buffer); | ||
| 102 | } | ||
| 103 | async_buffers_death_ring.clear(); | ||
| 104 | } | 105 | } |
| 106 | async_buffers_death_ring.clear(); | ||
| 105 | } | 107 | } |
| 106 | 108 | ||
| 107 | template <class P> | 109 | template <class P> |
| 108 | void BufferCache<P>::WriteMemory(DAddr device_addr, u64 size) { | 110 | void BufferCache<P>::WriteMemory(DAddr device_addr, u64 size) { |
| 109 | if (memory_tracker.IsRegionGpuModified(device_addr, size)) { | 111 | if (memory_tracker.IsRegionGpuModified(device_addr, size)) { |
| 110 | const IntervalType subtract_interval{device_addr, device_addr + size}; | 112 | ClearDownload(device_addr, size); |
| 111 | ClearDownload(subtract_interval); | 113 | gpu_modified_ranges.Subtract(device_addr, size); |
| 112 | common_ranges.subtract(subtract_interval); | ||
| 113 | } | 114 | } |
| 114 | memory_tracker.MarkRegionAsCpuModified(device_addr, size); | 115 | memory_tracker.MarkRegionAsCpuModified(device_addr, size); |
| 115 | } | 116 | } |
| @@ -174,11 +175,11 @@ void BufferCache<P>::DownloadMemory(DAddr device_addr, u64 size) { | |||
| 174 | } | 175 | } |
| 175 | 176 | ||
| 176 | template <class P> | 177 | template <class P> |
| 177 | void BufferCache<P>::ClearDownload(IntervalType subtract_interval) { | 178 | void BufferCache<P>::ClearDownload(DAddr device_addr, u64 size) { |
| 178 | RemoveEachInOverlapCounter(async_downloads, subtract_interval, -1024); | 179 | async_downloads.DeleteAll(device_addr, size); |
| 179 | uncommitted_ranges.subtract(subtract_interval); | 180 | uncommitted_gpu_modified_ranges.Subtract(device_addr, size); |
| 180 | for (auto& interval_set : committed_ranges) { | 181 | for (auto& interval_set : committed_gpu_modified_ranges) { |
| 181 | interval_set.subtract(subtract_interval); | 182 | interval_set.Subtract(device_addr, size); |
| 182 | } | 183 | } |
| 183 | } | 184 | } |
| 184 | 185 | ||
| @@ -195,8 +196,7 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am | |||
| 195 | return false; | 196 | return false; |
| 196 | } | 197 | } |
| 197 | 198 | ||
| 198 | const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount}; | 199 | ClearDownload(*cpu_dest_address, amount); |
| 199 | ClearDownload(subtract_interval); | ||
| 200 | 200 | ||
| 201 | BufferId buffer_a; | 201 | BufferId buffer_a; |
| 202 | BufferId buffer_b; | 202 | BufferId buffer_b; |
| @@ -215,21 +215,20 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am | |||
| 215 | .size = amount, | 215 | .size = amount, |
| 216 | }}; | 216 | }}; |
| 217 | 217 | ||
| 218 | boost::container::small_vector<IntervalType, 4> tmp_intervals; | 218 | boost::container::small_vector<std::pair<DAddr, size_t>, 4> tmp_intervals; |
| 219 | auto mirror = [&](DAddr base_address, DAddr base_address_end) { | 219 | auto mirror = [&](DAddr base_address, DAddr base_address_end) { |
| 220 | const u64 size = base_address_end - base_address; | 220 | const u64 size = base_address_end - base_address; |
| 221 | const DAddr diff = base_address - *cpu_src_address; | 221 | const DAddr diff = base_address - *cpu_src_address; |
| 222 | const DAddr new_base_address = *cpu_dest_address + diff; | 222 | const DAddr new_base_address = *cpu_dest_address + diff; |
| 223 | const IntervalType add_interval{new_base_address, new_base_address + size}; | 223 | tmp_intervals.push_back({new_base_address, size}); |
| 224 | tmp_intervals.push_back(add_interval); | 224 | uncommitted_gpu_modified_ranges.Add(new_base_address, size); |
| 225 | uncommitted_ranges.add(add_interval); | ||
| 226 | }; | 225 | }; |
| 227 | ForEachInRangeSet(common_ranges, *cpu_src_address, amount, mirror); | 226 | gpu_modified_ranges.ForEachInRange(*cpu_src_address, amount, mirror); |
| 228 | // This subtraction in this order is important for overlapping copies. | 227 | // This subtraction in this order is important for overlapping copies. |
| 229 | common_ranges.subtract(subtract_interval); | 228 | gpu_modified_ranges.Subtract(*cpu_dest_address, amount); |
| 230 | const bool has_new_downloads = tmp_intervals.size() != 0; | 229 | const bool has_new_downloads = tmp_intervals.size() != 0; |
| 231 | for (const IntervalType& add_interval : tmp_intervals) { | 230 | for (const auto& pair : tmp_intervals) { |
| 232 | common_ranges.add(add_interval); | 231 | gpu_modified_ranges.Add(pair.first, pair.second); |
| 233 | } | 232 | } |
| 234 | const auto& copy = copies[0]; | 233 | const auto& copy = copies[0]; |
| 235 | src_buffer.MarkUsage(copy.src_offset, copy.size); | 234 | src_buffer.MarkUsage(copy.src_offset, copy.size); |
| @@ -257,9 +256,8 @@ bool BufferCache<P>::DMAClear(GPUVAddr dst_address, u64 amount, u32 value) { | |||
| 257 | } | 256 | } |
| 258 | 257 | ||
| 259 | const size_t size = amount * sizeof(u32); | 258 | const size_t size = amount * sizeof(u32); |
| 260 | const IntervalType subtract_interval{*cpu_dst_address, *cpu_dst_address + size}; | 259 | ClearDownload(*cpu_dst_address, size); |
| 261 | ClearDownload(subtract_interval); | 260 | gpu_modified_ranges.Subtract(*cpu_dst_address, size); |
| 262 | common_ranges.subtract(subtract_interval); | ||
| 263 | 261 | ||
| 264 | const BufferId buffer = FindBuffer(*cpu_dst_address, static_cast<u32>(size)); | 262 | const BufferId buffer = FindBuffer(*cpu_dst_address, static_cast<u32>(size)); |
| 265 | Buffer& dest_buffer = slot_buffers[buffer]; | 263 | Buffer& dest_buffer = slot_buffers[buffer]; |
| @@ -300,11 +298,11 @@ std::pair<typename P::Buffer*, u32> BufferCache<P>::ObtainCPUBuffer( | |||
| 300 | MarkWrittenBuffer(buffer_id, device_addr, size); | 298 | MarkWrittenBuffer(buffer_id, device_addr, size); |
| 301 | break; | 299 | break; |
| 302 | case ObtainBufferOperation::DiscardWrite: { | 300 | case ObtainBufferOperation::DiscardWrite: { |
| 303 | DAddr device_addr_start = Common::AlignDown(device_addr, 64); | 301 | const DAddr device_addr_start = Common::AlignDown(device_addr, 64); |
| 304 | DAddr device_addr_end = Common::AlignUp(device_addr + size, 64); | 302 | const DAddr device_addr_end = Common::AlignUp(device_addr + size, 64); |
| 305 | IntervalType interval{device_addr_start, device_addr_end}; | 303 | const size_t new_size = device_addr_end - device_addr_start; |
| 306 | ClearDownload(interval); | 304 | ClearDownload(device_addr_start, new_size); |
| 307 | common_ranges.subtract(interval); | 305 | gpu_modified_ranges.Subtract(device_addr_start, new_size); |
| 308 | break; | 306 | break; |
| 309 | } | 307 | } |
| 310 | default: | 308 | default: |
| @@ -504,46 +502,40 @@ void BufferCache<P>::FlushCachedWrites() { | |||
| 504 | 502 | ||
| 505 | template <class P> | 503 | template <class P> |
| 506 | bool BufferCache<P>::HasUncommittedFlushes() const noexcept { | 504 | bool BufferCache<P>::HasUncommittedFlushes() const noexcept { |
| 507 | return !uncommitted_ranges.empty() || !committed_ranges.empty(); | 505 | return !uncommitted_gpu_modified_ranges.Empty() || !committed_gpu_modified_ranges.empty(); |
| 508 | } | 506 | } |
| 509 | 507 | ||
| 510 | template <class P> | 508 | template <class P> |
| 511 | void BufferCache<P>::AccumulateFlushes() { | 509 | void BufferCache<P>::AccumulateFlushes() { |
| 512 | if (uncommitted_ranges.empty()) { | 510 | if (uncommitted_gpu_modified_ranges.Empty()) { |
| 513 | return; | 511 | return; |
| 514 | } | 512 | } |
| 515 | committed_ranges.emplace_back(std::move(uncommitted_ranges)); | 513 | committed_gpu_modified_ranges.emplace_back(std::move(uncommitted_gpu_modified_ranges)); |
| 516 | } | 514 | } |
| 517 | 515 | ||
| 518 | template <class P> | 516 | template <class P> |
| 519 | bool BufferCache<P>::ShouldWaitAsyncFlushes() const noexcept { | 517 | bool BufferCache<P>::ShouldWaitAsyncFlushes() const noexcept { |
| 520 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 518 | return (!async_buffers.empty() && async_buffers.front().has_value()); |
| 521 | return (!async_buffers.empty() && async_buffers.front().has_value()); | ||
| 522 | } else { | ||
| 523 | return false; | ||
| 524 | } | ||
| 525 | } | 519 | } |
| 526 | 520 | ||
| 527 | template <class P> | 521 | template <class P> |
| 528 | void BufferCache<P>::CommitAsyncFlushesHigh() { | 522 | void BufferCache<P>::CommitAsyncFlushesHigh() { |
| 529 | AccumulateFlushes(); | 523 | AccumulateFlushes(); |
| 530 | 524 | ||
| 531 | if (committed_ranges.empty()) { | 525 | if (committed_gpu_modified_ranges.empty()) { |
| 532 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 526 | async_buffers.emplace_back(std::optional<Async_Buffer>{}); |
| 533 | async_buffers.emplace_back(std::optional<Async_Buffer>{}); | ||
| 534 | } | ||
| 535 | return; | 527 | return; |
| 536 | } | 528 | } |
| 537 | MICROPROFILE_SCOPE(GPU_DownloadMemory); | 529 | MICROPROFILE_SCOPE(GPU_DownloadMemory); |
| 538 | 530 | ||
| 539 | auto it = committed_ranges.begin(); | 531 | auto it = committed_gpu_modified_ranges.begin(); |
| 540 | while (it != committed_ranges.end()) { | 532 | while (it != committed_gpu_modified_ranges.end()) { |
| 541 | auto& current_intervals = *it; | 533 | auto& current_intervals = *it; |
| 542 | auto next_it = std::next(it); | 534 | auto next_it = std::next(it); |
| 543 | while (next_it != committed_ranges.end()) { | 535 | while (next_it != committed_gpu_modified_ranges.end()) { |
| 544 | for (auto& interval : *next_it) { | 536 | next_it->ForEach([¤t_intervals](DAddr start, DAddr end) { |
| 545 | current_intervals.subtract(interval); | 537 | current_intervals.Subtract(start, end - start); |
| 546 | } | 538 | }); |
| 547 | next_it++; | 539 | next_it++; |
| 548 | } | 540 | } |
| 549 | it++; | 541 | it++; |
| @@ -552,10 +544,10 @@ void BufferCache<P>::CommitAsyncFlushesHigh() { | |||
| 552 | boost::container::small_vector<std::pair<BufferCopy, BufferId>, 16> downloads; | 544 | boost::container::small_vector<std::pair<BufferCopy, BufferId>, 16> downloads; |
| 553 | u64 total_size_bytes = 0; | 545 | u64 total_size_bytes = 0; |
| 554 | u64 largest_copy = 0; | 546 | u64 largest_copy = 0; |
| 555 | for (const IntervalSet& intervals : committed_ranges) { | 547 | for (const Common::RangeSet<DAddr>& range_set : committed_gpu_modified_ranges) { |
| 556 | for (auto& interval : intervals) { | 548 | range_set.ForEach([&](DAddr interval_lower, DAddr interval_upper) { |
| 557 | const std::size_t size = interval.upper() - interval.lower(); | 549 | const std::size_t size = interval_upper - interval_lower; |
| 558 | const DAddr device_addr = interval.lower(); | 550 | const DAddr device_addr = interval_lower; |
| 559 | ForEachBufferInRange(device_addr, size, [&](BufferId buffer_id, Buffer& buffer) { | 551 | ForEachBufferInRange(device_addr, size, [&](BufferId buffer_id, Buffer& buffer) { |
| 560 | const DAddr buffer_start = buffer.CpuAddr(); | 552 | const DAddr buffer_start = buffer.CpuAddr(); |
| 561 | const DAddr buffer_end = buffer_start + buffer.SizeBytes(); | 553 | const DAddr buffer_end = buffer_start + buffer.SizeBytes(); |
| @@ -583,77 +575,35 @@ void BufferCache<P>::CommitAsyncFlushesHigh() { | |||
| 583 | largest_copy = std::max(largest_copy, new_size); | 575 | largest_copy = std::max(largest_copy, new_size); |
| 584 | }; | 576 | }; |
| 585 | 577 | ||
| 586 | ForEachInRangeSet(common_ranges, device_addr_out, range_size, add_download); | 578 | gpu_modified_ranges.ForEachInRange(device_addr_out, range_size, |
| 579 | add_download); | ||
| 587 | }); | 580 | }); |
| 588 | }); | 581 | }); |
| 589 | } | 582 | }); |
| 590 | } | 583 | } |
| 591 | committed_ranges.clear(); | 584 | committed_gpu_modified_ranges.clear(); |
| 592 | if (downloads.empty()) { | 585 | if (downloads.empty()) { |
| 593 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 586 | async_buffers.emplace_back(std::optional<Async_Buffer>{}); |
| 594 | async_buffers.emplace_back(std::optional<Async_Buffer>{}); | ||
| 595 | } | ||
| 596 | return; | 587 | return; |
| 597 | } | 588 | } |
| 598 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 589 | auto download_staging = runtime.DownloadStagingBuffer(total_size_bytes, true); |
| 599 | auto download_staging = runtime.DownloadStagingBuffer(total_size_bytes, true); | 590 | boost::container::small_vector<BufferCopy, 4> normalized_copies; |
| 600 | boost::container::small_vector<BufferCopy, 4> normalized_copies; | 591 | runtime.PreCopyBarrier(); |
| 601 | IntervalSet new_async_range{}; | 592 | for (auto& [copy, buffer_id] : downloads) { |
| 602 | runtime.PreCopyBarrier(); | 593 | copy.dst_offset += download_staging.offset; |
| 603 | for (auto& [copy, buffer_id] : downloads) { | 594 | const std::array copies{copy}; |
| 604 | copy.dst_offset += download_staging.offset; | 595 | BufferCopy second_copy{copy}; |
| 605 | const std::array copies{copy}; | 596 | Buffer& buffer = slot_buffers[buffer_id]; |
| 606 | BufferCopy second_copy{copy}; | 597 | second_copy.src_offset = static_cast<size_t>(buffer.CpuAddr()) + copy.src_offset; |
| 607 | Buffer& buffer = slot_buffers[buffer_id]; | 598 | const DAddr orig_device_addr = static_cast<DAddr>(second_copy.src_offset); |
| 608 | second_copy.src_offset = static_cast<size_t>(buffer.CpuAddr()) + copy.src_offset; | 599 | async_downloads.Add(orig_device_addr, copy.size); |
| 609 | DAddr orig_device_addr = static_cast<DAddr>(second_copy.src_offset); | 600 | buffer.MarkUsage(copy.src_offset, copy.size); |
| 610 | const IntervalType base_interval{orig_device_addr, orig_device_addr + copy.size}; | 601 | runtime.CopyBuffer(download_staging.buffer, buffer, copies, false); |
| 611 | async_downloads += std::make_pair(base_interval, 1); | 602 | normalized_copies.push_back(second_copy); |
| 612 | buffer.MarkUsage(copy.src_offset, copy.size); | ||
| 613 | runtime.CopyBuffer(download_staging.buffer, buffer, copies, false); | ||
| 614 | normalized_copies.push_back(second_copy); | ||
| 615 | } | ||
| 616 | runtime.PostCopyBarrier(); | ||
| 617 | pending_downloads.emplace_back(std::move(normalized_copies)); | ||
| 618 | async_buffers.emplace_back(download_staging); | ||
| 619 | } else { | ||
| 620 | if (!Settings::IsGPULevelHigh()) { | ||
| 621 | committed_ranges.clear(); | ||
| 622 | uncommitted_ranges.clear(); | ||
| 623 | } else { | ||
| 624 | if constexpr (USE_MEMORY_MAPS) { | ||
| 625 | auto download_staging = runtime.DownloadStagingBuffer(total_size_bytes); | ||
| 626 | runtime.PreCopyBarrier(); | ||
| 627 | for (auto& [copy, buffer_id] : downloads) { | ||
| 628 | // Have in mind the staging buffer offset for the copy | ||
| 629 | copy.dst_offset += download_staging.offset; | ||
| 630 | const std::array copies{copy}; | ||
| 631 | Buffer& buffer = slot_buffers[buffer_id]; | ||
| 632 | buffer.MarkUsage(copy.src_offset, copy.size); | ||
| 633 | runtime.CopyBuffer(download_staging.buffer, buffer, copies, false); | ||
| 634 | } | ||
| 635 | runtime.PostCopyBarrier(); | ||
| 636 | runtime.Finish(); | ||
| 637 | for (const auto& [copy, buffer_id] : downloads) { | ||
| 638 | const Buffer& buffer = slot_buffers[buffer_id]; | ||
| 639 | const DAddr device_addr = buffer.CpuAddr() + copy.src_offset; | ||
| 640 | // Undo the modified offset | ||
| 641 | const u64 dst_offset = copy.dst_offset - download_staging.offset; | ||
| 642 | const u8* read_mapped_memory = download_staging.mapped_span.data() + dst_offset; | ||
| 643 | device_memory.WriteBlockUnsafe(device_addr, read_mapped_memory, copy.size); | ||
| 644 | } | ||
| 645 | } else { | ||
| 646 | const std::span<u8> immediate_buffer = ImmediateBuffer(largest_copy); | ||
| 647 | for (const auto& [copy, buffer_id] : downloads) { | ||
| 648 | Buffer& buffer = slot_buffers[buffer_id]; | ||
| 649 | buffer.ImmediateDownload(copy.src_offset, | ||
| 650 | immediate_buffer.subspan(0, copy.size)); | ||
| 651 | const DAddr device_addr = buffer.CpuAddr() + copy.src_offset; | ||
| 652 | device_memory.WriteBlockUnsafe(device_addr, immediate_buffer.data(), copy.size); | ||
| 653 | } | ||
| 654 | } | ||
| 655 | } | ||
| 656 | } | 603 | } |
| 604 | runtime.PostCopyBarrier(); | ||
| 605 | pending_downloads.emplace_back(std::move(normalized_copies)); | ||
| 606 | async_buffers.emplace_back(download_staging); | ||
| 657 | } | 607 | } |
| 658 | 608 | ||
| 659 | template <class P> | 609 | template <class P> |
| @@ -676,37 +626,31 @@ void BufferCache<P>::PopAsyncBuffers() { | |||
| 676 | async_buffers.pop_front(); | 626 | async_buffers.pop_front(); |
| 677 | return; | 627 | return; |
| 678 | } | 628 | } |
| 679 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 629 | auto& downloads = pending_downloads.front(); |
| 680 | auto& downloads = pending_downloads.front(); | 630 | auto& async_buffer = async_buffers.front(); |
| 681 | auto& async_buffer = async_buffers.front(); | 631 | u8* base = async_buffer->mapped_span.data(); |
| 682 | u8* base = async_buffer->mapped_span.data(); | 632 | const size_t base_offset = async_buffer->offset; |
| 683 | const size_t base_offset = async_buffer->offset; | 633 | for (const auto& copy : downloads) { |
| 684 | for (const auto& copy : downloads) { | 634 | const DAddr device_addr = static_cast<DAddr>(copy.src_offset); |
| 685 | const DAddr device_addr = static_cast<DAddr>(copy.src_offset); | 635 | const u64 dst_offset = copy.dst_offset - base_offset; |
| 686 | const u64 dst_offset = copy.dst_offset - base_offset; | 636 | const u8* read_mapped_memory = base + dst_offset; |
| 687 | const u8* read_mapped_memory = base + dst_offset; | 637 | async_downloads.ForEachInRange(device_addr, copy.size, [&](DAddr start, DAddr end, s32) { |
| 688 | ForEachInOverlapCounter( | 638 | device_memory.WriteBlockUnsafe(start, &read_mapped_memory[start - device_addr], |
| 689 | async_downloads, device_addr, copy.size, [&](DAddr start, DAddr end, int count) { | 639 | end - start); |
| 690 | device_memory.WriteBlockUnsafe(start, &read_mapped_memory[start - device_addr], | 640 | }); |
| 691 | end - start); | 641 | async_downloads.Subtract(device_addr, copy.size, [&](DAddr start, DAddr end) { |
| 692 | if (count == 1) { | 642 | gpu_modified_ranges.Subtract(start, end - start); |
| 693 | const IntervalType base_interval{start, end}; | 643 | }); |
| 694 | common_ranges.subtract(base_interval); | ||
| 695 | } | ||
| 696 | }); | ||
| 697 | const IntervalType subtract_interval{device_addr, device_addr + copy.size}; | ||
| 698 | RemoveEachInOverlapCounter(async_downloads, subtract_interval, -1); | ||
| 699 | } | ||
| 700 | async_buffers_death_ring.emplace_back(*async_buffer); | ||
| 701 | async_buffers.pop_front(); | ||
| 702 | pending_downloads.pop_front(); | ||
| 703 | } | 644 | } |
| 645 | async_buffers_death_ring.emplace_back(*async_buffer); | ||
| 646 | async_buffers.pop_front(); | ||
| 647 | pending_downloads.pop_front(); | ||
| 704 | } | 648 | } |
| 705 | 649 | ||
| 706 | template <class P> | 650 | template <class P> |
| 707 | bool BufferCache<P>::IsRegionGpuModified(DAddr addr, size_t size) { | 651 | bool BufferCache<P>::IsRegionGpuModified(DAddr addr, size_t size) { |
| 708 | bool is_dirty = false; | 652 | bool is_dirty = false; |
| 709 | ForEachInRangeSet(common_ranges, addr, size, [&](DAddr, DAddr) { is_dirty = true; }); | 653 | gpu_modified_ranges.ForEachInRange(addr, size, [&](DAddr, DAddr) { is_dirty = true; }); |
| 710 | return is_dirty; | 654 | return is_dirty; |
| 711 | } | 655 | } |
| 712 | 656 | ||
| @@ -1320,10 +1264,8 @@ void BufferCache<P>::UpdateComputeTextureBuffers() { | |||
| 1320 | template <class P> | 1264 | template <class P> |
| 1321 | void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, DAddr device_addr, u32 size) { | 1265 | void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, DAddr device_addr, u32 size) { |
| 1322 | memory_tracker.MarkRegionAsGpuModified(device_addr, size); | 1266 | memory_tracker.MarkRegionAsGpuModified(device_addr, size); |
| 1323 | 1267 | gpu_modified_ranges.Add(device_addr, size); | |
| 1324 | const IntervalType base_interval{device_addr, device_addr + size}; | 1268 | uncommitted_gpu_modified_ranges.Add(device_addr, size); |
| 1325 | common_ranges.add(base_interval); | ||
| 1326 | uncommitted_ranges.add(base_interval); | ||
| 1327 | } | 1269 | } |
| 1328 | 1270 | ||
| 1329 | template <class P> | 1271 | template <class P> |
| @@ -1600,9 +1542,8 @@ bool BufferCache<P>::InlineMemory(DAddr dest_address, size_t copy_size, | |||
| 1600 | template <class P> | 1542 | template <class P> |
| 1601 | void BufferCache<P>::InlineMemoryImplementation(DAddr dest_address, size_t copy_size, | 1543 | void BufferCache<P>::InlineMemoryImplementation(DAddr dest_address, size_t copy_size, |
| 1602 | std::span<const u8> inlined_buffer) { | 1544 | std::span<const u8> inlined_buffer) { |
| 1603 | const IntervalType subtract_interval{dest_address, dest_address + copy_size}; | 1545 | ClearDownload(dest_address, copy_size); |
| 1604 | ClearDownload(subtract_interval); | 1546 | gpu_modified_ranges.Subtract(dest_address, copy_size); |
| 1605 | common_ranges.subtract(subtract_interval); | ||
| 1606 | 1547 | ||
| 1607 | BufferId buffer_id = FindBuffer(dest_address, static_cast<u32>(copy_size)); | 1548 | BufferId buffer_id = FindBuffer(dest_address, static_cast<u32>(copy_size)); |
| 1608 | auto& buffer = slot_buffers[buffer_id]; | 1549 | auto& buffer = slot_buffers[buffer_id]; |
| @@ -1652,12 +1593,9 @@ void BufferCache<P>::DownloadBufferMemory(Buffer& buffer, DAddr device_addr, u64 | |||
| 1652 | largest_copy = std::max(largest_copy, new_size); | 1593 | largest_copy = std::max(largest_copy, new_size); |
| 1653 | }; | 1594 | }; |
| 1654 | 1595 | ||
| 1655 | const DAddr start_address = device_addr_out; | 1596 | gpu_modified_ranges.ForEachInRange(device_addr_out, range_size, add_download); |
| 1656 | const DAddr end_address = start_address + range_size; | 1597 | ClearDownload(device_addr_out, range_size); |
| 1657 | ForEachInRangeSet(common_ranges, start_address, range_size, add_download); | 1598 | gpu_modified_ranges.Subtract(device_addr_out, range_size); |
| 1658 | const IntervalType subtract_interval{start_address, end_address}; | ||
| 1659 | ClearDownload(subtract_interval); | ||
| 1660 | common_ranges.subtract(subtract_interval); | ||
| 1661 | }); | 1599 | }); |
| 1662 | if (total_size_bytes == 0) { | 1600 | if (total_size_bytes == 0) { |
| 1663 | return; | 1601 | return; |
diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h index 80dbb81e7..240e9f015 100644 --- a/src/video_core/buffer_cache/buffer_cache_base.h +++ b/src/video_core/buffer_cache/buffer_cache_base.h | |||
| @@ -13,25 +13,15 @@ | |||
| 13 | #include <unordered_map> | 13 | #include <unordered_map> |
| 14 | #include <vector> | 14 | #include <vector> |
| 15 | 15 | ||
| 16 | #include <boost/container/small_vector.hpp> | ||
| 17 | #define BOOST_NO_MT | ||
| 18 | #include <boost/pool/detail/mutex.hpp> | ||
| 19 | #undef BOOST_NO_MT | ||
| 20 | #include <boost/icl/interval.hpp> | ||
| 21 | #include <boost/icl/interval_base_set.hpp> | ||
| 22 | #include <boost/icl/interval_set.hpp> | ||
| 23 | #include <boost/icl/split_interval_map.hpp> | ||
| 24 | #include <boost/pool/pool.hpp> | ||
| 25 | #include <boost/pool/pool_alloc.hpp> | ||
| 26 | #include <boost/pool/poolfwd.hpp> | ||
| 27 | |||
| 28 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 29 | #include "common/div_ceil.h" | 17 | #include "common/div_ceil.h" |
| 30 | #include "common/literals.h" | 18 | #include "common/literals.h" |
| 31 | #include "common/lru_cache.h" | 19 | #include "common/lru_cache.h" |
| 32 | #include "common/microprofile.h" | 20 | #include "common/microprofile.h" |
| 21 | #include "common/range_sets.h" | ||
| 33 | #include "common/scope_exit.h" | 22 | #include "common/scope_exit.h" |
| 34 | #include "common/settings.h" | 23 | #include "common/settings.h" |
| 24 | #include "common/slot_vector.h" | ||
| 35 | #include "video_core/buffer_cache/buffer_base.h" | 25 | #include "video_core/buffer_cache/buffer_base.h" |
| 36 | #include "video_core/control/channel_state_cache.h" | 26 | #include "video_core/control/channel_state_cache.h" |
| 37 | #include "video_core/delayed_destruction_ring.h" | 27 | #include "video_core/delayed_destruction_ring.h" |
| @@ -41,21 +31,15 @@ | |||
| 41 | #include "video_core/engines/maxwell_3d.h" | 31 | #include "video_core/engines/maxwell_3d.h" |
| 42 | #include "video_core/memory_manager.h" | 32 | #include "video_core/memory_manager.h" |
| 43 | #include "video_core/surface.h" | 33 | #include "video_core/surface.h" |
| 44 | #include "video_core/texture_cache/slot_vector.h" | ||
| 45 | #include "video_core/texture_cache/types.h" | 34 | #include "video_core/texture_cache/types.h" |
| 46 | 35 | ||
| 47 | namespace boost { | ||
| 48 | template <typename T> | ||
| 49 | class fast_pool_allocator<T, default_user_allocator_new_delete, details::pool::null_mutex, 4096, 0>; | ||
| 50 | } | ||
| 51 | |||
| 52 | namespace VideoCommon { | 36 | namespace VideoCommon { |
| 53 | 37 | ||
| 54 | MICROPROFILE_DECLARE(GPU_PrepareBuffers); | 38 | MICROPROFILE_DECLARE(GPU_PrepareBuffers); |
| 55 | MICROPROFILE_DECLARE(GPU_BindUploadBuffers); | 39 | MICROPROFILE_DECLARE(GPU_BindUploadBuffers); |
| 56 | MICROPROFILE_DECLARE(GPU_DownloadMemory); | 40 | MICROPROFILE_DECLARE(GPU_DownloadMemory); |
| 57 | 41 | ||
| 58 | using BufferId = SlotId; | 42 | using BufferId = Common::SlotId; |
| 59 | 43 | ||
| 60 | using VideoCore::Surface::PixelFormat; | 44 | using VideoCore::Surface::PixelFormat; |
| 61 | using namespace Common::Literals; | 45 | using namespace Common::Literals; |
| @@ -184,7 +168,6 @@ class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInf | |||
| 184 | static constexpr bool NEEDS_BIND_STORAGE_INDEX = P::NEEDS_BIND_STORAGE_INDEX; | 168 | static constexpr bool NEEDS_BIND_STORAGE_INDEX = P::NEEDS_BIND_STORAGE_INDEX; |
| 185 | static constexpr bool USE_MEMORY_MAPS = P::USE_MEMORY_MAPS; | 169 | static constexpr bool USE_MEMORY_MAPS = P::USE_MEMORY_MAPS; |
| 186 | static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS; | 170 | static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS; |
| 187 | static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = P::IMPLEMENTS_ASYNC_DOWNLOADS; | ||
| 188 | static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = P::USE_MEMORY_MAPS_FOR_UPLOADS; | 171 | static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = P::USE_MEMORY_MAPS_FOR_UPLOADS; |
| 189 | 172 | ||
| 190 | static constexpr s64 DEFAULT_EXPECTED_MEMORY = 512_MiB; | 173 | static constexpr s64 DEFAULT_EXPECTED_MEMORY = 512_MiB; |
| @@ -202,34 +185,6 @@ class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInf | |||
| 202 | using Async_Buffer = typename P::Async_Buffer; | 185 | using Async_Buffer = typename P::Async_Buffer; |
| 203 | using MemoryTracker = typename P::MemoryTracker; | 186 | using MemoryTracker = typename P::MemoryTracker; |
| 204 | 187 | ||
| 205 | using IntervalCompare = std::less<DAddr>; | ||
| 206 | using IntervalInstance = boost::icl::interval_type_default<DAddr, std::less>; | ||
| 207 | using IntervalAllocator = boost::fast_pool_allocator<DAddr>; | ||
| 208 | using IntervalSet = boost::icl::interval_set<DAddr>; | ||
| 209 | using IntervalType = typename IntervalSet::interval_type; | ||
| 210 | |||
| 211 | template <typename Type> | ||
| 212 | struct counter_add_functor : public boost::icl::identity_based_inplace_combine<Type> { | ||
| 213 | // types | ||
| 214 | typedef counter_add_functor<Type> type; | ||
| 215 | typedef boost::icl::identity_based_inplace_combine<Type> base_type; | ||
| 216 | |||
| 217 | // public member functions | ||
| 218 | void operator()(Type& current, const Type& added) const { | ||
| 219 | current += added; | ||
| 220 | if (current < base_type::identity_element()) { | ||
| 221 | current = base_type::identity_element(); | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | // public static functions | ||
| 226 | static void version(Type&){}; | ||
| 227 | }; | ||
| 228 | |||
| 229 | using OverlapCombine = counter_add_functor<int>; | ||
| 230 | using OverlapSection = boost::icl::inter_section<int>; | ||
| 231 | using OverlapCounter = boost::icl::split_interval_map<DAddr, int>; | ||
| 232 | |||
| 233 | struct OverlapResult { | 188 | struct OverlapResult { |
| 234 | boost::container::small_vector<BufferId, 16> ids; | 189 | boost::container::small_vector<BufferId, 16> ids; |
| 235 | DAddr begin; | 190 | DAddr begin; |
| @@ -240,6 +195,8 @@ class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInf | |||
| 240 | public: | 195 | public: |
| 241 | explicit BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, Runtime& runtime_); | 196 | explicit BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, Runtime& runtime_); |
| 242 | 197 | ||
| 198 | ~BufferCache(); | ||
| 199 | |||
| 243 | void TickFrame(); | 200 | void TickFrame(); |
| 244 | 201 | ||
| 245 | void WriteMemory(DAddr device_addr, u64 size); | 202 | void WriteMemory(DAddr device_addr, u64 size); |
| @@ -379,75 +336,6 @@ private: | |||
| 379 | } | 336 | } |
| 380 | } | 337 | } |
| 381 | 338 | ||
| 382 | template <typename Func> | ||
| 383 | void ForEachInRangeSet(IntervalSet& current_range, DAddr device_addr, u64 size, Func&& func) { | ||
| 384 | const DAddr start_address = device_addr; | ||
| 385 | const DAddr end_address = start_address + size; | ||
| 386 | const IntervalType search_interval{start_address, end_address}; | ||
| 387 | auto it = current_range.lower_bound(search_interval); | ||
| 388 | if (it == current_range.end()) { | ||
| 389 | return; | ||
| 390 | } | ||
| 391 | auto end_it = current_range.upper_bound(search_interval); | ||
| 392 | for (; it != end_it; it++) { | ||
| 393 | DAddr inter_addr_end = it->upper(); | ||
| 394 | DAddr inter_addr = it->lower(); | ||
| 395 | if (inter_addr_end > end_address) { | ||
| 396 | inter_addr_end = end_address; | ||
| 397 | } | ||
| 398 | if (inter_addr < start_address) { | ||
| 399 | inter_addr = start_address; | ||
| 400 | } | ||
| 401 | func(inter_addr, inter_addr_end); | ||
| 402 | } | ||
| 403 | } | ||
| 404 | |||
| 405 | template <typename Func> | ||
| 406 | void ForEachInOverlapCounter(OverlapCounter& current_range, DAddr device_addr, u64 size, | ||
| 407 | Func&& func) { | ||
| 408 | const DAddr start_address = device_addr; | ||
| 409 | const DAddr end_address = start_address + size; | ||
| 410 | const IntervalType search_interval{start_address, end_address}; | ||
| 411 | auto it = current_range.lower_bound(search_interval); | ||
| 412 | if (it == current_range.end()) { | ||
| 413 | return; | ||
| 414 | } | ||
| 415 | auto end_it = current_range.upper_bound(search_interval); | ||
| 416 | for (; it != end_it; it++) { | ||
| 417 | auto& inter = it->first; | ||
| 418 | DAddr inter_addr_end = inter.upper(); | ||
| 419 | DAddr inter_addr = inter.lower(); | ||
| 420 | if (inter_addr_end > end_address) { | ||
| 421 | inter_addr_end = end_address; | ||
| 422 | } | ||
| 423 | if (inter_addr < start_address) { | ||
| 424 | inter_addr = start_address; | ||
| 425 | } | ||
| 426 | func(inter_addr, inter_addr_end, it->second); | ||
| 427 | } | ||
| 428 | } | ||
| 429 | |||
| 430 | void RemoveEachInOverlapCounter(OverlapCounter& current_range, | ||
| 431 | const IntervalType search_interval, int subtract_value) { | ||
| 432 | bool any_removals = false; | ||
| 433 | current_range.add(std::make_pair(search_interval, subtract_value)); | ||
| 434 | do { | ||
| 435 | any_removals = false; | ||
| 436 | auto it = current_range.lower_bound(search_interval); | ||
| 437 | if (it == current_range.end()) { | ||
| 438 | return; | ||
| 439 | } | ||
| 440 | auto end_it = current_range.upper_bound(search_interval); | ||
| 441 | for (; it != end_it; it++) { | ||
| 442 | if (it->second <= 0) { | ||
| 443 | any_removals = true; | ||
| 444 | current_range.erase(it); | ||
| 445 | break; | ||
| 446 | } | ||
| 447 | } | ||
| 448 | } while (any_removals); | ||
| 449 | } | ||
| 450 | |||
| 451 | static bool IsRangeGranular(DAddr device_addr, size_t size) { | 339 | static bool IsRangeGranular(DAddr device_addr, size_t size) { |
| 452 | return (device_addr & ~Core::DEVICE_PAGEMASK) == | 340 | return (device_addr & ~Core::DEVICE_PAGEMASK) == |
| 453 | ((device_addr + size) & ~Core::DEVICE_PAGEMASK); | 341 | ((device_addr + size) & ~Core::DEVICE_PAGEMASK); |
| @@ -552,14 +440,14 @@ private: | |||
| 552 | 440 | ||
| 553 | [[nodiscard]] bool HasFastUniformBufferBound(size_t stage, u32 binding_index) const noexcept; | 441 | [[nodiscard]] bool HasFastUniformBufferBound(size_t stage, u32 binding_index) const noexcept; |
| 554 | 442 | ||
| 555 | void ClearDownload(IntervalType subtract_interval); | 443 | void ClearDownload(DAddr base_addr, u64 size); |
| 556 | 444 | ||
| 557 | void InlineMemoryImplementation(DAddr dest_address, size_t copy_size, | 445 | void InlineMemoryImplementation(DAddr dest_address, size_t copy_size, |
| 558 | std::span<const u8> inlined_buffer); | 446 | std::span<const u8> inlined_buffer); |
| 559 | 447 | ||
| 560 | Tegra::MaxwellDeviceMemoryManager& device_memory; | 448 | Tegra::MaxwellDeviceMemoryManager& device_memory; |
| 561 | 449 | ||
| 562 | SlotVector<Buffer> slot_buffers; | 450 | Common::SlotVector<Buffer> slot_buffers; |
| 563 | DelayedDestructionRing<Buffer, 8> delayed_destruction_ring; | 451 | DelayedDestructionRing<Buffer, 8> delayed_destruction_ring; |
| 564 | 452 | ||
| 565 | const Tegra::Engines::DrawManager::IndirectParams* current_draw_indirect{}; | 453 | const Tegra::Engines::DrawManager::IndirectParams* current_draw_indirect{}; |
| @@ -567,13 +455,12 @@ private: | |||
| 567 | u32 last_index_count = 0; | 455 | u32 last_index_count = 0; |
| 568 | 456 | ||
| 569 | MemoryTracker memory_tracker; | 457 | MemoryTracker memory_tracker; |
| 570 | IntervalSet uncommitted_ranges; | 458 | Common::RangeSet<DAddr> uncommitted_gpu_modified_ranges; |
| 571 | IntervalSet common_ranges; | 459 | Common::RangeSet<DAddr> gpu_modified_ranges; |
| 572 | IntervalSet cached_ranges; | 460 | std::deque<Common::RangeSet<DAddr>> committed_gpu_modified_ranges; |
| 573 | std::deque<IntervalSet> committed_ranges; | ||
| 574 | 461 | ||
| 575 | // Async Buffers | 462 | // Async Buffers |
| 576 | OverlapCounter async_downloads; | 463 | Common::OverlapRangeSet<DAddr> async_downloads; |
| 577 | std::deque<std::optional<Async_Buffer>> async_buffers; | 464 | std::deque<std::optional<Async_Buffer>> async_buffers; |
| 578 | std::deque<boost::container::small_vector<BufferCopy, 4>> pending_downloads; | 465 | std::deque<boost::container::small_vector<BufferCopy, 4>> pending_downloads; |
| 579 | std::optional<Async_Buffer> current_buffer; | 466 | std::optional<Async_Buffer> current_buffer; |
diff --git a/src/video_core/host1x/host1x.cpp b/src/video_core/host1x/host1x.cpp index c4c7a5883..e923bfa22 100644 --- a/src/video_core/host1x/host1x.cpp +++ b/src/video_core/host1x/host1x.cpp | |||
| @@ -10,7 +10,7 @@ namespace Host1x { | |||
| 10 | 10 | ||
| 11 | Host1x::Host1x(Core::System& system_) | 11 | Host1x::Host1x(Core::System& system_) |
| 12 | : system{system_}, syncpoint_manager{}, | 12 | : system{system_}, syncpoint_manager{}, |
| 13 | memory_manager(system.DeviceMemory()), gmmu_manager{system, memory_manager, 32, 12}, | 13 | memory_manager(system.DeviceMemory()), gmmu_manager{system, memory_manager, 32, 0, 12}, |
| 14 | allocator{std::make_unique<Common::FlatAllocator<u32, 0, 32>>(1 << 12)} {} | 14 | allocator{std::make_unique<Common::FlatAllocator<u32, 0, 32>>(1 << 12)} {} |
| 15 | 15 | ||
| 16 | Host1x::~Host1x() = default; | 16 | Host1x::~Host1x() = default; |
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index a52f8e486..ffafc48ef 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp | |||
| @@ -22,11 +22,12 @@ using Tegra::Memory::GuestMemoryFlags; | |||
| 22 | std::atomic<size_t> MemoryManager::unique_identifier_generator{}; | 22 | std::atomic<size_t> MemoryManager::unique_identifier_generator{}; |
| 23 | 23 | ||
| 24 | MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_, | 24 | MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_, |
| 25 | u64 address_space_bits_, u64 big_page_bits_, u64 page_bits_) | 25 | u64 address_space_bits_, GPUVAddr split_address_, u64 big_page_bits_, |
| 26 | u64 page_bits_) | ||
| 26 | : system{system_}, memory{memory_}, address_space_bits{address_space_bits_}, | 27 | : system{system_}, memory{memory_}, address_space_bits{address_space_bits_}, |
| 27 | page_bits{page_bits_}, big_page_bits{big_page_bits_}, entries{}, big_entries{}, | 28 | split_address{split_address_}, page_bits{page_bits_}, big_page_bits{big_page_bits_}, |
| 28 | page_table{address_space_bits, address_space_bits + page_bits - 38, | 29 | entries{}, big_entries{}, page_table{address_space_bits, address_space_bits + page_bits - 38, |
| 29 | page_bits != big_page_bits ? page_bits : 0}, | 30 | page_bits != big_page_bits ? page_bits : 0}, |
| 30 | kind_map{PTEKind::INVALID}, unique_identifier{unique_identifier_generator.fetch_add( | 31 | kind_map{PTEKind::INVALID}, unique_identifier{unique_identifier_generator.fetch_add( |
| 31 | 1, std::memory_order_acq_rel)}, | 32 | 1, std::memory_order_acq_rel)}, |
| 32 | accumulator{std::make_unique<VideoCommon::InvalidationAccumulator>()} { | 33 | accumulator{std::make_unique<VideoCommon::InvalidationAccumulator>()} { |
| @@ -48,10 +49,10 @@ MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& | |||
| 48 | entries.resize(page_table_size / 32, 0); | 49 | entries.resize(page_table_size / 32, 0); |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | MemoryManager::MemoryManager(Core::System& system_, u64 address_space_bits_, u64 big_page_bits_, | 52 | MemoryManager::MemoryManager(Core::System& system_, u64 address_space_bits_, |
| 52 | u64 page_bits_) | 53 | GPUVAddr split_address_, u64 big_page_bits_, u64 page_bits_) |
| 53 | : MemoryManager(system_, system_.Host1x().MemoryManager(), address_space_bits_, big_page_bits_, | 54 | : MemoryManager(system_, system_.Host1x().MemoryManager(), address_space_bits_, split_address_, |
| 54 | page_bits_) {} | 55 | big_page_bits_, page_bits_) {} |
| 55 | 56 | ||
| 56 | MemoryManager::~MemoryManager() = default; | 57 | MemoryManager::~MemoryManager() = default; |
| 57 | 58 | ||
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index c5255f36c..ac7c1472a 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h | |||
| @@ -36,10 +36,11 @@ namespace Tegra { | |||
| 36 | class MemoryManager final { | 36 | class MemoryManager final { |
| 37 | public: | 37 | public: |
| 38 | explicit MemoryManager(Core::System& system_, u64 address_space_bits_ = 40, | 38 | explicit MemoryManager(Core::System& system_, u64 address_space_bits_ = 40, |
| 39 | u64 big_page_bits_ = 16, u64 page_bits_ = 12); | 39 | GPUVAddr split_address = 1ULL << 34, u64 big_page_bits_ = 16, |
| 40 | explicit MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_, | ||
| 41 | u64 address_space_bits_ = 40, u64 big_page_bits_ = 16, | ||
| 42 | u64 page_bits_ = 12); | 40 | u64 page_bits_ = 12); |
| 41 | explicit MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_, | ||
| 42 | u64 address_space_bits_ = 40, GPUVAddr split_address = 1ULL << 34, | ||
| 43 | u64 big_page_bits_ = 16, u64 page_bits_ = 12); | ||
| 43 | ~MemoryManager(); | 44 | ~MemoryManager(); |
| 44 | 45 | ||
| 45 | size_t GetID() const { | 46 | size_t GetID() const { |
| @@ -192,6 +193,7 @@ private: | |||
| 192 | MaxwellDeviceMemoryManager& memory; | 193 | MaxwellDeviceMemoryManager& memory; |
| 193 | 194 | ||
| 194 | const u64 address_space_bits; | 195 | const u64 address_space_bits; |
| 196 | GPUVAddr split_address; | ||
| 195 | const u64 page_bits; | 197 | const u64 page_bits; |
| 196 | u64 address_space_size; | 198 | u64 address_space_size; |
| 197 | u64 page_size; | 199 | u64 page_size; |
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 4861b123a..e1019f228 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -18,12 +18,12 @@ | |||
| 18 | 18 | ||
| 19 | #include "common/assert.h" | 19 | #include "common/assert.h" |
| 20 | #include "common/settings.h" | 20 | #include "common/settings.h" |
| 21 | #include "common/slot_vector.h" | ||
| 21 | #include "video_core/control/channel_state_cache.h" | 22 | #include "video_core/control/channel_state_cache.h" |
| 22 | #include "video_core/engines/maxwell_3d.h" | 23 | #include "video_core/engines/maxwell_3d.h" |
| 23 | #include "video_core/host1x/gpu_device_memory_manager.h" | 24 | #include "video_core/host1x/gpu_device_memory_manager.h" |
| 24 | #include "video_core/memory_manager.h" | 25 | #include "video_core/memory_manager.h" |
| 25 | #include "video_core/rasterizer_interface.h" | 26 | #include "video_core/rasterizer_interface.h" |
| 26 | #include "video_core/texture_cache/slot_vector.h" | ||
| 27 | 27 | ||
| 28 | namespace VideoCore { | 28 | namespace VideoCore { |
| 29 | enum class QueryType { | 29 | enum class QueryType { |
| @@ -37,7 +37,7 @@ constexpr std::size_t NumQueryTypes = static_cast<size_t>(QueryType::Count); | |||
| 37 | 37 | ||
| 38 | namespace VideoCommon { | 38 | namespace VideoCommon { |
| 39 | 39 | ||
| 40 | using AsyncJobId = SlotId; | 40 | using AsyncJobId = Common::SlotId; |
| 41 | 41 | ||
| 42 | static constexpr AsyncJobId NULL_ASYNC_JOB_ID{0}; | 42 | static constexpr AsyncJobId NULL_ASYNC_JOB_ID{0}; |
| 43 | 43 | ||
| @@ -341,7 +341,7 @@ private: | |||
| 341 | static constexpr std::uintptr_t YUZU_PAGESIZE = 4096; | 341 | static constexpr std::uintptr_t YUZU_PAGESIZE = 4096; |
| 342 | static constexpr unsigned YUZU_PAGEBITS = 12; | 342 | static constexpr unsigned YUZU_PAGEBITS = 12; |
| 343 | 343 | ||
| 344 | SlotVector<AsyncJob> slot_async_jobs; | 344 | Common::SlotVector<AsyncJob> slot_async_jobs; |
| 345 | 345 | ||
| 346 | VideoCore::RasterizerInterface& rasterizer; | 346 | VideoCore::RasterizerInterface& rasterizer; |
| 347 | Tegra::MaxwellDeviceMemoryManager& device_memory; | 347 | Tegra::MaxwellDeviceMemoryManager& device_memory; |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index af34c272b..fd471e979 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h | |||
| @@ -90,7 +90,7 @@ public: | |||
| 90 | void PostCopyBarrier(); | 90 | void PostCopyBarrier(); |
| 91 | void Finish(); | 91 | void Finish(); |
| 92 | 92 | ||
| 93 | void TickFrame(VideoCommon::SlotVector<Buffer>&) noexcept {} | 93 | void TickFrame(Common::SlotVector<Buffer>&) noexcept {} |
| 94 | 94 | ||
| 95 | void ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value); | 95 | void ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value); |
| 96 | 96 | ||
| @@ -251,7 +251,6 @@ struct BufferCacheParams { | |||
| 251 | static constexpr bool NEEDS_BIND_STORAGE_INDEX = true; | 251 | static constexpr bool NEEDS_BIND_STORAGE_INDEX = true; |
| 252 | static constexpr bool USE_MEMORY_MAPS = true; | 252 | static constexpr bool USE_MEMORY_MAPS = true; |
| 253 | static constexpr bool SEPARATE_IMAGE_BUFFER_BINDINGS = true; | 253 | static constexpr bool SEPARATE_IMAGE_BUFFER_BINDINGS = true; |
| 254 | static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true; | ||
| 255 | 254 | ||
| 256 | // TODO: Investigate why OpenGL seems to perform worse with persistently mapped buffer uploads | 255 | // TODO: Investigate why OpenGL seems to perform worse with persistently mapped buffer uploads |
| 257 | static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = false; | 256 | static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = false; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 3e54edcc2..d4165d8e4 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -30,13 +30,13 @@ class Image; | |||
| 30 | class ImageView; | 30 | class ImageView; |
| 31 | class Sampler; | 31 | class Sampler; |
| 32 | 32 | ||
| 33 | using Common::SlotVector; | ||
| 33 | using VideoCommon::ImageId; | 34 | using VideoCommon::ImageId; |
| 34 | using VideoCommon::ImageViewId; | 35 | using VideoCommon::ImageViewId; |
| 35 | using VideoCommon::ImageViewType; | 36 | using VideoCommon::ImageViewType; |
| 36 | using VideoCommon::NUM_RT; | 37 | using VideoCommon::NUM_RT; |
| 37 | using VideoCommon::Region2D; | 38 | using VideoCommon::Region2D; |
| 38 | using VideoCommon::RenderTargets; | 39 | using VideoCommon::RenderTargets; |
| 39 | using VideoCommon::SlotVector; | ||
| 40 | 40 | ||
| 41 | struct FormatProperties { | 41 | struct FormatProperties { |
| 42 | GLenum compatibility_class; | 42 | GLenum compatibility_class; |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 31001d142..e5e1e3ab6 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp | |||
| @@ -368,7 +368,7 @@ u32 BufferCacheRuntime::GetStorageBufferAlignment() const { | |||
| 368 | return static_cast<u32>(device.GetStorageBufferAlignment()); | 368 | return static_cast<u32>(device.GetStorageBufferAlignment()); |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | void BufferCacheRuntime::TickFrame(VideoCommon::SlotVector<Buffer>& slot_buffers) noexcept { | 371 | void BufferCacheRuntime::TickFrame(Common::SlotVector<Buffer>& slot_buffers) noexcept { |
| 372 | for (auto it = slot_buffers.begin(); it != slot_buffers.end(); it++) { | 372 | for (auto it = slot_buffers.begin(); it != slot_buffers.end(); it++) { |
| 373 | it->ResetUsageTracking(); | 373 | it->ResetUsageTracking(); |
| 374 | } | 374 | } |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index e273f4988..efe960258 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h | |||
| @@ -81,7 +81,7 @@ public: | |||
| 81 | ComputePassDescriptorQueue& compute_pass_descriptor_queue, | 81 | ComputePassDescriptorQueue& compute_pass_descriptor_queue, |
| 82 | DescriptorPool& descriptor_pool); | 82 | DescriptorPool& descriptor_pool); |
| 83 | 83 | ||
| 84 | void TickFrame(VideoCommon::SlotVector<Buffer>& slot_buffers) noexcept; | 84 | void TickFrame(Common::SlotVector<Buffer>& slot_buffers) noexcept; |
| 85 | 85 | ||
| 86 | void Finish(); | 86 | void Finish(); |
| 87 | 87 | ||
| @@ -181,7 +181,6 @@ struct BufferCacheParams { | |||
| 181 | static constexpr bool NEEDS_BIND_STORAGE_INDEX = false; | 181 | static constexpr bool NEEDS_BIND_STORAGE_INDEX = false; |
| 182 | static constexpr bool USE_MEMORY_MAPS = true; | 182 | static constexpr bool USE_MEMORY_MAPS = true; |
| 183 | static constexpr bool SEPARATE_IMAGE_BUFFER_BINDINGS = false; | 183 | static constexpr bool SEPARATE_IMAGE_BUFFER_BINDINGS = false; |
| 184 | static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true; | ||
| 185 | static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = true; | 184 | static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = true; |
| 186 | }; | 185 | }; |
| 187 | 186 | ||
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 0dbde65d6..aaeb5ef93 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h | |||
| @@ -20,11 +20,11 @@ struct ResolutionScalingInfo; | |||
| 20 | 20 | ||
| 21 | namespace Vulkan { | 21 | namespace Vulkan { |
| 22 | 22 | ||
| 23 | using Common::SlotVector; | ||
| 23 | using VideoCommon::ImageId; | 24 | using VideoCommon::ImageId; |
| 24 | using VideoCommon::NUM_RT; | 25 | using VideoCommon::NUM_RT; |
| 25 | using VideoCommon::Region2D; | 26 | using VideoCommon::Region2D; |
| 26 | using VideoCommon::RenderTargets; | 27 | using VideoCommon::RenderTargets; |
| 27 | using VideoCommon::SlotVector; | ||
| 28 | using VideoCore::Surface::PixelFormat; | 28 | using VideoCore::Surface::PixelFormat; |
| 29 | 29 | ||
| 30 | class BlitImageHelper; | 30 | class BlitImageHelper; |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index e7b910121..da98a634b 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "common/lru_cache.h" | 21 | #include "common/lru_cache.h" |
| 22 | #include "common/polyfill_ranges.h" | 22 | #include "common/polyfill_ranges.h" |
| 23 | #include "common/scratch_buffer.h" | 23 | #include "common/scratch_buffer.h" |
| 24 | #include "common/slot_vector.h" | ||
| 24 | #include "common/thread_worker.h" | 25 | #include "common/thread_worker.h" |
| 25 | #include "video_core/compatible_formats.h" | 26 | #include "video_core/compatible_formats.h" |
| 26 | #include "video_core/control/channel_state_cache.h" | 27 | #include "video_core/control/channel_state_cache.h" |
| @@ -32,7 +33,6 @@ | |||
| 32 | #include "video_core/texture_cache/image_info.h" | 33 | #include "video_core/texture_cache/image_info.h" |
| 33 | #include "video_core/texture_cache/image_view_base.h" | 34 | #include "video_core/texture_cache/image_view_base.h" |
| 34 | #include "video_core/texture_cache/render_targets.h" | 35 | #include "video_core/texture_cache/render_targets.h" |
| 35 | #include "video_core/texture_cache/slot_vector.h" | ||
| 36 | #include "video_core/texture_cache/types.h" | 36 | #include "video_core/texture_cache/types.h" |
| 37 | #include "video_core/textures/texture.h" | 37 | #include "video_core/textures/texture.h" |
| 38 | 38 | ||
| @@ -451,16 +451,16 @@ private: | |||
| 451 | struct PendingDownload { | 451 | struct PendingDownload { |
| 452 | bool is_swizzle; | 452 | bool is_swizzle; |
| 453 | size_t async_buffer_id; | 453 | size_t async_buffer_id; |
| 454 | SlotId object_id; | 454 | Common::SlotId object_id; |
| 455 | }; | 455 | }; |
| 456 | 456 | ||
| 457 | SlotVector<Image> slot_images; | 457 | Common::SlotVector<Image> slot_images; |
| 458 | SlotVector<ImageMapView> slot_map_views; | 458 | Common::SlotVector<ImageMapView> slot_map_views; |
| 459 | SlotVector<ImageView> slot_image_views; | 459 | Common::SlotVector<ImageView> slot_image_views; |
| 460 | SlotVector<ImageAlloc> slot_image_allocs; | 460 | Common::SlotVector<ImageAlloc> slot_image_allocs; |
| 461 | SlotVector<Sampler> slot_samplers; | 461 | Common::SlotVector<Sampler> slot_samplers; |
| 462 | SlotVector<Framebuffer> slot_framebuffers; | 462 | Common::SlotVector<Framebuffer> slot_framebuffers; |
| 463 | SlotVector<BufferDownload> slot_buffer_downloads; | 463 | Common::SlotVector<BufferDownload> slot_buffer_downloads; |
| 464 | 464 | ||
| 465 | // TODO: This data structure is not optimal and it should be reworked | 465 | // TODO: This data structure is not optimal and it should be reworked |
| 466 | 466 | ||
diff --git a/src/video_core/texture_cache/types.h b/src/video_core/texture_cache/types.h index 0453456b4..07c304386 100644 --- a/src/video_core/texture_cache/types.h +++ b/src/video_core/texture_cache/types.h | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/common_funcs.h" | 6 | #include "common/common_funcs.h" |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "video_core/texture_cache/slot_vector.h" | 8 | #include "common/slot_vector.h" |
| 9 | 9 | ||
| 10 | namespace VideoCommon { | 10 | namespace VideoCommon { |
| 11 | 11 | ||
| 12 | constexpr size_t NUM_RT = 8; | 12 | constexpr size_t NUM_RT = 8; |
| 13 | constexpr size_t MAX_MIP_LEVELS = 14; | 13 | constexpr size_t MAX_MIP_LEVELS = 14; |
| 14 | 14 | ||
| 15 | constexpr SlotId CORRUPT_ID{0xfffffffe}; | 15 | constexpr Common::SlotId CORRUPT_ID{0xfffffffe}; |
| 16 | 16 | ||
| 17 | using ImageId = SlotId; | 17 | using ImageId = Common::SlotId; |
| 18 | using ImageMapId = SlotId; | 18 | using ImageMapId = Common::SlotId; |
| 19 | using ImageViewId = SlotId; | 19 | using ImageViewId = Common::SlotId; |
| 20 | using ImageAllocId = SlotId; | 20 | using ImageAllocId = Common::SlotId; |
| 21 | using SamplerId = SlotId; | 21 | using SamplerId = Common::SlotId; |
| 22 | using FramebufferId = SlotId; | 22 | using FramebufferId = Common::SlotId; |
| 23 | 23 | ||
| 24 | /// Fake image ID for null image views | 24 | /// Fake image ID for null image views |
| 25 | constexpr ImageId NULL_IMAGE_ID{0}; | 25 | constexpr ImageId NULL_IMAGE_ID{0}; |
diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index dff380cca..fdf3ac846 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp | |||
| @@ -32,9 +32,14 @@ struct Client::Impl { | |||
| 32 | Impl(std::string host_, std::string username_, std::string token_) | 32 | Impl(std::string host_, std::string username_, std::string token_) |
| 33 | : host{std::move(host_)}, username{std::move(username_)}, token{std::move(token_)} { | 33 | : host{std::move(host_)}, username{std::move(username_)}, token{std::move(token_)} { |
| 34 | std::scoped_lock lock{jwt_cache.mutex}; | 34 | std::scoped_lock lock{jwt_cache.mutex}; |
| 35 | if (username == jwt_cache.username && token == jwt_cache.token) { | 35 | if (this->username == jwt_cache.username && this->token == jwt_cache.token) { |
| 36 | jwt = jwt_cache.jwt; | 36 | jwt = jwt_cache.jwt; |
| 37 | } | 37 | } |
| 38 | |||
| 39 | // Normalize host expression | ||
| 40 | if (!this->host.empty() && this->host.back() == '/') { | ||
| 41 | static_cast<void>(this->host.pop_back()); | ||
| 42 | } | ||
| 38 | } | 43 | } |
| 39 | 44 | ||
| 40 | /// A generic function handles POST, GET and DELETE request together | 45 | /// A generic function handles POST, GET and DELETE request together |
| @@ -71,18 +76,16 @@ struct Client::Impl { | |||
| 71 | const std::string& jwt_ = "", const std::string& username_ = "", | 76 | const std::string& jwt_ = "", const std::string& username_ = "", |
| 72 | const std::string& token_ = "") { | 77 | const std::string& token_ = "") { |
| 73 | if (cli == nullptr) { | 78 | if (cli == nullptr) { |
| 74 | cli = std::make_unique<httplib::Client>(host); | 79 | cli = std::make_unique<httplib::Client>(host.c_str()); |
| 80 | cli->set_connection_timeout(TIMEOUT_SECONDS); | ||
| 81 | cli->set_read_timeout(TIMEOUT_SECONDS); | ||
| 82 | cli->set_write_timeout(TIMEOUT_SECONDS); | ||
| 75 | } | 83 | } |
| 76 | |||
| 77 | if (!cli->is_valid()) { | 84 | if (!cli->is_valid()) { |
| 78 | LOG_ERROR(WebService, "Client is invalid, skipping request!"); | 85 | LOG_ERROR(WebService, "Invalid URL {}", host + path); |
| 79 | return {}; | 86 | return WebResult{WebResult::Code::InvalidURL, "Invalid URL", ""}; |
| 80 | } | 87 | } |
| 81 | 88 | ||
| 82 | cli->set_connection_timeout(TIMEOUT_SECONDS); | ||
| 83 | cli->set_read_timeout(TIMEOUT_SECONDS); | ||
| 84 | cli->set_write_timeout(TIMEOUT_SECONDS); | ||
| 85 | |||
| 86 | httplib::Headers params; | 89 | httplib::Headers params; |
| 87 | if (!jwt_.empty()) { | 90 | if (!jwt_.empty()) { |
| 88 | params = { | 91 | params = { |
| @@ -107,15 +110,15 @@ struct Client::Impl { | |||
| 107 | request.headers = params; | 110 | request.headers = params; |
| 108 | request.body = data; | 111 | request.body = data; |
| 109 | 112 | ||
| 110 | httplib::Response response; | 113 | httplib::Result result = cli->send(request); |
| 111 | httplib::Error error; | ||
| 112 | 114 | ||
| 113 | if (!cli->send(request, response, error)) { | 115 | if (!result) { |
| 114 | LOG_ERROR(WebService, "{} to {} returned null (httplib Error: {})", method, host + path, | 116 | LOG_ERROR(WebService, "{} to {} returned null", method, host + path); |
| 115 | httplib::to_string(error)); | ||
| 116 | return WebResult{WebResult::Code::LibError, "Null response", ""}; | 117 | return WebResult{WebResult::Code::LibError, "Null response", ""}; |
| 117 | } | 118 | } |
| 118 | 119 | ||
| 120 | httplib::Response response = result.value(); | ||
| 121 | |||
| 119 | if (response.status >= 400) { | 122 | if (response.status >= 400) { |
| 120 | LOG_ERROR(WebService, "{} to {} returned error status code: {}", method, host + path, | 123 | LOG_ERROR(WebService, "{} to {} returned error status code: {}", method, host + path, |
| 121 | response.status); | 124 | response.status); |
diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index 3d18670ce..3f68de12d 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp | |||
| @@ -45,15 +45,23 @@ ConfigureHotkeys::ConfigureHotkeys(Core::HID::HIDCore& hid_core, QWidget* parent | |||
| 45 | 45 | ||
| 46 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); | 46 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); |
| 47 | 47 | ||
| 48 | connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); }); | 48 | connect(timeout_timer.get(), &QTimer::timeout, [this] { |
| 49 | const bool is_button_pressed = pressed_buttons != Core::HID::NpadButton::None || | ||
| 50 | pressed_home_button || pressed_capture_button; | ||
| 51 | SetPollingResult(!is_button_pressed); | ||
| 52 | }); | ||
| 49 | 53 | ||
| 50 | connect(poll_timer.get(), &QTimer::timeout, [this] { | 54 | connect(poll_timer.get(), &QTimer::timeout, [this] { |
| 51 | const auto buttons = controller->GetNpadButtons(); | 55 | pressed_buttons |= controller->GetNpadButtons().raw; |
| 52 | const auto home_pressed = controller->GetHomeButtons().home != 0; | 56 | pressed_home_button |= this->controller->GetHomeButtons().home != 0; |
| 53 | const auto capture_pressed = controller->GetCaptureButtons().capture != 0; | 57 | pressed_capture_button |= this->controller->GetCaptureButtons().capture != 0; |
| 54 | if (home_pressed || capture_pressed) { | 58 | if (pressed_buttons != Core::HID::NpadButton::None || pressed_home_button || |
| 55 | SetPollingResult(buttons.raw, false); | 59 | pressed_capture_button) { |
| 56 | return; | 60 | const QString button_name = |
| 61 | GetButtonCombinationName(pressed_buttons, pressed_home_button, | ||
| 62 | pressed_capture_button) + | ||
| 63 | QStringLiteral("..."); | ||
| 64 | model->setData(button_model_index, button_name); | ||
| 57 | } | 65 | } |
| 58 | }); | 66 | }); |
| 59 | RetranslateUI(); | 67 | RetranslateUI(); |
| @@ -154,16 +162,14 @@ void ConfigureHotkeys::ConfigureController(QModelIndex index) { | |||
| 154 | 162 | ||
| 155 | const auto previous_key = model->data(index); | 163 | const auto previous_key = model->data(index); |
| 156 | 164 | ||
| 157 | input_setter = [this, index, previous_key](const Core::HID::NpadButton button, | 165 | input_setter = [this, index, previous_key](const bool cancel) { |
| 158 | const bool cancel) { | ||
| 159 | if (cancel) { | 166 | if (cancel) { |
| 160 | model->setData(index, previous_key); | 167 | model->setData(index, previous_key); |
| 161 | return; | 168 | return; |
| 162 | } | 169 | } |
| 163 | const auto home_pressed = this->controller->GetHomeButtons().home != 0; | 170 | |
| 164 | const auto capture_pressed = this->controller->GetCaptureButtons().capture != 0; | ||
| 165 | const QString button_string = | 171 | const QString button_string = |
| 166 | GetButtonCombinationName(button, home_pressed, capture_pressed); | 172 | GetButtonCombinationName(pressed_buttons, pressed_home_button, pressed_capture_button); |
| 167 | 173 | ||
| 168 | const auto [key_sequence_used, used_action] = IsUsedControllerKey(button_string); | 174 | const auto [key_sequence_used, used_action] = IsUsedControllerKey(button_string); |
| 169 | 175 | ||
| @@ -177,17 +183,22 @@ void ConfigureHotkeys::ConfigureController(QModelIndex index) { | |||
| 177 | } | 183 | } |
| 178 | }; | 184 | }; |
| 179 | 185 | ||
| 186 | button_model_index = index; | ||
| 187 | pressed_buttons = Core::HID::NpadButton::None; | ||
| 188 | pressed_home_button = false; | ||
| 189 | pressed_capture_button = false; | ||
| 190 | |||
| 180 | model->setData(index, tr("[waiting]")); | 191 | model->setData(index, tr("[waiting]")); |
| 181 | timeout_timer->start(2500); // Cancel after 2.5 seconds | 192 | timeout_timer->start(2500); // Cancel after 2.5 seconds |
| 182 | poll_timer->start(200); // Check for new inputs every 200ms | 193 | poll_timer->start(100); // Check for new inputs every 100ms |
| 183 | // We need to disable configuration to be able to read npad buttons | 194 | // We need to disable configuration to be able to read npad buttons |
| 184 | controller->DisableConfiguration(); | 195 | controller->DisableConfiguration(); |
| 185 | } | 196 | } |
| 186 | 197 | ||
| 187 | void ConfigureHotkeys::SetPollingResult(Core::HID::NpadButton button, const bool cancel) { | 198 | void ConfigureHotkeys::SetPollingResult(const bool cancel) { |
| 188 | timeout_timer->stop(); | 199 | timeout_timer->stop(); |
| 189 | poll_timer->stop(); | 200 | poll_timer->stop(); |
| 190 | (*input_setter)(button, cancel); | 201 | (*input_setter)(cancel); |
| 191 | // Re-Enable configuration | 202 | // Re-Enable configuration |
| 192 | controller->EnableConfiguration(); | 203 | controller->EnableConfiguration(); |
| 193 | 204 | ||
diff --git a/src/yuzu/configuration/configure_hotkeys.h b/src/yuzu/configuration/configure_hotkeys.h index 5fd1bcbfe..20ea3b515 100644 --- a/src/yuzu/configuration/configure_hotkeys.h +++ b/src/yuzu/configuration/configure_hotkeys.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <QStandardItemModel> | ||
| 7 | #include <QWidget> | 8 | #include <QWidget> |
| 8 | 9 | ||
| 9 | namespace Common { | 10 | namespace Common { |
| @@ -54,14 +55,20 @@ private: | |||
| 54 | void RestoreControllerHotkey(QModelIndex index); | 55 | void RestoreControllerHotkey(QModelIndex index); |
| 55 | void RestoreHotkey(QModelIndex index); | 56 | void RestoreHotkey(QModelIndex index); |
| 56 | 57 | ||
| 58 | void SetPollingResult(bool cancel); | ||
| 59 | QString GetButtonCombinationName(Core::HID::NpadButton button, bool home, bool capture) const; | ||
| 60 | |||
| 57 | std::unique_ptr<Ui::ConfigureHotkeys> ui; | 61 | std::unique_ptr<Ui::ConfigureHotkeys> ui; |
| 58 | 62 | ||
| 59 | QStandardItemModel* model; | 63 | QStandardItemModel* model; |
| 60 | 64 | ||
| 61 | void SetPollingResult(Core::HID::NpadButton button, bool cancel); | 65 | bool pressed_home_button; |
| 62 | QString GetButtonCombinationName(Core::HID::NpadButton button, bool home, bool capture) const; | 66 | bool pressed_capture_button; |
| 67 | QModelIndex button_model_index; | ||
| 68 | Core::HID::NpadButton pressed_buttons; | ||
| 69 | |||
| 63 | Core::HID::EmulatedController* controller; | 70 | Core::HID::EmulatedController* controller; |
| 64 | std::unique_ptr<QTimer> timeout_timer; | 71 | std::unique_ptr<QTimer> timeout_timer; |
| 65 | std::unique_ptr<QTimer> poll_timer; | 72 | std::unique_ptr<QTimer> poll_timer; |
| 66 | std::optional<std::function<void(Core::HID::NpadButton, bool)>> input_setter; | 73 | std::optional<std::function<void(bool)>> input_setter; |
| 67 | }; | 74 | }; |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 9d38ab812..4dbe801a9 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -73,8 +73,11 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st | |||
| 73 | ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); | 73 | ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); |
| 74 | ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); | 74 | ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); |
| 75 | ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles")); | 75 | ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles")); |
| 76 | |||
| 76 | // Only show Linux tab on Unix | 77 | // Only show Linux tab on Unix |
| 78 | linux_tab->setVisible(false); | ||
| 77 | #ifdef __unix__ | 79 | #ifdef __unix__ |
| 80 | linux_tab->setVisible(true); | ||
| 78 | ui->tabWidget->addTab(linux_tab.get(), tr("Linux")); | 81 | ui->tabWidget->addTab(linux_tab.get(), tr("Linux")); |
| 79 | #endif | 82 | #endif |
| 80 | 83 | ||
diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index c8e871151..f3c91586c 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp | |||
| @@ -248,82 +248,22 @@ void ConfigureUi::RetranslateUI() { | |||
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | void ConfigureUi::InitializeLanguageComboBox() { | 250 | void ConfigureUi::InitializeLanguageComboBox() { |
| 251 | // This is a list of lexicographically sorted languages, only the available translations are | ||
| 252 | // shown to the user. | ||
| 253 | static const struct { | ||
| 254 | const QString name; | ||
| 255 | const char* id; | ||
| 256 | } languages[] = { | ||
| 257 | // clang-format off | ||
| 258 | {QStringLiteral(u"Bahasa Indonesia"), "id"}, // Indonesian | ||
| 259 | {QStringLiteral(u"Bahasa Melayu"), "ms"}, // Malay | ||
| 260 | {QStringLiteral(u"Catal\u00E0"), "ca"}, // Catalan | ||
| 261 | {QStringLiteral(u"\u010Ce\u0161tina"), "cs"}, // Czech | ||
| 262 | {QStringLiteral(u"Dansk"), "da"}, // Danish | ||
| 263 | {QStringLiteral(u"Deutsch"), "de"}, // German | ||
| 264 | {QStringLiteral(u"English"), "en"}, // English | ||
| 265 | {QStringLiteral(u"Espa\u00F1ol"), "es"}, // Spanish | ||
| 266 | {QStringLiteral(u"Fran\u00E7ais"), "fr"}, // French | ||
| 267 | {QStringLiteral(u"Hrvatski"), "hr"}, // Croatian | ||
| 268 | {QStringLiteral(u"Italiano"), "it"}, // Italian | ||
| 269 | {QStringLiteral(u"Magyar"), "hu"}, // Hungarian | ||
| 270 | {QStringLiteral(u"Nederlands"), "nl"}, // Dutch | ||
| 271 | {QStringLiteral(u"Norsk bokm\u00E5l"), "nb"}, // Norwegian | ||
| 272 | {QStringLiteral(u"Polski"), "pl"}, // Polish | ||
| 273 | {QStringLiteral(u"Portugu\u00EAs"), "pt_PT"}, // Portuguese | ||
| 274 | {QStringLiteral(u"Portugu\u00EAs (Brasil)"), "pt_BR"}, // Portuguese (Brazil) | ||
| 275 | {QStringLiteral(u"Rom\u00E2n\u0103"), "ro"}, // Romanian | ||
| 276 | {QStringLiteral(u"Srpski"), "sr"}, // Serbian | ||
| 277 | {QStringLiteral(u"Suomi"), "fi"}, // Finnish | ||
| 278 | {QStringLiteral(u"Svenska"), "sv"}, // Swedish | ||
| 279 | {QStringLiteral(u"Ti\u1EBFng Vi\u1EC7t"), "vi"}, // Vietnamese | ||
| 280 | {QStringLiteral(u"Ti\u1EBFng Vi\u1EC7t (Vi\u1EC7t Nam)"), "vi_VN"}, // Vietnamese | ||
| 281 | {QStringLiteral(u"T\u00FCrk\u00E7e"), "tr_TR"}, // Turkish | ||
| 282 | {QStringLiteral(u"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"), "el"}, // Greek | ||
| 283 | {QStringLiteral(u"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"), "ru_RU"}, // Russian | ||
| 284 | {QStringLiteral(u"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"), | ||
| 285 | "uk"}, // Ukrainian | ||
| 286 | {QStringLiteral(u"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"), "ar"}, // Arabic | ||
| 287 | {QStringLiteral(u"\u0641\u0627\u0631\u0633\u06CC"), "fa"}, // Farsi | ||
| 288 | {QStringLiteral(u"\uD55C\uAD6D\uC5B4"), "ko_KR"}, // Korean | ||
| 289 | {QStringLiteral(u"\u65E5\u672C\u8A9E"), "ja_JP"}, // Japanese | ||
| 290 | {QStringLiteral(u"\u7B80\u4F53\u4E2D\u6587"), "zh_CN"}, // Simplified Chinese | ||
| 291 | {QStringLiteral(u"\u7E41\u9AD4\u4E2D\u6587"), "zh_TW"}, // Traditional Chinese | ||
| 292 | // clang-format on | ||
| 293 | }; | ||
| 294 | ui->language_combobox->addItem(tr("<System>"), QString{}); | 251 | ui->language_combobox->addItem(tr("<System>"), QString{}); |
| 295 | QDir languages_dir{QStringLiteral(":/languages")}; | 252 | ui->language_combobox->addItem(tr("English"), QStringLiteral("en")); |
| 296 | QStringList language_files = languages_dir.entryList(); | 253 | QDirIterator it(QStringLiteral(":/languages"), QDirIterator::NoIteratorFlags); |
| 297 | for (const auto& lang : languages) { | 254 | while (it.hasNext()) { |
| 298 | if (QString::fromLatin1(lang.id) == QStringLiteral("en")) { | 255 | QString locale = it.next(); |
| 299 | ui->language_combobox->addItem(lang.name, QStringLiteral("en")); | ||
| 300 | language_files.removeOne(QStringLiteral("en.qm")); | ||
| 301 | continue; | ||
| 302 | } | ||
| 303 | for (int i = 0; i < language_files.size(); ++i) { | ||
| 304 | QString locale = language_files[i]; | ||
| 305 | locale.truncate(locale.lastIndexOf(QLatin1Char{'.'})); | ||
| 306 | if (QString::fromLatin1(lang.id) == locale) { | ||
| 307 | ui->language_combobox->addItem(lang.name, locale); | ||
| 308 | language_files.removeAt(i); | ||
| 309 | break; | ||
| 310 | } | ||
| 311 | } | ||
| 312 | } | ||
| 313 | // Anything remaining will be at the bottom | ||
| 314 | for (const QString& file : language_files) { | ||
| 315 | LOG_CRITICAL(Frontend, "Unexpected Language File: {}", file.toStdString()); | ||
| 316 | QString locale = file; | ||
| 317 | locale.truncate(locale.lastIndexOf(QLatin1Char{'.'})); | 256 | locale.truncate(locale.lastIndexOf(QLatin1Char{'.'})); |
| 318 | const QString language_name = QLocale::languageToString(QLocale(locale).language()); | 257 | locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1); |
| 319 | const QString lang = QStringLiteral("%1 [%2]").arg(language_name, locale); | 258 | const QString lang = QLocale::languageToString(QLocale(locale).language()); |
| 320 | ui->language_combobox->addItem(lang, locale); | 259 | const QString country = QLocale::countryToString(QLocale(locale).country()); |
| 260 | ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale); | ||
| 321 | } | 261 | } |
| 322 | 262 | ||
| 323 | // Unlike other configuration changes, interface language changes need to be reflected on the | 263 | // Unlike other configuration changes, interface language changes need to be reflected on the |
| 324 | // interface immediately. This is done by passing a signal to the main window, and then | 264 | // interface immediately. This is done by passing a signal to the main window, and then |
| 325 | // retranslating when passing back. | 265 | // retranslating when passing back. |
| 326 | connect(ui->language_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | 266 | connect(ui->language_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this, |
| 327 | &ConfigureUi::OnLanguageChanged); | 267 | &ConfigureUi::OnLanguageChanged); |
| 328 | } | 268 | } |
| 329 | 269 | ||
diff --git a/src/yuzu/hotkeys.cpp b/src/yuzu/hotkeys.cpp index b7693ad0d..170f14684 100644 --- a/src/yuzu/hotkeys.cpp +++ b/src/yuzu/hotkeys.cpp | |||
| @@ -193,8 +193,7 @@ void ControllerShortcut::ControllerUpdateEvent(Core::HID::ControllerTriggerType | |||
| 193 | if (!Settings::values.controller_navigation) { | 193 | if (!Settings::values.controller_navigation) { |
| 194 | return; | 194 | return; |
| 195 | } | 195 | } |
| 196 | if (button_sequence.npad.raw == Core::HID::NpadButton::None && | 196 | if (button_sequence.npad.raw == Core::HID::NpadButton::None) { |
| 197 | button_sequence.capture.raw == 0 && button_sequence.home.raw == 0) { | ||
| 198 | return; | 197 | return; |
| 199 | } | 198 | } |
| 200 | 199 | ||