pcsx-redux icon indicating copy to clipboard operation
pcsx-redux copied to clipboard

Add save state and screen access options to the web server

Open Giragast opened this issue 1 year ago • 0 comments

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-9

  • http://localhost:8080/api/v1/state/load?name=examplename - loads named save TITLEPREFIX_examplename.sstate

  • http://localhost:8080/api/v1/state/save?slot=0 - saves current state in slot 0

  • http://localhost:8080/api/v1/state/save?name=examplename - creates/overwrites named save TITLEPREFIX_examplename.sstate

  • http://localhost:8080/api/v1/state/delete?slot=0 - deletes state in slot 0, if available

  • http://localhost:8080/api/v1/state/delete?name=examplename - deletes named save TITLEPREFIX_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.

{
    "named": [
        {
            "filepath": "D:\\pcsx-redux\\SLUS01234_chapter1_boss_fight.sstate",
            "name": "chapter1_boss_fight"
        },
        {
            "filepath": "D:\\pcsx-redux\\SLUS01234_intro_start.sstate",
            "name": "intro_start"
        },
        {
            "filepath": "D:\\pcsx-redux\\SLUS01234_shotgun.sstate",
            "name": "shotgun"
        }
    ],
    "slots": [
        true,
        true,
        false,
        true,
        false,
        false,
        false,
        true,
        true,
        false
    ]
}

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 with Content-Type: image/png. Example refreshing <img> use-case (will affect emulator performance):
<html>
<head>
<script type="text/javascript">
window.onload = function() {
    img = document.getElementById('refreshImage');
    img.src += "?";
    setInterval("img.src=img.src.replace(/\\?[0-9]*/, '?'+Math.floor(Math.random()*9999999+1));", 200);
}
</script>
</head>

<body>
<img id="refreshImage" src="http://localhost:8080/api/v1/screen/still" />
</body>
</html>

Giragast avatar Apr 18 '24 22:04 Giragast