-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add save state and screen access options to the web server #1643
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the review delay, I was busy overhauling the way we're distributing the emulator.
src/core/web-server.cc
Outdated
} | ||
virtual bool execute(PCSX::WebClient* client, PCSX::RequestData& request) final { | ||
if (PCSX::g_gui == nullptr) { | ||
client->write("HTTP/1.1 400 Bad Request\r\n\r\nSave states unavailable in CLI/no-UI mode."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to move the savestate code to the general UI class instead of the GUI one, but that's for another PR.
src/core/web-server.cc
Outdated
message = | ||
fmt::format("HTTP/1.1 200 OK\r\n\r\nState slot index {} {} successful.", slot, path); | ||
} else { | ||
message = fmt::format("HTTP/1.1 400 Bad Request\r\n\r\nState slot index {} {} failed.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically that's a 500 Internal Server Error :) The request was fine, the server didn't manage to handle it properly.
src/core/web-server.cc
Outdated
virtual ~StateExecutor() = default; | ||
}; | ||
|
||
clip::image convertScreenshotToImage(PCSX::GPU::ScreenShot&& screenshot) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should either be static
, or moved as methods of the ScreenExecutor
.
Web server GET options that allow for:
Save state access - load/save/delete/usage - NOT AVAILABLE for CLI/no-UI:
http://localhost:8080/api/v1/state/load?slot=0
- loads save state from slot 0, if available. Valid slots IDs are 0-9http://localhost:8080/api/v1/state/load?name=examplename
- loads named saveTITLEPREFIX_examplename.sstate
http://localhost:8080/api/v1/state/save?slot=0
- saves current state in slot 0http://localhost:8080/api/v1/state/save?name=examplename
- creates/overwrites named saveTITLEPREFIX_examplename.sstate
http://localhost:8080/api/v1/state/delete?slot=0
- deletes state in slot 0, if availablehttp://localhost:8080/api/v1/state/delete?name=examplename
- deletes named saveTITLEPREFIX_examplename.sstate
http://localhost:8080/api/v1/state/usage
- outputs Json that lists all existing named saves for the active title, and booleans for which save slots are in use, e.g.Screen access:
http://localhost:8080/api/v1/screen/save?filepath=d:\\screenshot.png
- outputs a PNG screenshot to the given filepath.http://localhost:8080/api/v1/screen/still
- outputs a PNG withContent-Type: image/png
. Example refreshing<img>
use-case (will affect emulator performance):