CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/Debugger/WebSocket/GameSubscriber.cpp
Views: 1401
// Copyright (c) 2018- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#include "Common/System/System.h"18#include "Core/Config.h"19#include "Core/Debugger/WebSocket/GameSubscriber.h"20#include "Core/Debugger/WebSocket/WebSocketUtils.h"21#include "Core/ELF/ParamSFO.h"22#include "Core/System.h"2324DebuggerSubscriber *WebSocketGameInit(DebuggerEventHandlerMap &map) {25map["game.reset"] = &WebSocketGameReset;26map["game.status"] = &WebSocketGameStatus;27map["version"] = &WebSocketVersion;2829return nullptr;30}3132// Reset emulation (game.reset)33//34// Use this if you need to break on start and do something before the game starts.35//36// Parameters:37// - break: optional boolean, true to break CPU on start. Use cpu.resume afterward.38//39// Response (same event name) with no extra data or error.40void WebSocketGameReset(DebuggerRequest &req) {41if (!PSP_IsInited())42return req.Fail("Game not running");4344bool needBreak = false;45if (!req.ParamBool("break", &needBreak, DebuggerParamType::OPTIONAL))46return;4748if (needBreak)49PSP_CoreParameter().startBreak = true;5051std::string resetError;52if (!PSP_Reboot(&resetError)) {53ERROR_LOG(Log::Boot, "Error resetting: %s", resetError.c_str());54return req.Fail("Could not reset");55}5657System_Notify(SystemNotification::BOOT_DONE);58System_Notify(SystemNotification::DISASSEMBLY);5960req.Respond();61}6263// Check game status (game.status)64//65// No parameters.66//67// Response (same event name):68// - game: null or an object with properties:69// - id: string disc ID (such as ULUS12345.)70// - version: string disc version.71// - title: string game title.72// - paused: boolean, true when gameplay is paused (not the same as stepping.)73void WebSocketGameStatus(DebuggerRequest &req) {74JsonWriter &json = req.Respond();75if (PSP_IsInited()) {76json.pushDict("game");77json.writeString("id", g_paramSFO.GetDiscID());78json.writeString("version", g_paramSFO.GetValueString("DISC_VERSION"));79json.writeString("title", g_paramSFO.GetValueString("TITLE"));80json.pop();81} else {82json.writeNull("game");83}84json.writeBool("paused", GetUIState() == UISTATE_PAUSEMENU);85}8687// Notify debugger version info (version)88//89// Parameters:90// - name: string indicating name of app or tool.91// - version: string version.92//93// Response (same event name):94// - name: string, "PPSSPP" unless some special build.95// - version: string, typically starts with "v" and may have git build info.96void WebSocketVersion(DebuggerRequest &req) {97JsonWriter &json = req.Respond();9899std::string version = req.client->version;100if (!req.ParamString("version", &version, DebuggerParamType::OPTIONAL_LOOSE))101return;102std::string name = req.client->name;103if (!req.ParamString("name", &name, DebuggerParamType::OPTIONAL_LOOSE))104return;105106req.client->version = version;107req.client->name = name;108109json.writeString("name", "PPSSPP");110json.writeString("version", PPSSPP_GIT_VERSION);111}112113114