mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-13 15:19:11 +00:00
Simple IPC for external control (#3345)
* add simple IPC protocol to allow communication via stdin/stdout * ipc: add PATCH_MEMORY command enables patches & cheates
This commit is contained in:
39
src/core/ipc/ipc.h
Normal file
39
src/core/ipc/ipc.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include <semaphore>
|
||||
#include <thread>
|
||||
|
||||
class IPC {
|
||||
bool enabled{false};
|
||||
std::jthread input_thread{};
|
||||
|
||||
std::binary_semaphore run_semaphore{0};
|
||||
std::binary_semaphore start_semaphore{0};
|
||||
|
||||
public:
|
||||
static IPC& Instance() {
|
||||
return *Common::Singleton<IPC>::Instance();
|
||||
}
|
||||
|
||||
void Init();
|
||||
|
||||
operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsEnabled() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void WaitForStart() {
|
||||
start_semaphore.acquire();
|
||||
}
|
||||
|
||||
private:
|
||||
[[noreturn]] void InputLoop();
|
||||
};
|
||||
Reference in New Issue
Block a user