mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 11:24:27 +01:00
Merge branch 'master' into TemporaryHackishBranch
# Conflicts: # Core/Config.cpp # Core/Config.h # Core/KeyMap.cpp # Core/SaveState.cpp # UI/GameSettingsScreen.cpp # assets/compat.ini
This commit is contained in:
commit
072e1522b3
321 files changed
+53762
-2959
No files matched your search
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: Bug, crash, or compatibility issue
|
||||
about: Choose this if something doesn't work and no other template applies.
|
||||
labels: needs triage
|
||||
---
|
||||
<!-- Want the issue fixed faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
You can remove this stuff - just don't forget to answer the questions.
|
||||
They're important. -->
|
||||
|
||||
|
||||
### What happens?
|
||||
|
||||
|
||||
### What *should* happen?
|
||||
|
||||
|
||||
### What are you using?
|
||||
#### What hardware / device and operating system?
|
||||
|
||||
#### What graphics card (GPU) or mobile phone model?
|
||||
|
||||
#### What PPSSPP version (standalone/official), and did it work before?
|
||||
|
||||
#### Which game or games?
|
||||
<!-- Long press on the game in PPSSPP to include the game ID. -->
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Don't forget the below, change [ ] to [X] when done. Note anything else you tried. -->
|
||||
- [ ] Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed.
|
||||
- [ ] [Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue.
|
||||
- [ ] Try resetting settings or older versions and include if the issue is related.
|
||||
- [ ] Include logs or screenshots of issue.
|
||||
@@ -0,0 +1,135 @@
|
||||
name: Bug, crash, or compatibility issue
|
||||
description: Choose this if something doesn't work and no other template applies.
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Want the issue fixed faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
|
||||
- type: input
|
||||
id: game
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Game or games this happens in
|
||||
placeholder: ULUS-10336 - Crisis Core
|
||||
description: >
|
||||
Shown in the title bar, logs, and long press on the game icon. If it's outside a game, put 'None.'
|
||||
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What area of the game / PPSSPP
|
||||
placeholder: |
|
||||
When I equip a Mythril Bangle, a blue screen appears and it says the game crashed.
|
||||
|
||||
Here's a screenshot of the blue screen:
|
||||
[upload screenshot]
|
||||
|
||||
Here's a my savedata with a Mythril Bangle not equipped yet:
|
||||
[upload zip of savedata]
|
||||
description: >
|
||||
Try to explain so someone else could do the same thing. Upload savedata if possible to make it easier to reproduce.
|
||||
|
||||
- type: textarea
|
||||
id: desired
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What should happen
|
||||
placeholder: |
|
||||
The Mythril Bangle should be equipped without crashing.
|
||||
|
||||
My friend also tried this on their actual PSP, and it worked fine. Here's a screenshot right after equipping frmo my savedata:
|
||||
[upload photo]
|
||||
description: >
|
||||
If it's a crash, just say "It shouldn't crash." For more complex bugs, it helps to explain what should happen as it's not always obvious.
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Logs
|
||||
placeholder: '[drag files here...]'
|
||||
description: |
|
||||
Upload logs if possible (use DebugLog.bat on Windows or [adb logcat][] on Android.)
|
||||
[adb logcat]: https://github.com/hrydgard/ppsspp/wiki/How-to-get-an-adb-logcat-from-a-PC
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Your device
|
||||
|
||||
If you're not sure about any of these questions, check Settings -> Tools -> System Information.
|
||||
|
||||
- type: dropdown
|
||||
id: platform
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Platform
|
||||
options:
|
||||
- Android
|
||||
- Windows
|
||||
- libretro / Retroarch
|
||||
- iOS
|
||||
- Switch
|
||||
- Raspberry Pi
|
||||
- Linux / BSD
|
||||
- macOS
|
||||
- Other
|
||||
|
||||
- type: input
|
||||
id: device
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Mobile phone model or graphics card
|
||||
placeholder: Google Pixel 4a or NVIDIA GeForce GTX 1080Ti
|
||||
description: >
|
||||
If you don't know, copy what's under 'Driver version' in System Information.
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: PPSSPP version affected
|
||||
placeholder: v2.0.0-999-gabcdef123
|
||||
description: >
|
||||
Shown on the main screen of PPSSPP where games are listed.
|
||||
|
||||
- type: input
|
||||
id: workingversion
|
||||
attributes:
|
||||
label: Last working version
|
||||
placeholder: v2.0.0-500-g321fedcba
|
||||
description: >
|
||||
If it worked before, it's usually easier to narrow down a fix.
|
||||
|
||||
- type: dropdown
|
||||
id: gpubackend
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Graphics backend (3D API)
|
||||
options:
|
||||
- Vulkan
|
||||
- OpenGL / GLES
|
||||
- Direct3D 11
|
||||
- Direct3D 9
|
||||
- Other
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: "Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed."
|
||||
required: true
|
||||
- label: "[Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue."
|
||||
required: true
|
||||
- label: "Try resetting settings or older versions and include if the issue is related."
|
||||
- label: "Try without any cheats and without loading any save states."
|
||||
- label: "Include logs or screenshots of issue."
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
name: Building or contributing
|
||||
about: Choose for issues building PPSSPP on certain platforms or with certain toolsets.
|
||||
labels: needs triage
|
||||
---
|
||||
<!-- You can remove this stuff - just don't forget to answer the questions.
|
||||
They're important. -->
|
||||
|
||||
### What platform, compiler, and build tools?
|
||||
|
||||
|
||||
### What compile flags or command did you run specifically?
|
||||
|
||||
|
||||
### What happens (don't forget logs)?
|
||||
|
||||
|
||||
### What are you using?
|
||||
#### What hardware / device and operating system?
|
||||
|
||||
#### What PPSSPP version (standalone/official), and did it work before?
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Don't forget the below, change [ ] to [X] when done. Note anything else you tried. -->
|
||||
- [ ] Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed.
|
||||
- [ ] Don't forget `git submodule update --init --recursive`.
|
||||
- [ ] [Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue.
|
||||
- [ ] Try deleting the build directory and starting fresh.
|
||||
- [ ] Include logs and help us reproduce.
|
||||
- [ ] Check GitHub Actions, which builds every merge and PR.
|
||||
@@ -0,0 +1,95 @@
|
||||
name: Building or contributing
|
||||
description: Choose for issues building PPSSPP on certain platforms or with certain toolsets.
|
||||
body:
|
||||
- type: dropdown
|
||||
id: platform
|
||||
attributes:
|
||||
label: Platform
|
||||
options:
|
||||
- Android
|
||||
- Windows
|
||||
- libretro / Retroarch
|
||||
- iOS
|
||||
- Switch
|
||||
- Raspberry Pi
|
||||
- Linux / BSD
|
||||
- macOS
|
||||
- Other
|
||||
|
||||
- type: input
|
||||
id: buildversions
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Compiler and build tool versions
|
||||
placeholder: Clang 8.0.0 + CMake 3.21.1
|
||||
description: >
|
||||
The more detail, the better.
|
||||
|
||||
- type: input
|
||||
id: osversion
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Operating system version
|
||||
placeholder: Arch Linux 2021.08.01
|
||||
|
||||
- type: textarea
|
||||
id: commands
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Build commands used
|
||||
placeholder: './b.sh --release'
|
||||
description: >
|
||||
Include the command or commands you ran, script you used, build arguments, etc.
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What happens
|
||||
placeholder: |
|
||||
I receive the following error:
|
||||
```
|
||||
ld.gold: undefined reference to function 'vkCreateWaylandSurfaceKHR'
|
||||
```
|
||||
|
||||
Here's the entire build log:
|
||||
[upload zip file of log]
|
||||
description: >
|
||||
Include logs and as much detail as possible. Paste exact error messages.
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: PPSSPP version affected
|
||||
placeholder: v2.0.0-999-gabcdef123
|
||||
description: >
|
||||
Use `git describe` if a git checkout. Please try the latest git build if using an older version.
|
||||
|
||||
- type: input
|
||||
id: workingversion
|
||||
attributes:
|
||||
label: Last working version
|
||||
placeholder: v2.0.0-500-g321fedcba
|
||||
description: >
|
||||
If it worked before, it's usually easier to narrow down a fix.
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: "Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed."
|
||||
required: true
|
||||
- label: "Make sure to run `git submodule update --init --recursive` before building."
|
||||
required: true
|
||||
- label: "[Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue."
|
||||
required: true
|
||||
- label: "Try deleting the build directory and running the build again."
|
||||
required: true
|
||||
- label: "Check GitHub Actions, which builds every merge and PR."
|
||||
- label: "Include logs and help us reproduce."
|
||||
@@ -7,5 +7,5 @@ contact_links:
|
||||
url: http://report.ppsspp.org/games
|
||||
about: Look here for user reports on best settings and compatibility.
|
||||
- name: Translations
|
||||
url: https://github.com/hrydgard/ppsspp-lang
|
||||
url: 'https://github.com/hrydgard/ppsspp/tree/master/assets/lang#readme'
|
||||
about: Look here to contribute translations to PPSSPP.
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: New feature or behavior change
|
||||
about: Choose when something isn't broken, but you want it to be better.
|
||||
labels: needs triage
|
||||
---
|
||||
<!-- Want the improvement faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
You can remove this stuff - just don't forget to answer the questions.
|
||||
They're important. -->
|
||||
|
||||
|
||||
### What should happen?
|
||||
|
||||
|
||||
### Who would benefit from it?
|
||||
|
||||
|
||||
### What's it specific to (remove if not)?
|
||||
#### Hardware, device, or operating system?
|
||||
|
||||
#### Specific games?
|
||||
<!-- Requests for mods to game logic belong in the forum or Discord. -->
|
||||
|
||||
### Does anything else have a similar feature?
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Don't forget the below, change [ ] to [X] when done. Note anything else you tried. -->
|
||||
- [ ] Check the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already implemented.
|
||||
- [ ] [Search for other requests](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same feature.
|
||||
@@ -0,0 +1,73 @@
|
||||
name: New feature or behavior change
|
||||
description: "Choose when something isn't broken, but you want it to be better."
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Want the improvement faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
|
||||
- type: textarea
|
||||
id: desired
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What should happen
|
||||
placeholder: |
|
||||
PPSSPP should have a button that makes all graphics look like the screen was cracked.
|
||||
|
||||
The button should always be present on the screen and be labeled "Drop PSP".
|
||||
description: >
|
||||
Be specific and descriptive.
|
||||
|
||||
- type: textarea
|
||||
id: audience
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Who would this benefit
|
||||
placeholder: |
|
||||
No one really. I know it'd be a lot of work but it'd be fun for a 2 minute nostalgia trip since I've dropped by PSP before.
|
||||
description: >
|
||||
PPSSPP features are contributed by the community, so explaining who else would benefit may help your case.
|
||||
|
||||
- type: dropdown
|
||||
id: platform
|
||||
attributes:
|
||||
label: Platform (if relevant)
|
||||
options:
|
||||
- Android
|
||||
- Windows
|
||||
- libretro / Retroarch
|
||||
- iOS
|
||||
- Switch
|
||||
- Raspberry Pi
|
||||
- Linux / BSD
|
||||
- macOS
|
||||
- Other
|
||||
|
||||
- type: input
|
||||
id: game
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Games this would be useful in
|
||||
placeholder: 'ULUS-10336 - Crisis Core, ULUS-10482 - Lunar: Silver Star Harmony'
|
||||
description: >
|
||||
Requests for mods to game logic belong in the forum or Discord. This isn't the place to request game hacks.
|
||||
|
||||
- type: textarea
|
||||
id: notes
|
||||
attributes:
|
||||
label: Other emulators or software with a similar feature
|
||||
description: >
|
||||
May be helpful in showing someone how it'd be helpful.
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: "Check the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already implemented."
|
||||
required: true
|
||||
- label: "[Search for other requests](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same feature."
|
||||
required: true
|
||||
@@ -1,43 +0,0 @@
|
||||
---
|
||||
name: Graphics or rendering issue
|
||||
about: Choose when something is drawing wrong.
|
||||
labels: needs triage
|
||||
---
|
||||
<!-- Want the issue fixed faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
You can remove this stuff - just don't forget to answer the questions.
|
||||
They're important. -->
|
||||
|
||||
|
||||
### What happens?
|
||||
<!-- Include screenshots and explain why they're wrong. -->
|
||||
|
||||
|
||||
### What *should* happen?
|
||||
|
||||
|
||||
### Include a GE frame capture
|
||||
<!-- See: https://github.com/hrydgard/ppsspp/wiki/How-to-create-a-frame-dump
|
||||
Make sure the issue is visible when you take it. -->
|
||||
|
||||
|
||||
### What are you using?
|
||||
#### What hardware / device and operating system?
|
||||
|
||||
#### What graphics card (GPU) or mobile phone model?
|
||||
|
||||
#### What PPSSPP version (standalone/official), and did it work before?
|
||||
|
||||
#### Which game or games?
|
||||
<!-- Long press on the game in PPSSPP to include the game ID. -->
|
||||
|
||||
#### Graphics backend (Vulkan, OpenGL, etc.)?
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Don't forget the below, change [ ] to [X] when done. Note anything else you tried. -->
|
||||
- [ ] Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed.
|
||||
- [ ] [Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue.
|
||||
- [ ] Try resetting settings or older versions and include if the issue is related.
|
||||
- [ ] Try changing graphics settings to determine if one causes the bug.
|
||||
- [ ] Include logs or screenshots of issue.
|
||||
@@ -0,0 +1,149 @@
|
||||
name: Graphics or rendering issue
|
||||
description: Choose when something is drawing wrong.
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Want the issue fixed faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
|
||||
- type: input
|
||||
id: game
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Game or games this happens in
|
||||
placeholder: ULUS-10336 - Crisis Core
|
||||
description: >
|
||||
Shown in the title bar, logs, and long press on the game icon.
|
||||
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What area of the game
|
||||
placeholder: 'At the start of Chapter 3, in Sector 8. Right outside the briefing room, the save point looks garbled.'
|
||||
description: >
|
||||
If it happens from the start of any game, just say "After new game". Try to explain so someone else could do the same thing.
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What happens
|
||||
placeholder: |
|
||||
The save point seems to be moving like it should, but the colors all all wrong - it shouldn't be red. Here's what it looks like:
|
||||
[upload screenshot]
|
||||
|
||||
Even when I step into it, it turned black which it shouldn't:
|
||||
[upload screenshot]
|
||||
description: >
|
||||
Include screenshots, they're important. But explain what's wrong in the screenshot - it may not be obvious to others.
|
||||
|
||||
- type: textarea
|
||||
id: desired
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What should happen
|
||||
placeholder: |
|
||||
The save point should look like it does in other places:
|
||||
[upload screenshot]
|
||||
|
||||
My friend also tried this on their actual PSP, where it looks right:
|
||||
[upload photo]
|
||||
description: >
|
||||
If you can include a screenshot (from a previous version, another emulator, or a PSP), it helps a lot. But explaining how it should look helps a lot too.
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Including a frame capture (or multiple) usually helps a lot. These are like 3D screenshots for PPSSPP. Instructions are available [on the wiki][] to create one.
|
||||
[on the wiki]: https://github.com/hrydgard/ppsspp/wiki/How-to-create-a-frame-dump
|
||||
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: GE frame capture
|
||||
placeholder: '[drag files here...]'
|
||||
description: >
|
||||
You can upload the frame capture or captures as a zip file. Make sure the issue is visible on screen during the capture.
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Your device
|
||||
|
||||
If you're not sure about any of these questions, check Settings -> Tools -> System Information.
|
||||
|
||||
- type: dropdown
|
||||
id: platform
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Platform
|
||||
options:
|
||||
- Android
|
||||
- Windows
|
||||
- libretro / Retroarch
|
||||
- iOS
|
||||
- Switch
|
||||
- Raspberry Pi
|
||||
- Linux / BSD
|
||||
- macOS
|
||||
- Other
|
||||
|
||||
- type: input
|
||||
id: device
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Mobile phone model or graphics card
|
||||
placeholder: Google Pixel 4a or NVIDIA GeForce GTX 1080Ti
|
||||
description: >
|
||||
If you don't know, copy what's under 'Driver version' in System Information.
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: PPSSPP version affected
|
||||
placeholder: v2.0.0-999-gabcdef123
|
||||
description: >
|
||||
Shown on the main screen of PPSSPP where games are listed.
|
||||
|
||||
- type: input
|
||||
id: workingversion
|
||||
attributes:
|
||||
label: Last working version
|
||||
placeholder: v2.0.0-500-g321fedcba
|
||||
description: >
|
||||
If it worked before, it's usually easier to narrow down a fix.
|
||||
|
||||
- type: dropdown
|
||||
id: gpubackend
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Graphics backend (3D API)
|
||||
options:
|
||||
- Vulkan
|
||||
- OpenGL / GLES
|
||||
- Direct3D 11
|
||||
- Direct3D 9
|
||||
- Other
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: "Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed."
|
||||
required: true
|
||||
- label: "[Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue."
|
||||
required: true
|
||||
- label: "Try resetting settings or older versions and include if the issue is related."
|
||||
- label: "Try changing graphics settings to determine if one causes the glitch (especially speed hacks or enhancements/replacements.)"
|
||||
- label: "Include logs or screenshots of issue."
|
||||
@@ -1,42 +0,0 @@
|
||||
---
|
||||
name: Slowdown or performance problem
|
||||
about: Choose when things got slower from a previous version or a specific scene runs really poorly.
|
||||
labels: needs triage
|
||||
---
|
||||
<!-- Want the issue fixed faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
You can remove this stuff - just don't forget to answer the questions.
|
||||
They're important. -->
|
||||
|
||||
|
||||
### What games and where in them does it happen?
|
||||
<!-- Long press on the game in PPSSPP to include the game ID. -->
|
||||
|
||||
|
||||
### What speed are you getting with PPSSPP speed display enabled?
|
||||
|
||||
|
||||
### Include a GE frame capture and debug stats
|
||||
<!-- See: https://github.com/hrydgard/ppsspp/wiki/How-to-create-a-frame-dump
|
||||
Many performance issues are graphics related.
|
||||
|
||||
Also enable "Show debug statistics" and include a screenshot while it's on. -->
|
||||
|
||||
|
||||
### What are you using?
|
||||
#### What hardware / device and operating system?
|
||||
|
||||
#### What graphics card (GPU) or mobile phone model?
|
||||
|
||||
#### What PPSSPP version (standalone/official), and did it work before?
|
||||
|
||||
#### Graphics backend (Vulkan, OpenGL, etc.)?
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Don't forget the below, change [ ] to [X] when done. Note anything else you tried. -->
|
||||
- [ ] Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed.
|
||||
- [ ] [Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue.
|
||||
- [ ] Try resetting settings or older versions and include if the issue is related.
|
||||
- [ ] Try changing graphics settings to determine if one causes the slowdown.
|
||||
- [ ] Include logs of screenshots of issue.
|
||||
@@ -0,0 +1,133 @@
|
||||
name: Slowdown or performance problem
|
||||
description: Choose when things got slower from a previous version or a specific scene runs really poorly.
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Want the issue fixed faster? Check the wiki for tips:
|
||||
https://github.com/hrydgard/ppsspp/wiki/How-to-report-an-issue-properly
|
||||
|
||||
- type: input
|
||||
id: game
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Game or games this happens in
|
||||
placeholder: ULUS-10336 - Crisis Core
|
||||
description: >
|
||||
Shown in the title bar, logs, and long press on the game icon.
|
||||
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: What area of the game
|
||||
placeholder: 'At the start of Chapter 3, in Sector 8. It got slow when I talked to the Sephiroth fan.'
|
||||
description: >
|
||||
If it happens from the start of any game, just say "After new game". Try to explain so someone else could do the same thing.
|
||||
|
||||
- type: input
|
||||
id: speed
|
||||
attributes:
|
||||
label: Speed seen in PPSSPP
|
||||
placeholder: 75% (45/60)
|
||||
description: Enable FPS and Speed display in settings.
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Many performance issues are graphics related. Instructions are available [on the wiki][] to create a frame capture.
|
||||
|
||||
Please also include 1 or 2 screenshots during the performance problem while "Show debug statistics" (in Settings) is enabled.
|
||||
[on the wiki]: https://github.com/hrydgard/ppsspp/wiki/How-to-create-a-frame-dump
|
||||
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: GE frame capture and debug statistics
|
||||
placeholder: '[drag files here...]'
|
||||
description: >
|
||||
You can upload the frame capture as a zip file, and upload screenshots directly.
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Your device
|
||||
|
||||
If you're not sure about any of these questions, check Settings -> Tools -> System Information.
|
||||
|
||||
- type: dropdown
|
||||
id: platform
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Platform
|
||||
options:
|
||||
- Android
|
||||
- Windows
|
||||
- libretro / Retroarch
|
||||
- iOS
|
||||
- Switch
|
||||
- Raspberry Pi
|
||||
- Linux / BSD
|
||||
- macOS
|
||||
- Other
|
||||
|
||||
- type: input
|
||||
id: device
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Mobile phone model or graphics card
|
||||
placeholder: Google Pixel 4a or NVIDIA GeForce GTX 1080Ti
|
||||
description: >
|
||||
If you don't know, copy what's under 'Driver version' in System Information.
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: PPSSPP version affected
|
||||
placeholder: v2.0.0-999-gabcdef123
|
||||
description: >
|
||||
Shown on the main screen of PPSSPP where games are listed.
|
||||
|
||||
- type: input
|
||||
id: workingversion
|
||||
attributes:
|
||||
label: Last working version
|
||||
placeholder: v2.0.0-500-g321fedcba
|
||||
description: >
|
||||
If it worked before, it's usually easier to narrow down a fix.
|
||||
|
||||
- type: dropdown
|
||||
id: gpubackend
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Graphics backend (3D API)
|
||||
options:
|
||||
- Vulkan
|
||||
- OpenGL / GLES
|
||||
- Direct3D 11
|
||||
- Direct3D 9
|
||||
- Other
|
||||
|
||||
- type: textarea
|
||||
id: notes
|
||||
attributes:
|
||||
label: Any other notes or things you've tried
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: "Test in the [latest git build](https://buildbot.orphis.net/ppsspp/) in case it's already fixed."
|
||||
required: true
|
||||
- label: "[Search for other reports](https://github.com/hrydgard/ppsspp/search?q=my+issue&type=issues) of the same issue."
|
||||
required: true
|
||||
- label: "Try resetting settings or older versions and include if the issue is related."
|
||||
- label: "Try changing graphics settings to determine if one causes the slowdown."
|
||||
- label: "Include logs or screenshots of issue."
|
||||
@@ -1,9 +1,6 @@
|
||||
[submodule "pspautotests"]
|
||||
path = pspautotests
|
||||
url = https://github.com/hrydgard/pspautotests.git
|
||||
[submodule "lang"]
|
||||
path = assets/lang
|
||||
url = https://github.com/hrydgard/ppsspp-lang.git
|
||||
[submodule "ffmpeg"]
|
||||
path = ffmpeg
|
||||
url = https://github.com/hrydgard/ppsspp-ffmpeg.git
|
||||
|
||||
+34
-4
@@ -56,6 +56,8 @@ if(CMAKE_SYSTEM_PROCESSOR)
|
||||
set(X86_DEVICE ON)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^mips")
|
||||
set(MIPS_DEVICE ON)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64")
|
||||
set(RISCV64_DEVICE ON)
|
||||
else()
|
||||
message("Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
@@ -113,6 +115,7 @@ endif()
|
||||
option(ARMV7 "Set to ON if targeting an ARMv7 processor" ${ARMV7_DEVICE})
|
||||
option(ARM "Set to ON if targeting an ARM processor" ${ARM_DEVICE})
|
||||
option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS_DEVICE})
|
||||
option(RISCV64 "Set to ON if targeting a RISCV64 processor" ${RISCV64_DEVICE})
|
||||
option(X86 "Set to ON if targeting an X86 processor" ${X86_DEVICE})
|
||||
option(X86_64 "Set to ON if targeting an X86_64 processor" ${X86_64_DEVICE})
|
||||
# :: Environments
|
||||
@@ -121,6 +124,7 @@ option(USING_FBDEV "Set to ON if target environment uses fbdev (eg. Pandora)" ${
|
||||
option(USING_GLES2 "Set to ON if target device uses OpenGL ES 2.0" ${USING_GLES2})
|
||||
option(USING_X11_VULKAN "Set to OFF if target environment doesn't use X11 for Vulkan" ON)
|
||||
option(USE_WAYLAND_WSI "Enable or disable Wayland WSI support for Vulkan" ${USE_WAYLAND_WSI})
|
||||
option(USE_VULKAN_DISPLAY_KHR "Enable or disable full screen display of Vulkan" ${USE_VULKAN_DISPLAY_KHR})
|
||||
# :: Frontends
|
||||
option(USING_QT_UI "Set to ON if you wish to use the Qt frontend wrapper" ${USING_QT_UI})
|
||||
option(MOBILE_DEVICE "Set to ON when targeting a mobile device" ${MOBILE_DEVICE})
|
||||
@@ -145,6 +149,7 @@ if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
|
||||
else()
|
||||
message("NOT using X11 for Vulkan")
|
||||
endif()
|
||||
|
||||
# add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
|
||||
if(USE_WAYLAND_WSI)
|
||||
find_package(Wayland)
|
||||
@@ -155,6 +160,11 @@ if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
|
||||
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_VULKAN_DISPLAY_KHR)
|
||||
message(STATUS "Using experimental full-screen display for Vulkan.")
|
||||
add_definitions(-DVK_USE_PLATFORM_DISPLAY_KHR)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LIBRETRO)
|
||||
@@ -178,7 +188,7 @@ else()
|
||||
set(CoreLinkType STATIC)
|
||||
endif()
|
||||
|
||||
# Work around for some misfeature of the current glslang build system
|
||||
# Work around for some misfeature of the current glslang build system
|
||||
include_directories(ext/glslang)
|
||||
|
||||
# Not sure if this is the best way - what about system glew?
|
||||
@@ -248,6 +258,9 @@ endif()
|
||||
if(MIPS)
|
||||
message("Generating for MIPS, ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
if(RISCV64)
|
||||
message("Generating for RISCV64, ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
if(X86)
|
||||
message("Generating for x86, ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
@@ -423,6 +436,13 @@ set(CommonMIPS
|
||||
)
|
||||
source_group(MIPS FILES ${CommonMIPS})
|
||||
|
||||
set(CommonRISCV64
|
||||
Common/RiscVCPUDetect.cpp
|
||||
Core/MIPS/fake/FakeJit.cpp
|
||||
Core/MIPS/fake/FakeJit.h
|
||||
)
|
||||
source_group(RISCV64 FILES ${CommonRISCV64})
|
||||
|
||||
if(WIN32)
|
||||
set(CommonD3D
|
||||
Common/GPU/D3D9/D3D9ShaderCompiler.cpp
|
||||
@@ -442,6 +462,7 @@ add_library(Common STATIC
|
||||
${CommonARM}
|
||||
${CommonARM64}
|
||||
${CommonMIPS}
|
||||
${CommonRISCV64}
|
||||
${CommonD3D}
|
||||
Common/Serialize/Serializer.cpp
|
||||
Common/Serialize/Serializer.h
|
||||
@@ -712,6 +733,8 @@ if(USE_FFMPEG)
|
||||
set(PLATFORM_ARCH "linux/arm")
|
||||
elseif(MIPS)
|
||||
set(PLATFORM_ARCH "linux/mips32")
|
||||
elseif(RISCV64)
|
||||
set(PLATFORM_ARCH "linux/riscv64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(PLATFORM_ARCH "linux/x86_64")
|
||||
elseif(X86)
|
||||
@@ -1129,7 +1152,6 @@ if(TARGET SDL2::SDL2 AND NOT IOS)
|
||||
target_link_libraries(Common SDL2::SDL2)
|
||||
endif()
|
||||
|
||||
|
||||
list(APPEND NativeAppSource
|
||||
android/jni/TestRunner.cpp
|
||||
UI/DiscordIntegration.cpp
|
||||
@@ -1582,6 +1604,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/Instance.h
|
||||
Core/KeyMap.cpp
|
||||
Core/KeyMap.h
|
||||
Core/KeyMapDefaults.cpp
|
||||
Core/KeyMapDefaults.h
|
||||
Core/ThreadEventQueue.h
|
||||
Core/WebServer.cpp
|
||||
Core/WebServer.h
|
||||
@@ -1954,11 +1978,17 @@ if(WIN32)
|
||||
set(GlslangLibs ${GlslangLibs} spirv-cross-hlsl)
|
||||
endif()
|
||||
|
||||
if(OPENGL_opengl_LIBRARY AND OpenGL_GL_PREFERENCE STREQUAL GLVND AND NOT APPLE)
|
||||
set(OPENGL_LIBRARIES OpenGL::OpenGL)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${CoreLibName} Common native kirk cityhash sfmt19937 xbrz xxhash ${GlslangLibs}
|
||||
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
|
||||
if(FFmpeg_FOUND)
|
||||
target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1)
|
||||
set_target_properties(${CoreLibName} PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
|
||||
target_include_directories(${CoreLibName} BEFORE PUBLIC ${FFmpeg_INCLUDE_avcodec})
|
||||
target_link_libraries(${CoreLibName}
|
||||
FFmpeg::avcodec
|
||||
FFmpeg::avformat
|
||||
@@ -1985,7 +2015,7 @@ if(USE_MINIUPNPC)
|
||||
if (NO_GETADDRINFO)
|
||||
add_definitions(-DNO_GETADDRINFO)
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT WIN32)
|
||||
add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT)
|
||||
add_definitions (-D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112L)
|
||||
@@ -1998,7 +2028,7 @@ if(USE_MINIUPNPC)
|
||||
else()
|
||||
add_definitions(-fPIC)
|
||||
endif()
|
||||
|
||||
|
||||
add_definitions(-DWITH_UPNP -DMINIUPNP_STATICLIB)
|
||||
set(MINIUPNP_DIR "ext/miniupnp/miniupnpc")
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -898,6 +898,7 @@
|
||||
<ClCompile Include="Render\Text\draw_text_uwp.cpp" />
|
||||
<ClCompile Include="Render\Text\draw_text_win.cpp" />
|
||||
<ClCompile Include="LogReporting.cpp" />
|
||||
<ClCompile Include="RiscVCPUDetect.cpp" />
|
||||
<ClCompile Include="Serialize\Serializer.cpp" />
|
||||
<ClCompile Include="Data\Convert\ColorConv.cpp" />
|
||||
<ClCompile Include="ConsoleListener.cpp" />
|
||||
|
||||
@@ -777,6 +777,7 @@
|
||||
<ClCompile Include="Thread\ParallelLoop.cpp">
|
||||
<Filter>Thread</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RiscVCPUDetect.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Data/Format/JSONReader.h"
|
||||
|
||||
@@ -11,7 +12,7 @@ JsonReader::JsonReader(const std::string &filename) {
|
||||
parse();
|
||||
} else {
|
||||
// Okay, try to read on the local file system
|
||||
buffer_ = (char *)File::ReadLocalFile(filename.c_str(), &buf_size);
|
||||
buffer_ = (char *)File::ReadLocalFile(Path(filename), &buf_size);
|
||||
if (buffer_) {
|
||||
parse();
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,23 @@
|
||||
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
// Not strictly a parser...
|
||||
void NiceSizeFormat(size_t size, char *out, size_t bufSize) {
|
||||
const char *sizes[] = { "B","KB","MB","GB","TB","PB","EB" };
|
||||
int s = 0;
|
||||
int frac = 0;
|
||||
while (size >= 1024) {
|
||||
s++;
|
||||
frac = (int)size & 1023;
|
||||
size /= 1024;
|
||||
}
|
||||
float f = (float)size + ((float)frac / 1024.0f);
|
||||
if (s == 0)
|
||||
snprintf(out, bufSize, "%d B", (int)size);
|
||||
else
|
||||
snprintf(out, bufSize, "%3.1f %s", f, sizes[s]);
|
||||
}
|
||||
|
||||
bool Version::ParseVersionString(std::string str) {
|
||||
if (str.empty())
|
||||
return false;
|
||||
@@ -79,7 +96,7 @@ bool TryParse(const std::string &str, uint64_t *const output) {
|
||||
// Reset errno to a value other than ERANGE
|
||||
errno = 0;
|
||||
|
||||
uint64_t value = strtoul(str.c_str(), &endptr, 0);
|
||||
uint64_t value = strtoull(str.c_str(), &endptr, 0);
|
||||
|
||||
if (!endptr || *endptr)
|
||||
return false;
|
||||
|
||||
@@ -70,3 +70,5 @@ static bool TryParse(const std::string &str, N *const output) {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
void NiceSizeFormat(size_t size, char *out, size_t bufSize);
|
||||
@@ -22,6 +22,8 @@
|
||||
#define REAL_CPUDETECT_AVAIL 1
|
||||
#elif PPSSPP_ARCH(MIPS) || PPSSPP_ARCH(MIPS64)
|
||||
#define REAL_CPUDETECT_AVAIL 1
|
||||
#elif PPSSPP_ARCH(RISCV64)
|
||||
#define REAL_CPUDETECT_AVAIL 1
|
||||
#endif
|
||||
|
||||
#ifndef REAL_CPUDETECT_AVAIL
|
||||
|
||||
+131
-15
@@ -11,10 +11,16 @@ static jmethodID openContentUri;
|
||||
static jmethodID listContentUriDir;
|
||||
static jmethodID contentUriCreateFile;
|
||||
static jmethodID contentUriCreateDirectory;
|
||||
static jmethodID contentUriCopyFile;
|
||||
static jmethodID contentUriMoveFile;
|
||||
static jmethodID contentUriRemoveFile;
|
||||
static jmethodID contentUriRenameFileTo;
|
||||
static jmethodID contentUriGetFileInfo;
|
||||
static jmethodID contentUriFileExists;
|
||||
static jmethodID contentUriGetFreeStorageSpace;
|
||||
static jmethodID filePathGetFreeStorageSpace;
|
||||
static jmethodID isExternalStoragePreservedLegacy;
|
||||
static jmethodID computeRecursiveDirectorySize;
|
||||
|
||||
static jobject g_nativeActivity;
|
||||
|
||||
@@ -27,18 +33,30 @@ void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj) {
|
||||
_dbg_assert_(openContentUri);
|
||||
listContentUriDir = env->GetMethodID(env->GetObjectClass(obj), "listContentUriDir", "(Ljava/lang/String;)[Ljava/lang/String;");
|
||||
_dbg_assert_(listContentUriDir);
|
||||
contentUriCreateDirectory = env->GetMethodID(env->GetObjectClass(obj), "contentUriCreateDirectory", "(Ljava/lang/String;Ljava/lang/String;)Z");
|
||||
contentUriCreateDirectory = env->GetMethodID(env->GetObjectClass(obj), "contentUriCreateDirectory", "(Ljava/lang/String;Ljava/lang/String;)I");
|
||||
_dbg_assert_(contentUriCreateDirectory);
|
||||
contentUriCreateFile = env->GetMethodID(env->GetObjectClass(obj), "contentUriCreateFile", "(Ljava/lang/String;Ljava/lang/String;)Z");
|
||||
contentUriCreateFile = env->GetMethodID(env->GetObjectClass(obj), "contentUriCreateFile", "(Ljava/lang/String;Ljava/lang/String;)I");
|
||||
_dbg_assert_(contentUriCreateFile);
|
||||
contentUriRemoveFile = env->GetMethodID(env->GetObjectClass(obj), "contentUriRemoveFile", "(Ljava/lang/String;)Z");
|
||||
contentUriCopyFile = env->GetMethodID(env->GetObjectClass(obj), "contentUriCopyFile", "(Ljava/lang/String;Ljava/lang/String;)I");
|
||||
_dbg_assert_(contentUriCopyFile);
|
||||
contentUriRemoveFile = env->GetMethodID(env->GetObjectClass(obj), "contentUriRemoveFile", "(Ljava/lang/String;)I");
|
||||
_dbg_assert_(contentUriRemoveFile);
|
||||
contentUriMoveFile = env->GetMethodID(env->GetObjectClass(obj), "contentUriMoveFile", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I");
|
||||
_dbg_assert_(contentUriMoveFile);
|
||||
contentUriRenameFileTo = env->GetMethodID(env->GetObjectClass(obj), "contentUriRenameFileTo", "(Ljava/lang/String;Ljava/lang/String;)I");
|
||||
_dbg_assert_(contentUriRenameFileTo);
|
||||
contentUriGetFileInfo = env->GetMethodID(env->GetObjectClass(obj), "contentUriGetFileInfo", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
_dbg_assert_(contentUriGetFileInfo);
|
||||
contentUriFileExists = env->GetMethodID(env->GetObjectClass(obj), "contentUriFileExists", "(Ljava/lang/String;)Z");
|
||||
_dbg_assert_(contentUriFileExists);
|
||||
contentUriGetFreeStorageSpace = env->GetMethodID(env->GetObjectClass(obj), "contentUriGetFreeStorageSpace", "(Ljava/lang/String;)J");
|
||||
_dbg_assert_(contentUriGetFreeStorageSpace);
|
||||
filePathGetFreeStorageSpace = env->GetMethodID(env->GetObjectClass(obj), "filePathGetFreeStorageSpace", "(Ljava/lang/String;)J");
|
||||
_dbg_assert_(filePathGetFreeStorageSpace);
|
||||
isExternalStoragePreservedLegacy = env->GetMethodID(env->GetObjectClass(obj), "isExternalStoragePreservedLegacy", "()Z");
|
||||
_dbg_assert_(isExternalStoragePreservedLegacy);
|
||||
computeRecursiveDirectorySize = env->GetMethodID(env->GetObjectClass(obj), "computeRecursiveDirectorySize", "(Ljava/lang/String;)J");
|
||||
_dbg_assert_(computeRecursiveDirectorySize);
|
||||
}
|
||||
|
||||
bool Android_IsContentUri(const std::string &filename) {
|
||||
@@ -69,39 +87,71 @@ int Android_OpenContentUriFd(const std::string &filename, Android_OpenContentUri
|
||||
return fd;
|
||||
}
|
||||
|
||||
bool Android_CreateDirectory(const std::string &rootTreeUri, const std::string &dirName) {
|
||||
StorageError Android_CreateDirectory(const std::string &rootTreeUri, const std::string &dirName) {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
return StorageError::UNKNOWN;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramRoot = env->NewStringUTF(rootTreeUri.c_str());
|
||||
jstring paramDirName = env->NewStringUTF(dirName.c_str());
|
||||
return env->CallBooleanMethod(g_nativeActivity, contentUriCreateDirectory, paramRoot, paramDirName);
|
||||
return StorageErrorFromInt(env->CallIntMethod(g_nativeActivity, contentUriCreateDirectory, paramRoot, paramDirName));
|
||||
}
|
||||
|
||||
bool Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) {
|
||||
StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
return StorageError::UNKNOWN;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramRoot = env->NewStringUTF(parentTreeUri.c_str());
|
||||
jstring paramFileName = env->NewStringUTF(fileName.c_str());
|
||||
return env->CallBooleanMethod(g_nativeActivity, contentUriCreateFile, paramRoot, paramFileName);
|
||||
return StorageErrorFromInt(env->CallIntMethod(g_nativeActivity, contentUriCreateFile, paramRoot, paramFileName));
|
||||
}
|
||||
|
||||
bool Android_RemoveFile(const std::string &fileUri) {
|
||||
StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri) {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
return StorageError::UNKNOWN;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramFileName = env->NewStringUTF(fileUri.c_str());
|
||||
return env->CallBooleanMethod(g_nativeActivity, contentUriRemoveFile, paramFileName);
|
||||
jstring paramDestParentUri = env->NewStringUTF(destParentUri.c_str());
|
||||
return StorageErrorFromInt(env->CallIntMethod(g_nativeActivity, contentUriCopyFile, paramFileName, paramDestParentUri));
|
||||
}
|
||||
|
||||
StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri) {
|
||||
if (!g_nativeActivity) {
|
||||
return StorageError::UNKNOWN;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramFileName = env->NewStringUTF(fileUri.c_str());
|
||||
jstring paramSrcParentUri = env->NewStringUTF(srcParentUri.c_str());
|
||||
jstring paramDestParentUri = env->NewStringUTF(destParentUri.c_str());
|
||||
return StorageErrorFromInt(env->CallIntMethod(g_nativeActivity, contentUriMoveFile, paramFileName, paramSrcParentUri, paramDestParentUri));
|
||||
}
|
||||
|
||||
StorageError Android_RemoveFile(const std::string &fileUri) {
|
||||
if (!g_nativeActivity) {
|
||||
return StorageError::UNKNOWN;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramFileName = env->NewStringUTF(fileUri.c_str());
|
||||
return StorageErrorFromInt(env->CallIntMethod(g_nativeActivity, contentUriRemoveFile, paramFileName));
|
||||
}
|
||||
|
||||
StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName) {
|
||||
if (!g_nativeActivity) {
|
||||
return StorageError::UNKNOWN;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramFileUri = env->NewStringUTF(fileUri.c_str());
|
||||
jstring paramNewName = env->NewStringUTF(newName.c_str());
|
||||
return StorageErrorFromInt(env->CallIntMethod(g_nativeActivity, contentUriRenameFileTo, paramFileUri, paramNewName));
|
||||
}
|
||||
|
||||
// NOTE: Does not set fullName - you're supposed to already know it.
|
||||
static bool ParseFileInfo(const std::string &line, File::FileInfo *fileInfo) {
|
||||
std::vector<std::string> parts;
|
||||
SplitString(line, '|', parts);
|
||||
if (parts.size() != 5) {
|
||||
if (parts.size() != 4) {
|
||||
ERROR_LOG(FILESYS, "Bad format: %s", line.c_str());
|
||||
return false;
|
||||
}
|
||||
@@ -109,9 +159,19 @@ static bool ParseFileInfo(const std::string &line, File::FileInfo *fileInfo) {
|
||||
fileInfo->isDirectory = parts[0][0] == 'D';
|
||||
fileInfo->exists = true;
|
||||
sscanf(parts[1].c_str(), "%" PRIu64, &fileInfo->size);
|
||||
fileInfo->fullName = Path(parts[3]);
|
||||
fileInfo->isWritable = true; // TODO: Should be passed as part of the string.
|
||||
sscanf(parts[4].c_str(), "%" PRIu64, &fileInfo->lastModified);
|
||||
fileInfo->access = fileInfo->isDirectory ? 0666 : 0777; // TODO: For read-only mappings, reflect that here, similarly as with isWritable.
|
||||
|
||||
uint64_t lastModifiedMs = 0;
|
||||
sscanf(parts[3].c_str(), "%" PRIu64, &lastModifiedMs);
|
||||
|
||||
// Convert from milliseconds
|
||||
uint32_t lastModified = lastModifiedMs / 1000;
|
||||
|
||||
// We don't have better information, so let's just spam lastModified into all the date/time fields.
|
||||
fileInfo->mtime = lastModified;
|
||||
fileInfo->ctime = lastModified;
|
||||
fileInfo->atime = lastModified;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -128,10 +188,22 @@ bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *fileInfo) {
|
||||
}
|
||||
const char *charArray = env->GetStringUTFChars(str, 0);
|
||||
bool retval = ParseFileInfo(std::string(charArray), fileInfo);
|
||||
fileInfo->fullName = Path(fileUri);
|
||||
|
||||
env->DeleteLocalRef(str);
|
||||
return retval && fileInfo->exists;
|
||||
}
|
||||
|
||||
bool Android_FileExists(const std::string &fileUri) {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramFileUri = env->NewStringUTF(fileUri.c_str());
|
||||
bool exists = env->CallBooleanMethod(g_nativeActivity, contentUriFileExists, paramFileUri);
|
||||
return exists;
|
||||
}
|
||||
|
||||
std::vector<File::FileInfo> Android_ListContentUri(const std::string &path) {
|
||||
if (!g_nativeActivity) {
|
||||
return std::vector<File::FileInfo>();
|
||||
@@ -152,6 +224,8 @@ std::vector<File::FileInfo> Android_ListContentUri(const std::string &path) {
|
||||
if (charArray) { // paranoia
|
||||
File::FileInfo info;
|
||||
if (ParseFileInfo(std::string(charArray), &info)) {
|
||||
// We can just reconstruct the URI.
|
||||
info.fullName = Path(path) / info.name;
|
||||
items.push_back(info);
|
||||
}
|
||||
}
|
||||
@@ -187,4 +261,46 @@ int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) {
|
||||
return env->CallLongMethod(g_nativeActivity, filePathGetFreeStorageSpace, param);
|
||||
}
|
||||
|
||||
int64_t Android_ComputeRecursiveDirectorySize(const std::string &uri) {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
}
|
||||
auto env = getEnv();
|
||||
|
||||
jstring param = env->NewStringUTF(uri.c_str());
|
||||
|
||||
double start = time_now_d();
|
||||
int64_t size = env->CallLongMethod(g_nativeActivity, computeRecursiveDirectorySize, param);
|
||||
double elapsed = time_now_d() - start;
|
||||
|
||||
INFO_LOG(IO, "ComputeRecursiveDirectorySize(%s) in %0.3f s", uri.c_str(), elapsed);
|
||||
return size;
|
||||
}
|
||||
|
||||
bool Android_IsExternalStoragePreservedLegacy() {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
}
|
||||
auto env = getEnv();
|
||||
return env->CallBooleanMethod(g_nativeActivity, isExternalStoragePreservedLegacy);
|
||||
}
|
||||
|
||||
const char *Android_ErrorToString(StorageError error) {
|
||||
switch (error) {
|
||||
case StorageError::SUCCESS: return "SUCCESS";
|
||||
case StorageError::UNKNOWN: return "UNKNOWN";
|
||||
case StorageError::NOT_FOUND: return "NOT_FOUND";
|
||||
case StorageError::DISK_FULL: return "DISK_FULL";
|
||||
case StorageError::ALREADY_EXISTS: return "ALREADY_EXISTS";
|
||||
default: return "(UNKNOWN)";
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// These strings should never appear except on Android.
|
||||
// Very hacky.
|
||||
std::string g_extFilesDir = "(IF YOU SEE THIS THERE'S A BUG)";
|
||||
std::string g_externalDir = "(IF YOU SEE THIS THERE'S A BUG (2))";
|
||||
|
||||
#endif
|
||||
@@ -13,22 +13,47 @@ enum class Android_OpenContentUriMode {
|
||||
READ_WRITE_TRUNCATE = 2, // "rwt"
|
||||
};
|
||||
|
||||
// Matches the constants in PpssppActivity.java.
|
||||
enum class StorageError {
|
||||
SUCCESS = 0,
|
||||
UNKNOWN = -1,
|
||||
NOT_FOUND = -2,
|
||||
DISK_FULL = -3,
|
||||
ALREADY_EXISTS = -4,
|
||||
};
|
||||
|
||||
inline StorageError StorageErrorFromInt(int ival) {
|
||||
if (ival >= 0) {
|
||||
return StorageError::SUCCESS;
|
||||
} else {
|
||||
return (StorageError)ival;
|
||||
}
|
||||
}
|
||||
|
||||
extern std::string g_extFilesDir;
|
||||
extern std::string g_externalDir;
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID) && !defined(__LIBRETRO__)
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
extern std::string g_extFilesDir;
|
||||
|
||||
void Android_StorageSetNativeActivity(jobject nativeActivity);
|
||||
|
||||
bool Android_IsContentUri(const std::string &uri);
|
||||
int Android_OpenContentUriFd(const std::string &uri, const Android_OpenContentUriMode mode);
|
||||
bool Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName);
|
||||
bool Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName);
|
||||
bool Android_RemoveFile(const std::string &fileUri);
|
||||
StorageError Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName);
|
||||
StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName);
|
||||
StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri);
|
||||
StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri);
|
||||
StorageError Android_RemoveFile(const std::string &fileUri);
|
||||
StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName);
|
||||
bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info);
|
||||
bool Android_FileExists(const std::string &fileUri);
|
||||
int64_t Android_ComputeRecursiveDirectorySize(const std::string &fileUri);
|
||||
int64_t Android_GetFreeSpaceByContentUri(const std::string &uri);
|
||||
int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath);
|
||||
bool Android_IsExternalStoragePreservedLegacy();
|
||||
const char *Android_ErrorToString(StorageError error);
|
||||
|
||||
std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri);
|
||||
|
||||
@@ -40,12 +65,19 @@ void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj);
|
||||
|
||||
inline bool Android_IsContentUri(const std::string &uri) { return false; }
|
||||
inline int Android_OpenContentUriFd(const std::string &uri, const Android_OpenContentUriMode mode) { return -1; }
|
||||
inline bool Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName) { return false; }
|
||||
inline bool Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) { return false; }
|
||||
inline bool Android_RemoveFile(const std::string &fileUri) { return false; }
|
||||
inline StorageError Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName) { return StorageError::UNKNOWN; }
|
||||
inline StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) { return StorageError::UNKNOWN; }
|
||||
inline StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri) { return StorageError::UNKNOWN; }
|
||||
inline StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri) { return StorageError::UNKNOWN; }
|
||||
inline StorageError Android_RemoveFile(const std::string &fileUri) { return StorageError::UNKNOWN; }
|
||||
inline StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName) { return StorageError::UNKNOWN; }
|
||||
inline bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info) { return false; }
|
||||
inline bool Android_FileExists(const std::string &fileUri) { return false; }
|
||||
inline int64_t Android_ComputeRecursiveDirectorySize(const std::string &fileUri) { return -1; }
|
||||
inline int64_t Android_GetFreeSpaceByContentUri(const std::string &uri) { return -1; }
|
||||
inline int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) { return -1; }
|
||||
inline bool Android_IsExternalStoragePreservedLegacy() { return false; }
|
||||
inline const char *Android_ErrorToString(StorageError error) { return ""; }
|
||||
inline std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri) {
|
||||
return std::vector<File::FileInfo>();
|
||||
}
|
||||
|
||||
+77
-87
@@ -1,6 +1,6 @@
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <direct.h>
|
||||
@@ -38,6 +38,15 @@
|
||||
|
||||
namespace File {
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
static uint64_t FiletimeToStatTime(FILETIME ft) {
|
||||
const int windowsTickResolution = 10000000;
|
||||
const int64_t secToUnixEpoch = 11644473600LL;
|
||||
int64_t ticks = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
|
||||
return (int64_t)(ticks / windowsTickResolution - secToUnixEpoch);
|
||||
};
|
||||
#endif
|
||||
|
||||
bool GetFileInfo(const Path &path, FileInfo * fileInfo) {
|
||||
switch (path.Type()) {
|
||||
case PathType::NATIVE:
|
||||
@@ -51,14 +60,7 @@ bool GetFileInfo(const Path &path, FileInfo * fileInfo) {
|
||||
// TODO: Expand relative paths?
|
||||
fileInfo->fullName = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
auto FiletimeToStatTime = [](FILETIME ft) {
|
||||
const int windowsTickResolution = 10000000;
|
||||
const int64_t secToUnixEpoch = 11644473600LL;
|
||||
int64_t ticks = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
|
||||
return (int64_t)(ticks / windowsTickResolution - secToUnixEpoch);
|
||||
};
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA attrs;
|
||||
if (!GetFileAttributesExW(path.ToWString().c_str(), GetFileExInfoStandard, &attrs)) {
|
||||
fileInfo->size = 0;
|
||||
@@ -160,7 +162,7 @@ std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const
|
||||
return files;
|
||||
}
|
||||
|
||||
size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> * files, const char *filter, int flags) {
|
||||
bool GetFilesInDir(const Path &directory, std::vector<FileInfo> *files, const char *filter, int flags) {
|
||||
if (directory.Type() == PathType::CONTENT_URI) {
|
||||
std::vector<File::FileInfo> fileList = Android_ListContentUri(directory.ToString());
|
||||
*files = ApplyFilter(fileList, filter);
|
||||
@@ -168,6 +170,22 @@ size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> * files, const
|
||||
return true;
|
||||
}
|
||||
|
||||
std::set<std::string> filters;
|
||||
if (filter) {
|
||||
std::string tmp;
|
||||
while (*filter) {
|
||||
if (*filter == ':') {
|
||||
filters.insert(std::move(tmp));
|
||||
tmp.clear();
|
||||
} else {
|
||||
tmp.push_back(*filter);
|
||||
}
|
||||
filter++;
|
||||
}
|
||||
if (!tmp.empty())
|
||||
filters.insert(std::move(tmp));
|
||||
}
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
if (directory.IsRoot()) {
|
||||
// Special path that means root of file system.
|
||||
@@ -186,74 +204,33 @@ size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> * files, const
|
||||
}
|
||||
return files->size();
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t foundEntries = 0;
|
||||
std::set<std::string> filters;
|
||||
if (filter) {
|
||||
std::string tmp;
|
||||
while (*filter) {
|
||||
if (*filter == ':') {
|
||||
filters.insert(std::move(tmp));
|
||||
tmp.clear();
|
||||
} else {
|
||||
tmp.push_back(*filter);
|
||||
}
|
||||
filter++;
|
||||
}
|
||||
if (!tmp.empty())
|
||||
filters.insert(std::move(tmp));
|
||||
}
|
||||
#ifdef _WIN32
|
||||
// Find the first file in the directory.
|
||||
WIN32_FIND_DATA ffd;
|
||||
HANDLE hFind = FindFirstFileEx((directory.ToWString() + L"\\*").c_str(), FindExInfoStandard, &ffd, FindExSearchNameMatch, NULL, 0);
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
return 0;
|
||||
}
|
||||
// windows loop
|
||||
do
|
||||
{
|
||||
do {
|
||||
const std::string virtualName = ConvertWStringToUTF8(ffd.cFileName);
|
||||
#else
|
||||
struct dirent *result = NULL;
|
||||
|
||||
//std::string directoryWithSlash = directory;
|
||||
//if (directoryWithSlash.back() != '/')
|
||||
// directoryWithSlash += "/";
|
||||
|
||||
DIR *dirp = opendir(directory.c_str());
|
||||
if (!dirp)
|
||||
return 0;
|
||||
// non windows loop
|
||||
while ((result = readdir(dirp)))
|
||||
{
|
||||
const std::string virtualName(result->d_name);
|
||||
#endif
|
||||
// check for "." and ".."
|
||||
if (virtualName == "." || virtualName == "..")
|
||||
if (!(flags & GETFILES_GET_NAVIGATION_ENTRIES) && (virtualName == "." || virtualName == ".."))
|
||||
continue;
|
||||
|
||||
// Remove dotfiles (optional with flag.)
|
||||
if (!(flags & GETFILES_GETHIDDEN))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!(flags & GETFILES_GETHIDDEN)) {
|
||||
if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)
|
||||
continue;
|
||||
#else
|
||||
if (virtualName[0] == '.')
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
|
||||
FileInfo info;
|
||||
info.name = virtualName;
|
||||
|
||||
info.fullName = directory / virtualName;
|
||||
info.isDirectory = IsDirectory(info.fullName);
|
||||
info.exists = true;
|
||||
info.size = 0;
|
||||
info.isWritable = false; // TODO - implement some kind of check
|
||||
info.size = ((uint64_t)ffd.nFileSizeHigh << 32) | ffd.nFileSizeLow;
|
||||
info.isDirectory = (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
info.isWritable = (ffd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
info.atime = FiletimeToStatTime(ffd.ftLastAccessTime);
|
||||
info.mtime = FiletimeToStatTime(ffd.ftLastWriteTime);
|
||||
info.ctime = FiletimeToStatTime(ffd.ftCreationTime);
|
||||
if (!info.isDirectory) {
|
||||
std::string ext = info.fullName.GetFileExtension();
|
||||
if (!ext.empty()) {
|
||||
@@ -263,39 +240,52 @@ size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> * files, const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (files)
|
||||
files->push_back(std::move(info));
|
||||
foundEntries++;
|
||||
#ifdef _WIN32
|
||||
files->push_back(info);
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
FindClose(hFind);
|
||||
#else
|
||||
struct dirent *result = NULL;
|
||||
DIR *dirp = opendir(directory.c_str());
|
||||
if (!dirp)
|
||||
return 0;
|
||||
while ((result = readdir(dirp))) {
|
||||
const std::string virtualName(result->d_name);
|
||||
// check for "." and ".."
|
||||
if (!(flags & GETFILES_GET_NAVIGATION_ENTRIES) && (virtualName == "." || virtualName == ".."))
|
||||
continue;
|
||||
|
||||
// Remove dotfiles (optional with flag.)
|
||||
if (!(flags & GETFILES_GETHIDDEN)) {
|
||||
if (virtualName[0] == '.')
|
||||
continue;
|
||||
}
|
||||
|
||||
// Let's just reuse GetFileInfo. We're calling stat anyway to get isDirectory information.
|
||||
Path fullName = directory / virtualName;
|
||||
|
||||
FileInfo info;
|
||||
info.name = virtualName;
|
||||
if (!GetFileInfo(fullName, &info)) {
|
||||
continue;
|
||||
}
|
||||
if (!info.isDirectory) {
|
||||
std::string ext = info.fullName.GetFileExtension();
|
||||
if (!ext.empty()) {
|
||||
ext = ext.substr(1); // Remove the dot.
|
||||
if (filter && filters.find(ext) == filters.end()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
files->push_back(info);
|
||||
}
|
||||
closedir(dirp);
|
||||
#endif
|
||||
if (files)
|
||||
std::sort(files->begin(), files->end());
|
||||
return foundEntries;
|
||||
std::sort(files->begin(), files->end());
|
||||
return true;
|
||||
}
|
||||
|
||||
int64_t GetDirectoryRecursiveSize(const Path &path, const char *filter, int flags) {
|
||||
std::vector<FileInfo> fileInfo;
|
||||
GetFilesInDir(path, &fileInfo, filter, flags);
|
||||
int64_t sizeSum = 0;
|
||||
// Note: GetFilesInDir does not fill in fileSize.
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
FileInfo finfo;
|
||||
GetFileInfo(fileInfo[i].fullName, &finfo);
|
||||
if (!finfo.isDirectory)
|
||||
sizeSum += finfo.size;
|
||||
else
|
||||
sizeSum += GetDirectoryRecursiveSize(finfo.fullName, filter, flags);
|
||||
}
|
||||
return sizeSum;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
// Returns a vector with the device names
|
||||
std::vector<std::string> GetWindowsDrives()
|
||||
{
|
||||
@@ -321,8 +311,8 @@ std::vector<std::string> GetWindowsDrives()
|
||||
}
|
||||
}
|
||||
return drives;
|
||||
#endif
|
||||
#endif // PPSSPP_PLATFORM(UWP)
|
||||
}
|
||||
#endif
|
||||
#endif // PPSSPP_PLATFORM(WINDOWS)
|
||||
|
||||
} // namespace File
|
||||
@@ -19,14 +19,10 @@ struct FileInfo {
|
||||
bool isWritable = false;
|
||||
uint64_t size = 0;
|
||||
|
||||
uint64_t atime;
|
||||
uint64_t mtime;
|
||||
uint64_t ctime;
|
||||
uint32_t access; // st_mode & 0x1ff
|
||||
|
||||
// Currently only supported for Android storage files.
|
||||
// Other places use different methods to get this.
|
||||
uint64_t lastModified = 0;
|
||||
uint64_t atime = 0;
|
||||
uint64_t mtime = 0;
|
||||
uint64_t ctime = 0;
|
||||
uint32_t access = 0; // st_mode & 0x1ff
|
||||
|
||||
bool operator <(const FileInfo &other) const;
|
||||
};
|
||||
@@ -35,10 +31,10 @@ bool GetFileInfo(const Path &path, FileInfo *fileInfo);
|
||||
|
||||
enum {
|
||||
GETFILES_GETHIDDEN = 1,
|
||||
GETFILES_GET_NAVIGATION_ENTRIES = 2, // If you don't set this, "." and ".." will be skipped.
|
||||
};
|
||||
|
||||
size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> *files, const char *filter = nullptr, int flags = 0);
|
||||
int64_t GetDirectoryRecursiveSize(const Path &path, const char *filter = nullptr, int flags = 0);
|
||||
bool GetFilesInDir(const Path &directory, std::vector<FileInfo> *files, const char *filter = nullptr, int flags = 0);
|
||||
std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const char *filter);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -16,24 +16,35 @@
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/File/AndroidStorage.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
|
||||
bool free_disk_space(const std::string &dir, uint64_t &space) {
|
||||
bool free_disk_space(const Path &path, int64_t &space) {
|
||||
#ifdef _WIN32
|
||||
const std::wstring w32path = ConvertUTF8ToWString(dir);
|
||||
ULARGE_INTEGER free;
|
||||
if (GetDiskFreeSpaceExW(w32path.c_str(), &free, nullptr, nullptr)) {
|
||||
if (GetDiskFreeSpaceExW(path.ToWString().c_str(), &free, nullptr, nullptr)) {
|
||||
space = free.QuadPart;
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (path.Type() == PathType::CONTENT_URI) {
|
||||
space = Android_GetFreeSpaceByContentUri(path.ToString());
|
||||
INFO_LOG(COMMON, "Free space at '%s': %" PRIu64, path.c_str(), space);
|
||||
return space >= 0;
|
||||
}
|
||||
|
||||
struct statvfs diskstat;
|
||||
int res = statvfs(dir.c_str(), &diskstat);
|
||||
int res = statvfs(path.c_str(), &diskstat);
|
||||
|
||||
if (res == 0) {
|
||||
// Not sure why we're excluding Android here anyway...
|
||||
#ifndef __ANDROID__
|
||||
if (diskstat.f_flag & ST_RDONLY) {
|
||||
// No space to write.
|
||||
space = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
bool free_disk_space(const std::string &dir, uint64_t &space);
|
||||
#include "Common/File/Path.h"
|
||||
|
||||
// If this fails, false is returned and space is negative.
|
||||
bool free_disk_space(const Path &path, int64_t &space);
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/File/FileDescriptor.h"
|
||||
#include "Common/Log.h"
|
||||
|
||||
@@ -159,10 +160,11 @@ std::string GetLocalIP(int sock) {
|
||||
addr = &server_addr.ipv4.sin_addr;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
wchar_t wtemp[sizeof(temp)];
|
||||
DWORD len = (DWORD)sizeof(temp);
|
||||
// Windows XP doesn't support inet_ntop.
|
||||
if (WSAAddressToStringA((struct sockaddr *)&server_addr, sizeof(server_addr), nullptr, temp, &len) == 0) {
|
||||
return temp;
|
||||
if (WSAAddressToStringW((struct sockaddr *)&server_addr, sizeof(server_addr), nullptr, wtemp, &len) == 0) {
|
||||
return ConvertWStringToUTF8(wtemp);
|
||||
}
|
||||
#else
|
||||
const char *result = inet_ntop(server_addr.sa.sa_family, addr, temp, sizeof(temp));
|
||||
|
||||
+146
-44
@@ -103,23 +103,23 @@ FILE *OpenCFile(const Path &path, const char *mode) {
|
||||
break;
|
||||
case PathType::CONTENT_URI:
|
||||
// We're gonna need some error codes..
|
||||
if (!strcmp(mode, "r") || !strcmp(mode, "rb")) {
|
||||
if (!strcmp(mode, "r") || !strcmp(mode, "rb") || !strcmp(mode, "rt")) {
|
||||
INFO_LOG(COMMON, "Opening content file for read: '%s'", path.c_str());
|
||||
// Read, let's support this - easy one.
|
||||
int descriptor = Android_OpenContentUriFd(path.ToString(), Android_OpenContentUriMode::READ);
|
||||
if (descriptor == -1) {
|
||||
if (descriptor < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return fdopen(descriptor, "rb");
|
||||
} else if (!strcmp(mode, "w") || !strcmp(mode, "wb")) {
|
||||
} else if (!strcmp(mode, "w") || !strcmp(mode, "wb") || !strcmp(mode, "wt") || !strcmp(mode, "at") || !strcmp(mode, "a")) {
|
||||
// Need to be able to create the file here if it doesn't exist.
|
||||
// Not exactly sure which abstractions are best, let's start simple.
|
||||
if (!File::Exists(path)) {
|
||||
INFO_LOG(COMMON, "Opening content file '%s' for write. Doesn't exist, creating empty and reopening.", path.c_str());
|
||||
INFO_LOG(COMMON, "OpenCFile(%s): Opening content file for write. Doesn't exist, creating empty and reopening.", path.c_str());
|
||||
std::string name = path.GetFilename();
|
||||
if (path.CanNavigateUp()) {
|
||||
Path parent = path.NavigateUp();
|
||||
if (!Android_CreateFile(parent.ToString(), name)) {
|
||||
if (Android_CreateFile(parent.ToString(), name) != StorageError::SUCCESS) {
|
||||
WARN_LOG(COMMON, "Failed to create file '%s' in '%s'", name.c_str(), parent.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -128,16 +128,21 @@ FILE *OpenCFile(const Path &path, const char *mode) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(COMMON, "Opening file by fd for write");
|
||||
INFO_LOG(COMMON, "OpenCFile(%s): Opening existing content file for write (truncating). Requested mode: '%s'", path.c_str(), mode);
|
||||
}
|
||||
|
||||
// TODO: Support append modes and stuff... For now let's go with the most common one.
|
||||
int descriptor = Android_OpenContentUriFd(path.ToString(), Android_OpenContentUriMode::READ_WRITE_TRUNCATE);
|
||||
if (descriptor == -1) {
|
||||
if (descriptor < 0) {
|
||||
INFO_LOG(COMMON, "Opening '%s' for write failed", path.ToString().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return fdopen(descriptor, "wb");
|
||||
FILE *f = fdopen(descriptor, "wb");
|
||||
if (!strcmp(mode, "at") || !strcmp(mode, "a")) {
|
||||
// Append mode.
|
||||
fseek(f, 0, SEEK_END);
|
||||
}
|
||||
return f;
|
||||
} else {
|
||||
ERROR_LOG(COMMON, "OpenCFile(%s): Mode not yet supported: %s", path.c_str(), mode);
|
||||
return nullptr;
|
||||
@@ -155,32 +160,80 @@ FILE *OpenCFile(const Path &path, const char *mode) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::string OpenFlagToString(OpenFlag flags) {
|
||||
std::string s;
|
||||
if (flags & OPEN_READ)
|
||||
s += "READ|";
|
||||
if (flags & OPEN_WRITE)
|
||||
s += "WRITE|";
|
||||
if (flags & OPEN_APPEND)
|
||||
s += "APPEND|";
|
||||
if (flags & OPEN_CREATE)
|
||||
s += "CREATE|";
|
||||
if (flags & OPEN_TRUNCATE)
|
||||
s += "TRUNCATE|";
|
||||
if (!s.empty()) {
|
||||
s.pop_back(); // Remove trailing separator.
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
int OpenFD(const Path &path, OpenFlag flags) {
|
||||
switch (path.Type()) {
|
||||
case PathType::CONTENT_URI:
|
||||
break;
|
||||
default:
|
||||
// Not yet supported.
|
||||
ERROR_LOG(COMMON, "OpenFD: Only supports Content URI paths. Not '%s' (%s)!", path.c_str(), OpenFlagToString(flags).c_str());
|
||||
// Not yet supported - use other paths.
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (flags & OPEN_CREATE) {
|
||||
if (!File::Exists(path)) {
|
||||
INFO_LOG(COMMON, "OpenFD(%s): Creating file.", path.c_str());
|
||||
std::string name = path.GetFilename();
|
||||
if (path.CanNavigateUp()) {
|
||||
Path parent = path.NavigateUp();
|
||||
if (Android_CreateFile(parent.ToString(), name) != StorageError::SUCCESS) {
|
||||
WARN_LOG(COMMON, "OpenFD: Failed to create file '%s' in '%s'", name.c_str(), parent.c_str());
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(COMMON, "Failed to navigate up to create file: %s", path.c_str());
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(COMMON, "OpenCFile(%s): Opening existing content file ('%s')", path.c_str(), OpenFlagToString(flags).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Android_OpenContentUriMode mode;
|
||||
if (flags == OPEN_READ) {
|
||||
mode = Android_OpenContentUriMode::READ;
|
||||
} else if (flags & OPEN_WRITE) {
|
||||
if (flags & OPEN_TRUNCATE) {
|
||||
mode = Android_OpenContentUriMode::READ_WRITE;
|
||||
} else {
|
||||
mode = Android_OpenContentUriMode::READ_WRITE_TRUNCATE;
|
||||
} else {
|
||||
mode = Android_OpenContentUriMode::READ_WRITE;
|
||||
}
|
||||
// TODO: Maybe better checking of additional flags here.
|
||||
} else {
|
||||
// TODO: Add support for more modes if possible.
|
||||
ERROR_LOG_REPORT_ONCE(openFlagNotSupported, COMMON, "OpenFlag 0x%x not yet supported", flags);
|
||||
ERROR_LOG_REPORT_ONCE(openFlagNotSupported, COMMON, "OpenFlag %s not yet supported", OpenFlagToString(flags).c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
INFO_LOG(COMMON, "Android_OpenContentUriFd: %s (%s)", path.c_str(), OpenFlagToString(flags).c_str());
|
||||
int descriptor = Android_OpenContentUriFd(path.ToString(), mode);
|
||||
if (descriptor < 0) {
|
||||
ERROR_LOG(COMMON, "Android_OpenContentUriFd failed: '%s'", path.c_str());
|
||||
}
|
||||
|
||||
if (flags & OPEN_APPEND) {
|
||||
// Simply seek to the end of the file to simulate append mode.
|
||||
lseek(descriptor, 0, SEEK_END);
|
||||
}
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@@ -271,6 +324,32 @@ std::string ResolvePath(const std::string &path) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static int64_t RecursiveSize(const Path &path) {
|
||||
// TODO: Some file systems can optimize this.
|
||||
std::vector<FileInfo> fileInfo;
|
||||
if (!GetFilesInDir(path, &fileInfo, nullptr, GETFILES_GETHIDDEN)) {
|
||||
return -1;
|
||||
}
|
||||
int64_t sizeSum = 0;
|
||||
for (const auto &file : fileInfo) {
|
||||
if (file.isDirectory) {
|
||||
sizeSum += RecursiveSize(file.fullName);
|
||||
} else {
|
||||
sizeSum += file.size;
|
||||
}
|
||||
}
|
||||
return sizeSum;
|
||||
}
|
||||
|
||||
uint64_t ComputeRecursiveDirectorySize(const Path &path) {
|
||||
if (path.Type() == PathType::CONTENT_URI) {
|
||||
return Android_ComputeRecursiveDirectorySize(path.ToString());
|
||||
}
|
||||
|
||||
// Generic solution.
|
||||
return RecursiveSize(path);
|
||||
}
|
||||
|
||||
// Returns true if file filename exists. Will return true on directories.
|
||||
bool ExistsInDir(const Path &path, const std::string &filename) {
|
||||
return Exists(path / filename);
|
||||
@@ -278,11 +357,7 @@ bool ExistsInDir(const Path &path, const std::string &filename) {
|
||||
|
||||
bool Exists(const Path &path) {
|
||||
if (path.Type() == PathType::CONTENT_URI) {
|
||||
FileInfo info;
|
||||
if (!Android_GetFileInfo(path.c_str(), &info)) {
|
||||
return false;
|
||||
}
|
||||
return info.exists;
|
||||
return Android_FileExists(path.c_str());
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
@@ -352,7 +427,7 @@ bool Delete(const Path &filename) {
|
||||
case PathType::NATIVE:
|
||||
break; // OK
|
||||
case PathType::CONTENT_URI:
|
||||
return Android_RemoveFile(filename.ToString());
|
||||
return Android_RemoveFile(filename.ToString()) == StorageError::SUCCESS;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -395,13 +470,19 @@ bool CreateDir(const Path &path) {
|
||||
break; // OK
|
||||
case PathType::CONTENT_URI:
|
||||
{
|
||||
// NOTE: The Android storage API will simply create a renamed directory (append a number) if it already exists.
|
||||
// We want to avoid that, so let's just return true if the directory already is there.
|
||||
if (File::Exists(path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Convert it to a "CreateDirIn" call, if possible, since that's
|
||||
// what we can do with the storage API.
|
||||
AndroidContentURI uri(path.ToString());
|
||||
std::string newDirName = uri.GetLastPart();
|
||||
if (uri.NavigateUp()) {
|
||||
INFO_LOG(COMMON, "Calling Android_CreateDirectory(%s, %s)", uri.ToString().c_str(), newDirName.c_str());
|
||||
return Android_CreateDirectory(uri.ToString(), newDirName);
|
||||
return Android_CreateDirectory(uri.ToString(), newDirName) == StorageError::SUCCESS;
|
||||
} else {
|
||||
// Bad path - can't create this directory.
|
||||
WARN_LOG(COMMON, "CreateDir failed: '%s'", path.c_str());
|
||||
@@ -460,7 +541,10 @@ bool CreateFullPath(const Path &path) {
|
||||
|
||||
Path root = path.GetRootVolume();
|
||||
|
||||
std::string diff = root.PathTo(path); // always with forward slashes
|
||||
std::string diff;
|
||||
if (!root.ComputePathTo(path, diff)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> parts;
|
||||
SplitString(diff, '/', parts);
|
||||
@@ -488,7 +572,7 @@ bool DeleteDir(const Path &path) {
|
||||
case PathType::NATIVE:
|
||||
break; // OK
|
||||
case PathType::CONTENT_URI:
|
||||
return Android_RemoveFile(path.ToString());
|
||||
return Android_RemoveFile(path.ToString()) == StorageError::SUCCESS;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -513,19 +597,28 @@ bool DeleteDir(const Path &path) {
|
||||
}
|
||||
|
||||
// renames file srcFilename to destFilename, returns true on success
|
||||
bool Rename(const Path &srcFilename, const Path &destFilename)
|
||||
{
|
||||
bool Rename(const Path &srcFilename, const Path &destFilename) {
|
||||
if (srcFilename.Type() != destFilename.Type()) {
|
||||
// Impossible.
|
||||
// Impossible. You're gonna need to make a copy, and delete the original. Not the responsibility
|
||||
// of Rename.
|
||||
return false;
|
||||
}
|
||||
|
||||
// We've already asserted that they're the same Type, so only need to check either src or dest.
|
||||
switch (srcFilename.Type()) {
|
||||
case PathType::NATIVE:
|
||||
break; // OK
|
||||
// OK, proceed with the regular code.
|
||||
break;
|
||||
case PathType::CONTENT_URI:
|
||||
ERROR_LOG_REPORT_ONCE(renameUriNotSupported, COMMON, "Moving files by Android URI is not yet supported");
|
||||
return false;
|
||||
// Content URI: Can only rename if in the same folder.
|
||||
// TODO: Fallback to move + rename? Or do we even care about that use case?
|
||||
if (srcFilename.GetDirectory() != destFilename.GetDirectory()) {
|
||||
INFO_LOG(COMMON, "Content URI rename: Directories not matching, failing. %s --> %s", srcFilename.c_str(), destFilename.c_str());
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(COMMON, "Content URI rename: %s --> %s", srcFilename.c_str(), destFilename.c_str());
|
||||
|
||||
return Android_RenameFileTo(srcFilename.ToString(), destFilename.GetFilename()) == StorageError::SUCCESS;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -548,26 +641,23 @@ bool Rename(const Path &srcFilename, const Path &destFilename)
|
||||
}
|
||||
|
||||
// copies file srcFilename to destFilename, returns true on success
|
||||
bool Copy(const Path &srcFilename, const Path &destFilename)
|
||||
{
|
||||
bool Copy(const Path &srcFilename, const Path &destFilename) {
|
||||
switch (srcFilename.Type()) {
|
||||
case PathType::NATIVE:
|
||||
break; // OK
|
||||
case PathType::CONTENT_URI:
|
||||
ERROR_LOG_REPORT_ONCE(copyUriNotSupported, COMMON, "Copying files by Android URI is not yet supported");
|
||||
if (destFilename.Type() == PathType::CONTENT_URI && destFilename.CanNavigateUp()) {
|
||||
Path destParent = destFilename.NavigateUp();
|
||||
// Use native file copy.
|
||||
if (Android_CopyFile(srcFilename.ToString(), destParent.ToString()) == StorageError::SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
// Else fall through, and try using file I/O.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
switch (destFilename.Type()) {
|
||||
case PathType::NATIVE:
|
||||
break; // OK
|
||||
case PathType::CONTENT_URI:
|
||||
ERROR_LOG_REPORT_ONCE(copyUriNotSupported, COMMON, "Copying files by Android URI is not yet supported");
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str());
|
||||
#ifdef _WIN32
|
||||
@@ -585,7 +675,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename)
|
||||
#else
|
||||
|
||||
// buffer size
|
||||
#define BSIZE 4096
|
||||
#define BSIZE 16384
|
||||
|
||||
char buffer[BSIZE];
|
||||
|
||||
@@ -639,7 +729,21 @@ bool Copy(const Path &srcFilename, const Path &destFilename)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Will overwrite the target.
|
||||
bool Move(const Path &srcFilename, const Path &destFilename) {
|
||||
// Try a shortcut in Android Storage scenarios.
|
||||
if (srcFilename.Type() == PathType::CONTENT_URI && destFilename.Type() == PathType::CONTENT_URI && srcFilename.CanNavigateUp() && destFilename.CanNavigateUp()) {
|
||||
// We do not handle simultaneous renames here.
|
||||
if (srcFilename.GetFilename() == destFilename.GetFilename()) {
|
||||
Path srcParent = srcFilename.NavigateUp();
|
||||
Path dstParent = destFilename.NavigateUp();
|
||||
if (Android_MoveFile(srcFilename.ToString(), srcParent.ToString(), dstParent.ToString()) == StorageError::SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
// If failed, fall through and try other ways.
|
||||
}
|
||||
}
|
||||
|
||||
if (Rename(srcFilename, destFilename)) {
|
||||
return true;
|
||||
} else if (Copy(srcFilename, destFilename)) {
|
||||
@@ -979,10 +1083,8 @@ bool ReadFileToString(bool text_file, const Path &filename, std::string &str) {
|
||||
return success;
|
||||
}
|
||||
|
||||
// This is an odd one, mainly used for asset reading, so doesn't really
|
||||
// need to support Path.
|
||||
uint8_t *ReadLocalFile(const char *filename, size_t * size) {
|
||||
FILE *file = File::OpenCFile(Path(filename), "rb");
|
||||
uint8_t *ReadLocalFile(const Path &filename, size_t *size) {
|
||||
FILE *file = File::OpenCFile(filename, "rb");
|
||||
if (!file) {
|
||||
*size = 0;
|
||||
return nullptr;
|
||||
|
||||
@@ -79,6 +79,9 @@ uint64_t GetFileSize(const Path &filename);
|
||||
// Overloaded GetSize, accepts FILE*
|
||||
uint64_t GetFileSize(FILE *f);
|
||||
|
||||
// Computes the recursive size of a directory. Warning: Might be slow!
|
||||
uint64_t ComputeRecursiveDirectorySize(const Path &path);
|
||||
|
||||
// Returns true if successful, or path already exists.
|
||||
bool CreateDir(const Path &filename);
|
||||
|
||||
@@ -201,6 +204,6 @@ bool WriteDataToFile(bool text_file, const void* data, const unsigned int size,
|
||||
|
||||
bool ReadFileToString(bool text_file, const Path &filename, std::string &str);
|
||||
// Return value must be delete[]-d.
|
||||
uint8_t *ReadLocalFile(const char *filename, size_t *size);
|
||||
uint8_t *ReadLocalFile(const Path &filename, size_t *size);
|
||||
|
||||
} // namespace
|
||||
+152
-21
@@ -2,6 +2,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
@@ -9,17 +10,13 @@
|
||||
#include "android/jni/app-android.h"
|
||||
#include "android/jni/AndroidContentURI.h"
|
||||
|
||||
Path::Path(const std::string &str) {
|
||||
if (str.empty()) {
|
||||
type_ = PathType::UNDEFINED;
|
||||
} else if (startsWith(str, "http://") || startsWith(str, "https://")) {
|
||||
type_ = PathType::HTTP;
|
||||
} else if (Android_IsContentUri(str)) {
|
||||
type_ = PathType::CONTENT_URI;
|
||||
} else {
|
||||
type_ = PathType::NATIVE;
|
||||
}
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
Path::Path(const std::string &str) {
|
||||
Init(str);
|
||||
}
|
||||
|
||||
@@ -31,7 +28,35 @@ Path::Path(const std::wstring &str) {
|
||||
#endif
|
||||
|
||||
void Path::Init(const std::string &str) {
|
||||
path_ = str;
|
||||
if (str.empty()) {
|
||||
type_ = PathType::UNDEFINED;
|
||||
path_.clear();
|
||||
} else if (startsWith(str, "http://") || startsWith(str, "https://")) {
|
||||
type_ = PathType::HTTP;
|
||||
path_ = str;
|
||||
} else if (Android_IsContentUri(str)) {
|
||||
// Content URIs on non scoped-storage (and possibly other cases?) can contain
|
||||
// "raw:/" URIs inside. This happens when picking the Download folder using the folder browser
|
||||
// on Android 9.
|
||||
// Here's an example:
|
||||
// content://com.android.providers.downloads.documents/tree/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fp/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fp
|
||||
//
|
||||
// Since this is a legacy use case, I think it's safe enough to just detect this
|
||||
// and flip it to a NATIVE url and hope for the best.
|
||||
AndroidContentURI uri(str);
|
||||
if (startsWith(uri.FilePath(), "raw:/")) {
|
||||
INFO_LOG(SYSTEM, "Raw path detected: %s", uri.FilePath().c_str());
|
||||
path_ = uri.FilePath().substr(4);
|
||||
type_ = PathType::NATIVE;
|
||||
} else {
|
||||
// A normal content URI path.
|
||||
type_ = PathType::CONTENT_URI;
|
||||
path_ = str;
|
||||
}
|
||||
} else {
|
||||
type_ = PathType::NATIVE;
|
||||
path_ = str;
|
||||
}
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
// Flip all the slashes around. We flip them back on ToWString().
|
||||
@@ -236,7 +261,6 @@ bool Path::CanNavigateUp() const {
|
||||
if (type_ == PathType::CONTENT_URI) {
|
||||
return AndroidContentURI(path_).CanNavigateUp();
|
||||
}
|
||||
|
||||
if (path_ == "/" || path_ == "") {
|
||||
return false;
|
||||
}
|
||||
@@ -279,7 +303,6 @@ Path Path::GetRootVolume() const {
|
||||
return Path(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Path("/");
|
||||
}
|
||||
|
||||
@@ -301,27 +324,135 @@ bool Path::IsAbsolute() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Path::PathTo(const Path &other) {
|
||||
bool Path::ComputePathTo(const Path &other, std::string &path) const {
|
||||
if (!other.StartsWith(*this)) {
|
||||
// Can't do this. Should return an error.
|
||||
return std::string();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*this == other) {
|
||||
// Equal, the path is empty.
|
||||
path.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string diff;
|
||||
|
||||
if (type_ == PathType::CONTENT_URI) {
|
||||
AndroidContentURI a(path_);
|
||||
AndroidContentURI b(other.path_);
|
||||
if (a.RootPath() != b.RootPath()) {
|
||||
// No common root, can't do anything
|
||||
return std::string();
|
||||
return false;
|
||||
}
|
||||
diff = a.PathTo(b);
|
||||
return a.ComputePathTo(b, path);
|
||||
} else if (path_ == "/") {
|
||||
diff = other.path_.substr(1);
|
||||
path = other.path_.substr(1);
|
||||
return true;
|
||||
} else {
|
||||
diff = other.path_.substr(path_.size() + 1);
|
||||
path = other.path_.substr(path_.size() + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
|
||||
static bool FixFilenameCase(const std::string &path, std::string &filename) {
|
||||
// Are we lucky?
|
||||
if (File::Exists(Path(path + filename)))
|
||||
return true;
|
||||
|
||||
size_t filenameSize = filename.size(); // size in bytes, not characters
|
||||
for (size_t i = 0; i < filenameSize; i++)
|
||||
{
|
||||
filename[i] = tolower(filename[i]);
|
||||
}
|
||||
|
||||
return diff;
|
||||
//TODO: lookup filename in cache for "path"
|
||||
struct dirent *result = NULL;
|
||||
|
||||
DIR *dirp = opendir(path.c_str());
|
||||
if (!dirp)
|
||||
return false;
|
||||
|
||||
bool retValue = false;
|
||||
|
||||
while ((result = readdir(dirp)))
|
||||
{
|
||||
if (strlen(result->d_name) != filenameSize)
|
||||
continue;
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < filenameSize; i++)
|
||||
{
|
||||
if (filename[i] != tolower(result->d_name[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < filenameSize)
|
||||
continue;
|
||||
|
||||
filename = result->d_name;
|
||||
retValue = true;
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
bool FixPathCase(const Path &realBasePath, std::string &path, FixPathCaseBehavior behavior) {
|
||||
if (realBasePath.Type() == PathType::CONTENT_URI) {
|
||||
// Nothing to do. These are already case insensitive, I think.
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string basePath = realBasePath.ToString();
|
||||
|
||||
size_t len = path.size();
|
||||
|
||||
if (len == 0)
|
||||
return true;
|
||||
|
||||
if (path[len - 1] == '/')
|
||||
{
|
||||
len--;
|
||||
|
||||
if (len == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string fullPath;
|
||||
fullPath.reserve(basePath.size() + len + 1);
|
||||
fullPath.append(basePath);
|
||||
|
||||
size_t start = 0;
|
||||
while (start < len)
|
||||
{
|
||||
size_t i = path.find('/', start);
|
||||
if (i == std::string::npos)
|
||||
i = len;
|
||||
|
||||
if (i > start)
|
||||
{
|
||||
std::string component = path.substr(start, i - start);
|
||||
|
||||
// Fix case and stop on nonexistant path component
|
||||
if (FixFilenameCase(fullPath, component) == false) {
|
||||
// Still counts as success if partial matches allowed or if this
|
||||
// is the last component and only the ones before it are required
|
||||
return (behavior == FPC_PARTIAL_ALLOWED || (behavior == FPC_PATH_MUST_EXIST && i >= len));
|
||||
}
|
||||
|
||||
path.replace(start, i - start, component);
|
||||
|
||||
fullPath.append(1, '/');
|
||||
fullPath.append(component);
|
||||
}
|
||||
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
+37
-1
@@ -4,6 +4,26 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
#elif TARGET_IPHONE_SIMULATOR
|
||||
#define HOST_IS_CASE_SENSITIVE 0
|
||||
#else
|
||||
// Mac OSX case sensitivity defaults off, but is user configurable (when
|
||||
// creating a filesytem), so assume the worst:
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#define HOST_IS_CASE_SENSITIVE 0
|
||||
|
||||
#else // Android, Linux, BSD (and the rest?)
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
|
||||
#endif
|
||||
|
||||
enum class PathType {
|
||||
UNDEFINED = 0,
|
||||
NATIVE = 1, // Can be relative.
|
||||
@@ -79,9 +99,10 @@ public:
|
||||
|
||||
// Navigates as far up as possible from this path. If not possible to navigate upwards, returns the same path.
|
||||
// Not actually always the root of the volume, especially on systems like Mac and Linux where things are often mounted.
|
||||
// For Android directory trees, navigates to the root of the tree.
|
||||
Path GetRootVolume() const;
|
||||
|
||||
std::string PathTo(const Path &child);
|
||||
bool ComputePathTo(const Path &other, std::string &path) const;
|
||||
|
||||
bool operator ==(const Path &other) const {
|
||||
return path_ == other.path_ && type_ == other.type_;
|
||||
@@ -107,3 +128,18 @@ private:
|
||||
|
||||
PathType type_;
|
||||
};
|
||||
|
||||
|
||||
// Utility function for fixing the case of paths. Only present on Unix-like systems.
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
|
||||
enum FixPathCaseBehavior {
|
||||
FPC_FILE_MUST_EXIST, // all path components must exist (rmdir, move from)
|
||||
FPC_PATH_MUST_EXIST, // all except the last one must exist - still tries to fix last one (fopen, move to)
|
||||
FPC_PARTIAL_ALLOWED, // don't care how many exist (mkdir recursive)
|
||||
};
|
||||
|
||||
bool FixPathCase(const Path &basePath, std::string &path, FixPathCaseBehavior behavior);
|
||||
|
||||
#endif
|
||||
@@ -38,10 +38,11 @@ bool LoadRemoteFileList(const Path &url, bool *cancel, std::vector<File::FileInf
|
||||
}
|
||||
|
||||
// Start by requesting the list of files from the server.
|
||||
http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8");
|
||||
if (http.Resolve(baseURL.Host().c_str(), baseURL.Port())) {
|
||||
if (http.Connect(2, 20.0, cancel)) {
|
||||
http::RequestProgress progress(cancel);
|
||||
code = http.GET(baseURL.Resource().c_str(), &result, responseHeaders, &progress);
|
||||
code = http.GET(req, &result, responseHeaders, &progress);
|
||||
http.Disconnect();
|
||||
}
|
||||
}
|
||||
@@ -144,11 +145,14 @@ void PathBrowser::HandlePath() {
|
||||
|
||||
std::unique_lock<std::mutex> guard(pendingLock_);
|
||||
std::vector<File::FileInfo> results;
|
||||
Path lastPath;
|
||||
Path lastPath("NONSENSE THAT WONT EQUAL A PATH");
|
||||
while (!pendingStop_) {
|
||||
while (lastPath == pendingPath_ && !pendingCancel_) {
|
||||
pendingCond_.wait(guard);
|
||||
}
|
||||
if (pendingStop_) {
|
||||
break;
|
||||
}
|
||||
lastPath = pendingPath_;
|
||||
bool success = false;
|
||||
if (lastPath.Type() == PathType::HTTP) {
|
||||
@@ -156,11 +160,13 @@ void PathBrowser::HandlePath() {
|
||||
results.clear();
|
||||
success = LoadRemoteFileList(lastPath, &pendingCancel_, results);
|
||||
guard.lock();
|
||||
} else if (lastPath.empty()) {
|
||||
results.clear();
|
||||
success = true;
|
||||
} else {
|
||||
guard.unlock();
|
||||
results.clear();
|
||||
File::GetFilesInDir(lastPath, &results, nullptr);
|
||||
success = true;
|
||||
success = File::GetFilesInDir(lastPath, &results, nullptr);
|
||||
guard.lock();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,18 @@ public:
|
||||
|
||||
bool CanNavigateUp();
|
||||
void NavigateUp();
|
||||
|
||||
void Navigate(const std::string &subdir);
|
||||
|
||||
Path GetPath() const {
|
||||
const Path &GetPath() const {
|
||||
return path_;
|
||||
}
|
||||
std::string GetFriendlyPath() const;
|
||||
|
||||
bool empty() const {
|
||||
return path_.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
void HandlePath();
|
||||
void ResetPending();
|
||||
|
||||
@@ -172,7 +172,7 @@ DirectoryAssetReader::DirectoryAssetReader(const Path &path) {
|
||||
|
||||
uint8_t *DirectoryAssetReader::ReadAsset(const char *path, size_t *size) {
|
||||
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
|
||||
return File::ReadLocalFile(new_path.c_str(), size);
|
||||
return File::ReadLocalFile(new_path, size);
|
||||
}
|
||||
|
||||
bool DirectoryAssetReader::GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = nullptr) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/File/VFS/AssetReader.h"
|
||||
#include "Common/File/AndroidStorage.h"
|
||||
|
||||
struct VFSEntry {
|
||||
const char *prefix;
|
||||
@@ -32,7 +33,8 @@ static bool IsLocalAbsolutePath(const char *path) {
|
||||
#else
|
||||
bool isWindowsLocal = false;
|
||||
#endif
|
||||
return isUnixLocal || isWindowsLocal;
|
||||
bool isContentURI = Android_IsContentUri(path);
|
||||
return isUnixLocal || isWindowsLocal || isContentURI;
|
||||
}
|
||||
|
||||
// The returned data should be free'd with delete[].
|
||||
@@ -40,7 +42,7 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) {
|
||||
if (IsLocalAbsolutePath(filename)) {
|
||||
// Local path, not VFS.
|
||||
// INFO_LOG(IO, "Not a VFS path: %s . Reading local file.", filename);
|
||||
return File::ReadLocalFile(filename, size);
|
||||
return File::ReadLocalFile(Path(filename), size);
|
||||
}
|
||||
|
||||
int fn_len = (int)strlen(filename);
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
void BindSamplerStates(int start, int count, SamplerState **states) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override;
|
||||
void BindIndexBuffer(Buffer *indexBuffer, int offset) override;
|
||||
void BindPipeline(Pipeline *pipeline) override;
|
||||
|
||||
@@ -1163,7 +1163,7 @@ void D3D11DrawContext::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t
|
||||
context_->UpdateSubresource(buf->buf, 0, &box, data, 0, 0);
|
||||
}
|
||||
|
||||
void D3D11DrawContext::BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) {
|
||||
void D3D11DrawContext::BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) {
|
||||
_assert_(start + count <= ARRAY_SIZE(nextVertexBuffers_));
|
||||
// Lazy application
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
@@ -533,7 +533,7 @@ public:
|
||||
s->Apply(device_, start + i);
|
||||
}
|
||||
}
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override {
|
||||
_assert_(start + count <= ARRAY_SIZE(curVBuffers_));
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (D3D9Buffer *)buffers[i];
|
||||
|
||||
@@ -162,7 +162,8 @@ void CheckGLExtensions() {
|
||||
|| vendor == "nouveau") {
|
||||
gl_extensions.gpuVendor = GPU_VENDOR_NVIDIA;
|
||||
} else if (vendor == "Advanced Micro Devices, Inc."
|
||||
|| vendor == "ATI Technologies Inc.") {
|
||||
|| vendor == "ATI Technologies Inc."
|
||||
|| vendor == "AMD") {
|
||||
gl_extensions.gpuVendor = GPU_VENDOR_AMD;
|
||||
} else if (vendor == "Intel"
|
||||
|| vendor == "Intel Inc."
|
||||
@@ -191,7 +192,7 @@ void CheckGLExtensions() {
|
||||
gl_extensions.gpuVendor = GPU_VENDOR_UNKNOWN;
|
||||
}
|
||||
|
||||
INFO_LOG(G3D, "GPU Vendor : %s ; renderer: %s version str: %s ; GLSL version str: %s", cvendor, renderer ? renderer : "N/A", versionStr ? versionStr : "N/A", glslVersionStr ? glslVersionStr : "N/A");
|
||||
INFO_LOG(G3D, "GPU Vendor : %s ; renderer: %s version str: %s ; GLSL version str: %s", cvendor ? cvendor : "N/A", renderer ? renderer : "N/A", versionStr ? versionStr : "N/A", glslVersionStr ? glslVersionStr : "N/A");
|
||||
|
||||
if (renderer) {
|
||||
strncpy(gl_extensions.model, renderer, sizeof(gl_extensions.model));
|
||||
|
||||
@@ -104,7 +104,7 @@ bool glsl_recompile(GLSLProgram *program, std::string *error_message) {
|
||||
program->vshader_mtime = vs.st_mtime;
|
||||
if (!program->vshader_source) {
|
||||
size_t sz;
|
||||
vsh_src.reset((char *)File::ReadLocalFile(program->vshader_filename, &sz));
|
||||
vsh_src.reset((char *)File::ReadLocalFile(Path(program->vshader_filename), &sz));
|
||||
}
|
||||
} else {
|
||||
program->vshader_mtime = 0;
|
||||
@@ -114,7 +114,7 @@ bool glsl_recompile(GLSLProgram *program, std::string *error_message) {
|
||||
program->fshader_mtime = fs.st_mtime;
|
||||
if (!program->fshader_source) {
|
||||
size_t sz;
|
||||
fsh_src.reset((char *)File::ReadLocalFile(program->fshader_filename, &sz));
|
||||
fsh_src.reset((char *)File::ReadLocalFile(Path(program->fshader_filename), &sz));
|
||||
}
|
||||
} else {
|
||||
program->fshader_mtime = 0;
|
||||
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
void BindPipeline(Pipeline *pipeline) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override {
|
||||
_assert_(start + count <= ARRAY_SIZE(curVBuffers_));
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (OpenGLBuffer *)buffers[i];
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#define new DBG_NEW
|
||||
#endif
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
VulkanLogOptions g_LogOptions;
|
||||
|
||||
static const char *validationLayers[] = {
|
||||
@@ -114,6 +116,11 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
|
||||
instance_extensions_enabled_.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
|
||||
if (IsInstanceExtensionAvailable(VK_KHR_DISPLAY_EXTENSION_NAME)) {
|
||||
instance_extensions_enabled_.push_back(VK_KHR_DISPLAY_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
if (IsInstanceExtensionAvailable(VK_EXT_METAL_SURFACE_EXTENSION_NAME)) {
|
||||
instance_extensions_enabled_.push_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME);
|
||||
@@ -769,6 +776,15 @@ VkResult VulkanContext::ReinitSurface() {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
|
||||
case WINDOWSYSTEM_DISPLAY:
|
||||
{
|
||||
VkDisplaySurfaceCreateInfoKHR display{ VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR };
|
||||
display.flags = 0;
|
||||
retval = vkCreateDisplayPlaneSurfaceKHR(instance_, &display, nullptr, &surface_);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
_assert_msg_(false, "Vulkan support for chosen window system not implemented");
|
||||
|
||||
@@ -48,6 +48,9 @@ enum WindowSystem {
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
WINDOWSYSTEM_WAYLAND,
|
||||
#endif
|
||||
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
|
||||
WINDOWSYSTEM_DISPLAY,
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VulkanPhysicalDeviceInfo {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/Log.h"
|
||||
|
||||
#include "Common/GPU/Vulkan/VulkanImage.h"
|
||||
#include "Common/GPU/Vulkan/VulkanMemory.h"
|
||||
#include "Common/Log.h"
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
void VulkanTexture::Wipe() {
|
||||
if (image_) {
|
||||
@@ -209,15 +214,15 @@ void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip, VkImageLayout imag
|
||||
blit.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
blit.srcSubresource.layerCount = 1;
|
||||
blit.srcSubresource.mipLevel = mip - 1;
|
||||
blit.srcOffsets[1].x = width_ >> (mip - 1);
|
||||
blit.srcOffsets[1].y = height_ >> (mip - 1);
|
||||
blit.srcOffsets[1].x = std::max(width_ >> (mip - 1), 1);
|
||||
blit.srcOffsets[1].y = std::max(height_ >> (mip - 1), 1);
|
||||
blit.srcOffsets[1].z = 1;
|
||||
|
||||
blit.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
blit.dstSubresource.layerCount = 1;
|
||||
blit.dstSubresource.mipLevel = mip;
|
||||
blit.dstOffsets[1].x = width_ >> mip;
|
||||
blit.dstOffsets[1].y = height_ >> mip;
|
||||
blit.dstOffsets[1].x = std::max(width_ >> mip, 1);
|
||||
blit.dstOffsets[1].y = std::max(height_ >> mip, 1);
|
||||
blit.dstOffsets[1].z = 1;
|
||||
|
||||
// TODO: We could do better with the image transitions - would be enough with one per level
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
namespace PPSSPP_VK {
|
||||
PFN_vkCreateInstance vkCreateInstance;
|
||||
PFN_vkDestroyInstance vkDestroyInstance;
|
||||
PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
|
||||
@@ -186,6 +187,9 @@ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
|
||||
PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
|
||||
#endif
|
||||
|
||||
PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
|
||||
|
||||
@@ -213,6 +217,9 @@ PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
|
||||
PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
|
||||
PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
|
||||
PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
|
||||
} // namespace PPSSPP_VK
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
#ifdef _WIN32
|
||||
static HINSTANCE vulkanLibrary;
|
||||
@@ -535,6 +542,9 @@ void VulkanLoadInstanceFunctions(VkInstance instance, const VulkanExtensions &en
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
LOAD_INSTANCE_FUNC(instance, vkCreateWaylandSurfaceKHR);
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
|
||||
LOAD_INSTANCE_FUNC(instance, vkCreateDisplayPlaneSurfaceKHR);
|
||||
#endif
|
||||
|
||||
LOAD_INSTANCE_FUNC(instance, vkDestroySurfaceKHR);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "ext/vulkan/vulkan.h"
|
||||
|
||||
namespace PPSSPP_VK {
|
||||
// Putting our own Vulkan function pointers in a namespace ensures that ppsspp_libretro.so doesn't collide with libvulkan.so.
|
||||
extern PFN_vkCreateInstance vkCreateInstance;
|
||||
extern PFN_vkDestroyInstance vkDestroyInstance;
|
||||
extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
|
||||
@@ -184,6 +186,9 @@ extern PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
extern PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
|
||||
extern PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
|
||||
#endif
|
||||
|
||||
extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
|
||||
|
||||
@@ -213,6 +218,7 @@ extern PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
|
||||
extern PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
|
||||
extern PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
|
||||
extern PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
|
||||
} // namespace PPSSPP_VK
|
||||
|
||||
// For fast extension-enabled checks.
|
||||
struct VulkanExtensions {
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/GPU/Vulkan/VulkanMemory.h"
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
VulkanPushBuffer::VulkanPushBuffer(VulkanContext *vulkan, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryPropertyMask)
|
||||
: vulkan_(vulkan), memoryPropertyMask_(memoryPropertyMask), size_(size), usage_(usage) {
|
||||
bool res = AddBuffer();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "VulkanQueueRunner.h"
|
||||
#include "VulkanRenderManager.h"
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
// Debug help: adb logcat -s DEBUG PPSSPPNativeActivity PPSSPP NativeGLView NativeRenderer NativeSurfaceView PowerSaveModeReceiver InputDeviceState
|
||||
|
||||
static void MergeRenderAreaRectInto(VkRect2D *dest, VkRect2D &src) {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||
#endif
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VkRenderPass renderPass, int _width, int _height, const char *tag) : vulkan_(vk) {
|
||||
width = _width;
|
||||
height = _height;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Only draws and binds are handled here, resource creation and allocations are handled as normal -
|
||||
// that's the nice thing with Vulkan.
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
@@ -185,13 +186,22 @@ public:
|
||||
|
||||
// Clamp to curWidth_/curHeight_. Apparently an issue.
|
||||
if ((int)(rc.offset.x + rc.extent.width) > curWidth_) {
|
||||
rc.extent.width = curWidth_ - rc.offset.x;
|
||||
int newWidth = curWidth_ - rc.offset.x;
|
||||
rc.extent.width = std::max(1, newWidth);
|
||||
if (rc.offset.x >= curWidth_) {
|
||||
// Fallback.
|
||||
rc.offset.x = curWidth_ - rc.extent.width;
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)(rc.offset.y + rc.extent.height) > curHeight_) {
|
||||
rc.extent.height = curHeight_ - rc.offset.y;
|
||||
int newHeight = curHeight_ - rc.offset.y;
|
||||
rc.extent.height = std::max(1, newHeight);
|
||||
if (rc.offset.y >= curHeight_) {
|
||||
// Fallback.
|
||||
rc.offset.y = curHeight_ - rc.extent.height;
|
||||
}
|
||||
}
|
||||
_dbg_assert_((int)(rc.offset.x + rc.extent.width) <= curWidth_);
|
||||
_dbg_assert_((int)(rc.offset.y + rc.extent.height) <= curHeight_);
|
||||
curRenderArea_.Apply(rc);
|
||||
|
||||
VkRenderData data{ VKRRenderCommand::SCISSOR };
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
#include "Common/GPU/Vulkan/VulkanLoader.h"
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
namespace Draw {
|
||||
|
||||
// This can actually be replaced with a cast as the values are in the right order.
|
||||
@@ -415,7 +417,7 @@ public:
|
||||
}
|
||||
|
||||
// TODO: Make VKBuffers proper buffers, and do a proper binding model. This is just silly.
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override {
|
||||
_assert_(start + count <= ARRAY_SIZE(curVBuffers_));
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (VKBuffer *)buffers[i];
|
||||
|
||||
+1
-1
@@ -643,7 +643,7 @@ public:
|
||||
|
||||
virtual void BindSamplerStates(int start, int count, SamplerState **state) = 0;
|
||||
virtual void BindTextures(int start, int count, Texture **textures) = 0;
|
||||
virtual void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) = 0;
|
||||
virtual void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) = 0;
|
||||
virtual void BindIndexBuffer(Buffer *indexBuffer, int offset) = 0;
|
||||
|
||||
// Only supports a single dynamic uniform buffer, for maximum compatibility with the old APIs and ease of emulation.
|
||||
|
||||
@@ -17,10 +17,10 @@ const char *GetDeviceName(int deviceId) {
|
||||
case DEVICE_ID_PAD_7: return "pad8";
|
||||
case DEVICE_ID_PAD_8: return "pad9";
|
||||
case DEVICE_ID_PAD_9: return "pad10";
|
||||
case DEVICE_ID_X360_0: return "x360";
|
||||
case DEVICE_ID_X360_1: return "x360_2";
|
||||
case DEVICE_ID_X360_2: return "x360_3";
|
||||
case DEVICE_ID_X360_3: return "x360_4";
|
||||
case DEVICE_ID_XINPUT_0: return "x360"; // keeping these strings for backward compat
|
||||
case DEVICE_ID_XINPUT_1: return "x360_2";
|
||||
case DEVICE_ID_XINPUT_2: return "x360_3";
|
||||
case DEVICE_ID_XINPUT_3: return "x360_4";
|
||||
case DEVICE_ID_ACCELEROMETER: return "accelerometer";
|
||||
case DEVICE_ID_MOUSE: return "mouse";
|
||||
default:
|
||||
|
||||
@@ -28,10 +28,10 @@ enum {
|
||||
DEVICE_ID_PAD_7 = 17,
|
||||
DEVICE_ID_PAD_8 = 18,
|
||||
DEVICE_ID_PAD_9 = 19,
|
||||
DEVICE_ID_X360_0 = 20, // XInput joypads
|
||||
DEVICE_ID_X360_1 = 21,
|
||||
DEVICE_ID_X360_2 = 22,
|
||||
DEVICE_ID_X360_3 = 23,
|
||||
DEVICE_ID_XINPUT_0 = 20, // XInput joypads
|
||||
DEVICE_ID_XINPUT_1 = 21,
|
||||
DEVICE_ID_XINPUT_2 = 22,
|
||||
DEVICE_ID_XINPUT_3 = 23,
|
||||
DEVICE_ID_ACCELEROMETER = 30,
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ enum {
|
||||
PAD_BUTTON_LEFT_TRIGGER = 1 << 21, // Click left thumb stick on X360
|
||||
PAD_BUTTON_RIGHT_TRIGGER = 1 << 22, // Click left thumb stick on X360
|
||||
|
||||
PAD_BUTTON_UNTHROTTLE = 1 << 20, // Click Tab to unthrottle
|
||||
PAD_BUTTON_FASTFORWARD = 1 << 20, // Click Tab to unthrottle
|
||||
};
|
||||
|
||||
#ifndef MAX_KEYQUEUESIZE
|
||||
|
||||
+1
-1
@@ -53,6 +53,6 @@ private:
|
||||
size_t vm_size;
|
||||
vm_address_t vm_mem; // same type as vm_address_t
|
||||
#else
|
||||
int fd;
|
||||
int fd = -1;
|
||||
#endif
|
||||
};
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#if !defined(_WIN32) && !defined(ANDROID) && !defined(__APPLE__)
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
@@ -51,21 +52,34 @@ bool MemArena::NeedsProbing() {
|
||||
}
|
||||
|
||||
bool MemArena::GrabMemSpace(size_t size) {
|
||||
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
constexpr mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
|
||||
// Some platforms (like Raspberry Pi) end up flushing to disk.
|
||||
// To avoid this, we try to use /dev/shm (tmpfs) if it exists.
|
||||
fd = -1;
|
||||
if (File::Exists(Path(tmpfs_location))) {
|
||||
// Try a few times in case multiple instances are started near each other.
|
||||
char ram_temp_filename[128]{};
|
||||
bool is_shm = false;
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
snprintf(ram_temp_filename, sizeof(ram_temp_filename), "/ppsspp_%d.ram", i);
|
||||
// This opens atomically, so will fail if another process is starting.
|
||||
fd = open(ram_temp_filename, O_RDWR | O_CREAT | O_EXCL, mode);
|
||||
if (fd >= 0) {
|
||||
INFO_LOG(MEMMAP, "Got shm file: %s", ram_temp_filename);
|
||||
is_shm = true;
|
||||
// Our handle persists per POSIX, so no need to keep it around.
|
||||
if (shm_unlink(ram_temp_filename) != 0) {
|
||||
WARN_LOG(MEMMAP, "Failed to shm_unlink %s", ram_temp_file.c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to old tmpfs behavior.
|
||||
if (fd < 0 && File::Exists(Path(tmpfs_location))) {
|
||||
fd = open(tmpfs_ram_temp_file.c_str(), O_RDWR | O_CREAT, mode);
|
||||
if (fd >= 0) {
|
||||
// Great, this definitely shouldn't flush to disk.
|
||||
ram_temp_file = tmpfs_ram_temp_file;
|
||||
} else {
|
||||
INFO_LOG(MEMMAP, "Got tmpfs ram file: %s", tmpfs_ram_temp_file.c_str());
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(MEMMAP, "'%s' does not exist. Trying other ram file options.", tmpfs_location.c_str());
|
||||
}
|
||||
|
||||
if (fd < 0) {
|
||||
@@ -77,7 +91,7 @@ bool MemArena::GrabMemSpace(size_t size) {
|
||||
return false;
|
||||
}
|
||||
// delete immediately, we keep the fd so it still lives
|
||||
if (unlink(ram_temp_file.c_str()) != 0) {
|
||||
if (!is_shm && unlink(ram_temp_file.c_str()) != 0) {
|
||||
WARN_LOG(MEMMAP, "Failed to unlink %s", ram_temp_file.c_str());
|
||||
}
|
||||
if (ftruncate(fd, size) != 0) {
|
||||
|
||||
+23
-16
@@ -243,11 +243,10 @@ void DeChunk(Buffer *inbuffer, Buffer *outbuffer, int contentLength, float *prog
|
||||
}
|
||||
}
|
||||
|
||||
int Client::GET(const char *resource, Buffer *output, std::vector<std::string> &responseHeaders, RequestProgress *progress) {
|
||||
int Client::GET(const RequestParams &req, Buffer *output, std::vector<std::string> &responseHeaders, RequestProgress *progress) {
|
||||
const char *otherHeaders =
|
||||
"Accept: */*\r\n"
|
||||
"Accept-Encoding: gzip\r\n";
|
||||
int err = SendRequest("GET", resource, otherHeaders, progress);
|
||||
int err = SendRequest("GET", req, otherHeaders, progress);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
@@ -265,20 +264,20 @@ int Client::GET(const char *resource, Buffer *output, std::vector<std::string> &
|
||||
return code;
|
||||
}
|
||||
|
||||
int Client::GET(const char *resource, Buffer *output, RequestProgress *progress) {
|
||||
int Client::GET(const RequestParams &req, Buffer *output, RequestProgress *progress) {
|
||||
std::vector<std::string> responseHeaders;
|
||||
int code = GET(resource, output, responseHeaders, progress);
|
||||
int code = GET(req, output, responseHeaders, progress);
|
||||
return code;
|
||||
}
|
||||
|
||||
int Client::POST(const char *resource, const std::string &data, const std::string &mime, Buffer *output, RequestProgress *progress) {
|
||||
int Client::POST(const RequestParams &req, const std::string &data, const std::string &mime, Buffer *output, RequestProgress *progress) {
|
||||
char otherHeaders[2048];
|
||||
if (mime.empty()) {
|
||||
snprintf(otherHeaders, sizeof(otherHeaders), "Content-Length: %lld\r\n", (long long)data.size());
|
||||
} else {
|
||||
snprintf(otherHeaders, sizeof(otherHeaders), "Content-Length: %lld\r\nContent-Type: %s\r\n", (long long)data.size(), mime.c_str());
|
||||
}
|
||||
int err = SendRequestWithData("POST", resource, data, otherHeaders, progress);
|
||||
int err = SendRequestWithData("POST", req, data, otherHeaders, progress);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
@@ -297,15 +296,15 @@ int Client::POST(const char *resource, const std::string &data, const std::strin
|
||||
return code;
|
||||
}
|
||||
|
||||
int Client::POST(const char *resource, const std::string &data, Buffer *output, RequestProgress *progress) {
|
||||
return POST(resource, data, "", output, progress);
|
||||
int Client::POST(const RequestParams &req, const std::string &data, Buffer *output, RequestProgress *progress) {
|
||||
return POST(req, data, "", output, progress);
|
||||
}
|
||||
|
||||
int Client::SendRequest(const char *method, const char *resource, const char *otherHeaders, RequestProgress *progress) {
|
||||
return SendRequestWithData(method, resource, "", otherHeaders, progress);
|
||||
int Client::SendRequest(const char *method, const RequestParams &req, const char *otherHeaders, RequestProgress *progress) {
|
||||
return SendRequestWithData(method, req, "", otherHeaders, progress);
|
||||
}
|
||||
|
||||
int Client::SendRequestWithData(const char *method, const char *resource, const std::string &data, const char *otherHeaders, RequestProgress *progress) {
|
||||
int Client::SendRequestWithData(const char *method, const RequestParams &req, const std::string &data, const char *otherHeaders, RequestProgress *progress) {
|
||||
progress->progress = 0.01f;
|
||||
|
||||
net::Buffer buffer;
|
||||
@@ -313,14 +312,16 @@ int Client::SendRequestWithData(const char *method, const char *resource, const
|
||||
"%s %s HTTP/%s\r\n"
|
||||
"Host: %s\r\n"
|
||||
"User-Agent: %s\r\n"
|
||||
"Accept: %s\r\n"
|
||||
"Connection: close\r\n"
|
||||
"%s"
|
||||
"\r\n";
|
||||
|
||||
buffer.Printf(tpl,
|
||||
method, resource, httpVersion_,
|
||||
method, req.resource.c_str(), httpVersion_,
|
||||
host_.c_str(),
|
||||
userAgent_.c_str(),
|
||||
req.acceptMime,
|
||||
otherHeaders ? otherHeaders : "");
|
||||
buffer.Append(data);
|
||||
bool flushed = buffer.FlushSocket(sock(), dataTimeout_, progress->cancelled);
|
||||
@@ -508,7 +509,8 @@ int Download::PerformGET(const std::string &url) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return client.GET(fileUrl.Resource().c_str(), &buffer_, responseHeaders_, &progress_);
|
||||
RequestParams req(fileUrl.Resource(), acceptMime_);
|
||||
return client.GET(req, &buffer_, responseHeaders_, &progress_);
|
||||
}
|
||||
|
||||
std::string Download::RedirectLocation(const std::string &baseUrl) {
|
||||
@@ -569,8 +571,10 @@ void Download::Do() {
|
||||
completed_ = true;
|
||||
}
|
||||
|
||||
std::shared_ptr<Download> Downloader::StartDownload(const std::string &url, const Path &outfile) {
|
||||
std::shared_ptr<Download> Downloader::StartDownload(const std::string &url, const Path &outfile, const char *acceptMime) {
|
||||
std::shared_ptr<Download> dl(new Download(url, outfile));
|
||||
if (acceptMime)
|
||||
dl->SetAccept(acceptMime);
|
||||
downloads_.push_back(dl);
|
||||
dl->Start();
|
||||
return dl;
|
||||
@@ -579,8 +583,11 @@ std::shared_ptr<Download> Downloader::StartDownload(const std::string &url, cons
|
||||
std::shared_ptr<Download> Downloader::StartDownloadWithCallback(
|
||||
const std::string &url,
|
||||
const Path &outfile,
|
||||
std::function<void(Download &)> callback) {
|
||||
std::function<void(Download &)> callback,
|
||||
const char *acceptMime) {
|
||||
std::shared_ptr<Download> dl(new Download(url, outfile));
|
||||
if (acceptMime)
|
||||
dl->SetAccept(acceptMime);
|
||||
dl->SetCallback(callback);
|
||||
downloads_.push_back(dl);
|
||||
dl->Start();
|
||||
|
||||
+24
-8
@@ -53,23 +53,32 @@ struct RequestProgress {
|
||||
bool *cancelled = nullptr;
|
||||
};
|
||||
|
||||
struct RequestParams {
|
||||
RequestParams() {}
|
||||
explicit RequestParams(const char *r) : resource(r) {}
|
||||
RequestParams(const std::string &r, const char *a) : resource(r), acceptMime(a) {}
|
||||
|
||||
std::string resource;
|
||||
const char *acceptMime = "*/*";
|
||||
};
|
||||
|
||||
class Client : public net::Connection {
|
||||
public:
|
||||
Client();
|
||||
~Client();
|
||||
|
||||
// Return value is the HTTP return code. 200 means OK. < 0 means some local error.
|
||||
int GET(const char *resource, Buffer *output, RequestProgress *progress);
|
||||
int GET(const char *resource, Buffer *output, std::vector<std::string> &responseHeaders, RequestProgress *progress);
|
||||
int GET(const RequestParams &req, Buffer *output, RequestProgress *progress);
|
||||
int GET(const RequestParams &req, Buffer *output, std::vector<std::string> &responseHeaders, RequestProgress *progress);
|
||||
|
||||
// Return value is the HTTP return code.
|
||||
int POST(const char *resource, const std::string &data, const std::string &mime, Buffer *output, RequestProgress *progress);
|
||||
int POST(const char *resource, const std::string &data, Buffer *output, RequestProgress *progress);
|
||||
int POST(const RequestParams &req, const std::string &data, const std::string &mime, Buffer *output, RequestProgress *progress);
|
||||
int POST(const RequestParams &req, const std::string &data, Buffer *output, RequestProgress *progress);
|
||||
|
||||
// HEAD, PUT, DELETE aren't implemented yet, but can be done with SendRequest.
|
||||
|
||||
int SendRequest(const char *method, const char *resource, const char *otherHeaders, RequestProgress *progress);
|
||||
int SendRequestWithData(const char *method, const char *resource, const std::string &data, const char *otherHeaders, RequestProgress *progress);
|
||||
int SendRequest(const char *method, const RequestParams &req, const char *otherHeaders, RequestProgress *progress);
|
||||
int SendRequestWithData(const char *method, const RequestParams &req, const std::string &data, const char *otherHeaders, RequestProgress *progress);
|
||||
int ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &responseHeaders, RequestProgress *progress);
|
||||
// If your response contains a response, you must read it.
|
||||
int ReadResponseEntity(net::Buffer *readbuf, const std::vector<std::string> &responseHeaders, Buffer *output, RequestProgress *progress);
|
||||
@@ -111,6 +120,10 @@ public:
|
||||
std::string url() const { return url_; }
|
||||
const Path &outfile() const { return outfile_; }
|
||||
|
||||
void SetAccept(const char *mime) {
|
||||
acceptMime_ = mime;
|
||||
}
|
||||
|
||||
// If not downloading to a file, access this to get the result.
|
||||
Buffer &buffer() { return buffer_; }
|
||||
const Buffer &buffer() const { return buffer_; }
|
||||
@@ -144,12 +157,14 @@ private:
|
||||
int PerformGET(const std::string &url);
|
||||
std::string RedirectLocation(const std::string &baseUrl);
|
||||
void SetFailed(int code);
|
||||
|
||||
RequestProgress progress_;
|
||||
Buffer buffer_;
|
||||
std::vector<std::string> responseHeaders_;
|
||||
std::string url_;
|
||||
Path outfile_;
|
||||
std::thread thread_;
|
||||
const char *acceptMime_ = "*/*";
|
||||
int resultCode_ = 0;
|
||||
bool completed_ = false;
|
||||
bool failed_ = false;
|
||||
@@ -167,12 +182,13 @@ public:
|
||||
CancelAll();
|
||||
}
|
||||
|
||||
std::shared_ptr<Download> StartDownload(const std::string &url, const Path &outfile);
|
||||
std::shared_ptr<Download> StartDownload(const std::string &url, const Path &outfile, const char *acceptMime = nullptr);
|
||||
|
||||
std::shared_ptr<Download> StartDownloadWithCallback(
|
||||
const std::string &url,
|
||||
const Path &outfile,
|
||||
std::function<void(Download &)> callback);
|
||||
std::function<void(Download &)> callback,
|
||||
const char *acceptMime = nullptr);
|
||||
|
||||
// Drops finished downloads from the list.
|
||||
void Update();
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
enum {
|
||||
// Enough?
|
||||
MAX_VERTS = 65536,
|
||||
};
|
||||
|
||||
DrawBuffer::DrawBuffer() : count_(0), atlas(0) {
|
||||
verts_ = new Vertex[MAX_VERTS];
|
||||
fontscalex = 1.0f;
|
||||
@@ -123,17 +118,17 @@ void DrawBuffer::Rect(float x, float y, float w, float h, uint32_t color, int al
|
||||
}
|
||||
|
||||
void DrawBuffer::hLine(float x1, float y, float x2, uint32_t color) {
|
||||
// Round Y to the closest full pixel, since we're making it 1-pixel-thin.
|
||||
y -= fmodf(y, pixel_in_dps_y);
|
||||
Rect(x1, y, x2 - x1, pixel_in_dps_y, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::vLine(float x, float y1, float y2, uint32_t color) {
|
||||
// Round X to the closest full pixel, since we're making it 1-pixel-thin.
|
||||
x -= fmodf(x, pixel_in_dps_x);
|
||||
Rect(x, y1, pixel_in_dps_x, y2 - y1, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::vLineAlpha50(float x, float y1, float y2, uint32_t color) {
|
||||
Rect(x, y1, pixel_in_dps_x, y2 - y1, (color | 0xFF000000) & 0x7F000000);
|
||||
}
|
||||
|
||||
void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32_t colorTop, uint32_t colorBottom) {
|
||||
V(x, y, 0, colorTop, 0, 0);
|
||||
V(x + w, y, 0, colorTop, 1, 0);
|
||||
@@ -311,7 +306,56 @@ void DrawBuffer::DrawImageRotated(ImageID atlas_image, float x, float y, float s
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add arc support
|
||||
void DrawBuffer::DrawImageRotatedStretch(ImageID atlas_image, const Bounds &bounds, float scales[2], float angle, Color color, bool mirror_h) {
|
||||
const AtlasImage *image = atlas->getImage(atlas_image);
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
if (scales[0] == 0.0f || scales[1] == 0.0f) {
|
||||
float rotatedSize[2]{ (float)image->w, (float)image->h };
|
||||
rot(rotatedSize, angle, 0.0f, 0.0f);
|
||||
|
||||
// With that, we calculate the scale to stretch to, and rotate it back.
|
||||
scales[0] = bounds.w / rotatedSize[0];
|
||||
scales[1] = bounds.h / rotatedSize[1];
|
||||
rot(scales, -angle, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
float w = (float)image->w * scales[0];
|
||||
float h = (float)image->h * scales[1];
|
||||
float x1 = bounds.centerX() - w / 2;
|
||||
float x2 = bounds.centerX() + w / 2;
|
||||
float y1 = bounds.centerY() - h / 2;
|
||||
float y2 = bounds.centerY() + h / 2;
|
||||
float v[6][2] = {
|
||||
{x1, y1},
|
||||
{x2, y1},
|
||||
{x2, y2},
|
||||
{x1, y1},
|
||||
{x2, y2},
|
||||
{x1, y2},
|
||||
};
|
||||
float u1 = image->u1;
|
||||
float u2 = image->u2;
|
||||
if (mirror_h) {
|
||||
float temp = u1;
|
||||
u1 = u2;
|
||||
u2 = temp;
|
||||
}
|
||||
const float uv[6][2] = {
|
||||
{u1, image->v1},
|
||||
{u2, image->v1},
|
||||
{u2, image->v2},
|
||||
{u1, image->v1},
|
||||
{u2, image->v2},
|
||||
{u1, image->v2},
|
||||
};
|
||||
for (int i = 0; i < 6; i++) {
|
||||
rot(v[i], angle, bounds.centerX(), bounds.centerY());
|
||||
V(v[i][0], v[i][1], 0, color, uv[i][0], uv[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBuffer::Circle(float xc, float yc, float radius, float thickness, int segments, float startAngle, uint32_t color, float u_mul) {
|
||||
float angleDelta = PI * 2 / segments;
|
||||
float uDelta = 1.0f / segments;
|
||||
@@ -327,12 +371,31 @@ void DrawBuffer::Circle(float xc, float yc, float radius, float thickness, int s
|
||||
float c1 = cosf(angle1), s1 = sinf(angle1), c2 = cosf(angle2), s2 = sinf(angle2);
|
||||
const float x[4] = {c1 * r1 + xc, c2 * r1 + xc, c1 * r2 + xc, c2 * r2 + xc};
|
||||
const float y[4] = {s1 * r1 + yc, s2 * r1 + yc, s1 * r2 + yc, s2 * r2 + yc};
|
||||
V(x[0], y[0], color, u1, 0);
|
||||
V(x[1], y[1], color, u2, 0);
|
||||
V(x[2], y[2], color, u1, 1);
|
||||
V(x[1], y[1], color, u2, 0);
|
||||
V(x[3], y[3], color, u2, 1);
|
||||
V(x[2], y[2], color, u1, 1);
|
||||
V(x[0], y[0], color, u1, 0.0f);
|
||||
V(x[1], y[1], color, u2, 0.0f);
|
||||
V(x[2], y[2], color, u1, 1.0f);
|
||||
V(x[1], y[1], color, u2, 0.0f);
|
||||
V(x[3], y[3], color, u2, 1.0f);
|
||||
V(x[2], y[2], color, u1, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBuffer::FillCircle(float xc, float yc, float radius, int segments, uint32_t color) {
|
||||
float angleDelta = PI * 2 / segments;
|
||||
float uDelta = 1.0f / segments;
|
||||
float r1 = radius;
|
||||
for (int i = 0; i < segments + 1; i++) {
|
||||
float angle1 = i * angleDelta;
|
||||
float angle2 = (i + 1) * angleDelta;
|
||||
float u1 = i * uDelta;
|
||||
float u2 = (i + 1) * uDelta;
|
||||
// TODO: get rid of one pair of cos/sin per loop, can reuse from last iteration
|
||||
float c1 = cosf(angle1), s1 = sinf(angle1), c2 = cosf(angle2), s2 = sinf(angle2);
|
||||
const float x[2] = { c1 * r1 + xc, c2 * r1 + xc };
|
||||
const float y[2] = { s1 * r1 + yc, s2 * r1 + yc };
|
||||
V(xc, yc, color, 0.0f, 0.0f);
|
||||
V(x[0], y[0], color, u1, 0.0f);
|
||||
V(x[1], y[1], color, u2, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
|
||||
struct Atlas;
|
||||
|
||||
enum {
|
||||
// Enough?
|
||||
MAX_VERTS = 65536,
|
||||
};
|
||||
|
||||
enum {
|
||||
ALIGN_LEFT = 0,
|
||||
ALIGN_RIGHT = 16,
|
||||
@@ -73,7 +78,6 @@ public:
|
||||
void Rect(float x, float y, float w, float h, uint32_t color, int align = ALIGN_TOPLEFT);
|
||||
void hLine(float x1, float y, float x2, uint32_t color);
|
||||
void vLine(float x, float y1, float y2, uint32_t color);
|
||||
void vLineAlpha50(float x, float y1, float y2, uint32_t color);
|
||||
|
||||
void Line(ImageID atlas_image, float x1, float y1, float x2, float y2, float thickness, uint32_t color);
|
||||
|
||||
@@ -97,6 +101,7 @@ public:
|
||||
}
|
||||
|
||||
void Circle(float x, float y, float radius, float thickness, int segments, float startAngle, uint32_t color, float u_mul);
|
||||
void FillCircle(float x, float y, float radius, int segments, uint32_t color);
|
||||
|
||||
// New drawing APIs
|
||||
|
||||
@@ -116,6 +121,7 @@ public:
|
||||
DrawImageStretch(atlas_image, bounds.x, bounds.y, bounds.x2(), bounds.y2(), color);
|
||||
}
|
||||
void DrawImageRotated(ImageID atlas_image, float x, float y, float scale, float angle, Color color = COLOR(0xFFFFFF), bool mirror_h = false); // Always centers
|
||||
void DrawImageRotatedStretch(ImageID atlas_image, const Bounds &bounds, float scales[2], float angle, Color color = COLOR(0xFFFFFF), bool mirror_h = false);
|
||||
void DrawTexRect(float x1, float y1, float x2, float y2, float u1, float v1, float u2, float v2, Color color);
|
||||
void DrawTexRect(const Bounds &bounds, float u1, float v1, float u2, float v2, Color color) {
|
||||
DrawTexRect(bounds.x, bounds.y, bounds.x2(), bounds.y2(), u1, v1, u2, v2, color);
|
||||
|
||||
@@ -221,6 +221,9 @@ void TextDrawerAndroid::DrawStringBitmap(std::vector<uint8_t> &bitmapData, TextS
|
||||
|
||||
void TextDrawerAndroid::DrawString(DrawBuffer &target, const char *str, float x, float y, uint32_t color, int align) {
|
||||
using namespace Draw;
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
std::string text(NormalizeString(std::string(str)));
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#if PPSSPP_ARCH(RISCV64)
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
// Only Linux platforms have /proc/cpuinfo
|
||||
#if defined(__linux__)
|
||||
const char procfile[] = "/proc/cpuinfo";
|
||||
// https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu
|
||||
const char syscpupresentfile[] = "/sys/devices/system/cpu/present";
|
||||
|
||||
std::string GetCPUString() {
|
||||
//TODO
|
||||
std::string cpu_string;
|
||||
cpu_string = "Unknown";
|
||||
return cpu_string;
|
||||
}
|
||||
|
||||
std::string GetCPUBrandString() {
|
||||
//TODO
|
||||
std::string brand_string;
|
||||
brand_string = "Unknown";
|
||||
return brand_string;
|
||||
}
|
||||
|
||||
int GetCoreCount()
|
||||
{
|
||||
std::string line, marker = "processor\t: ";
|
||||
int cores = 1;
|
||||
|
||||
std::string presentData;
|
||||
bool presentSuccess = File::ReadFileToString(true, Path(syscpupresentfile), presentData);
|
||||
std::istringstream presentFile(presentData);
|
||||
|
||||
if (presentSuccess) {
|
||||
int low, high, found;
|
||||
std::getline(presentFile, line);
|
||||
found = sscanf(line.c_str(), "%d-%d", &low, &high);
|
||||
if (found == 1)
|
||||
return 1;
|
||||
if (found == 2)
|
||||
return high - low + 1;
|
||||
}
|
||||
|
||||
std::string procdata;
|
||||
if (!File::ReadFileToString(true, Path(procfile), procdata))
|
||||
return 1;
|
||||
std::istringstream file(procdata);
|
||||
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
if (line.find(marker) != std::string::npos)
|
||||
++cores;
|
||||
}
|
||||
|
||||
return cores;
|
||||
}
|
||||
#endif
|
||||
|
||||
CPUInfo cpu_info;
|
||||
|
||||
CPUInfo::CPUInfo() {
|
||||
Detect();
|
||||
}
|
||||
|
||||
// Detects the various cpu features
|
||||
void CPUInfo::Detect()
|
||||
{
|
||||
// Set some defaults here
|
||||
HTT = false;
|
||||
#if PPSSPP_ARCH(RISCV64)
|
||||
OS64bit = true;
|
||||
CPU64bit = true;
|
||||
Mode64bit = true;
|
||||
#else
|
||||
OS64bit = false;
|
||||
CPU64bit = false;
|
||||
Mode64bit = false;
|
||||
#endif
|
||||
vendor = VENDOR_OTHER;
|
||||
logical_cpu_count = 1;
|
||||
|
||||
// Get the information about the CPU
|
||||
#if !defined(__linux__)
|
||||
num_cores = 1;
|
||||
#else // __linux__
|
||||
truncate_cpy(cpu_string, GetCPUString().c_str());
|
||||
truncate_cpy(brand_string, GetCPUBrandString().c_str());
|
||||
num_cores = GetCoreCount();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Turn the cpu info into a string we can show
|
||||
std::string CPUInfo::Summarize()
|
||||
{
|
||||
std::string sum;
|
||||
if (num_cores == 1)
|
||||
sum = StringFromFormat("%s, %i core", cpu_string, num_cores);
|
||||
else
|
||||
sum = StringFromFormat("%s, %i cores", cpu_string, num_cores);
|
||||
if (CPU64bit) sum += ", 64-bit";
|
||||
|
||||
//TODO: parse "isa : rv64imafdc" from /proc/cpuinfo
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
#endif // PPSSPP_ARCH(RISCV64)
|
||||
@@ -25,6 +25,14 @@
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
enum class SerializeCompressType {
|
||||
NONE = 0,
|
||||
SNAPPY = 1,
|
||||
ZSTD = 2,
|
||||
};
|
||||
|
||||
static constexpr SerializeCompressType SAVE_TYPE = SerializeCompressType::ZSTD;
|
||||
|
||||
PointerWrapSection PointerWrap::Section(const char *title, int ver) {
|
||||
return Section(title, ver, ver);
|
||||
}
|
||||
@@ -289,12 +297,17 @@ CChunkFileReader::Error CChunkFileReader::LoadFile(const Path &filename, std::st
|
||||
u8 *uncomp_buffer = new u8[header.UncompressedSize];
|
||||
size_t uncomp_size = header.UncompressedSize;
|
||||
bool success = false;
|
||||
if (header.Compress == 1) {
|
||||
if (SerializeCompressType(header.Compress) == SerializeCompressType::SNAPPY) {
|
||||
auto status = snappy_uncompress((const char *)buffer, sz, (char *)uncomp_buffer, &uncomp_size);
|
||||
success = status == SNAPPY_OK;
|
||||
} else {
|
||||
auto status = ZSTD_decompress((char *)uncomp_buffer, uncomp_size, (const char *)buffer, sz);
|
||||
} else if (SerializeCompressType(header.Compress) == SerializeCompressType::ZSTD) {
|
||||
size_t status = ZSTD_decompress((char *)uncomp_buffer, uncomp_size, (const char *)buffer, sz);
|
||||
success = !ZSTD_isError(status);
|
||||
if (success) {
|
||||
uncomp_size = status;
|
||||
}
|
||||
} else {
|
||||
ERROR_LOG(SAVESTATE, "ChunkReader: Unexpected compression type %d", header.Compress);
|
||||
}
|
||||
if (!success) {
|
||||
ERROR_LOG(SAVESTATE, "ChunkReader: Failed to decompress file");
|
||||
@@ -336,24 +349,70 @@ CChunkFileReader::Error CChunkFileReader::SaveFile(const Path &filename, const s
|
||||
}
|
||||
|
||||
// Make sure we can allocate a buffer to compress before compressing.
|
||||
size_t write_len = ZSTD_compressBound(sz);
|
||||
u8 *compressed_buffer = (u8 *)malloc(write_len);
|
||||
size_t write_len;
|
||||
SerializeCompressType usedType = SAVE_TYPE;
|
||||
switch (usedType) {
|
||||
case SerializeCompressType::NONE:
|
||||
write_len = 0;
|
||||
break;
|
||||
case SerializeCompressType::SNAPPY:
|
||||
write_len = snappy_max_compressed_length(sz);
|
||||
break;
|
||||
case SerializeCompressType::ZSTD:
|
||||
write_len = ZSTD_compressBound(sz);
|
||||
break;
|
||||
}
|
||||
u8 *compressed_buffer = write_len == 0 ? nullptr : (u8 *)malloc(write_len);
|
||||
u8 *write_buffer = buffer;
|
||||
if (!compressed_buffer) {
|
||||
ERROR_LOG(SAVESTATE, "ChunkReader: Unable to allocate compressed buffer");
|
||||
if (write_len != 0)
|
||||
ERROR_LOG(SAVESTATE, "ChunkReader: Unable to allocate compressed buffer");
|
||||
// We'll save uncompressed. Better than not saving...
|
||||
write_len = sz;
|
||||
usedType = SerializeCompressType::NONE;
|
||||
} else {
|
||||
// TODO: If free disk space is low, we could max this out to 22?
|
||||
write_len = ZSTD_compress(compressed_buffer, write_len, buffer, sz, 1);
|
||||
free(buffer);
|
||||
bool success = true;
|
||||
switch (usedType) {
|
||||
case SerializeCompressType::NONE:
|
||||
_assert_(false);
|
||||
break;
|
||||
case SerializeCompressType::SNAPPY:
|
||||
success = snappy_compress((const char *)buffer, sz, (char *)compressed_buffer, &write_len) == SNAPPY_OK;
|
||||
break;
|
||||
case SerializeCompressType::ZSTD:
|
||||
{
|
||||
auto ctx = ZSTD_createCCtx();
|
||||
if (!ctx) {
|
||||
success = false;
|
||||
} else {
|
||||
// TODO: If free disk space is low, we could max this out to 22?
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_c_compressionLevel, ZSTD_CLEVEL_DEFAULT);
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_c_checksumFlag, 1);
|
||||
ZSTD_CCtx_setPledgedSrcSize(ctx, sz);
|
||||
write_len = ZSTD_compress2(ctx, compressed_buffer, write_len, buffer, sz);
|
||||
success = !ZSTD_isError(write_len);
|
||||
}
|
||||
ZSTD_freeCCtx(ctx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
write_buffer = compressed_buffer;
|
||||
if (success) {
|
||||
free(buffer);
|
||||
write_buffer = compressed_buffer;
|
||||
} else {
|
||||
ERROR_LOG(SAVESTATE, "ChunkReader: Compression failed");
|
||||
free(compressed_buffer);
|
||||
|
||||
// We can still save uncompressed.
|
||||
write_len = sz;
|
||||
usedType = SerializeCompressType::NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// Create header
|
||||
SChunkHeader header{};
|
||||
header.Compress = compressed_buffer ? 2 : 0;
|
||||
header.Compress = (int)usedType;
|
||||
header.Revision = REVISION_CURRENT;
|
||||
header.ExpectedSize = (u32)write_len;
|
||||
header.UncompressedSize = (u32)sz;
|
||||
|
||||
@@ -143,7 +143,8 @@ public:
|
||||
if (p.error != p.ERROR_FAILURE) {
|
||||
return ERROR_NONE;
|
||||
} else {
|
||||
*errorString = std::string("Failure at ") + p.GetBadSectionTitle();
|
||||
std::string badSectionTitle = p.GetBadSectionTitle() ? p.GetBadSectionTitle() : "(unknown bad section)";
|
||||
*errorString = std::string("Failure at ") + badSectionTitle;
|
||||
return ERROR_BROKEN_STATE;
|
||||
}
|
||||
}
|
||||
@@ -159,12 +160,13 @@ public:
|
||||
|
||||
// Expects ptr to have at least MeasurePtr bytes at ptr.
|
||||
template<class T>
|
||||
static Error SavePtr(u8 *ptr, T &_class)
|
||||
static Error SavePtr(u8 *ptr, T &_class, size_t expected_size)
|
||||
{
|
||||
const u8 *expected_end = ptr + expected_size;
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_WRITE);
|
||||
_class.DoState(p);
|
||||
|
||||
if (p.error != p.ERROR_FAILURE) {
|
||||
if (p.error != p.ERROR_FAILURE && (expected_end == ptr || expected_size == 0)) {
|
||||
return ERROR_NONE;
|
||||
} else {
|
||||
return ERROR_BROKEN_STATE;
|
||||
@@ -200,7 +202,7 @@ public:
|
||||
u8 *buffer = (u8 *)malloc(sz);
|
||||
if (!buffer)
|
||||
return ERROR_BAD_ALLOC;
|
||||
Error error = SavePtr(buffer, _class);
|
||||
Error error = SavePtr(buffer, _class, sz);
|
||||
|
||||
// SaveFile takes ownership of buffer
|
||||
if (error == ERROR_NONE)
|
||||
|
||||
@@ -89,3 +89,5 @@ void NativeSetMixer(void* mixer);
|
||||
// Main thread.
|
||||
void NativeShutdownGraphics();
|
||||
void NativeShutdown();
|
||||
|
||||
void PostLoadConfig();
|
||||
@@ -98,7 +98,7 @@ static void WorkerThreadFunc(GlobalThreadContext *global, ThreadContext *thread)
|
||||
}
|
||||
|
||||
void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) {
|
||||
if (!global_->threads_.empty()) {
|
||||
if (IsInitialized()) {
|
||||
Teardown();
|
||||
}
|
||||
|
||||
@@ -118,6 +118,8 @@ void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) {
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTask(Task *task, TaskType taskType) {
|
||||
_assert_msg_(IsInitialized(), "ThreadManager not initialized");
|
||||
|
||||
int maxThread;
|
||||
int threadOffset = 0;
|
||||
if (taskType == TaskType::CPU_COMPUTE) {
|
||||
@@ -158,7 +160,7 @@ void ThreadManager::EnqueueTask(Task *task, TaskType taskType) {
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType) {
|
||||
_assert_(threadNum >= 0 && threadNum < (int)global_->threads_.size());
|
||||
_assert_msg_(threadNum >= 0 && threadNum < (int)global_->threads_.size(), "Bad threadnum or not initialized");
|
||||
ThreadContext *thread = global_->threads_[threadNum];
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(thread->mutex);
|
||||
@@ -172,5 +174,9 @@ int ThreadManager::GetNumLooperThreads() const {
|
||||
}
|
||||
|
||||
void ThreadManager::TryCancelTask(uint64_t taskID) {
|
||||
// Do nothing
|
||||
// Do nothing for now, just let it finish.
|
||||
}
|
||||
|
||||
bool ThreadManager::IsInitialized() const {
|
||||
return !global_->threads_.empty();
|
||||
}
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
void EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType);
|
||||
void Teardown();
|
||||
|
||||
bool IsInitialized() const;
|
||||
|
||||
// Currently does nothing. It will always be best-effort - maybe it cancels,
|
||||
// maybe it doesn't. Note that the id is the id() returned by the task. You need to make that
|
||||
// something meaningful yourself.
|
||||
@@ -58,7 +60,8 @@ public:
|
||||
int GetNumLooperThreads() const;
|
||||
|
||||
private:
|
||||
GlobalThreadContext *global_ = nullptr;
|
||||
// This is always pointing to a context, initialized in the constructor.
|
||||
GlobalThreadContext *global_;
|
||||
|
||||
int numThreads_ = 0;
|
||||
int numComputeThreads_ = 0;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(LINUX)
|
||||
#if (PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(LINUX)) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,12 @@
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <pthread_np.h>
|
||||
#elif defined(__NetBSD__)
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
#ifdef TLS_SUPPORTED
|
||||
static thread_local const char *curThreadName;
|
||||
#endif
|
||||
@@ -119,6 +125,10 @@ void SetCurrentThreadName(const char* threadName) {
|
||||
pthread_setname_np(pthread_self(), threadName);
|
||||
#elif defined(__APPLE__)
|
||||
pthread_setname_np(threadName);
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
pthread_set_name_np(pthread_self(), threadName);
|
||||
#elif defined(__NetBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", (void*)threadName);
|
||||
#endif
|
||||
|
||||
// Do nothing
|
||||
@@ -144,7 +154,7 @@ int GetCurrentThreadIdForDebug() {
|
||||
return 1;
|
||||
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||
return (int)GetCurrentThreadId();
|
||||
#elif PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#elif PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
|
||||
uint64_t tid = 0;
|
||||
pthread_threadid_np(NULL, &tid);
|
||||
return (int)tid;
|
||||
@@ -152,6 +162,12 @@ int GetCurrentThreadIdForDebug() {
|
||||
// See issue 14545
|
||||
return (int)syscall(__NR_gettid);
|
||||
// return (int)gettid();
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||
return pthread_getthreadid_np();
|
||||
#elif defined(__NetBSD__)
|
||||
return _lwp_self();
|
||||
#elif defined(__OpenBSD__)
|
||||
return getthrid();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
+21
-6
@@ -24,7 +24,6 @@ static std::mutex eventMutex_;
|
||||
static std::function<void(UISound)> soundCallback;
|
||||
static bool soundEnabled = true;
|
||||
|
||||
|
||||
struct DispatchQueueItem {
|
||||
Event *e;
|
||||
EventParams params;
|
||||
@@ -195,11 +194,23 @@ static std::set<HeldKey> heldKeys;
|
||||
const double repeatDelay = 15 * (1.0 / 60.0f); // 15 frames like before.
|
||||
const double repeatInterval = 5 * (1.0 / 60.0f); // 5 frames like before.
|
||||
|
||||
bool IsScrollKey(const KeyInput &input) {
|
||||
switch (input.keyCode) {
|
||||
case NKCODE_PAGE_UP:
|
||||
case NKCODE_PAGE_DOWN:
|
||||
case NKCODE_MOVE_HOME:
|
||||
case NKCODE_MOVE_END:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool KeyEvent(const KeyInput &key, ViewGroup *root) {
|
||||
bool retval = false;
|
||||
// Ignore repeats for focus moves.
|
||||
if ((key.flags & (KEY_DOWN | KEY_IS_REPEAT)) == KEY_DOWN) {
|
||||
if (IsDPadKey(key)) {
|
||||
if (IsDPadKey(key) || IsScrollKey(key)) {
|
||||
// Let's only repeat DPAD initially.
|
||||
HeldKey hk;
|
||||
hk.key = key.keyCode;
|
||||
@@ -329,10 +340,10 @@ bool AxisEvent(const AxisInput &axis, ViewGroup *root) {
|
||||
case DEVICE_ID_PAD_1:
|
||||
case DEVICE_ID_PAD_2:
|
||||
case DEVICE_ID_PAD_3:
|
||||
case DEVICE_ID_X360_0:
|
||||
case DEVICE_ID_X360_1:
|
||||
case DEVICE_ID_X360_2:
|
||||
case DEVICE_ID_X360_3:
|
||||
case DEVICE_ID_XINPUT_0:
|
||||
case DEVICE_ID_XINPUT_1:
|
||||
case DEVICE_ID_XINPUT_2:
|
||||
case DEVICE_ID_XINPUT_3:
|
||||
{
|
||||
PrevState &old = state[stateKey];
|
||||
DirState dir = DirState::NONE;
|
||||
@@ -399,6 +410,10 @@ void UpdateViewHierarchy(ViewGroup *root) {
|
||||
case NKCODE_DPAD_RIGHT: MoveFocus(root, FOCUS_RIGHT); break;
|
||||
case NKCODE_DPAD_UP: MoveFocus(root, FOCUS_UP); break;
|
||||
case NKCODE_DPAD_DOWN: MoveFocus(root, FOCUS_DOWN); break;
|
||||
case NKCODE_PAGE_UP: MoveFocus(root, FOCUS_PREV_PAGE); break;
|
||||
case NKCODE_PAGE_DOWN: MoveFocus(root, FOCUS_NEXT_PAGE); break;
|
||||
case NKCODE_MOVE_HOME: MoveFocus(root, FOCUS_FIRST); break;
|
||||
case NKCODE_MOVE_END: MoveFocus(root, FOCUS_LAST); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Common/UI/Screen.h"
|
||||
#include "Common/UI/UI.h"
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
@@ -163,6 +164,8 @@ void ScreenManager::render() {
|
||||
iter--;
|
||||
Layer backback = *iter;
|
||||
|
||||
_assert_(backback.screen);
|
||||
|
||||
// TODO: Make really sure that this "mismatched" pre/post only happens
|
||||
// when screens are "compatible" (both are UIScreens, for example).
|
||||
backback.screen->preRender();
|
||||
@@ -174,6 +177,7 @@ void ScreenManager::render() {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_assert_(stack_.back().screen);
|
||||
stack_.back().screen->preRender();
|
||||
stack_.back().screen->render();
|
||||
if (postRenderCb_)
|
||||
@@ -188,6 +192,15 @@ void ScreenManager::render() {
|
||||
processFinishDialog();
|
||||
}
|
||||
|
||||
void ScreenManager::getFocusPosition(float &x, float &y, float &z) {
|
||||
UI::ScrollView::GetLastScrollPosition(x, y);
|
||||
|
||||
UI::View *v = UI::GetFocusedView();
|
||||
x += v ? v->GetBounds().x : 0;
|
||||
y += v ? v->GetBounds().y : 0;
|
||||
z = stack_.size();
|
||||
}
|
||||
|
||||
void ScreenManager::sendMessage(const char *msg, const char *value) {
|
||||
if (!strcmp(msg, "recreateviews"))
|
||||
RecreateAllViews();
|
||||
|
||||
@@ -141,6 +141,8 @@ public:
|
||||
|
||||
Screen *topScreen() const;
|
||||
|
||||
void getFocusPosition(float &x, float &y, float &z);
|
||||
|
||||
std::recursive_mutex inputLock_;
|
||||
|
||||
private:
|
||||
|
||||
@@ -296,6 +296,10 @@ void PopupScreen::SetPopupOrigin(const UI::View *view) {
|
||||
popupOrigin_ = view->GetBounds().Center();
|
||||
}
|
||||
|
||||
void PopupScreen::SetPopupOffset(float y) {
|
||||
offsetY_ = y;
|
||||
}
|
||||
|
||||
void PopupScreen::TriggerFinish(DialogResult result) {
|
||||
if (CanComplete(result)) {
|
||||
finishFrame_ = frames_;
|
||||
@@ -320,7 +324,7 @@ void PopupScreen::CreateViews() {
|
||||
float yres = screenManager()->getUIContext()->GetBounds().h;
|
||||
|
||||
box_ = new LinearLayout(ORIENT_VERTICAL,
|
||||
new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), dc.GetBounds().centerY(), NONE, NONE, true));
|
||||
new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), dc.GetBounds().centerY() + offsetY_, NONE, NONE, true));
|
||||
|
||||
root_->Add(box_);
|
||||
box_->SetBG(dc.theme->popupStyle.background);
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
virtual void TriggerFinish(DialogResult result) override;
|
||||
|
||||
void SetPopupOrigin(const UI::View *view);
|
||||
void SetPopupOffset(float y);
|
||||
|
||||
protected:
|
||||
virtual bool FillVertical() const { return false; }
|
||||
@@ -109,6 +110,7 @@ private:
|
||||
DialogResult finishResult_;
|
||||
bool hasPopupOrigin_ = false;
|
||||
Point popupOrigin_;
|
||||
float offsetY_ = 0.0f;
|
||||
};
|
||||
|
||||
class ListPopupScreen : public PopupScreen {
|
||||
|
||||
+23
-2
@@ -801,6 +801,8 @@ void ImageView::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
const float bulletOffset = 25;
|
||||
|
||||
void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const {
|
||||
Bounds bounds(0, 0, layoutParams_->width, layoutParams_->height);
|
||||
if (bounds.w < 0) {
|
||||
@@ -812,6 +814,10 @@ void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz
|
||||
}
|
||||
ApplyBoundsBySpec(bounds, horiz, vert);
|
||||
dc.MeasureTextRect(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.length(), bounds, &w, &h, textAlign_);
|
||||
|
||||
if (bullet_) {
|
||||
w += bulletOffset;
|
||||
}
|
||||
}
|
||||
|
||||
void TextView::Draw(UIContext &dc) {
|
||||
@@ -838,11 +844,25 @@ void TextView::Draw(UIContext &dc) {
|
||||
dc.FillRect(style.background, bounds_);
|
||||
}
|
||||
dc.SetFontStyle(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont);
|
||||
|
||||
Bounds textBounds = bounds_;
|
||||
|
||||
if (bullet_) {
|
||||
float radius = 7.0f;
|
||||
dc.Flush();
|
||||
dc.BeginNoTex();
|
||||
dc.Draw()->FillCircle(textBounds.x + radius, textBounds.centerY(), radius, 20, textColor);
|
||||
dc.Flush();
|
||||
dc.Begin();
|
||||
textBounds.x += bulletOffset;
|
||||
textBounds.w -= bulletOffset;
|
||||
}
|
||||
|
||||
if (shadow_) {
|
||||
uint32_t shadowColor = 0x80000000;
|
||||
dc.DrawTextRect(text_.c_str(), bounds_.Offset(1.0f, 1.0f), shadowColor, textAlign_);
|
||||
dc.DrawTextRect(text_.c_str(), textBounds.Offset(1.0f, 1.0f), shadowColor, textAlign_);
|
||||
}
|
||||
dc.DrawTextRect(text_.c_str(), bounds_, textColor, textAlign_);
|
||||
dc.DrawTextRect(text_.c_str(), textBounds, textColor, textAlign_);
|
||||
if (small_) {
|
||||
// If we changed font style, reset it.
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
@@ -972,6 +992,7 @@ bool TextEdit::Key(const KeyInput &input) {
|
||||
}
|
||||
break;
|
||||
case NKCODE_ENTER:
|
||||
case NKCODE_NUMPAD_ENTER:
|
||||
{
|
||||
EventParams e{};
|
||||
e.v = this;
|
||||
|
||||
@@ -128,6 +128,10 @@ enum FocusDirection {
|
||||
FOCUS_RIGHT,
|
||||
FOCUS_NEXT,
|
||||
FOCUS_PREV,
|
||||
FOCUS_FIRST,
|
||||
FOCUS_LAST,
|
||||
FOCUS_PREV_PAGE,
|
||||
FOCUS_NEXT_PAGE,
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -177,6 +181,10 @@ inline FocusDirection Opposite(FocusDirection d) {
|
||||
case FOCUS_RIGHT: return FOCUS_LEFT;
|
||||
case FOCUS_PREV: return FOCUS_NEXT;
|
||||
case FOCUS_NEXT: return FOCUS_PREV;
|
||||
case FOCUS_FIRST: return FOCUS_LAST;
|
||||
case FOCUS_LAST: return FOCUS_FIRST;
|
||||
case FOCUS_PREV_PAGE: return FOCUS_NEXT_PAGE;
|
||||
case FOCUS_NEXT_PAGE: return FOCUS_PREV_PAGE;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
@@ -299,6 +307,7 @@ enum LayoutParamsType {
|
||||
LP_PLAIN = 0,
|
||||
LP_LINEAR = 1,
|
||||
LP_ANCHOR = 2,
|
||||
LP_GRID = 3,
|
||||
};
|
||||
|
||||
// Need a virtual destructor so vtables are created, otherwise RTTI can't work
|
||||
@@ -440,6 +449,7 @@ public:
|
||||
|
||||
// Fake RTTI
|
||||
virtual bool IsViewGroup() const { return false; }
|
||||
virtual bool ContainsSubview(const View *view) const { return false; }
|
||||
|
||||
Point GetFocusPosition(FocusDirection dir);
|
||||
|
||||
@@ -841,6 +851,7 @@ public:
|
||||
void SetShadow(bool shadow) { shadow_ = shadow; }
|
||||
void SetFocusable(bool focusable) { focusable_ = focusable; }
|
||||
void SetClip(bool clip) { clip_ = clip; }
|
||||
void SetBullet(bool bullet) { bullet_ = bullet; }
|
||||
|
||||
bool CanBeFocused() const override { return focusable_; }
|
||||
|
||||
@@ -853,6 +864,7 @@ private:
|
||||
bool shadow_;
|
||||
bool focusable_;
|
||||
bool clip_;
|
||||
bool bullet_ = false;
|
||||
};
|
||||
|
||||
class TextEdit : public View {
|
||||
|
||||
+191
-79
@@ -57,6 +57,14 @@ void ViewGroup::RemoveSubview(View *view) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewGroup::ContainsSubview(const View *view) const {
|
||||
for (const View *subview : views_) {
|
||||
if (subview == view || subview->ContainsSubview(view))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ViewGroup::Clear() {
|
||||
std::lock_guard<std::mutex> guard(modifyLock_);
|
||||
for (size_t i = 0; i < views_.size(); i++) {
|
||||
@@ -245,6 +253,7 @@ bool ViewGroup::SubviewFocused(View *view) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns the percentage the smaller one overlaps the bigger one.
|
||||
static float HorizontalOverlap(const Bounds &a, const Bounds &b) {
|
||||
if (a.x2() < b.x || b.x2() < a.x)
|
||||
return 0.0f;
|
||||
@@ -272,7 +281,7 @@ static float VerticalOverlap(const Bounds &a, const Bounds &b) {
|
||||
return std::min(1.0f, overlap / std::min(a.h, b.h));
|
||||
}
|
||||
|
||||
float GetDirectionScore(View *origin, View *destination, FocusDirection direction) {
|
||||
float GetTargetScore(const Point &originPos, int originIndex, View *origin, View *destination, FocusDirection direction) {
|
||||
// Skip labels and things like that.
|
||||
if (!destination->CanBeFocused())
|
||||
return 0.0f;
|
||||
@@ -281,7 +290,6 @@ float GetDirectionScore(View *origin, View *destination, FocusDirection directio
|
||||
if (destination->GetVisibility() != V_VISIBLE)
|
||||
return 0.0f;
|
||||
|
||||
Point originPos = origin->GetFocusPosition(direction);
|
||||
Point destPos = destination->GetFocusPosition(Opposite(direction));
|
||||
|
||||
float dx = destPos.x - originPos.x;
|
||||
@@ -297,8 +305,10 @@ float GetDirectionScore(View *origin, View *destination, FocusDirection directio
|
||||
float horizOverlap = HorizontalOverlap(origin->GetBounds(), destination->GetBounds());
|
||||
float vertOverlap = VerticalOverlap(origin->GetBounds(), destination->GetBounds());
|
||||
if (horizOverlap == 1.0f && vertOverlap == 1.0f) {
|
||||
INFO_LOG(SYSTEM, "Contain overlap");
|
||||
return 0.0;
|
||||
if (direction != FOCUS_PREV_PAGE && direction != FOCUS_NEXT_PAGE) {
|
||||
INFO_LOG(SYSTEM, "Contain overlap");
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
float originSize = 0.0f;
|
||||
switch (direction) {
|
||||
@@ -332,35 +342,45 @@ float GetDirectionScore(View *origin, View *destination, FocusDirection directio
|
||||
}
|
||||
vertical = true;
|
||||
break;
|
||||
case FOCUS_FIRST:
|
||||
if (originIndex == -1)
|
||||
return 0.0f;
|
||||
if (dirX > 0.0f || dirY > 0.0f)
|
||||
return 0.0f;
|
||||
// More distance is good.
|
||||
return distance;
|
||||
case FOCUS_LAST:
|
||||
if (originIndex == -1)
|
||||
return 0.0f;
|
||||
if (dirX < 0.0f || dirY < 0.0f)
|
||||
return 0.0f;
|
||||
// More distance is good.
|
||||
return distance;
|
||||
case FOCUS_PREV_PAGE:
|
||||
case FOCUS_NEXT_PAGE:
|
||||
// Not always, but let's go with the bonus on height.
|
||||
vertical = true;
|
||||
break;
|
||||
case FOCUS_PREV:
|
||||
case FOCUS_NEXT:
|
||||
ERROR_LOG(SYSTEM, "Invalid focus direction");
|
||||
break;
|
||||
}
|
||||
|
||||
// Add a small bonus if the views are the same size. This prioritizes moving to the next item
|
||||
// upwards in a scroll view instead of moving up to the top bar.
|
||||
float distanceBonus = 0.0f;
|
||||
if (vertical) {
|
||||
float widthDifference = origin->GetBounds().w - destination->GetBounds().w;
|
||||
if (widthDifference == 0) {
|
||||
distanceBonus = 40;
|
||||
}
|
||||
} else {
|
||||
float heightDifference = origin->GetBounds().h - destination->GetBounds().h;
|
||||
if (heightDifference == 0) {
|
||||
distanceBonus = 40;
|
||||
}
|
||||
}
|
||||
|
||||
// At large distances, ignore overlap.
|
||||
if (distance > 2 * originSize)
|
||||
overlap = 0;
|
||||
if (distance > 2.0 * originSize)
|
||||
overlap = 0.0f;
|
||||
|
||||
if (wrongDirection)
|
||||
if (wrongDirection) {
|
||||
return 0.0f;
|
||||
else
|
||||
return 10.0f / std::max(1.0f, distance - distanceBonus) + overlap;
|
||||
} else {
|
||||
return 10.0f / std::max(1.0f, distance) + overlap * 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
float GetDirectionScore(int originIndex, View *origin, View *destination, FocusDirection direction) {
|
||||
Point originPos = origin->GetFocusPosition(direction);
|
||||
return GetTargetScore(originPos, originIndex, origin, destination, direction);
|
||||
}
|
||||
|
||||
NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, NeighborResult result) {
|
||||
@@ -378,33 +398,38 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Do the cardinal directions right. Now we just map to
|
||||
// prev/next.
|
||||
if (direction == FOCUS_PREV || direction == FOCUS_NEXT) {
|
||||
switch (direction) {
|
||||
case FOCUS_PREV:
|
||||
// If view not found, no neighbor to find.
|
||||
if (num == -1)
|
||||
return NeighborResult(0, 0.0f);
|
||||
return NeighborResult(views_[(num + views_.size() - 1) % views_.size()], 0.0f);
|
||||
|
||||
case FOCUS_NEXT:
|
||||
// If view not found, no neighbor to find.
|
||||
if (num == -1)
|
||||
return NeighborResult(0, 0.0f);
|
||||
return NeighborResult(views_[(num + 1) % views_.size()], 0.0f);
|
||||
default:
|
||||
return NeighborResult(nullptr, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
switch (direction) {
|
||||
case FOCUS_PREV:
|
||||
// If view not found, no neighbor to find.
|
||||
if (num == -1)
|
||||
return NeighborResult(0, 0.0f);
|
||||
return NeighborResult(views_[(num + views_.size() - 1) % views_.size()], 0.0f);
|
||||
|
||||
case FOCUS_NEXT:
|
||||
// If view not found, no neighbor to find.
|
||||
if (num == -1)
|
||||
return NeighborResult(0, 0.0f);
|
||||
return NeighborResult(views_[(num + 1) % views_.size()], 0.0f);
|
||||
|
||||
case FOCUS_UP:
|
||||
case FOCUS_LEFT:
|
||||
case FOCUS_RIGHT:
|
||||
case FOCUS_DOWN:
|
||||
case FOCUS_FIRST:
|
||||
case FOCUS_LAST:
|
||||
{
|
||||
// First, try the child views themselves as candidates
|
||||
for (size_t i = 0; i < views_.size(); i++) {
|
||||
if (views_[i] == view)
|
||||
continue;
|
||||
|
||||
float score = GetDirectionScore(view, views_[i], direction);
|
||||
float score = GetDirectionScore(num, view, views_[i], direction);
|
||||
if (score > result.score) {
|
||||
result.score = score;
|
||||
result.view = views_[i];
|
||||
@@ -424,15 +449,44 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei
|
||||
if (num != -1) {
|
||||
//result.score += 100.0f;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
case FOCUS_PREV_PAGE:
|
||||
case FOCUS_NEXT_PAGE:
|
||||
return FindScrollNeighbor(view, Point(INFINITY, INFINITY), direction, result);
|
||||
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
NeighborResult ViewGroup::FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best) {
|
||||
if (!IsEnabled())
|
||||
return best;
|
||||
if (GetVisibility() != V_VISIBLE)
|
||||
return best;
|
||||
|
||||
if (target.x < INFINITY && target.y < INFINITY) {
|
||||
for (auto v : views_) {
|
||||
// Note: we consider the origin itself, which might already be the best option.
|
||||
float score = GetTargetScore(target, -1, view, v, direction);
|
||||
if (score > best.score) {
|
||||
best.score = score;
|
||||
best.view = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto v : views_) {
|
||||
if (v->IsViewGroup()) {
|
||||
ViewGroup *vg = static_cast<ViewGroup *>(v);
|
||||
if (vg)
|
||||
best = vg->FindScrollNeighbor(view, target, direction, best);
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
// TODO: This code needs some cleanup/restructuring...
|
||||
void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) {
|
||||
MeasureBySpec(layoutParams_->width, 0.0f, horiz, &measuredWidth_);
|
||||
@@ -702,6 +756,8 @@ void ScrollView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
}
|
||||
views_[0]->Measure(dc, MeasureSpec(UNSPECIFIED, measuredWidth_), v);
|
||||
MeasureBySpec(layoutParams_->height, views_[0]->GetMeasuredHeight(), vert, &measuredHeight_);
|
||||
if (layoutParams_->width == WRAP_CONTENT)
|
||||
MeasureBySpec(layoutParams_->width, views_[0]->GetMeasuredWidth(), horiz, &measuredWidth_);
|
||||
} else {
|
||||
MeasureSpec h = MeasureSpec(AT_MOST, measuredWidth_ - margins.horiz());
|
||||
if (measuredWidth_ == 0.0f && (horiz.type == UNSPECIFIED || layoutParams_->width == WRAP_CONTENT)) {
|
||||
@@ -709,16 +765,16 @@ void ScrollView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
}
|
||||
views_[0]->Measure(dc, h, MeasureSpec(UNSPECIFIED, measuredHeight_));
|
||||
MeasureBySpec(layoutParams_->width, views_[0]->GetMeasuredWidth(), horiz, &measuredWidth_);
|
||||
if (layoutParams_->height == WRAP_CONTENT)
|
||||
MeasureBySpec(layoutParams_->height, views_[0]->GetMeasuredHeight(), vert, &measuredHeight_);
|
||||
}
|
||||
if (orientation_ == ORIENT_VERTICAL && vert.type != EXACTLY) {
|
||||
if (measuredHeight_ < views_[0]->GetMeasuredHeight()) {
|
||||
measuredHeight_ = views_[0]->GetMeasuredHeight();
|
||||
}
|
||||
if (measuredHeight_ < views_[0]->GetBounds().h) {
|
||||
measuredHeight_ = views_[0]->GetBounds().h;
|
||||
}
|
||||
if (vert.type == AT_MOST && measuredHeight_ > vert.size) {
|
||||
measuredHeight_ = vert.size;
|
||||
float bestHeight = std::max(views_[0]->GetMeasuredHeight(), views_[0]->GetBounds().h);
|
||||
if (vert.type == AT_MOST)
|
||||
bestHeight = std::min(bestHeight, vert.size);
|
||||
|
||||
if (measuredHeight_ < bestHeight && layoutParams_->height < 0.0f) {
|
||||
measuredHeight_ = bestHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -739,7 +795,7 @@ void ScrollView::Layout() {
|
||||
scrolled.w = views_[0]->GetMeasuredWidth() - margins.horiz();
|
||||
scrolled.h = views_[0]->GetMeasuredHeight() - margins.vert();
|
||||
|
||||
float layoutScrollPos = ClampedScrollPos(scrollPos_);
|
||||
layoutScrollPos_ = ClampedScrollPos(scrollPos_);
|
||||
|
||||
switch (orientation_) {
|
||||
case ORIENT_HORIZONTAL:
|
||||
@@ -747,7 +803,7 @@ void ScrollView::Layout() {
|
||||
ScrollTo(0.0f);
|
||||
lastViewSize_ = scrolled.w;
|
||||
}
|
||||
scrolled.x = bounds_.x - layoutScrollPos;
|
||||
scrolled.x = bounds_.x - layoutScrollPos_;
|
||||
scrolled.y = bounds_.y + margins.top;
|
||||
break;
|
||||
case ORIENT_VERTICAL:
|
||||
@@ -756,7 +812,7 @@ void ScrollView::Layout() {
|
||||
lastViewSize_ = scrolled.h;
|
||||
}
|
||||
scrolled.x = bounds_.x + margins.left;
|
||||
scrolled.y = bounds_.y - layoutScrollPos;
|
||||
scrolled.y = bounds_.y - layoutScrollPos_;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -776,19 +832,6 @@ bool ScrollView::Key(const KeyInput &input) {
|
||||
case NKCODE_EXT_MOUSEWHEEL_DOWN:
|
||||
ScrollRelative(250);
|
||||
break;
|
||||
case NKCODE_PAGE_DOWN:
|
||||
ScrollRelative((orientation_ == ORIENT_VERTICAL ? bounds_.h : bounds_.w) - 50);
|
||||
break;
|
||||
case NKCODE_PAGE_UP:
|
||||
ScrollRelative(-(orientation_ == ORIENT_VERTICAL ? bounds_.h : bounds_.w) + 50);
|
||||
break;
|
||||
case NKCODE_MOVE_HOME:
|
||||
ScrollTo(0);
|
||||
break;
|
||||
case NKCODE_MOVE_END:
|
||||
if (views_.size())
|
||||
ScrollTo(orientation_ == ORIENT_VERTICAL ? views_[0]->GetBounds().h : views_[0]->GetBounds().w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ViewGroup::Key(input);
|
||||
@@ -872,28 +915,75 @@ bool ScrollView::SubviewFocused(View *view) {
|
||||
const float overscroll = std::min(view->GetBounds().h / 1.5f, GetBounds().h / 4.0f);
|
||||
|
||||
float pos = ClampedScrollPos(scrollPos_);
|
||||
float visibleSize = orientation_ == ORIENT_VERTICAL ? bounds_.h : bounds_.w;
|
||||
float visibleEnd = scrollPos_ + visibleSize;
|
||||
|
||||
float viewStart, viewEnd;
|
||||
switch (orientation_) {
|
||||
case ORIENT_HORIZONTAL:
|
||||
if (vBounds.x2() > bounds_.x2()) {
|
||||
ScrollTo(pos + vBounds.x2() - bounds_.x2() + overscroll);
|
||||
}
|
||||
if (vBounds.x < bounds_.x) {
|
||||
ScrollTo(pos + (vBounds.x - bounds_.x) - overscroll);
|
||||
}
|
||||
viewStart = layoutScrollPos_ + vBounds.x - bounds_.x;
|
||||
viewEnd = layoutScrollPos_ + vBounds.x2() - bounds_.x;
|
||||
break;
|
||||
case ORIENT_VERTICAL:
|
||||
if (vBounds.y2() > bounds_.y2()) {
|
||||
ScrollTo(pos + vBounds.y2() - bounds_.y2() + overscroll);
|
||||
}
|
||||
if (vBounds.y < bounds_.y) {
|
||||
ScrollTo(pos + (vBounds.y - bounds_.y) - overscroll);
|
||||
}
|
||||
viewStart = layoutScrollPos_ + vBounds.y - bounds_.y;
|
||||
viewEnd = layoutScrollPos_ + vBounds.y2() - bounds_.y;
|
||||
break;
|
||||
}
|
||||
|
||||
if (viewEnd > visibleEnd) {
|
||||
ScrollTo(viewEnd - visibleSize + overscroll);
|
||||
} else if (viewStart < pos) {
|
||||
ScrollTo(viewStart - overscroll);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NeighborResult ScrollView::FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best) {
|
||||
if (ContainsSubview(view) && views_[0]->IsViewGroup()) {
|
||||
ViewGroup *vg = static_cast<ViewGroup *>(views_[0]);
|
||||
int found = -1;
|
||||
for (int i = 0, n = vg->GetNumSubviews(); i < n; ++i) {
|
||||
View *child = vg->GetViewByIndex(i);
|
||||
if (child == view || child->ContainsSubview(view)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Okay, the previously focused view is inside this.
|
||||
if (found != -1) {
|
||||
float mult = 0.0f;
|
||||
switch (direction) {
|
||||
case FOCUS_PREV_PAGE:
|
||||
mult = -1.0f;
|
||||
break;
|
||||
case FOCUS_NEXT_PAGE:
|
||||
mult = 1.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Okay, now where is our ideal target?
|
||||
Point targetPos = view->GetBounds().Center();
|
||||
if (orientation_ == ORIENT_VERTICAL)
|
||||
targetPos.y += mult * bounds_.h;
|
||||
else
|
||||
targetPos.x += mult * bounds_.x;
|
||||
|
||||
// Okay, which subview is closest to that?
|
||||
best = vg->FindScrollNeighbor(view, targetPos, direction, best);
|
||||
// Avoid reselecting the same view.
|
||||
if (best.view == view)
|
||||
best.view = nullptr;
|
||||
return best;
|
||||
}
|
||||
}
|
||||
|
||||
return ViewGroup::FindScrollNeighbor(view, target, direction, best);
|
||||
}
|
||||
|
||||
void ScrollView::PersistData(PersistStatus status, std::string anonId, PersistMap &storage) {
|
||||
ViewGroup::PersistData(status, anonId, storage);
|
||||
|
||||
@@ -1001,11 +1091,25 @@ bool ScrollView::CanScroll() const {
|
||||
}
|
||||
}
|
||||
|
||||
float ScrollView::lastScrollPosX = 0;
|
||||
float ScrollView::lastScrollPosY = 0;
|
||||
|
||||
ScrollView::~ScrollView() {
|
||||
lastScrollPosX = 0;
|
||||
lastScrollPosY = 0;
|
||||
}
|
||||
|
||||
void ScrollView::GetLastScrollPosition(float &x, float &y) {
|
||||
x = lastScrollPosX;
|
||||
y = lastScrollPosY;
|
||||
}
|
||||
|
||||
void ScrollView::Update() {
|
||||
if (visibility_ != V_VISIBLE) {
|
||||
inertia_ = 0.0f;
|
||||
}
|
||||
ViewGroup::Update();
|
||||
float oldPos = scrollPos_;
|
||||
|
||||
Gesture gesture = orientation_ == ORIENT_VERTICAL ? GESTURE_DRAG_VERTICAL : GESTURE_DRAG_HORIZONTAL;
|
||||
gesture_.UpdateFrame();
|
||||
@@ -1034,6 +1138,9 @@ void ScrollView::Update() {
|
||||
pull_ = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldPos != scrollPos_)
|
||||
orientation_ == ORIENT_HORIZONTAL ? lastScrollPosX = scrollPos_ : lastScrollPosY = scrollPos_;
|
||||
}
|
||||
|
||||
void AnchorLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) {
|
||||
@@ -1111,7 +1218,8 @@ void AnchorLayout::Layout() {
|
||||
if (vBounds.w > bounds_.w) vBounds.w = bounds_.w;
|
||||
if (vBounds.h > bounds_.h) vBounds.h = bounds_.h;
|
||||
|
||||
float left = 0, top = 0, right = 0, bottom = 0, center = false;
|
||||
float left = 0, top = 0, right = 0, bottom = 0;
|
||||
bool center = false;
|
||||
if (params) {
|
||||
left = params->left;
|
||||
top = params->top;
|
||||
@@ -1159,7 +1267,9 @@ void GridLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
views_[i]->Measure(dc, MeasureSpec(measureType, settings_.columnWidth), MeasureSpec(measureType, settings_.rowHeight));
|
||||
}
|
||||
|
||||
MeasureBySpec(layoutParams_->width, 0.0f, horiz, &measuredWidth_);
|
||||
// Use the max possible width so AT_MOST gives us the full size.
|
||||
float maxWidth = (settings_.columnWidth + settings_.spacing) * views_.size() + settings_.spacing;
|
||||
MeasureBySpec(layoutParams_->width, maxWidth, horiz, &measuredWidth_);
|
||||
|
||||
// Okay, got the width we are supposed to adjust to. Now we can calculate the number of columns.
|
||||
numColumns_ = (measuredWidth_ - settings_.spacing) / (settings_.columnWidth + settings_.spacing);
|
||||
@@ -1176,7 +1286,9 @@ void GridLayout::Layout() {
|
||||
int x = 0;
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < views_.size(); i++) {
|
||||
const GridLayoutParams *lp = views_[i]->GetLayoutParams()->As<GridLayoutParams>();
|
||||
Bounds itemBounds, innerBounds;
|
||||
Gravity grav = lp ? lp->gravity : G_CENTER;
|
||||
|
||||
itemBounds.x = bounds_.x + x;
|
||||
itemBounds.y = bounds_.y + y;
|
||||
@@ -1185,7 +1297,7 @@ void GridLayout::Layout() {
|
||||
|
||||
ApplyGravity(itemBounds, Margins(0.0f),
|
||||
views_[i]->GetMeasuredWidth(), views_[i]->GetMeasuredHeight(),
|
||||
G_HCENTER | G_VCENTER, innerBounds);
|
||||
grav, innerBounds);
|
||||
|
||||
views_[i]->SetBounds(innerBounds);
|
||||
views_[i]->Layout();
|
||||
|
||||
+29
-2
@@ -63,9 +63,11 @@ public:
|
||||
|
||||
// Assumes that layout has taken place.
|
||||
NeighborResult FindNeighbor(View *view, FocusDirection direction, NeighborResult best);
|
||||
virtual NeighborResult FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best);
|
||||
|
||||
virtual bool CanBeFocused() const override { return false; }
|
||||
virtual bool IsViewGroup() const override { return true; }
|
||||
bool CanBeFocused() const override { return false; }
|
||||
bool IsViewGroup() const override { return true; }
|
||||
bool ContainsSubview(const View *view) const override;
|
||||
|
||||
virtual void SetBG(const Drawable &bg) { bg_ = bg; }
|
||||
|
||||
@@ -220,6 +222,21 @@ struct GridLayoutSettings {
|
||||
bool fillCells;
|
||||
};
|
||||
|
||||
class GridLayoutParams : public LayoutParams {
|
||||
public:
|
||||
GridLayoutParams()
|
||||
: LayoutParams(LP_GRID), gravity(G_CENTER) {}
|
||||
explicit GridLayoutParams(Gravity grav)
|
||||
: LayoutParams(LP_GRID), gravity(grav) {
|
||||
}
|
||||
|
||||
Gravity gravity;
|
||||
|
||||
static LayoutParamsType StaticType() {
|
||||
return LP_GRID;
|
||||
}
|
||||
};
|
||||
|
||||
class GridLayout : public ViewGroup {
|
||||
public:
|
||||
GridLayout(GridLayoutSettings settings, LayoutParams *layoutParams = 0);
|
||||
@@ -247,6 +264,7 @@ class ScrollView : public ViewGroup {
|
||||
public:
|
||||
ScrollView(Orientation orientation, LayoutParams *layoutParams = 0, bool rememberPosition = false)
|
||||
: ViewGroup(layoutParams), orientation_(orientation), rememberPosition_(rememberPosition) {}
|
||||
~ScrollView();
|
||||
|
||||
void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override;
|
||||
void Layout() override;
|
||||
@@ -263,11 +281,16 @@ public:
|
||||
bool CanScroll() const;
|
||||
void Update() override;
|
||||
|
||||
// Get the last moved scroll view position
|
||||
static void GetLastScrollPosition(float &x, float &y);
|
||||
|
||||
// Override so that we can scroll to the active one after moving the focus.
|
||||
bool SubviewFocused(View *view) override;
|
||||
void PersistData(PersistStatus status, std::string anonId, PersistMap &storage) override;
|
||||
void SetVisibility(Visibility visibility) override;
|
||||
|
||||
NeighborResult FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best) override;
|
||||
|
||||
// Quick hack to prevent scrolling to top in some lists
|
||||
void SetScrollToTop(bool t) { scrollToTopOnSizeChange_ = t; }
|
||||
|
||||
@@ -281,11 +304,15 @@ private:
|
||||
float scrollTarget_ = 0.0f;
|
||||
int scrollTouchId_ = -1;
|
||||
bool scrollToTarget_ = false;
|
||||
float layoutScrollPos_ = 0.0f;
|
||||
float inertia_ = 0.0f;
|
||||
float pull_ = 0.0f;
|
||||
float lastViewSize_ = 0.0f;
|
||||
bool scrollToTopOnSizeChange_ = false;
|
||||
bool rememberPosition_;
|
||||
|
||||
static float lastScrollPosX;
|
||||
static float lastScrollPosY;
|
||||
};
|
||||
|
||||
class ViewPager : public ScrollView {
|
||||
|
||||
+68
-33
@@ -538,6 +538,9 @@ static ConfigSetting generalSettings[] = {
|
||||
ConfigSetting("SaveLoadResetsAVdumping", &g_Config.bSaveLoadResetsAVdumping, false),
|
||||
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, true, true),
|
||||
ConfigSetting("EnableStateUndo", &g_Config.bEnableStateUndo, false/*&DefaultEnableStateUndo*/, true, true),
|
||||
ConfigSetting("StateLoadUndoGame", &g_Config.sStateLoadUndoGame, "NA", true, false),
|
||||
ConfigSetting("StateUndoLastSaveGame", &g_Config.sStateUndoLastSaveGame, "NA", true, false),
|
||||
ConfigSetting("StateUndoLastSaveSlot", &g_Config.iStateUndoLastSaveSlot, -5, true, false), // Start with an "invalid" value
|
||||
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true),
|
||||
|
||||
ConfigSetting("ShowOnScreenMessage", &g_Config.bShowOnScreenMessages, true, true, false),
|
||||
@@ -553,6 +556,15 @@ static ConfigSetting generalSettings[] = {
|
||||
ConfigSetting("RightAnalogRight", &g_Config.iRightAnalogRight, 0, true, true),
|
||||
ConfigSetting("RightAnalogPress", &g_Config.iRightAnalogPress, 0, true, true),
|
||||
ConfigSetting("RightAnalogCustom", &g_Config.bRightAnalogCustom, false, true, true),
|
||||
ConfigSetting("RightAnalogDisableDiagonal", &g_Config.bRightAnalogDisableDiagonal, false, true, true),
|
||||
ConfigSetting("SwipeUp", &g_Config.iSwipeUp, 0, true, true),
|
||||
ConfigSetting("SwipeDown", &g_Config.iSwipeDown, 0, true, true),
|
||||
ConfigSetting("SwipeLeft", &g_Config.iSwipeLeft, 0, true, true),
|
||||
ConfigSetting("SwipeRight", &g_Config.iSwipeRight, 0, true, true),
|
||||
ConfigSetting("SwipeSensitivity", &g_Config.fSwipeSensitivity, 1.0f, true, true),
|
||||
ConfigSetting("SwipeSmoothing", &g_Config.fSwipeSmoothing, 0.3f, true, true),
|
||||
ConfigSetting("DoubleTapGesture", &g_Config.iDoubleTapGesture, 0, true, true),
|
||||
ConfigSetting("GestureControlEnabled", &g_Config.bGestureControlEnabled, false, true, true),
|
||||
|
||||
// "default" means let emulator decide, "" means disable.
|
||||
ConfigSetting("ReportingHost", &g_Config.sReportHost, "default"),
|
||||
@@ -623,11 +635,11 @@ static int DefaultInternalResolution() {
|
||||
#endif
|
||||
}
|
||||
|
||||
static int DefaultUnthrottleMode() {
|
||||
static int DefaultFastForwardMode() {
|
||||
#if PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS)
|
||||
return (int)UnthrottleMode::SKIP_FLIP;
|
||||
return (int)FastForwardMode::SKIP_FLIP;
|
||||
#else
|
||||
return (int)UnthrottleMode::CONTINUOUS;
|
||||
return (int)FastForwardMode::CONTINUOUS;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -663,6 +675,11 @@ static int DefaultAndroidHwScale() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// See issue 14439. Should possibly even block these devices from selecting VK.
|
||||
const char * const vulkanDefaultBlacklist[] = {
|
||||
"Sony:BRAVIA VH1",
|
||||
};
|
||||
|
||||
static int DefaultGPUBackend() {
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
// If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.)
|
||||
@@ -670,11 +687,22 @@ static int DefaultGPUBackend() {
|
||||
return (int)GPUBackend::DIRECT3D11;
|
||||
}
|
||||
#elif PPSSPP_PLATFORM(ANDROID)
|
||||
// Default to Vulkan only on Oreo 8.1 (level 27) devices or newer. Drivers before
|
||||
// were generally too unreliable to default to (with some exceptions, of course).
|
||||
// Check blacklist.
|
||||
for (size_t i = 0; i < ARRAY_SIZE(vulkanDefaultBlacklist); i++) {
|
||||
if (System_GetProperty(SYSPROP_NAME) == vulkanDefaultBlacklist[i]) {
|
||||
return (int)GPUBackend::OPENGL;
|
||||
}
|
||||
}
|
||||
|
||||
// Default to Vulkan only on Oreo 8.1 (level 27) devices or newer, and only
|
||||
// on ARM64 and x86-64. Drivers before, and on other archs, are generally too
|
||||
// unreliable to default to (with some exceptions, of course).
|
||||
#if PPSSPP_ARCH(64BIT)
|
||||
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 27) {
|
||||
return (int)GPUBackend::VULKAN;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// TODO: On some additional Linux platforms, we should also default to Vulkan.
|
||||
return (int)GPUBackend::OPENGL;
|
||||
@@ -773,10 +801,6 @@ bool Config::IsBackendEnabled(GPUBackend backend, bool validate) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool DefaultVertexCache() {
|
||||
return DefaultGPUBackend() == (int)GPUBackend::OPENGL;
|
||||
}
|
||||
|
||||
template <typename T, std::string (*FTo)(T), T (*FFrom)(const std::string &)>
|
||||
struct ConfigTranslator {
|
||||
static std::string To(int v) {
|
||||
@@ -794,23 +818,23 @@ struct ConfigTranslator {
|
||||
|
||||
typedef ConfigTranslator<GPUBackend, GPUBackendToString, GPUBackendFromString> GPUBackendTranslator;
|
||||
|
||||
static int UnthrottleModeFromString(const std::string &s) {
|
||||
static int FastForwardModeFromString(const std::string &s) {
|
||||
if (!strcasecmp(s.c_str(), "CONTINUOUS"))
|
||||
return (int)UnthrottleMode::CONTINUOUS;
|
||||
return (int)FastForwardMode::CONTINUOUS;
|
||||
if (!strcasecmp(s.c_str(), "SKIP_DRAW"))
|
||||
return (int)UnthrottleMode::SKIP_DRAW;
|
||||
return (int)FastForwardMode::SKIP_DRAW;
|
||||
if (!strcasecmp(s.c_str(), "SKIP_FLIP"))
|
||||
return (int)UnthrottleMode::SKIP_FLIP;
|
||||
return DefaultUnthrottleMode();
|
||||
return (int)FastForwardMode::SKIP_FLIP;
|
||||
return DefaultFastForwardMode();
|
||||
}
|
||||
|
||||
std::string UnthrottleModeToString(int v) {
|
||||
switch (UnthrottleMode(v)) {
|
||||
case UnthrottleMode::CONTINUOUS:
|
||||
std::string FastForwardModeToString(int v) {
|
||||
switch (FastForwardMode(v)) {
|
||||
case FastForwardMode::CONTINUOUS:
|
||||
return "CONTINUOUS";
|
||||
case UnthrottleMode::SKIP_DRAW:
|
||||
case FastForwardMode::SKIP_DRAW:
|
||||
return "SKIP_DRAW";
|
||||
case UnthrottleMode::SKIP_FLIP:
|
||||
case FastForwardMode::SKIP_FLIP:
|
||||
return "SKIP_FLIP";
|
||||
}
|
||||
return "CONTINUOUS";
|
||||
@@ -845,7 +869,7 @@ static ConfigSetting graphicsSettings[] = {
|
||||
ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false, true, true),
|
||||
ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, true, true),
|
||||
ConfigSetting("FrameRate2", &g_Config.iFpsLimit2, -1, true, true),
|
||||
ConfigSetting("UnthrottlingMode", &g_Config.iUnthrottleMode, &DefaultUnthrottleMode, &UnthrottleModeToString, &UnthrottleModeFromString, true, true),
|
||||
ConfigSetting("UnthrottlingMode", &g_Config.iFastForwardMode, &DefaultFastForwardMode, &FastForwardModeToString, &FastForwardModeFromString, true, true),
|
||||
#if defined(USING_WIN_UI)
|
||||
ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, false),
|
||||
#endif
|
||||
@@ -853,7 +877,7 @@ static ConfigSetting graphicsSettings[] = {
|
||||
// Most low-performance (and many high performance) mobile GPUs do not support aniso anyway so defaulting to 4 is fine.
|
||||
ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 4, true, true),
|
||||
|
||||
ReportedConfigSetting("VertexDecCache", &g_Config.bVertexCache, false/*&DefaultVertexCache*/, true, true),
|
||||
ReportedConfigSetting("VertexDecCache", &g_Config.bVertexCache, false, true, true),
|
||||
ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, true, true),
|
||||
ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false, true, true),
|
||||
ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, false),
|
||||
@@ -909,7 +933,8 @@ static ConfigSetting soundSettings[] = {
|
||||
ConfigSetting("Enable", &g_Config.bEnableSound, true, true, true),
|
||||
ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, true, true),
|
||||
ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, true, false),
|
||||
ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_MAX, true, true),
|
||||
ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_FULL, true, true),
|
||||
ConfigSetting("ReverbVolume", &g_Config.iReverbVolume, VOLUME_FULL, true, true),
|
||||
ConfigSetting("SASVolume", &g_Config.iSASVolume, 8, true, true),
|
||||
ConfigSetting("ATRACMP3Volume", &g_Config.iATRACMP3Volume, 8, true, true),
|
||||
ConfigSetting("AltSpeedVolume", &g_Config.iAltSpeedVolume, -1, true, true),
|
||||
@@ -975,6 +1000,7 @@ static ConfigSetting controlSettings[] = {
|
||||
#ifdef MOBILE_DEVICE
|
||||
ConfigSetting("TiltBaseX", &g_Config.fTiltBaseX, 0.0f, true, true),
|
||||
ConfigSetting("TiltBaseY", &g_Config.fTiltBaseY, 0.0f, true, true),
|
||||
ConfigSetting("TiltOrientation", &g_Config.iTiltOrientation, 0, true, true),
|
||||
ConfigSetting("InvertTiltX", &g_Config.bInvertTiltX, false, true, true),
|
||||
ConfigSetting("InvertTiltY", &g_Config.bInvertTiltY, true, true, true),
|
||||
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 100, true, true),
|
||||
@@ -1005,7 +1031,7 @@ static ConfigSetting controlSettings[] = {
|
||||
ConfigSetting("DPadSpacing", &g_Config.fDpadSpacing, 1.0f, true, true),
|
||||
ConfigSetting("StartKeyX", "StartKeyY", "StartKeyScale", "ShowTouchStart", &g_Config.touchStartKey, defaultTouchPosShow, true, true),
|
||||
ConfigSetting("SelectKeyX", "SelectKeyY", "SelectKeyScale", "ShowTouchSelect", &g_Config.touchSelectKey, defaultTouchPosShow, true, true),
|
||||
ConfigSetting("UnthrottleKeyX", "UnthrottleKeyY", "UnthrottleKeyScale", "ShowTouchUnthrottle", &g_Config.touchUnthrottleKey, defaultTouchPosShow, true, true),
|
||||
ConfigSetting("UnthrottleKeyX", "UnthrottleKeyY", "UnthrottleKeyScale", "ShowTouchUnthrottle", &g_Config.touchFastForwardKey, defaultTouchPosShow, true, true),
|
||||
ConfigSetting("LKeyX", "LKeyY", "LKeyScale", "ShowTouchLTrigger", &g_Config.touchLKey, defaultTouchPosShow, true, true),
|
||||
ConfigSetting("RKeyX", "RKeyY", "RKeyScale", "ShowTouchRTrigger", &g_Config.touchRKey, defaultTouchPosShow, true, true),
|
||||
ConfigSetting("AnalogStickX", "AnalogStickY", "AnalogStickScale", "ShowAnalogStick", &g_Config.touchAnalogStick, defaultTouchPosShow, true, true),
|
||||
@@ -1031,6 +1057,10 @@ static ConfigSetting controlSettings[] = {
|
||||
ConfigSetting("AnalogLimiterDeadzone", &g_Config.fAnalogLimiterDeadzone, 0.6f, true, true),
|
||||
ConfigSetting("AxisBindThreshold", &g_Config.fAxisBindThreshold, 0.25f, true, true),
|
||||
|
||||
ConfigSetting("LeftStickHeadScale", &g_Config.fLeftStickHeadScale, 1.0f, true, true),
|
||||
ConfigSetting("RightStickHeadScale", &g_Config.fRightStickHeadScale, 1.0f, true, true),
|
||||
ConfigSetting("HideStickBackground", &g_Config.bHideStickBackground, false, true, true),
|
||||
|
||||
ConfigSetting("UseMouse", &g_Config.bMouseControl, false, true, true),
|
||||
ConfigSetting("MapMouse", &g_Config.bMapMouse, false, true, true),
|
||||
ConfigSetting("ConfineMap", &g_Config.bMouseConfine, false, true, true),
|
||||
@@ -1046,7 +1076,7 @@ static ConfigSetting networkSettings[] = {
|
||||
ConfigSetting("EnableWlan", &g_Config.bEnableWlan, false, true, true),
|
||||
ConfigSetting("EnableAdhocServer", &g_Config.bEnableAdhocServer, false, true, true),
|
||||
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "localhost", true, true),
|
||||
ConfigSetting("PortOffset", &g_Config.iPortOffset, 0, true, true),
|
||||
ConfigSetting("PortOffset", &g_Config.iPortOffset, 10000, true, true),
|
||||
ConfigSetting("MinTimeout", &g_Config.iMinTimeout, 0, true, true),
|
||||
ConfigSetting("TCPNoDelay", &g_Config.bTCPNoDelay, true, true, true),
|
||||
ConfigSetting("ForcedFirstConnect", &g_Config.bForcedFirstConnect, false, true, true),
|
||||
@@ -1386,8 +1416,9 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
// splash screen quickly), but then we'll just show the notification next time instead, we store the
|
||||
// upgrade number in the ini.
|
||||
if (iRunCount % 10 == 0 && bCheckForNewVersion) {
|
||||
std::shared_ptr<http::Download> dl = g_DownloadManager.StartDownloadWithCallback(
|
||||
"http://www.ppsspp.org/version.json", Path(), &DownloadCompletedCallback);
|
||||
const char *versionUrl = "http://www.ppsspp.org/version.json";
|
||||
const char *acceptMime = "application/json, text/*; q=0.9, */*; q=0.8";
|
||||
auto dl = g_DownloadManager.StartDownloadWithCallback(versionUrl, Path(), &DownloadCompletedCallback, acceptMime);
|
||||
dl->SetHidden(true);
|
||||
}
|
||||
|
||||
@@ -1427,12 +1458,14 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
INFO_LOG(LOADER, "Config loaded: '%s'", iniFilename_.c_str());
|
||||
}
|
||||
|
||||
void Config::Save(const char *saveReason) {
|
||||
bool Config::Save(const char *saveReason) {
|
||||
if (!IsFirstInstance()) {
|
||||
// TODO: Should we allow saving config if started from a different directory?
|
||||
// How do we tell?
|
||||
WARN_LOG(LOADER, "Not saving config - secondary instances don't.");
|
||||
return;
|
||||
|
||||
// Don't want to retry or something.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (jitForcedOff) {
|
||||
@@ -1502,8 +1535,7 @@ void Config::Save(const char *saveReason) {
|
||||
|
||||
if (!iniFile.Save(iniFilename_)) {
|
||||
ERROR_LOG(LOADER, "Error saving config (%s)- can't write ini '%s'", saveReason, iniFilename_.c_str());
|
||||
System_SendMessage("toast", "Failed to save settings!\nCheck permissions, or try to restart the device.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(LOADER, "Config saved (%s): '%s'", saveReason, iniFilename_.c_str());
|
||||
|
||||
@@ -1516,7 +1548,7 @@ void Config::Save(const char *saveReason) {
|
||||
KeyMap::SaveToIni(controllerIniFile);
|
||||
if (!controllerIniFile.Save(controllerIniFilename_)) {
|
||||
ERROR_LOG(LOADER, "Error saving config - can't write ini '%s'", controllerIniFilename_.c_str());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
|
||||
}
|
||||
@@ -1527,6 +1559,7 @@ void Config::Save(const char *saveReason) {
|
||||
// force JIT off again just in case Config::Save() is called without exiting PPSSPP
|
||||
g_Config.iCpuCore = (int)CPUCore::INTERPRETER;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use for debugging the version check without messing with the server
|
||||
@@ -1757,7 +1790,7 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title
|
||||
Path iniFileNameFull = getGameConfigFile(pGameId);
|
||||
|
||||
if (!hasGameConfig(pGameId)) {
|
||||
INFO_LOG(LOADER, "Failed to read %s. No game-specific settings found, using global defaults.", iniFileNameFull.c_str());
|
||||
DEBUG_LOG(LOADER, "No game-specific settings found in %s. Using global defaults.", iniFileNameFull.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1842,7 +1875,7 @@ void Config::ResetControlLayout() {
|
||||
g_Config.fDpadSpacing = 1.0f;
|
||||
reset(g_Config.touchStartKey);
|
||||
reset(g_Config.touchSelectKey);
|
||||
reset(g_Config.touchUnthrottleKey);
|
||||
reset(g_Config.touchFastForwardKey);
|
||||
reset(g_Config.touchLKey);
|
||||
reset(g_Config.touchRKey);
|
||||
reset(g_Config.touchAnalogStick);
|
||||
@@ -1857,6 +1890,8 @@ void Config::ResetControlLayout() {
|
||||
reset(g_Config.touchCombo7);
|
||||
reset(g_Config.touchCombo8);
|
||||
reset(g_Config.touchCombo9);
|
||||
g_Config.fLeftStickHeadScale = 1.0f;
|
||||
g_Config.fRightStickHeadScale = 1.0f;
|
||||
}
|
||||
|
||||
void Config::GetReportingInfo(UrlEncoder &data) {
|
||||
|
||||
+24
-4
@@ -168,7 +168,7 @@ public:
|
||||
bool bVendorBugChecksEnabled;
|
||||
|
||||
int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering
|
||||
int iTexFiltering; // 1 = off , 2 = nearest , 3 = linear , 4 = linear(CG)
|
||||
int iTexFiltering; // 1 = auto , 2 = nearest , 3 = linear , 4 = auto max quality
|
||||
int iBufFilter; // 1 = linear, 2 = nearest
|
||||
int iSmallDisplayZoomType; // Used to fit display into screen 0 = stretch, 1 = partial stretch, 2 = auto scaling, 3 = manual scaling.
|
||||
float fSmallDisplayOffsetX; // Along with Y it goes from 0.0 to 1.0, XY (0.5, 0.5) = center of the screen
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
bool bVSync;
|
||||
int iFrameSkip;
|
||||
int iFrameSkipType;
|
||||
int iUnthrottleMode; // See UnthrottleMode in ConfigValues.h.
|
||||
int iFastForwardMode; // See FastForwardMode in ConfigValues.h.
|
||||
bool bAutoFrameSkip;
|
||||
|
||||
bool bEnableCardboardVR; // Cardboard Master Switch
|
||||
@@ -218,6 +218,9 @@ public:
|
||||
int iRewindFlipFrequency;
|
||||
bool bUISound;
|
||||
bool bEnableStateUndo;
|
||||
std::string sStateLoadUndoGame;
|
||||
std::string sStateUndoLastSaveGame;
|
||||
int iStateUndoLastSaveSlot;
|
||||
int iAutoLoadSaveState; // 0 = off, 1 = oldest, 2 = newest, >2 = slot number + 3
|
||||
bool bEnableCheats;
|
||||
bool bReloadCheats;
|
||||
@@ -244,6 +247,7 @@ public:
|
||||
bool bEnableSound;
|
||||
int iAudioBackend;
|
||||
int iGlobalVolume, iSASVolume, iATRACMP3Volume;
|
||||
int iReverbVolume;
|
||||
int iAltSpeedVolume;
|
||||
bool bExtraAudioBuffering; // For bluetooth
|
||||
std::string sAudioDevice;
|
||||
@@ -297,6 +301,7 @@ public:
|
||||
//the base x and y tilt. this inclination is treated as (0,0) and the tilt input
|
||||
//considers this orientation to be equal to no movement of the analog stick.
|
||||
float fTiltBaseX, fTiltBaseY;
|
||||
int iTiltOrientation;
|
||||
//whether the x axes and y axes should invert directions (left becomes right, top becomes bottom.)
|
||||
bool bInvertTiltX, bInvertTiltY;
|
||||
//the sensitivity of the tilt in the x direction
|
||||
@@ -323,6 +328,17 @@ public:
|
||||
int iRightAnalogRight;
|
||||
int iRightAnalogPress;
|
||||
bool bRightAnalogCustom;
|
||||
bool bRightAnalogDisableDiagonal;
|
||||
|
||||
// Motion gesture controller
|
||||
bool bGestureControlEnabled;
|
||||
int iSwipeUp;
|
||||
int iSwipeDown;
|
||||
int iSwipeLeft;
|
||||
int iSwipeRight;
|
||||
float fSwipeSensitivity;
|
||||
float fSwipeSmoothing;
|
||||
int iDoubleTapGesture;
|
||||
|
||||
// Disable diagonals
|
||||
bool bDisableDpadDiagonals;
|
||||
@@ -352,7 +368,7 @@ public:
|
||||
float fDpadSpacing;
|
||||
ConfigTouchPos touchStartKey;
|
||||
ConfigTouchPos touchSelectKey;
|
||||
ConfigTouchPos touchUnthrottleKey;
|
||||
ConfigTouchPos touchFastForwardKey;
|
||||
ConfigTouchPos touchLKey;
|
||||
ConfigTouchPos touchRKey;
|
||||
ConfigTouchPos touchAnalogStick;
|
||||
@@ -369,6 +385,10 @@ public:
|
||||
ConfigTouchPos touchCombo8;
|
||||
ConfigTouchPos touchCombo9;
|
||||
|
||||
float fLeftStickHeadScale;
|
||||
float fRightStickHeadScale;
|
||||
bool bHideStickBackground;
|
||||
|
||||
// Controls Visibility
|
||||
bool bShowTouchControls;
|
||||
|
||||
@@ -506,7 +526,7 @@ public:
|
||||
std::string dismissedVersion;
|
||||
|
||||
void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
|
||||
void Save(const char *saveReason);
|
||||
bool Save(const char *saveReason);
|
||||
void Reload();
|
||||
void RestoreDefaults();
|
||||
|
||||
|
||||
+11
-2
@@ -28,7 +28,7 @@ const int PSP_MODEL_FAT = 0;
|
||||
const int PSP_MODEL_SLIM = 1;
|
||||
const int PSP_DEFAULT_FIRMWARE = 660;
|
||||
static const int8_t VOLUME_OFF = 0;
|
||||
static const int8_t VOLUME_MAX = 10;
|
||||
static const int8_t VOLUME_FULL = 10;
|
||||
|
||||
enum class CPUCore {
|
||||
INTERPRETER = 0,
|
||||
@@ -45,6 +45,13 @@ enum {
|
||||
ROTATION_AUTO_HORIZONTAL = 5,
|
||||
};
|
||||
|
||||
enum TextureFiltering {
|
||||
TEX_FILTER_AUTO = 1,
|
||||
TEX_FILTER_FORCE_NEAREST = 2,
|
||||
TEX_FILTER_FORCE_LINEAR = 3,
|
||||
TEX_FILTER_AUTO_MAX_QUALITY = 4,
|
||||
};
|
||||
|
||||
enum BufferFilter {
|
||||
SCALE_LINEAR = 1,
|
||||
SCALE_NEAREST = 2,
|
||||
@@ -111,7 +118,7 @@ enum class AutoLoadSaveState {
|
||||
NEWEST = 2,
|
||||
};
|
||||
|
||||
enum class UnthrottleMode {
|
||||
enum class FastForwardMode {
|
||||
CONTINUOUS = 0,
|
||||
SKIP_DRAW = 1,
|
||||
SKIP_FLIP = 2,
|
||||
@@ -121,4 +128,6 @@ enum class BackgroundAnimation {
|
||||
OFF = 0,
|
||||
FLOATING_SYMBOLS = 1,
|
||||
RECENT_GAMES = 2,
|
||||
WAVE = 3,
|
||||
MOVING_BACKGROUND = 4,
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/Log.h"
|
||||
|
||||
#include "Core/KeyMap.h"
|
||||
#include "Core/ControlMapper.h"
|
||||
@@ -79,6 +80,8 @@ bool ControlMapper::Key(const KeyInput &key, bool *pauseTrigger) {
|
||||
pspKey(pspKeys[i], key.flags);
|
||||
}
|
||||
|
||||
DEBUG_LOG(SYSTEM, "Key: %d DeviceId: %d", key.keyCode, key.deviceId);
|
||||
|
||||
if (!pspKeys.size() || key.deviceId == DEVICE_ID_DEFAULT) {
|
||||
if ((key.flags & KEY_DOWN) && key.keyCode == NKCODE_BACK) {
|
||||
*pauseTrigger = true;
|
||||
|
||||
+11
-3
@@ -85,6 +85,10 @@ void Core_ListenLifecycle(CoreLifecycleFunc func) {
|
||||
}
|
||||
|
||||
void Core_NotifyLifecycle(CoreLifecycle stage) {
|
||||
if (stage == CoreLifecycle::STARTING) {
|
||||
Core_ResetException();
|
||||
}
|
||||
|
||||
for (auto func : lifecycleFuncs) {
|
||||
func(stage);
|
||||
}
|
||||
@@ -95,7 +99,7 @@ void Core_ListenStopRequest(CoreStopRequestFunc func) {
|
||||
}
|
||||
|
||||
void Core_Stop() {
|
||||
g_exceptionInfo.type = ExceptionType::NONE;
|
||||
Core_ResetException();
|
||||
Core_UpdateState(CORE_POWERDOWN);
|
||||
for (auto func : stopFuncs) {
|
||||
func();
|
||||
@@ -263,7 +267,7 @@ void Core_UpdateSingleStep() {
|
||||
}
|
||||
|
||||
void Core_SingleStep() {
|
||||
g_exceptionInfo.type = ExceptionType::NONE;
|
||||
Core_ResetException();
|
||||
currentMIPS->SingleStep();
|
||||
if (coreState == CORE_STEPPING)
|
||||
steppingCounter++;
|
||||
@@ -362,7 +366,7 @@ void Core_EnableStepping(bool step) {
|
||||
} else {
|
||||
host->SetDebugMode(false);
|
||||
// Clear the exception if we resume.
|
||||
g_exceptionInfo.type = ExceptionType::NONE;
|
||||
Core_ResetException();
|
||||
coreState = CORE_RUNNING;
|
||||
coreStatePending = false;
|
||||
m_StepCond.notify_all();
|
||||
@@ -485,6 +489,10 @@ void Core_Break() {
|
||||
}
|
||||
}
|
||||
|
||||
void Core_ResetException() {
|
||||
g_exceptionInfo.type = ExceptionType::NONE;
|
||||
}
|
||||
|
||||
const ExceptionInfo &Core_GetExceptionInfo() {
|
||||
return g_exceptionInfo;
|
||||
}
|
||||
@@ -101,6 +101,8 @@ void Core_MemoryExceptionInfo(u32 address, u32 pc, MemoryExceptionType type, std
|
||||
|
||||
void Core_ExecException(u32 address, u32 pc, ExecExceptionType type);
|
||||
void Core_Break();
|
||||
// Call when loading save states, etc.
|
||||
void Core_ResetException();
|
||||
|
||||
enum class ExceptionType {
|
||||
NONE,
|
||||
|
||||
@@ -541,6 +541,7 @@
|
||||
<ClCompile Include="HW\Camera.cpp" />
|
||||
<ClCompile Include="Instance.cpp" />
|
||||
<ClCompile Include="KeyMap.cpp" />
|
||||
<ClCompile Include="KeyMapDefaults.cpp" />
|
||||
<ClCompile Include="MemFault.cpp" />
|
||||
<ClCompile Include="MIPS\fake\FakeJit.cpp" />
|
||||
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
|
||||
@@ -1098,6 +1099,7 @@
|
||||
<ClInclude Include="HW\Camera.h" />
|
||||
<ClInclude Include="Instance.h" />
|
||||
<ClInclude Include="KeyMap.h" />
|
||||
<ClInclude Include="KeyMapDefaults.h" />
|
||||
<ClInclude Include="MemFault.h" />
|
||||
<ClInclude Include="MIPS\fake\FakeJit.h" />
|
||||
<ClInclude Include="MIPS\IR\IRFrontend.h" />
|
||||
|
||||
@@ -1178,6 +1178,9 @@
|
||||
<ClCompile Include="ControlMapper.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="KeyMapDefaults.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@@ -1898,6 +1901,9 @@
|
||||
<ClInclude Include="ControlMapper.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="KeyMapDefaults.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
||||
@@ -75,7 +75,7 @@ struct CoreParameter {
|
||||
int pixelHeight;
|
||||
|
||||
// Can be modified at runtime.
|
||||
bool unthrottle = false;
|
||||
bool fastForward = false;
|
||||
FPSLimit fpsLimit = FPSLimit::NORMAL;
|
||||
|
||||
bool updateRecent = true;
|
||||
|
||||
@@ -98,6 +98,9 @@ bool CheatFileParser::Parse() {
|
||||
if (!tempLine)
|
||||
continue;
|
||||
|
||||
// Detect UTF-8 BOM sequence, and ignore it.
|
||||
if (line_ == 1 && memcmp(tempLine, "\xEF\xBB\xBF", 3) == 0)
|
||||
tempLine += 3;
|
||||
std::string line = TrimString(tempLine);
|
||||
|
||||
// Minimum length 5 is shortest possible _ lines name of the game "_G N+"
|
||||
|
||||
@@ -70,7 +70,8 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) {
|
||||
|
||||
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||
|
||||
// TODO(scoped): We're screwed here
|
||||
// TODO(scoped): Use gzdopen instead.
|
||||
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
gzFile f = gzopen_w(filename.ToWString().c_str(), "r");
|
||||
#else
|
||||
@@ -195,10 +196,10 @@ void SymbolMap::SaveSymbolMap(const Path &filename) const {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(scoped): Use gzdopen
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
gzFile f = gzopen_w(filename.ToWString().c_str(), "w9");
|
||||
#else
|
||||
// TODO(scoped): Use gzdopen? If we care, otherwise just compress into a buffer.
|
||||
gzFile f = gzopen(filename.c_str(), "w9");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -320,8 +320,10 @@ void WebSocketDisasmState::Disasm(DebuggerRequest &req) {
|
||||
req.ParamU32("address", &start);
|
||||
end = disasm_.getNthNextAddress(start, count);
|
||||
} else if (req.ParamU32("end", &end)) {
|
||||
end = std::min(std::max(start, end), start + MAX_RANGE * 4);
|
||||
// Let's assume everything is two instructions.
|
||||
end = std::max(start, end);
|
||||
if (end - start > MAX_RANGE * 4)
|
||||
end = start + MAX_RANGE * 4;
|
||||
// Let's assume everything is two instructions at most.
|
||||
disasm_.analyze(start - 4, end - start + 8);
|
||||
start = disasm_.getStartAddress(start);
|
||||
if (start == -1)
|
||||
@@ -329,8 +331,14 @@ void WebSocketDisasmState::Disasm(DebuggerRequest &req) {
|
||||
// Correct end and calculate count based on it.
|
||||
// This accounts for macros as one line, although two instructions.
|
||||
u32 stop = end;
|
||||
u32 next = start;
|
||||
count = 0;
|
||||
for (end = start; end < stop; end = disasm_.getNthNextAddress(end, 1)) {
|
||||
if (stop < start) {
|
||||
for (next = start; next > stop; next = disasm_.getNthNextAddress(next, 1)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
for (end = next; end < stop && end >= next; end = disasm_.getNthNextAddress(end, 1)) {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -121,10 +121,12 @@ void PSPDialog::ChangeStatusInit(int delayUs) {
|
||||
}
|
||||
|
||||
void PSPDialog::ChangeStatusShutdown(int delayUs) {
|
||||
// If we're doing shutdown right away and skipped start, we don't run the dialog thread.
|
||||
bool skipDialogShutdown = status == SCE_UTILITY_STATUS_NONE && pendingStatus == SCE_UTILITY_STATUS_NONE;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_SHUTDOWN, 0);
|
||||
|
||||
auto params = GetCommonParam();
|
||||
if (params)
|
||||
if (params && !skipDialogShutdown)
|
||||
UtilityDialogShutdown(DialogType(), delayUs, params->accessThread);
|
||||
else
|
||||
ChangeStatus(SCE_UTILITY_STATUS_NONE, delayUs);
|
||||
|
||||
@@ -25,23 +25,23 @@
|
||||
#include <ctime>
|
||||
#include <thread>
|
||||
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
#include "Core/Dialog/PSPSaveDialog.h"
|
||||
#include "Core/FileSystems/MetaFileSystem.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/HLE/sceUtility.h"
|
||||
#include "Core/HW/MemoryStick.h"
|
||||
#include "Core/MemMapHelpers.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/HW/MemoryStick.h"
|
||||
#include "Core/Dialog/PSPSaveDialog.h"
|
||||
#include "Core/SaveState.h"
|
||||
|
||||
const static float FONT_SCALE = 0.55f;
|
||||
|
||||
@@ -1018,6 +1018,10 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
case SAVEIO_PENDING:
|
||||
case SAVEIO_DONE:
|
||||
// To make sure there aren't any timing variations, we sync the next frame.
|
||||
if (g_Config.iIOTimingMethod == IOTIMING_HOST && ioThreadStatus == SAVEIO_PENDING) {
|
||||
// ... except in Host IO timing, where we wait as long as needed.
|
||||
break;
|
||||
}
|
||||
JoinIOThread();
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
@@ -1048,6 +1052,7 @@ void PSPSaveDialog::ExecuteIOAction() {
|
||||
}
|
||||
break;
|
||||
case DS_SAVE_SAVING:
|
||||
SaveState::NotifySaveData();
|
||||
if (param.Save(param.GetPspParam(), GetSelectedSaveDirName()) == 0) {
|
||||
display = DS_SAVE_DONE;
|
||||
} else {
|
||||
@@ -1085,6 +1090,7 @@ void PSPSaveDialog::ExecuteNotVisibleIOAction() {
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SAVE: // Only save and exit
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE:
|
||||
SaveState::NotifySaveData();
|
||||
result = param.Save(param.GetPspParam(), GetSelectedSaveDirName());
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SIZES:
|
||||
@@ -1129,6 +1135,7 @@ void PSPSaveDialog::ExecuteNotVisibleIOAction() {
|
||||
// TODO: Should reset the directory's other files.
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATA:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE:
|
||||
SaveState::NotifySaveData();
|
||||
result = param.Save(param.GetPspParam(), GetSelectedSaveDirName(), param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE);
|
||||
if (result == SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE) {
|
||||
result = SCE_UTILITY_SAVEDATA_ERROR_RW_MEMSTICK_FULL;
|
||||
@@ -1136,6 +1143,7 @@ void PSPSaveDialog::ExecuteNotVisibleIOAction() {
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE:
|
||||
SaveState::NotifySaveData();
|
||||
result = param.Save(param.GetPspParam(), GetSelectedSaveDirName(), param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_READDATA:
|
||||
|
||||
@@ -66,9 +66,12 @@ namespace
|
||||
if (handle < 0)
|
||||
return false;
|
||||
|
||||
if(dataSize == -1)
|
||||
{
|
||||
dataSize = pspFileSystem.GetFileInfo(filename).size;
|
||||
if (dataSize == -1) {
|
||||
// Determine the size through seeking instead of querying.
|
||||
pspFileSystem.SeekFile(handle, 0, FILEMOVE_END);
|
||||
dataSize = pspFileSystem.GetSeekPos(handle);
|
||||
pspFileSystem.SeekFile(handle, 0, FILEMOVE_BEGIN);
|
||||
|
||||
*data = new u8[(size_t)dataSize];
|
||||
}
|
||||
|
||||
@@ -208,12 +211,12 @@ void SavedataParam::Init()
|
||||
pspFileSystem.MkDir(savePath);
|
||||
}
|
||||
// Create a nomedia file to hide save icons form Android image viewer
|
||||
#ifdef __ANDROID__
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
int handle = pspFileSystem.OpenFile(savePath + ".nomedia", (FileAccess)(FILEACCESS_CREATE | FILEACCESS_WRITE), 0);
|
||||
if (handle >= 0) {
|
||||
pspFileSystem.CloseFile(handle);
|
||||
} else {
|
||||
ERROR_LOG(IO, "Failed to create .nomedia file");
|
||||
INFO_LOG(IO, "Failed to create .nomedia file (might be ok if it already exists)");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -450,9 +453,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
|
||||
|
||||
// SAVE PARAM.SFO
|
||||
ParamSFOData sfoFile;
|
||||
std::string sfopath = dirPath+"/" + SFO_FILENAME;
|
||||
PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath);
|
||||
if (sfoInfo.exists) // Read old sfo if exist
|
||||
std::string sfopath = dirPath + "/" + SFO_FILENAME;
|
||||
{
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0)
|
||||
@@ -572,14 +573,12 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
|
||||
std::string pic1path = dirPath + "/" + PIC1_FILENAME;
|
||||
WritePSPFile(pic1path, param->pic1FileData.buf, param->pic1FileData.size);
|
||||
}
|
||||
|
||||
// Save SND
|
||||
if (param->snd0FileData.buf.IsValid())
|
||||
{
|
||||
std::string snd0path = dirPath + "/" + SND0_FILENAME;
|
||||
WritePSPFile(snd0path, param->snd0FileData.buf, param->snd0FileData.size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -599,19 +598,19 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD
|
||||
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA : SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA;
|
||||
}
|
||||
|
||||
if (!pspFileSystem.GetFileInfo(sfoPath).exists)
|
||||
// Load sfo
|
||||
if (!LoadSFO(param, dirPath)) {
|
||||
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_DATA_BROKEN : SCE_UTILITY_SAVEDATA_ERROR_LOAD_DATA_BROKEN;
|
||||
}
|
||||
|
||||
if (fileName != "" && !pspFileSystem.GetFileInfo(filePath).exists) {
|
||||
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND : SCE_UTILITY_SAVEDATA_ERROR_LOAD_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
LoadSFO(param, dirPath); // Load sfo
|
||||
|
||||
// Don't know what it is, but PSP always respond this and this unlock some game
|
||||
param->bind = 1021;
|
||||
|
||||
// Load another files,seems these are required by some games, e.g. Fushigi no Dungeon Fuurai no Shiren 4 Plus.
|
||||
// Load other files, seems these are required by some games, e.g. Fushigi no Dungeon Fuurai no Shiren 4 Plus.
|
||||
|
||||
// Load ICON0.PNG
|
||||
LoadFile(dirPath, ICON0_FILENAME, ¶m->icon0FileData);
|
||||
@@ -649,7 +648,7 @@ int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::strin
|
||||
std::string filename = GetFileName(param);
|
||||
std::string filePath = dirPath + "/" + filename;
|
||||
s64 readSize;
|
||||
INFO_LOG(SCEUTILITY,"Loading file with size %u in %s",param->dataBufSize,filePath.c_str());
|
||||
INFO_LOG(SCEUTILITY, "Loading file with size %u in %s", param->dataBufSize, filePath.c_str());
|
||||
u8 *saveData = nullptr;
|
||||
int saveSize = -1;
|
||||
if (!ReadPSPFile(filePath, &saveData, saveSize, &readSize)) {
|
||||
@@ -790,35 +789,35 @@ u32 SavedataParam::LoadNotCryptedSave(SceUtilitySavedataParam *param, u8 *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SavedataParam::LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath) {
|
||||
bool SavedataParam::LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath) {
|
||||
ParamSFOData sfoFile;
|
||||
std::string sfopath = dirPath+"/" + SFO_FILENAME;
|
||||
PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath);
|
||||
if (sfoInfo.exists) {
|
||||
// Read sfo
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) {
|
||||
sfoFile.ReadSFO(sfoData);
|
||||
std::string sfopath = dirPath + "/" + SFO_FILENAME;
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) {
|
||||
sfoFile.ReadSFO(sfoData);
|
||||
|
||||
// copy back info in request
|
||||
strncpy(param->sfoParam.title,sfoFile.GetValueString("TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.savedataTitle,sfoFile.GetValueString("SAVEDATA_TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.detail,sfoFile.GetValueString("SAVEDATA_DETAIL").c_str(),1024);
|
||||
param->sfoParam.parentalLevel = sfoFile.GetValueInt("PARENTAL_LEVEL");
|
||||
}
|
||||
// copy back info in request
|
||||
strncpy(param->sfoParam.title,sfoFile.GetValueString("TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.savedataTitle,sfoFile.GetValueString("SAVEDATA_TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.detail,sfoFile.GetValueString("SAVEDATA_DETAIL").c_str(),1024);
|
||||
param->sfoParam.parentalLevel = sfoFile.GetValueInt("PARENTAL_LEVEL");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SaveSFOFileListEntry> SavedataParam::GetSFOEntries(const std::string &dirPath) {
|
||||
std::vector<SaveSFOFileListEntry> result;
|
||||
const std::string sfoPath = dirPath + "/" + SFO_FILENAME;
|
||||
if (!pspFileSystem.GetFileInfo(sfoPath).exists)
|
||||
return result;
|
||||
|
||||
ParamSFOData sfoFile;
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(dirPath + "/" + SFO_FILENAME, sfoData) >= 0)
|
||||
if (pspFileSystem.ReadEntireFile(sfoPath, sfoData) >= 0) {
|
||||
sfoFile.ReadSFO(sfoData);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
|
||||
const int FILE_LIST_COUNT_MAX = 99;
|
||||
u32 sfoFileListSize = 0;
|
||||
@@ -1045,11 +1044,11 @@ int SavedataParam::BuildHash(unsigned char *output,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: Merge with NiceSizeFormat? That one has a decimal though.
|
||||
std::string SavedataParam::GetSpaceText(u64 size, bool roundUp)
|
||||
{
|
||||
static const char *suffixes[] = {"B", "KB", "MB", "GB"};
|
||||
char text[50];
|
||||
|
||||
static const char *suffixes[] = {"B", "KB", "MB", "GB"};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i)
|
||||
{
|
||||
if (size < 1024)
|
||||
@@ -1063,7 +1062,6 @@ std::string SavedataParam::GetSpaceText(u64 size, bool roundUp)
|
||||
size /= 1024;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(text, sizeof(text), "%llu TB", size);
|
||||
return std::string(text);
|
||||
}
|
||||
@@ -1162,7 +1160,6 @@ int SavedataParam::GetSizes(SceUtilitySavedataParam *param)
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, param->utilityData.ptr, sizeof(SceUtilitySavedataUsedDataInfo), "SavedataGetSizes");
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
@@ -1179,11 +1176,11 @@ bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
std::vector<PSPFileInfo> sfoFiles;
|
||||
std::vector<PSPFileInfo> allDir = pspFileSystem.GetDirListing(savePath);
|
||||
|
||||
std::string searchString = GetGameName(param)+GetSaveName(param);
|
||||
std::string searchString = GetGameName(param) + GetSaveName(param);
|
||||
for (size_t i = 0; i < allDir.size() && validDir.size() < maxFile; i++)
|
||||
{
|
||||
std::string dirName = allDir[i].name;
|
||||
if(PSPMatch(dirName, searchString))
|
||||
if (PSPMatch(dirName, searchString))
|
||||
{
|
||||
validDir.push_back(allDir[i]);
|
||||
}
|
||||
@@ -1191,9 +1188,9 @@ bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
|
||||
PSPFileInfo sfoFile;
|
||||
for (size_t i = 0; i < validDir.size(); ++i) {
|
||||
// GetFileName(param) == NUll here
|
||||
// GetFileName(param) == null here
|
||||
// so use sfo files to set the date.
|
||||
sfoFile = pspFileSystem.GetFileInfo(savePath + validDir[i].name + "/" + "PARAM.SFO");
|
||||
sfoFile = pspFileSystem.GetFileInfo(savePath + validDir[i].name + "/" + SFO_FILENAME);
|
||||
sfoFiles.push_back(sfoFile);
|
||||
}
|
||||
|
||||
@@ -1263,7 +1260,7 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param)
|
||||
fileList->resultNumNormalEntries = 0;
|
||||
fileList->resultNumSystemEntries = 0;
|
||||
|
||||
// We need PARAMS.SFO's SAVEDATA_FILE_LIST to determine which entries are secure.
|
||||
// We need PARAM.SFO's SAVEDATA_FILE_LIST to determine which entries are secure.
|
||||
PSPFileInfo sfoFileInfo = pspFileSystem.GetFileInfo(dirPath + "/" + SFO_FILENAME);
|
||||
std::set<std::string> secureFilenames;
|
||||
|
||||
@@ -1922,16 +1919,3 @@ bool SavedataParam::IsInSaveDataList(std::string saveName, int count) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SavedataParam::IsSaveDirectoryExist(SceUtilitySavedataParam* param) {
|
||||
std::string dirPath = savePath + GetGameName(param) + GetSaveName(param);
|
||||
PSPFileInfo directoryInfo = pspFileSystem.GetFileInfo(dirPath);
|
||||
return directoryInfo.exists;
|
||||
}
|
||||
|
||||
bool SavedataParam::IsSfoFileExist(SceUtilitySavedataParam* param) {
|
||||
std::string dirPath = savePath + GetGameName(param) + GetSaveName(param);
|
||||
std::string sfoPath = dirPath + "/" + SFO_FILENAME;
|
||||
PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfoPath);
|
||||
return sfoInfo.exists;
|
||||
}
|
||||
@@ -319,8 +319,6 @@ public:
|
||||
bool GetSize(SceUtilitySavedataParam* param);
|
||||
int GetSaveCryptMode(SceUtilitySavedataParam* param, const std::string &saveDirName);
|
||||
bool IsInSaveDataList(std::string saveName, int count);
|
||||
bool IsSaveDirectoryExist(SceUtilitySavedataParam* param);
|
||||
bool IsSfoFileExist(SceUtilitySavedataParam* param);
|
||||
|
||||
std::string GetGameName(const SceUtilitySavedataParam *param) const;
|
||||
std::string GetSaveName(const SceUtilitySavedataParam *param) const;
|
||||
@@ -366,7 +364,7 @@ private:
|
||||
int LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string& dirPath, bool secureMode);
|
||||
u32 LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, const u8 *saveData, int &saveSize, int prevCryptMode, const u8 *expectedHash, bool &saveDone);
|
||||
u32 LoadNotCryptedSave(SceUtilitySavedataParam *param, u8 *data, u8 *saveData, int &saveSize);
|
||||
void LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath);
|
||||
bool LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath);
|
||||
void LoadFile(const std::string& dirPath, const std::string& filename, PspUtilitySavedataFileData *fileData);
|
||||
|
||||
int DecryptSave(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *cryptkey, const u8 *expectedHash);
|
||||
|
||||
@@ -754,10 +754,9 @@ u64 DiskCachingFileLoaderCache::FreeDiskSpace() {
|
||||
dir = GetSysDirectory(DIRECTORY_CACHE);
|
||||
}
|
||||
|
||||
// TODO(scoped):
|
||||
uint64_t result = 0;
|
||||
if (free_disk_space(dir.ToString(), result)) {
|
||||
return result;
|
||||
int64_t result = 0;
|
||||
if (free_disk_space(dir, result)) {
|
||||
return (u64)result;
|
||||
}
|
||||
|
||||
// We can't know for sure how much is free, so we have to assume none.
|
||||
|
||||
@@ -137,7 +137,8 @@ int HTTPFileLoader::SendHEAD(const Url &url, std::vector<std::string> &responseH
|
||||
return -400;
|
||||
}
|
||||
|
||||
int err = client_.SendRequest("HEAD", url.Resource().c_str(), nullptr, &progress_);
|
||||
http::RequestParams req(url.Resource(), "*/*");
|
||||
int err = client_.SendRequest("HEAD", req, nullptr, &progress_);
|
||||
if (err < 0) {
|
||||
ERROR_LOG(LOADER, "HTTP request failed, failed to send request: %s port %d", url.Host().c_str(), url.Port());
|
||||
latestError_ = "Could not connect (could not request data)";
|
||||
@@ -196,7 +197,8 @@ size_t HTTPFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags f
|
||||
snprintf(requestHeaders, sizeof(requestHeaders),
|
||||
"Range: bytes=%lld-%lld\r\n", absolutePos, absoluteEnd - 1);
|
||||
|
||||
int err = client_.SendRequest("GET", url_.Resource().c_str(), requestHeaders, &progress_);
|
||||
http::RequestParams req(url_.Resource(), "*/*");
|
||||
int err = client_.SendRequest("GET", req, requestHeaders, &progress_);
|
||||
if (err < 0) {
|
||||
latestError_ = "Invalid response reading data";
|
||||
Disconnect();
|
||||
|
||||
@@ -60,8 +60,8 @@ LocalFileLoader::LocalFileLoader(const Path &filename)
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
if (filename.Type() == PathType::CONTENT_URI) {
|
||||
int fd = Android_OpenContentUriFd(filename.ToString(), Android_OpenContentUriMode::READ);
|
||||
INFO_LOG(SYSTEM, "Fd %d for content URI: '%s'", fd, filename.c_str());
|
||||
if (fd == -1) {
|
||||
VERBOSE_LOG(SYSTEM, "Fd %d for content URI: '%s'", fd, filename.c_str());
|
||||
if (fd < 0) {
|
||||
ERROR_LOG(FILESYS, "LoadFileLoader failed to open content URI: '%s'", filename.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
bool RemoveFile(const std::string &filename) override;
|
||||
u64 FreeSpace(const std::string &path) override;
|
||||
|
||||
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; }
|
||||
|
||||
private:
|
||||
// File positions.
|
||||
std::map<u32, s64> entries_;
|
||||
|
||||
@@ -44,10 +44,13 @@ BlockDevice *constructBlockDevice(FileLoader *fileLoader) {
|
||||
size_t size = fileLoader->ReadAt(0, 1, 4, buffer);
|
||||
if (size == 4 && !memcmp(buffer, "CISO", 4))
|
||||
return new CISOFileBlockDevice(fileLoader);
|
||||
else if (size == 4 && !memcmp(buffer, "\x00PBP", 4))
|
||||
return new NPDRMDemoBlockDevice(fileLoader);
|
||||
else
|
||||
return new FileBlockDevice(fileLoader);
|
||||
if (size == 4 && !memcmp(buffer, "\x00PBP", 4)) {
|
||||
uint32_t psarOffset = 0;
|
||||
size = fileLoader->ReadAt(0x24, 1, 4, &psarOffset);
|
||||
if (size == 4 && psarOffset < fileLoader->FileSize())
|
||||
return new NPDRMDemoBlockDevice(fileLoader);
|
||||
}
|
||||
return new FileBlockDevice(fileLoader);
|
||||
}
|
||||
|
||||
u32 BlockDevice::CalculateCRC(volatile bool *cancel) {
|
||||
|
||||
@@ -66,103 +66,6 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
static bool FixFilenameCase(const std::string &path, std::string &filename)
|
||||
{
|
||||
// Are we lucky?
|
||||
if (File::Exists(Path(path + filename)))
|
||||
return true;
|
||||
|
||||
size_t filenameSize = filename.size(); // size in bytes, not characters
|
||||
for (size_t i = 0; i < filenameSize; i++)
|
||||
{
|
||||
filename[i] = tolower(filename[i]);
|
||||
}
|
||||
|
||||
//TODO: lookup filename in cache for "path"
|
||||
struct dirent *result = NULL;
|
||||
|
||||
DIR *dirp = opendir(path.c_str());
|
||||
if (!dirp)
|
||||
return false;
|
||||
|
||||
bool retValue = false;
|
||||
|
||||
while ((result = readdir(dirp)))
|
||||
{
|
||||
if (strlen(result->d_name) != filenameSize)
|
||||
continue;
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < filenameSize; i++)
|
||||
{
|
||||
if (filename[i] != tolower(result->d_name[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < filenameSize)
|
||||
continue;
|
||||
|
||||
filename = result->d_name;
|
||||
retValue = true;
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
bool FixPathCase(const std::string &basePath, std::string &path, FixPathCaseBehavior behavior)
|
||||
{
|
||||
size_t len = path.size();
|
||||
|
||||
if (len == 0)
|
||||
return true;
|
||||
|
||||
if (path[len - 1] == '/')
|
||||
{
|
||||
len--;
|
||||
|
||||
if (len == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string fullPath;
|
||||
fullPath.reserve(basePath.size() + len + 1);
|
||||
fullPath.append(basePath);
|
||||
|
||||
size_t start = 0;
|
||||
while (start < len)
|
||||
{
|
||||
size_t i = path.find('/', start);
|
||||
if (i == std::string::npos)
|
||||
i = len;
|
||||
|
||||
if (i > start)
|
||||
{
|
||||
std::string component = path.substr(start, i - start);
|
||||
|
||||
// Fix case and stop on nonexistant path component
|
||||
if (FixFilenameCase(fullPath, component) == false) {
|
||||
// Still counts as success if partial matches allowed or if this
|
||||
// is the last component and only the ones before it are required
|
||||
return (behavior == FPC_PARTIAL_ALLOWED || (behavior == FPC_PATH_MUST_EXIST && i >= len));
|
||||
}
|
||||
|
||||
path.replace(start, i - start, component);
|
||||
|
||||
fullPath.append(1, '/');
|
||||
fullPath.append(component);
|
||||
}
|
||||
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DirectoryFileSystem::DirectoryFileSystem(IHandleAllocator *_hAlloc, const Path & _basePath, FileSystemFlags _flags) : basePath(_basePath), flags(_flags) {
|
||||
File::CreateFullPath(basePath);
|
||||
hAlloc = _hAlloc;
|
||||
@@ -172,24 +75,47 @@ DirectoryFileSystem::~DirectoryFileSystem() {
|
||||
CloseAll();
|
||||
}
|
||||
|
||||
Path DirectoryFileHandle::GetLocalPath(const Path &basePath, std::string localpath)
|
||||
{
|
||||
// TODO(scoped): Merge the two below functions somehow.
|
||||
|
||||
Path DirectoryFileHandle::GetLocalPath(const Path &basePath, std::string localpath) const {
|
||||
if (localpath.empty())
|
||||
return basePath;
|
||||
|
||||
if (localpath[0] == '/')
|
||||
localpath.erase(0, 1);
|
||||
|
||||
if (fileSystemFlags_ & FileSystemFlags::STRIP_PSP) {
|
||||
if (startsWith(localpath, "PSP/")) {
|
||||
localpath = localpath.substr(4);
|
||||
}
|
||||
}
|
||||
|
||||
return basePath / localpath;
|
||||
}
|
||||
|
||||
Path DirectoryFileSystem::GetLocalPath(std::string internalPath) const {
|
||||
if (internalPath.empty())
|
||||
return basePath;
|
||||
|
||||
if (internalPath[0] == '/')
|
||||
internalPath.erase(0, 1);
|
||||
|
||||
if (flags & FileSystemFlags::STRIP_PSP) {
|
||||
if (startsWith(internalPath, "PSP/")) {
|
||||
internalPath = internalPath.substr(4);
|
||||
}
|
||||
}
|
||||
|
||||
return basePath / internalPath;
|
||||
}
|
||||
|
||||
bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, FileAccess access, u32 &error) {
|
||||
error = 0;
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (access & (FILEACCESS_APPEND | FILEACCESS_CREATE | FILEACCESS_WRITE)) {
|
||||
DEBUG_LOG(FILESYS, "Checking case for path %s", fileName.c_str());
|
||||
if (!FixPathCase(basePath.ToString(), fileName, FPC_PATH_MUST_EXIST)) {
|
||||
if (!FixPathCase(basePath, fileName, FPC_PATH_MUST_EXIST)) {
|
||||
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
return false; // or go on and attempt (for a better error code than just 0?)
|
||||
}
|
||||
@@ -198,7 +124,6 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
|
||||
#endif
|
||||
|
||||
Path fullName = GetLocalPath(basePath, fileName);
|
||||
VERBOSE_LOG(FILESYS, "Actually opening %s", fullName.c_str());
|
||||
|
||||
// On the PSP, truncating doesn't lose data. If you seek later, you'll recover it.
|
||||
// This is abnormal, so we deviate from the PSP's behavior and truncate on write/close.
|
||||
@@ -289,6 +214,7 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
|
||||
// Success
|
||||
return true;
|
||||
} else {
|
||||
ERROR_LOG(FILESYS, "File::OpenFD returned an error");
|
||||
// TODO: Need better error codes from OpenFD so we can distinguish
|
||||
// disk full. Just set not found for now.
|
||||
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
@@ -320,7 +246,7 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (!success && !(access & FILEACCESS_CREATE)) {
|
||||
if (!FixPathCase(basePath.ToString(), fileName, FPC_PATH_MUST_EXIST)) {
|
||||
if (!FixPathCase(basePath, fileName, FPC_PATH_MUST_EXIST)) {
|
||||
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
return false;
|
||||
}
|
||||
@@ -364,6 +290,9 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
|
||||
if (fullName.FilePathContains("PSP/GAME/")) {
|
||||
inGameDir_ = true;
|
||||
}
|
||||
if (access & (FILEACCESS_APPEND | FILEACCESS_CREATE | FILEACCESS_WRITE)) {
|
||||
MemoryStick_NotifyWrite();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -418,6 +347,8 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
|
||||
bytesWritten = ReplayApplyDiskWrite(pointer, (uint64_t)bytesWritten, (uint64_t)size, &diskFull, inGameDir_, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
MemoryStick_NotifyWrite();
|
||||
|
||||
if (diskFull) {
|
||||
ERROR_LOG(FILESYS, "Disk full");
|
||||
auto err = GetI18NCategory("Error");
|
||||
@@ -503,22 +434,6 @@ void DirectoryFileSystem::CloseAll() {
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
Path DirectoryFileSystem::GetLocalPath(std::string internalPath) {
|
||||
if (internalPath.empty())
|
||||
return basePath;
|
||||
|
||||
if (internalPath[0] == '/')
|
||||
internalPath.erase(0, 1);
|
||||
//Convert slashes
|
||||
#ifdef _WIN32
|
||||
for (size_t i = 0; i < internalPath.size(); i++) {
|
||||
if (internalPath[i] == '/')
|
||||
internalPath[i] = '\\';
|
||||
}
|
||||
#endif
|
||||
return basePath / internalPath;
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::MkDir(const std::string &dirname) {
|
||||
bool result;
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
@@ -526,13 +441,14 @@ bool DirectoryFileSystem::MkDir(const std::string &dirname) {
|
||||
// duplicate (different case) directories
|
||||
|
||||
std::string fixedCase = dirname;
|
||||
if (!FixPathCase(basePath.ToString(), fixedCase, FPC_PARTIAL_ALLOWED))
|
||||
if (!FixPathCase(basePath, fixedCase, FPC_PARTIAL_ALLOWED))
|
||||
result = false;
|
||||
else
|
||||
result = File::CreateFullPath(GetLocalPath(fixedCase));
|
||||
#else
|
||||
result = File::CreateFullPath(GetLocalPath(dirname));
|
||||
#endif
|
||||
MemoryStick_NotifyWrite();
|
||||
return ReplayApplyDisk(ReplayAction::MKDIR, result, CoreTiming::GetGlobalTimeUs()) != 0;
|
||||
}
|
||||
|
||||
@@ -541,23 +457,21 @@ bool DirectoryFileSystem::RmDir(const std::string &dirname) {
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
// Maybe we're lucky?
|
||||
if (File::DeleteDirRecursively(fullName))
|
||||
if (File::DeleteDirRecursively(fullName)) {
|
||||
MemoryStick_NotifyWrite();
|
||||
return (bool)ReplayApplyDisk(ReplayAction::RMDIR, true, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
// Nope, fix case and try again. Should we try again?
|
||||
std::string fullPath = dirname;
|
||||
if (!FixPathCase(basePath.ToString(), fullPath, FPC_FILE_MUST_EXIST))
|
||||
if (!FixPathCase(basePath, fullPath, FPC_FILE_MUST_EXIST))
|
||||
return (bool)ReplayApplyDisk(ReplayAction::RMDIR, false, CoreTiming::GetGlobalTimeUs());
|
||||
|
||||
fullName = GetLocalPath(fullPath);
|
||||
#endif
|
||||
|
||||
/*#ifdef _WIN32
|
||||
return RemoveDirectory(fullName.c_str()) == TRUE;
|
||||
#else
|
||||
return 0 == rmdir(fullName.c_str());
|
||||
#endif*/
|
||||
bool result = File::DeleteDirRecursively(fullName);
|
||||
MemoryStick_NotifyWrite();
|
||||
return ReplayApplyDisk(ReplayAction::RMDIR, result, CoreTiming::GetGlobalTimeUs()) != 0;
|
||||
}
|
||||
|
||||
@@ -582,70 +496,58 @@ int DirectoryFileSystem::RenameFile(const std::string &from, const std::string &
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
// In case TO should overwrite a file with different case. Check error code?
|
||||
if (!FixPathCase(basePath.ToString(), fullTo, FPC_PATH_MUST_EXIST))
|
||||
if (!FixPathCase(basePath, fullTo, FPC_PATH_MUST_EXIST))
|
||||
return ReplayApplyDisk(ReplayAction::FILE_RENAME, -1, CoreTiming::GetGlobalTimeUs());
|
||||
#endif
|
||||
|
||||
Path fullToPath = GetLocalPath(fullTo);
|
||||
|
||||
#ifdef _WIN32
|
||||
bool retValue = (MoveFileEx(fullFrom.ToWString().c_str(), fullToPath.ToWString().c_str(), 0) == TRUE);
|
||||
#else
|
||||
bool retValue = (0 == rename(fullFrom.c_str(), fullToPath.c_str()));
|
||||
#endif
|
||||
bool retValue = File::Rename(fullFrom, fullToPath);
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (! retValue)
|
||||
if (!retValue)
|
||||
{
|
||||
// May have failed due to case sensitivity on FROM, so try again. Check error code?
|
||||
std::string fullFromPath = from;
|
||||
if (!FixPathCase(basePath.ToString(), fullFromPath, FPC_FILE_MUST_EXIST))
|
||||
if (!FixPathCase(basePath, fullFromPath, FPC_FILE_MUST_EXIST))
|
||||
return ReplayApplyDisk(ReplayAction::FILE_RENAME, -1, CoreTiming::GetGlobalTimeUs());
|
||||
fullFrom = GetLocalPath(fullFromPath);
|
||||
|
||||
#ifdef _WIN32
|
||||
retValue = (MoveFile(fullFrom.c_str(), fullToPath.c_str()) == TRUE);
|
||||
#else
|
||||
retValue = (0 == rename(fullFrom.c_str(), fullToPath.c_str()));
|
||||
#endif
|
||||
retValue = File::Rename(fullFrom, fullToPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Better error codes.
|
||||
int result = retValue ? 0 : (int)SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS;
|
||||
MemoryStick_NotifyWrite();
|
||||
return ReplayApplyDisk(ReplayAction::FILE_RENAME, result, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::RemoveFile(const std::string &filename) {
|
||||
Path fullName = GetLocalPath(filename);
|
||||
#ifdef _WIN32
|
||||
bool retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
|
||||
#else
|
||||
bool retValue = (0 == unlink(fullName.c_str()));
|
||||
#endif
|
||||
Path localPath = GetLocalPath(filename);
|
||||
|
||||
bool retValue = File::Delete(localPath);
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (! retValue)
|
||||
if (!retValue)
|
||||
{
|
||||
// May have failed due to case sensitivity, so try again. Try even if it fails?
|
||||
std::string fullNamePath = filename;
|
||||
if (!FixPathCase(basePath.ToString(), fullNamePath, FPC_FILE_MUST_EXIST))
|
||||
if (!FixPathCase(basePath, fullNamePath, FPC_FILE_MUST_EXIST))
|
||||
return (bool)ReplayApplyDisk(ReplayAction::FILE_REMOVE, false, CoreTiming::GetGlobalTimeUs());
|
||||
fullName = GetLocalPath(fullNamePath);
|
||||
localPath = GetLocalPath(fullNamePath);
|
||||
|
||||
#ifdef _WIN32
|
||||
retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
|
||||
#else
|
||||
retValue = (0 == unlink(fullName.c_str()));
|
||||
#endif
|
||||
retValue = File::Delete(localPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
MemoryStick_NotifyWrite();
|
||||
return ReplayApplyDisk(ReplayAction::FILE_REMOVE, retValue, CoreTiming::GetGlobalTimeUs()) != 0;
|
||||
}
|
||||
|
||||
int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
OpenFileEntry entry;
|
||||
entry.hFile.fileSystemFlags_ = flags;
|
||||
u32 err = 0;
|
||||
bool success = entry.hFile.Open(basePath, filename, access, err);
|
||||
if (err == 0 && !success) {
|
||||
@@ -663,7 +565,7 @@ int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const
|
||||
#else
|
||||
logError = (int)errno;
|
||||
#endif
|
||||
ERROR_LOG(FILESYS, "DirectoryFileSystem::OpenFile(%s): FAILED, %i - access = %d '%s'", filename.c_str(), logError, (int)access, errorString.c_str());
|
||||
ERROR_LOG(FILESYS, "DirectoryFileSystem::OpenFile('%s'): FAILED, %d - access = %d '%s'", filename.c_str(), logError, (int)access, errorString.c_str());
|
||||
return err;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
@@ -724,7 +626,7 @@ size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &use
|
||||
size_t bytesRead = iter->second.hFile.Read(pointer,size);
|
||||
return bytesRead;
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
// This shouldn't happen...
|
||||
ERROR_LOG(FILESYS,"Cannot read file that hasn't been opened: %08x", handle);
|
||||
return 0;
|
||||
}
|
||||
@@ -737,8 +639,7 @@ size_t DirectoryFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size) {
|
||||
|
||||
size_t DirectoryFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size, int &usec) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end())
|
||||
{
|
||||
if (iter != entries.end()) {
|
||||
size_t bytesWritten = iter->second.hFile.Write(pointer,size);
|
||||
return bytesWritten;
|
||||
} else {
|
||||
@@ -766,7 +667,7 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
|
||||
Path fullName = GetLocalPath(filename);
|
||||
if (!File::Exists(fullName)) {
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (! FixPathCase(basePath.ToString(), filename, FPC_FILE_MUST_EXIST))
|
||||
if (! FixPathCase(basePath, filename, FPC_FILE_MUST_EXIST))
|
||||
return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs());
|
||||
fullName = GetLocalPath(filename);
|
||||
|
||||
@@ -776,6 +677,9 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
|
||||
return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs());
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Consolidate to just a File::GetFileInfo call.
|
||||
|
||||
x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
|
||||
x.exists = true;
|
||||
|
||||
@@ -872,122 +776,86 @@ static std::string SimulateVFATBug(std::string filename) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) {
|
||||
Path localPath = GetLocalPath(path);
|
||||
|
||||
int64_t sizeTemp = File::ComputeRecursiveDirectorySize(localPath);
|
||||
if (sizeTemp >= 0) {
|
||||
*size = sizeTemp;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
|
||||
std::vector<PSPFileInfo> myVector;
|
||||
bool listingRoot = path == "/" || path == "\\";
|
||||
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE hFind;
|
||||
|
||||
std::wstring w32path = GetLocalPath(path).ToWString() + L"\\*.*";
|
||||
|
||||
hFind = FindFirstFileEx(w32path.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0);
|
||||
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
// Just return the empty array.
|
||||
return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
bool hideISOFiles = PSP_CoreParameter().compat.flags().HideISOFiles;
|
||||
while (true) {
|
||||
PSPFileInfo entry;
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
entry.type = FILETYPE_DIRECTORY;
|
||||
else
|
||||
entry.type = FILETYPE_NORMAL;
|
||||
|
||||
// TODO: Make this more correct?
|
||||
entry.access = entry.type == FILETYPE_NORMAL ? 0666 : 0777;
|
||||
// TODO: is this just for .. or all subdirectories? Need to add a directory to the test
|
||||
// to find out. Also why so different than the old test results?
|
||||
if (!wcscmp(findData.cFileName, L".."))
|
||||
entry.size = 4096;
|
||||
else
|
||||
entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32);
|
||||
entry.name = ConvertWStringToUTF8(findData.cFileName);
|
||||
if (Flags() & FileSystemFlags::SIMULATE_FAT32)
|
||||
entry.name = SimulateVFATBug(entry.name);
|
||||
|
||||
bool hideFile = false;
|
||||
if (hideISOFiles && (endsWithNoCase(entry.name, ".cso") || endsWithNoCase(entry.name, ".iso"))) {
|
||||
// Workaround for DJ Max Portable, see compat.ini.
|
||||
hideFile = true;
|
||||
}
|
||||
tmFromFiletime(entry.atime, findData.ftLastAccessTime);
|
||||
tmFromFiletime(entry.ctime, findData.ftCreationTime);
|
||||
tmFromFiletime(entry.mtime, findData.ftLastWriteTime);
|
||||
if (!hideFile && (!listingRoot || (wcscmp(findData.cFileName, L"..") && wcscmp(findData.cFileName, L"."))))
|
||||
myVector.push_back(entry);
|
||||
|
||||
int retval = FindNextFile(hFind, &findData);
|
||||
if (!retval)
|
||||
break;
|
||||
}
|
||||
FindClose(hFind);
|
||||
#else
|
||||
dirent *dirp;
|
||||
std::vector<File::FileInfo> files;
|
||||
Path localPath = GetLocalPath(path);
|
||||
DIR *dp = opendir(localPath.c_str());
|
||||
|
||||
const int flags = File::GETFILES_GETHIDDEN | File::GETFILES_GET_NAVIGATION_ENTRIES;
|
||||
if (!File::GetFilesInDir(localPath, &files, nullptr, flags)) {
|
||||
// TODO: Case sensitivity should be checked on a file system basis, right?
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (dp == NULL && FixPathCase(basePath.ToString(), path, FPC_FILE_MUST_EXIST)) {
|
||||
// May have failed due to case sensitivity, try again
|
||||
localPath = GetLocalPath(path);
|
||||
dp = opendir(localPath.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dp == NULL) {
|
||||
ERROR_LOG(FILESYS,"Error opening directory %s\n",path.c_str());
|
||||
if (FixPathCase(basePath, path, FPC_FILE_MUST_EXIST)) {
|
||||
// May have failed due to case sensitivity, try again
|
||||
localPath = GetLocalPath(path);
|
||||
if (!File::GetFilesInDir(localPath, &files, nullptr, 0)) {
|
||||
return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
}
|
||||
#else
|
||||
return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool hideISOFiles = PSP_CoreParameter().compat.flags().HideISOFiles;
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
PSPFileInfo entry;
|
||||
struct stat s;
|
||||
Path fullName = GetLocalPath(path) / std::string(dirp->d_name);
|
||||
stat(fullName.c_str(), &s);
|
||||
if (S_ISDIR(s.st_mode))
|
||||
entry.type = FILETYPE_DIRECTORY;
|
||||
else
|
||||
entry.type = FILETYPE_NORMAL;
|
||||
entry.access = s.st_mode & 0x1FF;
|
||||
entry.name = dirp->d_name;
|
||||
if (Flags() & FileSystemFlags::SIMULATE_FAT32)
|
||||
entry.name = SimulateVFATBug(entry.name);
|
||||
entry.size = s.st_size;
|
||||
|
||||
bool hideFile = false;
|
||||
// Then apply transforms to match PSP idiosynchrasies, as we convert the entries.
|
||||
for (auto &file : files) {
|
||||
PSPFileInfo entry;
|
||||
if (Flags() & FileSystemFlags::SIMULATE_FAT32) {
|
||||
entry.name = SimulateVFATBug(file.name);
|
||||
} else {
|
||||
entry.name = file.name;
|
||||
}
|
||||
if (hideISOFiles && (endsWithNoCase(entry.name, ".cso") || endsWithNoCase(entry.name, ".iso"))) {
|
||||
// Workaround for DJ Max Portable, see compat.ini.
|
||||
hideFile = true;
|
||||
continue;
|
||||
}
|
||||
if (file.name == "..") {
|
||||
entry.size = 4096;
|
||||
} else {
|
||||
entry.size = file.size;
|
||||
}
|
||||
if (file.isDirectory) {
|
||||
entry.type = FILETYPE_DIRECTORY;
|
||||
} else {
|
||||
entry.type = FILETYPE_NORMAL;
|
||||
}
|
||||
entry.access = file.access;
|
||||
|
||||
localtime_r((time_t*)&s.st_atime,&entry.atime);
|
||||
localtime_r((time_t*)&s.st_ctime,&entry.ctime);
|
||||
localtime_r((time_t*)&s.st_mtime,&entry.mtime);
|
||||
if (!hideFile && (!listingRoot || (strcmp(dirp->d_name, "..") && strcmp(dirp->d_name, "."))))
|
||||
myVector.push_back(entry);
|
||||
localtime_r((time_t*)&file.atime, &entry.atime);
|
||||
localtime_r((time_t*)&file.ctime, &entry.ctime);
|
||||
localtime_r((time_t*)&file.mtime, &entry.mtime);
|
||||
|
||||
myVector.push_back(entry);
|
||||
}
|
||||
closedir(dp);
|
||||
#endif
|
||||
|
||||
return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
u64 DirectoryFileSystem::FreeSpace(const std::string &path) {
|
||||
uint64_t result = 0;
|
||||
if (free_disk_space(GetLocalPath(path).ToString(), result)) {
|
||||
return ReplayApplyDisk64(ReplayAction::FREESPACE, result, CoreTiming::GetGlobalTimeUs());
|
||||
int64_t result = 0;
|
||||
if (free_disk_space(GetLocalPath(path), result)) {
|
||||
return ReplayApplyDisk64(ReplayAction::FREESPACE, (uint64_t)result, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
std::string fixedCase = path;
|
||||
if (FixPathCase(basePath.ToString(), fixedCase, FPC_FILE_MUST_EXIST)) {
|
||||
if (FixPathCase(basePath, fixedCase, FPC_FILE_MUST_EXIST)) {
|
||||
// May have failed due to case sensitivity, try again.
|
||||
if (free_disk_space(GetLocalPath(fixedCase).ToString(), result)) {
|
||||
if (free_disk_space(GetLocalPath(fixedCase), result)) {
|
||||
return ReplayApplyDisk64(ReplayAction::FREESPACE, result, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
}
|
||||
@@ -1018,6 +886,7 @@ void DirectoryFileSystem::DoState(PointerWrap &p) {
|
||||
CloseAll();
|
||||
u32 key;
|
||||
OpenFileEntry entry;
|
||||
entry.hFile.fileSystemFlags_ = flags;
|
||||
for (u32 i = 0; i < num; i++) {
|
||||
Do(p, key);
|
||||
Do(p, entry.guestFilename);
|
||||
@@ -1096,7 +965,7 @@ int VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
const char *fullNameC = fullName.c_str();
|
||||
VERBOSE_LOG(FILESYS,"VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());
|
||||
VERBOSE_LOG(FILESYS, "VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());
|
||||
|
||||
size_t size;
|
||||
u8 *data = VFSReadFile(fullNameC, &size);
|
||||
|
||||
@@ -28,36 +28,6 @@
|
||||
typedef void * HANDLE;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
#elif TARGET_IPHONE_SIMULATOR
|
||||
#define HOST_IS_CASE_SENSITIVE 0
|
||||
#else
|
||||
// Mac OSX case sensitivity defaults off, but is user configurable (when
|
||||
// creating a filesytem), so assume the worst:
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#define HOST_IS_CASE_SENSITIVE 0
|
||||
|
||||
#else // Android, Linux, BSD (and the rest?)
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
|
||||
#endif
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
enum FixPathCaseBehavior {
|
||||
FPC_FILE_MUST_EXIST, // all path components must exist (rmdir, move from)
|
||||
FPC_PATH_MUST_EXIST, // all except the last one must exist - still tries to fix last one (fopen, move to)
|
||||
FPC_PARTIAL_ALLOWED, // don't care how many exist (mkdir recursive)
|
||||
};
|
||||
|
||||
bool FixPathCase(const std::string &basePath, std::string &path, FixPathCaseBehavior behavior);
|
||||
#endif
|
||||
|
||||
struct DirectoryFileHandle {
|
||||
enum Flags {
|
||||
NORMAL,
|
||||
@@ -72,11 +42,14 @@ struct DirectoryFileHandle {
|
||||
s64 needsTrunc_ = -1;
|
||||
bool replay_ = true;
|
||||
bool inGameDir_ = false;
|
||||
FileSystemFlags fileSystemFlags_ = (FileSystemFlags)0;
|
||||
|
||||
DirectoryFileHandle(Flags flags) : replay_(flags != SKIP_REPLAY) {
|
||||
}
|
||||
DirectoryFileHandle() {}
|
||||
|
||||
Path GetLocalPath(const Path &basePath, std::string localpath);
|
||||
DirectoryFileHandle(Flags flags, FileSystemFlags fileSystemFlags)
|
||||
: replay_(flags != SKIP_REPLAY), fileSystemFlags_(fileSystemFlags) {}
|
||||
|
||||
Path GetLocalPath(const Path &basePath, std::string localpath) const;
|
||||
bool Open(const Path &basePath, std::string &fileName, FileAccess access, u32 &err);
|
||||
size_t Read(u8* pointer, s64 size);
|
||||
size_t Write(const u8* pointer, s64 size);
|
||||
@@ -112,11 +85,13 @@ public:
|
||||
FileSystemFlags Flags() override { return flags; }
|
||||
u64 FreeSpace(const std::string &path) override;
|
||||
|
||||
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override;
|
||||
|
||||
private:
|
||||
struct OpenFileEntry {
|
||||
DirectoryFileHandle hFile = DirectoryFileHandle::NORMAL;
|
||||
DirectoryFileHandle hFile;
|
||||
std::string guestFilename;
|
||||
FileAccess access;
|
||||
FileAccess access = FILEACCESS_NONE;
|
||||
};
|
||||
|
||||
typedef std::map<u32, OpenFileEntry> EntryMap;
|
||||
@@ -124,8 +99,8 @@ private:
|
||||
Path basePath;
|
||||
IHandleAllocator *hAlloc;
|
||||
FileSystemFlags flags;
|
||||
// In case of Windows: Translate slashes, etc.
|
||||
Path GetLocalPath(std::string internalPath);
|
||||
|
||||
Path GetLocalPath(std::string internalPath) const;
|
||||
};
|
||||
|
||||
// VFSFileSystem: Ability to map in Android APK paths as well! Does not support all features, only meant for fonts.
|
||||
@@ -156,6 +131,8 @@ public:
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::FLASH; }
|
||||
u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
|
||||
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; }
|
||||
|
||||
private:
|
||||
struct OpenFileEntry {
|
||||
u8 *fileData;
|
||||
|
||||
@@ -63,6 +63,7 @@ enum class FileSystemFlags {
|
||||
UMD = 2,
|
||||
CARD = 4,
|
||||
FLASH = 8,
|
||||
STRIP_PSP = 16,
|
||||
};
|
||||
ENUM_CLASS_BITOPS(FileSystemFlags);
|
||||
|
||||
@@ -135,11 +136,11 @@ public:
|
||||
virtual PSPDevType DevType(u32 handle) = 0;
|
||||
virtual FileSystemFlags Flags() = 0;
|
||||
virtual u64 FreeSpace(const std::string &path) = 0;
|
||||
virtual bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) = 0;
|
||||
};
|
||||
|
||||
|
||||
class EmptyFileSystem : public IFileSystem
|
||||
{
|
||||
class EmptyFileSystem : public IFileSystem {
|
||||
public:
|
||||
virtual void DoState(PointerWrap &p) override {}
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override {std::vector<PSPFileInfo> vec; return vec;}
|
||||
@@ -160,6 +161,7 @@ public:
|
||||
virtual PSPDevType DevType(u32 handle) override { return PSPDevType::INVALID; }
|
||||
virtual FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
virtual u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; }
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "FileSystem.h"
|
||||
|
||||
@@ -53,23 +54,24 @@ public:
|
||||
int RenameFile(const std::string &from, const std::string &to) override { return -1; }
|
||||
bool RemoveFile(const std::string &filename) override { return false; }
|
||||
|
||||
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; }
|
||||
|
||||
private:
|
||||
struct TreeEntry {
|
||||
TreeEntry() : flags(0), valid(false) {}
|
||||
~TreeEntry();
|
||||
|
||||
std::string name;
|
||||
u32 flags;
|
||||
u32 startingPosition;
|
||||
s64 size;
|
||||
bool isDirectory;
|
||||
u32 flags = 0;
|
||||
u32 startingPosition = 0;
|
||||
s64 size = 0;
|
||||
bool isDirectory = false;
|
||||
|
||||
u32 startsector;
|
||||
u32 dirsize;
|
||||
u32 startsector = 0;
|
||||
u32 dirsize = 0;
|
||||
|
||||
TreeEntry *parent;
|
||||
TreeEntry *parent = nullptr;
|
||||
|
||||
bool valid;
|
||||
bool valid = false;
|
||||
std::vector<TreeEntry *> children;
|
||||
};
|
||||
|
||||
@@ -101,7 +103,7 @@ private:
|
||||
// the filenames to "", to achieve this.
|
||||
class ISOBlockSystem : public IFileSystem {
|
||||
public:
|
||||
ISOBlockSystem(ISOFileSystem *isoFileSystem) : isoFileSystem_(isoFileSystem) {}
|
||||
ISOBlockSystem(std::shared_ptr<IFileSystem> isoFileSystem) : isoFileSystem_(isoFileSystem) {}
|
||||
|
||||
void DoState(PointerWrap &p) override {
|
||||
// This is a bit iffy, as block device savestates already are iffy (loads/saves multiple times for multiple mounts..)
|
||||
@@ -150,6 +152,8 @@ public:
|
||||
int RenameFile(const std::string &from, const std::string &to) override { return -1; }
|
||||
bool RemoveFile(const std::string &filename) override { return false; }
|
||||
|
||||
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; }
|
||||
|
||||
private:
|
||||
ISOFileSystem *isoFileSystem_;
|
||||
std::shared_ptr<IFileSystem> isoFileSystem_;
|
||||
};
|
||||
Loaded 100 of 321 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user