From 0df0d0cb66632006f3300709d94b76b297f76c80 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:51:11 -0700 Subject: [PATCH 01/11] shader_recompiler: Fix last image sample address parameter. (#1334) --- src/shader_recompiler/ir/passes/resource_tracking_pass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index 76ffec81f..0cb6bff29 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -481,7 +481,7 @@ void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, IR::Inst* body1 = inst.Arg(1).InstRecursive(); IR::Inst* body2 = inst.Arg(2).InstRecursive(); IR::Inst* body3 = inst.Arg(3).InstRecursive(); - IR::Inst* body4 = inst.Arg(4).InstRecursive(); + IR::F32 body4 = IR::F32{inst.Arg(4)}; const auto get_addr_reg = [&](u32 index) -> IR::F32 { if (index <= 3) { return IR::F32{body1->Arg(index)}; @@ -493,7 +493,7 @@ void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, return IR::F32{body3->Arg(index - 8)}; } if (index == 12) { - return IR::F32{body4}; + return body4; } UNREACHABLE(); }; From dcc4057dd87d090b55affee6fb2f3859a326cb0f Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:04:51 -0700 Subject: [PATCH 02/11] shader_recompiler: Set correct operand field for VOP3b sdst. (#1335) --- src/shader_recompiler/frontend/decode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shader_recompiler/frontend/decode.cpp b/src/shader_recompiler/frontend/decode.cpp index 98f97dd12..796bed127 100644 --- a/src/shader_recompiler/frontend/decode.cpp +++ b/src/shader_recompiler/frontend/decode.cpp @@ -654,7 +654,7 @@ void GcnDecodeContext::decodeInstructionVOP3(uint64_t hexInstruction) { OpcodeVOP3 vop3Op = static_cast(op); if (IsVop3BEncoding(m_instruction.opcode)) { - m_instruction.dst[1].field = OperandField::ScalarGPR; + m_instruction.dst[1].field = getOperandField(sdst); m_instruction.dst[1].type = ScalarType::Uint64; m_instruction.dst[1].code = sdst; } else { From 21eb175aa10a5939a4eb306143af5713e3d80cee Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:14:50 -0700 Subject: [PATCH 03/11] shader_recompiler: Add asserts for get/set register bounds. (#1336) --- src/shader_recompiler/ir/ir_emitter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shader_recompiler/ir/ir_emitter.cpp b/src/shader_recompiler/ir/ir_emitter.cpp index e1b0eeed5..cfd044f9e 100644 --- a/src/shader_recompiler/ir/ir_emitter.cpp +++ b/src/shader_recompiler/ir/ir_emitter.cpp @@ -130,19 +130,23 @@ void IREmitter::DeviceMemoryBarrier() { } U32 IREmitter::GetUserData(IR::ScalarReg reg) { + ASSERT(static_cast(reg) < IR::NumScalarRegs); return Inst(Opcode::GetUserData, reg); } U1 IREmitter::GetThreadBitScalarReg(IR::ScalarReg reg) { + ASSERT(static_cast(reg) < IR::NumScalarRegs); return Inst(Opcode::GetThreadBitScalarReg, reg); } void IREmitter::SetThreadBitScalarReg(IR::ScalarReg reg, const U1& value) { + ASSERT(static_cast(reg) < IR::NumScalarRegs); Inst(Opcode::SetThreadBitScalarReg, reg, value); } template <> U32 IREmitter::GetScalarReg(IR::ScalarReg reg) { + ASSERT(static_cast(reg) < IR::NumScalarRegs); return Inst(Opcode::GetScalarRegister, reg); } @@ -153,6 +157,7 @@ F32 IREmitter::GetScalarReg(IR::ScalarReg reg) { template <> U32 IREmitter::GetVectorReg(IR::VectorReg reg) { + ASSERT(static_cast(reg) < IR::NumVectorRegs); return Inst(Opcode::GetVectorRegister, reg); } @@ -162,11 +167,13 @@ F32 IREmitter::GetVectorReg(IR::VectorReg reg) { } void IREmitter::SetScalarReg(IR::ScalarReg reg, const U32F32& value) { + ASSERT(static_cast(reg) < IR::NumScalarRegs); const U32 value_typed = value.Type() == Type::F32 ? BitCast(F32{value}) : U32{value}; Inst(Opcode::SetScalarRegister, reg, value_typed); } void IREmitter::SetVectorReg(IR::VectorReg reg, const U32F32& value) { + ASSERT(static_cast(reg) < IR::NumVectorRegs); const U32 value_typed = value.Type() == Type::F32 ? BitCast(F32{value}) : U32{value}; Inst(Opcode::SetVectorRegister, reg, value_typed); } From 2f80d7565de3c93b0813b360817d5f152e5c0e24 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:30:09 -0700 Subject: [PATCH 04/11] resource_tracking_pass: Fix type handling of sample offsets. (#1337) --- src/shader_recompiler/ir/passes/resource_tracking_pass.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index 0cb6bff29..21f2115d5 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -507,7 +507,11 @@ void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, } // The offsets are six-bit signed integers: X=[5:0], Y=[13:8], and Z=[21:16]. - const IR::Value arg = get_addr_reg(addr_reg++); + IR::Value arg = get_addr_reg(addr_reg++); + if (const IR::Inst* offset_inst = arg.TryInstRecursive()) { + ASSERT(offset_inst->GetOpcode() == IR::Opcode::BitCastF32U32); + arg = offset_inst->Arg(0); + } const auto read = [&](u32 off) -> IR::U32 { if (arg.IsImmediate()) { From 0f9166166074be844bce88bf25f6cf6cef1a77a0 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:58:01 -0700 Subject: [PATCH 05/11] resource_tracking_pass: Make sure immediate offset is accessed as correct type. (#1339) --- src/shader_recompiler/ir/passes/resource_tracking_pass.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index 21f2115d5..0d91badda 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -515,7 +515,9 @@ void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, const auto read = [&](u32 off) -> IR::U32 { if (arg.IsImmediate()) { - const u16 comp = (arg.U32() >> off) & 0x3F; + const u32 imm = + arg.Type() == IR::Type::F32 ? std::bit_cast(arg.F32()) : arg.U32(); + const u16 comp = (imm >> off) & 0x3F; return ir.Imm32(s32(comp << 26) >> 26); } return ir.BitFieldExtract(IR::U32{arg}, ir.Imm32(off), ir.Imm32(6), true); From 66f1bb937f056a899d7e7e6be8090fe98b194d0f Mon Sep 17 00:00:00 2001 From: Lander Gallastegi Date: Fri, 11 Oct 2024 03:53:32 +0200 Subject: [PATCH 06/11] ime_dialog: Initial implementation (#1267) * Add C string types * Prepare existing enums * Added missing enums * Types update * State base * Compile Ime Dialog UI * UI implementation * Scoped lock * Functional implementation * Link against iconv on macOS * Fix building on windows * Better UI * clang-format * Some fixes and cleanup * Enable reserved checks * clang-format * Fix default text encoding max size * clang-format (again) * Some review changes * Use std::vector for dynamic strings * Use CString * Accept dialog on enter press * clang-format * Use ImGUI for encoding/decoding --- CMakeLists.txt | 2 + src/common/cstring.h | 22 +- src/core/libraries/dialogs/ime_dialog.cpp | 207 ++++++++-- src/core/libraries/dialogs/ime_dialog.h | 280 +++++++------ src/core/libraries/dialogs/ime_dialog_ui.cpp | 390 +++++++++++++++++++ src/core/libraries/dialogs/ime_dialog_ui.h | 84 ++++ src/imgui/imgui_config.h | 5 +- 7 files changed, 847 insertions(+), 143 deletions(-) mode change 100644 => 100755 CMakeLists.txt create mode 100644 src/core/libraries/dialogs/ime_dialog_ui.cpp create mode 100644 src/core/libraries/dialogs/ime_dialog_ui.h diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 8a41e1ac9..7c58af6bb --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,6 +297,8 @@ set(LIBC_SOURCES src/core/libraries/libc_internal/libc_internal.cpp set(DIALOGS_LIB src/core/libraries/dialogs/error_dialog.cpp src/core/libraries/dialogs/error_dialog.h + src/core/libraries/dialogs/ime_dialog_ui.cpp + src/core/libraries/dialogs/ime_dialog_ui.h src/core/libraries/dialogs/ime_dialog.cpp src/core/libraries/dialogs/ime_dialog.h src/core/libraries/dialogs/error_codes.h diff --git a/src/common/cstring.h b/src/common/cstring.h index fb29443ee..45c291c14 100644 --- a/src/common/cstring.h +++ b/src/common/cstring.h @@ -81,34 +81,42 @@ public: return std::basic_string_view{data}; } - char* begin() { + T* begin() { if (this == nullptr) { return nullptr; } return data; } - const char* begin() const { + const T* begin() const { if (this == nullptr) { return nullptr; } return data; } - char* end() { + T* end() { if (this == nullptr) { return nullptr; } return data + N; } - const char* end() const { + const T* end() const { if (this == nullptr) { return nullptr; } return data + N; } + constexpr std::size_t capacity() const { + return N; + } + + std::size_t size() const { + return std::char_traits::length(data); + } + T& operator[](size_t idx) { return data[idx]; } @@ -152,6 +160,12 @@ public: static_assert(sizeof(CString<13>) == sizeof(char[13])); // Ensure size still matches a simple array static_assert(std::weakly_incrementable::Iterator>); +template +using CWString = CString; + +template +using CU16String = CString; + #pragma clang diagnostic pop } // namespace Common \ No newline at end of file diff --git a/src/core/libraries/dialogs/ime_dialog.cpp b/src/core/libraries/dialogs/ime_dialog.cpp index ddb1a89f8..3d168bb79 100644 --- a/src/core/libraries/dialogs/ime_dialog.cpp +++ b/src/core/libraries/dialogs/ime_dialog.cpp @@ -1,28 +1,75 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include "common/logging/log.h" #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" #include "ime_dialog.h" +#include "ime_dialog_ui.h" + +static constexpr std::array MAX_X_POSITIONS = {3840.0f, 1920.0f}; +static constexpr std::array MAX_Y_POSITIONS = {2160.0f, 1080.0f}; namespace Libraries::ImeDialog { -static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_NONE; +static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::NONE; +static OrbisImeDialogResult g_ime_dlg_result{}; +static ImeDialogState g_ime_dlg_state{}; +static ImeDialogUi g_ime_dlg_ui; -int PS4_SYSV_ABI sceImeDialogAbort() { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - return ORBIS_OK; +static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) { + if (False(~option & + (OrbisImeDialogOption::MULTILINE | OrbisImeDialogOption::NO_AUTO_COMPLETION))) { + return false; + } + + if (True(option & OrbisImeDialogOption::MULTILINE) && type != OrbisImeType::DEFAULT && + type != OrbisImeType::BASIC_LATIN) { + return false; + } + + if (True(option & OrbisImeDialogOption::NO_AUTO_COMPLETION) && type != OrbisImeType::NUMBER && + type != OrbisImeType::BASIC_LATIN) { + return false; + } + + return true; } -int PS4_SYSV_ABI sceImeDialogForceClose() { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - return ORBIS_OK; +Error PS4_SYSV_ABI sceImeDialogAbort() { + if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) { + LOG_INFO(Lib_ImeDialog, "IME dialog not in use"); + return Error::DIALOG_NOT_IN_USE; + } + + if (g_ime_dlg_status != OrbisImeDialogStatus::RUNNING) { + LOG_INFO(Lib_ImeDialog, "IME dialog not running"); + return Error::DIALOG_NOT_RUNNING; + } + + g_ime_dlg_status = OrbisImeDialogStatus::FINISHED; + g_ime_dlg_result.endstatus = OrbisImeDialogEndStatus::ABORTED; + + return Error::OK; } -int PS4_SYSV_ABI sceImeDialogForTestFunction() { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - return ORBIS_OK; +Error PS4_SYSV_ABI sceImeDialogForceClose() { + if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) { + LOG_INFO(Lib_ImeDialog, "IME dialog not in use"); + return Error::DIALOG_NOT_IN_USE; + } + + g_ime_dlg_status = OrbisImeDialogStatus::NONE; + g_ime_dlg_ui = ImeDialogUi(); + g_ime_dlg_state = ImeDialogState(); + + return Error::OK; +} + +Error PS4_SYSV_ABI sceImeDialogForTestFunction() { + return Error::INTERNAL; } int PS4_SYSV_ABI sceImeDialogGetCurrentStarState() { @@ -45,26 +92,118 @@ int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended() { return ORBIS_OK; } -int PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) { - result->endstatus = OrbisImeDialogEndStatus::ORBIS_IME_DIALOG_END_STATUS_OK; - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - return ORBIS_OK; +Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) { + if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) { + LOG_INFO(Lib_ImeDialog, "IME dialog is not running"); + return Error::DIALOG_NOT_IN_USE; + } + + if (result == nullptr) { + LOG_INFO(Lib_ImeDialog, "called with result (NULL)"); + return Error::INVALID_ADDRESS; + } + + result->endstatus = g_ime_dlg_result.endstatus; + + if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) { + return Error::DIALOG_NOT_FINISHED; + } + + g_ime_dlg_state.CopyTextToOrbisBuffer(); + return Error::OK; } -int PS4_SYSV_ABI sceImeDialogGetStatus() { - if (g_ime_dlg_status == OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_RUNNING) { - return OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_FINISHED; +OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() { + if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) { + g_ime_dlg_state.CallTextFilter(); } + return g_ime_dlg_status; } -int PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - const std::wstring_view text = L"shadPS4"; - param->maxTextLength = text.size(); - std::memcpy(param->inputTextBuffer, text.data(), text.size() * sizeof(wchar_t)); - g_ime_dlg_status = OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_RUNNING; - return ORBIS_OK; +Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) { + if (g_ime_dlg_status != OrbisImeDialogStatus::NONE) { + LOG_INFO(Lib_ImeDialog, "IME dialog is already running"); + return Error::BUSY; + } + + if (param == nullptr) { + LOG_INFO(Lib_ImeDialog, "called with param (NULL)"); + return Error::INVALID_ADDRESS; + } + + if (!magic_enum::enum_contains(param->type)) { + LOG_INFO(Lib_ImeDialog, "Invalid param->type"); + return Error::INVALID_ADDRESS; + } + + // TODO: do correct param->option validation + // TODO: do correct param->supportedLanguages validation + + if (param->posx < 0.0f || + param->posx >= + MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) { + LOG_INFO(Lib_ImeDialog, "Invalid param->posx"); + return Error::INVALID_POSX; + } + + if (param->posy < 0.0f || + param->posy >= + MAX_Y_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) { + LOG_INFO(Lib_ImeDialog, "Invalid param->posy"); + return Error::INVALID_POSY; + } + + if (!magic_enum::enum_contains(param->horizontalAlignment)) { + LOG_INFO(Lib_ImeDialog, "Invalid param->horizontalAlignment"); + return Error::INVALID_HORIZONTALIGNMENT; + } + + if (!magic_enum::enum_contains(param->verticalAlignment)) { + LOG_INFO(Lib_ImeDialog, "Invalid param->verticalAlignment"); + return Error::INVALID_VERTICALALIGNMENT; + } + + if (!IsValidOption(param->option, param->type)) { + LOG_INFO(Lib_ImeDialog, "Invalid param->option"); + return Error::INVALID_PARAM; + } + + if (param->inputTextBuffer == nullptr) { + LOG_INFO(Lib_ImeDialog, "Invalid param->inputTextBuffer"); + return Error::INVALID_INPUT_TEXT_BUFFER; + } + + if (extended) { + if (magic_enum::enum_contains(extended->priority)) { + LOG_INFO(Lib_ImeDialog, "Invalid extended->priority"); + return Error::INVALID_EXTENDED; + } + + // TODO: do correct extended->option validation + + if ((extended->extKeyboardMode & 0xe3fffffc) != 0) { + LOG_INFO(Lib_ImeDialog, "Invalid extended->extKeyboardMode"); + return Error::INVALID_EXTENDED; + } + + if (extended->disableDevice > 7) { + LOG_INFO(Lib_ImeDialog, "Invalid extended->disableDevice"); + return Error::INVALID_EXTENDED; + } + } + + if (param->maxTextLength > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) { + LOG_INFO(Lib_ImeDialog, "Invalid param->maxTextLength"); + return Error::INVALID_MAX_TEXT_LENGTH; + } + + g_ime_dlg_result = {}; + g_ime_dlg_state = ImeDialogState(param, extended); + g_ime_dlg_status = OrbisImeDialogStatus::RUNNING; + g_ime_dlg_ui = ImeDialogUi(&g_ime_dlg_state, &g_ime_dlg_status, &g_ime_dlg_result); + + return Error::OK; } int PS4_SYSV_ABI sceImeDialogInitInternal() { @@ -87,10 +226,22 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition() { return ORBIS_OK; } -int PS4_SYSV_ABI sceImeDialogTerm() { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - g_ime_dlg_status = OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_NONE; - return ORBIS_OK; +Error PS4_SYSV_ABI sceImeDialogTerm() { + if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) { + LOG_INFO(Lib_ImeDialog, "IME dialog not in use"); + return Error::DIALOG_NOT_IN_USE; + } + + if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) { + LOG_INFO(Lib_ImeDialog, "IME dialog is still running"); + return Error::DIALOG_NOT_FINISHED; + } + + g_ime_dlg_status = OrbisImeDialogStatus::NONE; + g_ime_dlg_ui = ImeDialogUi(); + g_ime_dlg_state = ImeDialogState(); + + return Error::OK; } void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym) { diff --git a/src/core/libraries/dialogs/ime_dialog.h b/src/core/libraries/dialogs/ime_dialog.h index ffe42b31a..66cf9fb93 100644 --- a/src/core/libraries/dialogs/ime_dialog.h +++ b/src/core/libraries/dialogs/ime_dialog.h @@ -3,6 +3,7 @@ #pragma once +#include "common/enum.h" #include "common/types.h" namespace Core::Loader { @@ -11,71 +12,150 @@ class SymbolsResolver; namespace Libraries::ImeDialog { -enum OrbisImeDialogStatus { - ORBIS_IME_DIALOG_STATUS_NONE = 0, - ORBIS_IME_DIALOG_STATUS_RUNNING = 1, - ORBIS_IME_DIALOG_STATUS_FINISHED = 2 +constexpr u32 ORBIS_IME_DIALOG_MAX_TEXT_LENGTH = 0x78; + +enum class Error : u32 { + OK = 0x0, + BUSY = 0x80bc0001, + NOT_OPENED = 0x80bc0002, + NO_MEMORY = 0x80bc0003, + CONNECTION_FAILED = 0x80bc0004, + TOO_MANY_REQUESTS = 0x80bc0005, + INVALID_TEXT = 0x80bc0006, + EVENT_OVERFLOW = 0x80bc0007, + NOT_ACTIVE = 0x80bc0008, + IME_SUSPENDING = 0x80bc0009, + DEVICE_IN_USE = 0x80bc000a, + INVALID_USER_ID = 0x80bc0010, + INVALID_TYPE = 0x80bc0011, + INVALID_SUPPORTED_LANGUAGES = 0x80bc0012, + INVALID_ENTER_LABEL = 0x80bc0013, + INVALID_INPUT_METHOD = 0x80bc0014, + INVALID_OPTION = 0x80bc0015, + INVALID_MAX_TEXT_LENGTH = 0x80bc0016, + INVALID_INPUT_TEXT_BUFFER = 0x80bc0017, + INVALID_POSX = 0x80bc0018, + INVALID_POSY = 0x80bc0019, + INVALID_HORIZONTALIGNMENT = 0x80bc001a, + INVALID_VERTICALALIGNMENT = 0x80bc001b, + INVALID_EXTENDED = 0x80bc001c, + INVALID_KEYBOARD_TYPE = 0x80bc001d, + INVALID_WORK = 0x80bc0020, + INVALID_ARG = 0x80bc0021, + INVALID_HANDLER = 0x80bc0022, + NO_RESOURCE_ID = 0x80bc0023, + INVALID_MODE = 0x80bc0024, + INVALID_PARAM = 0x80bc0030, + INVALID_ADDRESS = 0x80bc0031, + INVALID_RESERVED = 0x80bc0032, + INVALID_TIMING = 0x80bc0033, + INTERNAL = 0x80bc00ff, + DIALOG_INVALID_TITLE = 0x80bc0101, + DIALOG_NOT_RUNNING = 0x80bc0105, + DIALOG_NOT_FINISHED = 0x80bc0106, + DIALOG_NOT_IN_USE = 0x80bc0107, }; -enum OrbisImeDialogEndStatus { - ORBIS_IME_DIALOG_END_STATUS_OK = 0, - ORBIS_IME_DIALOG_END_STATUS_USER_CANCELED = 1, - ORBIS_IME_DIALOG_END_STATUS_ABORTED = 2 +enum class OrbisImeDialogStatus : u32 { + NONE = 0, + RUNNING = 1, + FINISHED = 2, }; -struct OrbisImeDialogResult { - OrbisImeDialogEndStatus endstatus; - s32 reserved[12]; +enum class OrbisImeDialogEndStatus : u32 { + OK = 0, + USER_CANCELED = 1, + ABORTED = 2, }; -enum OrbisImeType { - ORBIS_IME_TYPE_DEFAULT = 0, - ORBIS_IME_TYPE_BASIC_LATIN = 1, - ORBIS_IME_TYPE_URL = 2, - ORBIS_IME_TYPE_MAIL = 3, - ORBIS_IME_TYPE_NUMBER = 4 +enum class OrbisImeType : u32 { + DEFAULT = 0, + BASIC_LATIN = 1, + URL = 2, + MAIL = 3, + NUMBER = 4, }; -enum OrbisImeEnterLabel { - ORBIS_IME_ENTER_LABEL_DEFAULT = 0, - ORBIS_IME_ENTER_LABEL_SEND = 1, - ORBIS_IME_ENTER_LABEL_SEARCH = 2, - ORBIS_IME_ENTER_LABEL_GO = 3 -}; -enum OrbiImeInputMethod { ORBIS_IME_INPUT_METHOD_DEFAULT = 0 }; - -typedef int (*OrbisImeTextFilter)(wchar_t* outText, u32* outTextLength, const wchar_t* srcText, - u32 srcTextLength); - -enum OrbisImeHorizontalAlignment { - ORBIS_IME_HALIGN_LEFT = 0, - ORBIS_IME_HALIGN_CENTER = 1, - ORBIS_IME_HALIGN_RIGHT = 2 +enum class OrbisImeEnterLabel : u32 { + DEFAULT = 0, + SEND = 1, + SEARCH = 2, + GO = 3, }; -enum OrbisImeVerticalAlignment { - ORBIS_IME_VALIGN_TOP = 0, - ORBIS_IME_VALIGN_CENTER = 1, - ORBIS_IME_VALIGN_BOTTOM = 2 +enum class OrbisImeDialogOption : u32 { + DEFAULT = 0, + MULTILINE = 1, + NO_AUTO_CORRECTION = 2, + NO_AUTO_COMPLETION = 4, + // TODO: Document missing options + LARGE_RESOLUTION = 1024, }; -struct OrbisImeDialogParam { - s32 userId; - OrbisImeType type; - u64 supportedLanguages; - OrbisImeEnterLabel enterLabel; - OrbiImeInputMethod inputMethod; - OrbisImeTextFilter filter; - u32 option; - u32 maxTextLength; - wchar_t* inputTextBuffer; - float posx; - float posy; - OrbisImeHorizontalAlignment horizontalAlignment; - OrbisImeVerticalAlignment verticalAlignment; - const wchar_t* placeholder; - const wchar_t* title; - s8 reserved[16]; +DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDialogOption) + +enum class OrbisImeInputMethod : u32 { + DEFAULT = 0, +}; + +enum class OrbisImeHorizontalAlignment : u32 { + LEFT = 0, + CENTER = 1, + RIGHT = 2, +}; + +enum class OrbisImeVerticalAlignment : u32 { + TOP = 0, + CENTER = 1, + BOTTOM = 2, +}; + +enum class OrbisImePanelPriority : u32 { + DEFAULT = 0, + ALPHABET = 1, + SYMBOL = 2, + ACCENT = 3, +}; + +enum class OrbisImeKeyboardType : u32 { + NONE = 0, + DANISH = 1, + GERMAN = 2, + GERMAN_SW = 3, + ENGLISH_US = 4, + ENGLISH_GB = 5, + SPANISH = 6, + SPANISH_LA = 7, + FINNISH = 8, + FRENCH = 9, + FRENCH_BR = 10, + FRENCH_CA = 11, + FRENCH_SW = 12, + ITALIAN = 13, + DUTCH = 14, + NORWEGIAN = 15, + POLISH = 16, + PORTUGUESE_BR = 17, + PORTUGUESE_PT = 18, + RUSSIAN = 19, + SWEDISH = 20, + TURKISH = 21, + JAPANESE_ROMAN = 22, + JAPANESE_KANA = 23, + KOREAN = 24, + SM_CHINESE = 25, + TR_CHINESE_ZY = 26, + TR_CHINESE_PY_HK = 27, + TR_CHINESE_PY_TW = 28, + TR_CHINESE_CG = 29, + ARABIC_AR = 30, + THAI = 31, + CZECH = 32, + GREEK = 33, + INDONESIAN = 34, + VIETNAMESE = 35, + ROMANIAN = 36, + HUNGARIAN = 37, }; struct OrbisImeColor { @@ -85,57 +165,14 @@ struct OrbisImeColor { u8 a; }; -enum OrbisImePanelPriority { - ORBIS_IME_PANEL_PRIORITY_DEFAULT = 0, - ORBIS_IME_PANEL_PRIORITY_ALPHABET = 1, - ORBIS_IME_PANEL_PRIORITY_SYMBOL = 2, - ORBIS_IME_PANEL_PRIORITY_ACCENT = 3 -}; - -enum OrbisImeKeyboardType { - ORBIS_IME_KEYBOARD_TYPE_NONE = 0, - ORBIS_IME_KEYBOARD_TYPE_DANISH = 1, - ORBIS_IME_KEYBOARD_TYPE_GERMAN = 2, - ORBIS_IME_KEYBOARD_TYPE_GERMAN_SW = 3, - ORBIS_IME_KEYBOARD_TYPE_ENGLISH_US = 4, - ORBIS_IME_KEYBOARD_TYPE_ENGLISH_GB = 5, - ORBIS_IME_KEYBOARD_TYPE_SPANISH = 6, - ORBIS_IME_KEYBOARD_TYPE_SPANISH_LA = 7, - ORBIS_IME_KEYBOARD_TYPE_FINNISH = 8, - ORBIS_IME_KEYBOARD_TYPE_FRENCH = 9, - ORBIS_IME_KEYBOARD_TYPE_FRENCH_BR = 10, - ORBIS_IME_KEYBOARD_TYPE_FRENCH_CA = 11, - ORBIS_IME_KEYBOARD_TYPE_FRENCH_SW = 12, - ORBIS_IME_KEYBOARD_TYPE_ITALIAN = 13, - ORBIS_IME_KEYBOARD_TYPE_DUTCH = 14, - ORBIS_IME_KEYBOARD_TYPE_NORWEGIAN = 15, - ORBIS_IME_KEYBOARD_TYPE_POLISH = 16, - ORBIS_IME_KEYBOARD_TYPE_PORTUGUESE_BR = 17, - ORBIS_IME_KEYBOARD_TYPE_PORTUGUESE_PT = 18, - ORBIS_IME_KEYBOARD_TYPE_RUSSIAN = 19, - ORBIS_IME_KEYBOARD_TYPE_SWEDISH = 20, - ORBIS_IME_KEYBOARD_TYPE_TURKISH = 21, - ORBIS_IME_KEYBOARD_TYPE_JAPANESE_ROMAN = 22, - ORBIS_IME_KEYBOARD_TYPE_JAPANESE_KANA = 23, - ORBIS_IME_KEYBOARD_TYPE_KOREAN = 24, - ORBIS_IME_KEYBOARD_TYPE_SM_CHINESE = 25, - ORBIS_IME_KEYBOARD_TYPE_TR_CHINESE_ZY = 26, - ORBIS_IME_KEYBOARD_TYPE_TR_CHINESE_PY_HK = 27, - ORBIS_IME_KEYBOARD_TYPE_TR_CHINESE_PY_TW = 28, - ORBIS_IME_KEYBOARD_TYPE_TR_CHINESE_CG = 29, - ORBIS_IME_KEYBOARD_TYPE_ARABIC_AR = 30, - ORBIS_IME_KEYBOARD_TYPE_THAI = 31, - ORBIS_IME_KEYBOARD_TYPE_CZECH = 32, - ORBIS_IME_KEYBOARD_TYPE_GREEK = 33, - ORBIS_IME_KEYBOARD_TYPE_INDONESIAN = 34, - ORBIS_IME_KEYBOARD_TYPE_VIETNAMESE = 35, - ORBIS_IME_KEYBOARD_TYPE_ROMANIAN = 36, - ORBIS_IME_KEYBOARD_TYPE_HUNGARIAN = 37 +struct OrbisImeDialogResult { + OrbisImeDialogEndStatus endstatus; + s32 reserved[12]; }; struct OrbisImeKeycode { u16 keycode; - wchar_t character; + char16_t character; u32 status; OrbisImeKeyboardType type; s32 userId; @@ -143,11 +180,34 @@ struct OrbisImeKeycode { u64 timestamp; }; -typedef int (*OrbisImeExtKeyboardFilter)(const OrbisImeKeycode* srcKeycode, u16* outKeycode, - u32* outStatus, void* reserved); +typedef PS4_SYSV_ABI int (*OrbisImeTextFilter)(char16_t* outText, u32* outTextLength, + const char16_t* srcText, u32 srcTextLength); + +typedef PS4_SYSV_ABI int (*OrbisImeExtKeyboardFilter)(const OrbisImeKeycode* srcKeycode, + u16* outKeycode, u32* outStatus, + void* reserved); + +struct OrbisImeDialogParam { + s32 userId; + OrbisImeType type; + u64 supportedLanguages; + OrbisImeEnterLabel enterLabel; + OrbisImeInputMethod inputMethod; + OrbisImeTextFilter filter; + OrbisImeDialogOption option; + u32 maxTextLength; + char16_t* inputTextBuffer; + float posx; + float posy; + OrbisImeHorizontalAlignment horizontalAlignment; + OrbisImeVerticalAlignment verticalAlignment; + const char16_t* placeholder; + const char16_t* title; + s8 reserved[16]; +}; struct OrbisImeParamExtended { - u32 option; + u32 option; // OrbisImeDialogOptionExtended OrbisImeColor colorBase; OrbisImeColor colorLine; OrbisImeColor colorTextField; @@ -165,21 +225,21 @@ struct OrbisImeParamExtended { int8_t reserved[60]; }; -int PS4_SYSV_ABI sceImeDialogAbort(); -int PS4_SYSV_ABI sceImeDialogForceClose(); -int PS4_SYSV_ABI sceImeDialogForTestFunction(); +Error PS4_SYSV_ABI sceImeDialogAbort(); +Error PS4_SYSV_ABI sceImeDialogForceClose(); +Error PS4_SYSV_ABI sceImeDialogForTestFunction(); int PS4_SYSV_ABI sceImeDialogGetCurrentStarState(); int PS4_SYSV_ABI sceImeDialogGetPanelPositionAndForm(); int PS4_SYSV_ABI sceImeDialogGetPanelSize(); int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended(); -int PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result); -/*OrbisImeDialogStatus*/ int PS4_SYSV_ABI sceImeDialogGetStatus(); -int PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended); +Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result); +OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus(); +Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended); int PS4_SYSV_ABI sceImeDialogInitInternal(); int PS4_SYSV_ABI sceImeDialogInitInternal2(); int PS4_SYSV_ABI sceImeDialogInitInternal3(); int PS4_SYSV_ABI sceImeDialogSetPanelPosition(); -int PS4_SYSV_ABI sceImeDialogTerm(); +Error PS4_SYSV_ABI sceImeDialogTerm(); void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::ImeDialog \ No newline at end of file diff --git a/src/core/libraries/dialogs/ime_dialog_ui.cpp b/src/core/libraries/dialogs/ime_dialog_ui.cpp new file mode 100644 index 000000000..48f5d75dc --- /dev/null +++ b/src/core/libraries/dialogs/ime_dialog_ui.cpp @@ -0,0 +1,390 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include + +#include "common/assert.h" +#include "common/logging/log.h" +#include "common/singleton.h" +#include "core/libraries/dialogs/ime_dialog.h" +#include "core/libraries/dialogs/ime_dialog_ui.h" +#include "core/linker.h" +#include "imgui/imgui_std.h" + +using namespace ImGui; + +static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f}; + +namespace Libraries::ImeDialog { + +ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param, + const OrbisImeParamExtended* extended) { + if (!param) + return; + + userId = param->userId; + is_multiLine = True(param->option & OrbisImeDialogOption::MULTILINE); + is_numeric = param->type == OrbisImeType::NUMBER; + type = param->type; + enter_label = param->enterLabel; + text_filter = param->filter; + keyboard_filter = extended ? extended->extKeyboardFilter : nullptr; + max_text_length = param->maxTextLength; + text_buffer = param->inputTextBuffer; + + if (param->title) { + std::size_t title_len = std::char_traits::length(param->title); + title.resize(title_len * 4 + 1); + title[title_len * 4] = '\0'; + + if (!ConvertOrbisToUTF8(param->title, title_len, &title[0], title_len * 4)) { + LOG_ERROR(Lib_ImeDialog, "Failed to convert title to utf8 encoding"); + } + } + + if (param->placeholder) { + std::size_t placeholder_len = std::char_traits::length(param->placeholder); + placeholder.resize(placeholder_len * 4 + 1); + placeholder[placeholder_len * 4] = '\0'; + + if (!ConvertOrbisToUTF8(param->placeholder, placeholder_len, &placeholder[0], + placeholder_len * 4)) { + LOG_ERROR(Lib_ImeDialog, "Failed to convert placeholder to utf8 encoding"); + } + } + + std::size_t text_len = std::char_traits::length(text_buffer); + if (!ConvertOrbisToUTF8(text_buffer, text_len, current_text.begin(), + ORBIS_IME_DIALOG_MAX_TEXT_LENGTH * 4)) { + LOG_ERROR(Lib_ImeDialog, "Failed to convert text to utf8 encoding"); + } +} + +ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept + : input_changed(other.input_changed), userId(other.userId), is_multiLine(other.is_multiLine), + is_numeric(other.is_numeric), type(other.type), enter_label(other.enter_label), + text_filter(other.text_filter), keyboard_filter(other.keyboard_filter), + max_text_length(other.max_text_length), text_buffer(other.text_buffer), + title(std::move(other.title)), placeholder(std::move(other.placeholder)), + current_text(other.current_text) { + + other.text_buffer = nullptr; +} + +ImeDialogState& ImeDialogState::operator=(ImeDialogState&& other) { + if (this != &other) { + input_changed = other.input_changed; + userId = other.userId; + is_multiLine = other.is_multiLine; + is_numeric = other.is_numeric; + type = other.type; + enter_label = other.enter_label; + text_filter = other.text_filter; + keyboard_filter = other.keyboard_filter; + max_text_length = other.max_text_length; + text_buffer = other.text_buffer; + title = std::move(other.title); + placeholder = std::move(other.placeholder); + current_text = other.current_text; + + other.text_buffer = nullptr; + } + + return *this; +} + +bool ImeDialogState::CopyTextToOrbisBuffer() { + if (!text_buffer) { + return false; + } + + return ConvertUTF8ToOrbis(current_text.begin(), current_text.capacity(), text_buffer, + max_text_length); +} + +bool ImeDialogState::CallTextFilter() { + if (!text_filter || !input_changed) { + return true; + } + + input_changed = false; + + char16_t src_text[ORBIS_IME_DIALOG_MAX_TEXT_LENGTH + 1] = {0}; + u32 src_text_length = current_text.size(); + char16_t out_text[ORBIS_IME_DIALOG_MAX_TEXT_LENGTH + 1] = {0}; + u32 out_text_length = ORBIS_IME_DIALOG_MAX_TEXT_LENGTH; + + if (!ConvertUTF8ToOrbis(current_text.begin(), src_text_length, src_text, + ORBIS_IME_DIALOG_MAX_TEXT_LENGTH)) { + LOG_ERROR(Lib_ImeDialog, "Failed to convert text to orbis encoding"); + return false; + } + + auto* linker = Common::Singleton::Instance(); + int ret = + linker->ExecuteGuest(text_filter, out_text, &out_text_length, src_text, src_text_length); + + if (ret != 0) { + return false; + } + + if (!ConvertOrbisToUTF8(out_text, out_text_length, current_text.begin(), + ORBIS_IME_DIALOG_MAX_TEXT_LENGTH * 4)) { + LOG_ERROR(Lib_ImeDialog, "Failed to convert text to utf8 encoding"); + return false; + } + + return true; +} + +bool ImeDialogState::CallKeyboardFilter(const OrbisImeKeycode* src_keycode, u16* out_keycode, + u32* out_status) { + if (!keyboard_filter) { + return true; + } + + auto* linker = Common::Singleton::Instance(); + int ret = linker->ExecuteGuest(keyboard_filter, src_keycode, out_keycode, out_status, nullptr); + + return ret == 0; +} + +bool ImeDialogState::ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len, + char* utf8_text, std::size_t utf8_text_len) { + + std::fill(utf8_text, utf8_text + utf8_text_len, '\0'); + const ImWchar* orbis_text_ptr = reinterpret_cast(orbis_text); + ImTextStrToUtf8(utf8_text, utf8_text_len, orbis_text_ptr, orbis_text_ptr + orbis_text_len); + + return true; +} + +bool ImeDialogState::ConvertUTF8ToOrbis(const char* utf8_text, std::size_t utf8_text_len, + char16_t* orbis_text, std::size_t orbis_text_len) { + + std::fill(orbis_text, orbis_text + orbis_text_len, u'\0'); + ImTextStrFromUtf8(reinterpret_cast(orbis_text), orbis_text_len, utf8_text, nullptr); + + return true; +} + +ImeDialogUi::ImeDialogUi(ImeDialogState* state, OrbisImeDialogStatus* status, + OrbisImeDialogResult* result) + : state(state), status(status), result(result) { + + if (state && *status == OrbisImeDialogStatus::RUNNING) { + AddLayer(this); + } +} + +ImeDialogUi::~ImeDialogUi() { + std::scoped_lock lock(draw_mutex); + + Free(); +} + +ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept + : state(other.state), status(other.status), result(other.result), + first_render(other.first_render) { + + std::scoped_lock lock(draw_mutex, other.draw_mutex); + other.state = nullptr; + other.status = nullptr; + other.result = nullptr; + + if (state && *status == OrbisImeDialogStatus::RUNNING) { + AddLayer(this); + } +} + +ImeDialogUi& ImeDialogUi::operator=(ImeDialogUi&& other) { + std::scoped_lock lock(draw_mutex, other.draw_mutex); + Free(); + + state = other.state; + status = other.status; + result = other.result; + first_render = other.first_render; + other.state = nullptr; + other.status = nullptr; + other.result = nullptr; + + if (state && *status == OrbisImeDialogStatus::RUNNING) { + AddLayer(this); + } + + return *this; +} + +void ImeDialogUi::Free() { + RemoveLayer(this); +} + +void ImeDialogUi::Draw() { + std::unique_lock lock{draw_mutex}; + + if (!state) { + return; + } + + if (!status || *status != OrbisImeDialogStatus::RUNNING) { + return; + } + + const auto& ctx = *GetCurrentContext(); + const auto& io = ctx.IO; + + ImVec2 window_size; + + if (state->is_multiLine) { + window_size = {500.0f, 300.0f}; + } else { + window_size = {500.0f, 150.0f}; + } + + CentralizeWindow(); + SetNextWindowSize(window_size); + SetNextWindowCollapsed(false); + + if (first_render || !io.NavActive) { + SetNextWindowFocus(); + } + + if (Begin("IME Dialog##ImeDialog", nullptr, + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) { + DrawPrettyBackground(); + + if (!state->title.empty()) { + SetWindowFontScale(1.7f); + TextUnformatted(state->title.data()); + SetWindowFontScale(1.0f); + } + + if (state->is_multiLine) { + DrawMultiLineInputText(); + } else { + DrawInputText(); + } + + SetCursorPosY(GetCursorPosY() + 10.0f); + + const char* button_text; + + switch (state->enter_label) { + case OrbisImeEnterLabel::GO: + button_text = "Go##ImeDialogOK"; + break; + case OrbisImeEnterLabel::SEARCH: + button_text = "Search##ImeDialogOK"; + break; + case OrbisImeEnterLabel::SEND: + button_text = "Send##ImeDialogOK"; + break; + case OrbisImeEnterLabel::DEFAULT: + default: + button_text = "OK##ImeDialogOK"; + break; + } + + float button_spacing = 10.0f; + float total_button_width = BUTTON_SIZE.x * 2 + button_spacing; + float button_start_pos = (window_size.x - total_button_width) / 2.0f; + + SetCursorPosX(button_start_pos); + + if (Button(button_text, BUTTON_SIZE) || + (!state->is_multiLine && IsKeyPressed(ImGuiKey_Enter))) { + *status = OrbisImeDialogStatus::FINISHED; + result->endstatus = OrbisImeDialogEndStatus::OK; + } + + SameLine(0.0f, button_spacing); + + if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) { + *status = OrbisImeDialogStatus::FINISHED; + result->endstatus = OrbisImeDialogEndStatus::USER_CANCELED; + } + } + End(); + + first_render = false; +} + +void ImeDialogUi::DrawInputText() { + ImVec2 input_size = {GetWindowWidth() - 40.0f, 0.0f}; + SetCursorPosX(20.0f); + if (first_render) { + SetKeyboardFocusHere(); + } + const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data(); + if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(), + state->max_text_length, input_size, ImGuiInputTextFlags_CallbackCharFilter, + InputTextCallback, this)) { + state->input_changed = true; + } +} + +void ImeDialogUi::DrawMultiLineInputText() { + ImVec2 input_size = {GetWindowWidth() - 40.0f, 200.0f}; + SetCursorPosX(20.0f); + ImGuiInputTextFlags flags = ImGuiInputTextFlags_CallbackCharFilter | + static_cast(ImGuiInputTextFlags_Multiline); + if (first_render) { + SetKeyboardFocusHere(); + } + const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data(); + if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(), + state->max_text_length, input_size, flags, InputTextCallback, this)) { + state->input_changed = true; + } +} + +int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) { + ImeDialogUi* ui = static_cast(data->UserData); + + ASSERT(ui); + + // Should we filter punctuation? + if (ui->state->is_numeric && (data->EventChar < '0' || data->EventChar > '9') && + data->EventChar != '\b' && data->EventChar != ',' && data->EventChar != '.') { + return 1; + } + + if (!ui->state->keyboard_filter) { + return 0; + } + + // ImGui encodes ImWchar32 as multi-byte UTF-8 characters + char* event_char = reinterpret_cast(&data->EventChar); + + // Call the keyboard filter + OrbisImeKeycode src_keycode = { + .keycode = 0, + .character = 0, + .status = 1, // ??? 1 = key pressed, 0 = key released + .type = OrbisImeKeyboardType::ENGLISH_US, // TODO set this to the correct value (maybe use + // the current language?) + .userId = ui->state->userId, + .resourceId = 0, + .timestamp = 0}; + + if (!ui->state->ConvertUTF8ToOrbis(event_char, 4, &src_keycode.character, 1)) { + LOG_ERROR(Lib_ImeDialog, "Failed to convert orbis char to utf8"); + return 0; + } + src_keycode.keycode = src_keycode.character; // TODO set this to the correct value + + u16 out_keycode; + u32 out_status; + + ui->state->CallKeyboardFilter(&src_keycode, &out_keycode, &out_status); + + // TODO. set the keycode + + return 0; +} + +} // namespace Libraries::ImeDialog \ No newline at end of file diff --git a/src/core/libraries/dialogs/ime_dialog_ui.h b/src/core/libraries/dialogs/ime_dialog_ui.h new file mode 100644 index 000000000..96c83954a --- /dev/null +++ b/src/core/libraries/dialogs/ime_dialog_ui.h @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include "common/cstring.h" +#include "common/types.h" +#include "core/libraries/dialogs/ime_dialog.h" +#include "imgui/imgui_layer.h" + +namespace Libraries::ImeDialog { + +class ImeDialogUi; + +class ImeDialogState final { + friend ImeDialogUi; + + bool input_changed = false; + + s32 userId{}; + bool is_multiLine{}; + bool is_numeric{}; + OrbisImeType type{}; + OrbisImeEnterLabel enter_label{}; + OrbisImeTextFilter text_filter{}; + OrbisImeExtKeyboardFilter keyboard_filter{}; + u32 max_text_length{}; + char16_t* text_buffer{}; + std::vector title; + std::vector placeholder; + + // A character can hold up to 4 bytes in UTF-8 + Common::CString current_text; + +public: + ImeDialogState(const OrbisImeDialogParam* param = nullptr, + const OrbisImeParamExtended* extended = nullptr); + ImeDialogState(const ImeDialogState& other) = delete; + ImeDialogState(ImeDialogState&& other) noexcept; + ImeDialogState& operator=(ImeDialogState&& other); + + bool CopyTextToOrbisBuffer(); + bool CallTextFilter(); + +private: + bool CallKeyboardFilter(const OrbisImeKeycode* src_keycode, u16* out_keycode, u32* out_status); + + bool ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len, char* utf8_text, + std::size_t native_text_len); + bool ConvertUTF8ToOrbis(const char* native_text, std::size_t utf8_text_len, + char16_t* orbis_text, std::size_t orbis_text_len); +}; + +class ImeDialogUi final : public ImGui::Layer { + ImeDialogState* state{}; + OrbisImeDialogStatus* status{}; + OrbisImeDialogResult* result{}; + + bool first_render = true; + std::mutex draw_mutex; + +public: + explicit ImeDialogUi(ImeDialogState* state = nullptr, OrbisImeDialogStatus* status = nullptr, + OrbisImeDialogResult* result = nullptr); + ~ImeDialogUi() override; + ImeDialogUi(const ImeDialogUi& other) = delete; + ImeDialogUi(ImeDialogUi&& other) noexcept; + ImeDialogUi& operator=(ImeDialogUi&& other); + + void Draw() override; + +private: + void Free(); + + void DrawInputText(); + void DrawMultiLineInputText(); + + static int InputTextCallback(ImGuiInputTextCallbackData* data); +}; + +} // namespace Libraries::ImeDialog diff --git a/src/imgui/imgui_config.h b/src/imgui/imgui_config.h index 66d2b25c1..ccb084d94 100644 --- a/src/imgui/imgui_config.h +++ b/src/imgui/imgui_config.h @@ -21,7 +21,6 @@ extern void assert_fail_debug_msg(const char* msg); } \ }()) -#define IMGUI_USE_WCHAR32 #define IMGUI_ENABLE_STB_TRUETYPE #define IMGUI_DEFINE_MATH_OPERATORS @@ -30,3 +29,7 @@ extern void assert_fail_debug_msg(const char* msg); #define IM_VEC4_CLASS_EXTRA \ constexpr ImVec4(float _v) : x(_v), y(_v), z(_v), w(_v) {} + +#ifdef IMGUI_USE_WCHAR32 +#error "This project uses 16 bits wchar standard like Orbis" +#endif \ No newline at end of file From 04ad430115f3ccdf22d013d0c3e2efd38b444df1 Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier Date: Fri, 11 Oct 2024 06:26:30 +0000 Subject: [PATCH 07/11] cmake: add install rules (#1341) --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c58af6bb..3f3d7fcff 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -872,3 +872,11 @@ endif() # Discord RPC target_link_libraries(shadps4 PRIVATE discord-rpc) + +# Install rules +install(TARGETS shadps4 BUNDLE DESTINATION .) + +if (ENABLE_QT_GUI AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + install(FILES ".github/shadps4.desktop" DESTINATION "share/applications") + install(FILES ".github/shadps4.png" DESTINATION "share/icons/hicolor/512x512/apps") +endif() From dc99d3ebfc5ce69ed08a1b83129e99305851c1aa Mon Sep 17 00:00:00 2001 From: KrisCris <38860226+KrisCris@users.noreply.github.com> Date: Fri, 11 Oct 2024 14:27:28 +0800 Subject: [PATCH 08/11] Slightly refactor the game install dirs code (#1329) * fix: game dir dupes on each launch * fix copy around settings_addon_install_dir vector * do not show the path if it is not added * remove installDir from config file * format * moved migration code to save, and added notice * move ui->removeFolderButton->setEnabled to LoadValuesFromConfig * avoid checking duplicates for gameDirs loaded from config * use else condition to switch to the installDirs --- src/common/config.cpp | 38 ++++++++++++++++++------------ src/common/config.h | 5 ++-- src/qt_gui/game_install_dialog.cpp | 5 +--- src/qt_gui/settings_dialog.cpp | 24 ++++--------------- 4 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 37e51c655..78da372e7 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -325,9 +325,19 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) { main_window_geometry_w = w; main_window_geometry_h = h; } -void setGameInstallDirs(const std::vector& dir) { - settings_install_dirs.resize(dir.size()); - settings_install_dirs = dir; +bool addGameInstallDir(const std::filesystem::path& dir) { + if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) == + settings_install_dirs.end()) { + settings_install_dirs.push_back(dir); + return true; + } + return false; +} +void removeGameInstallDir(const std::filesystem::path& dir) { + auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir); + if (iterator != settings_install_dirs.end()) { + settings_install_dirs.erase(iterator); + } } void setAddonInstallDir(const std::filesystem::path& dir) { settings_addon_install_dir = dir; @@ -385,7 +395,7 @@ u32 getMainWindowGeometryW() { u32 getMainWindowGeometryH() { return main_window_geometry_h; } -std::vector getGameInstallDirs() { +const std::vector& getGameInstallDirs() { return settings_install_dirs; } std::filesystem::path getAddonInstallDir() { @@ -525,19 +535,14 @@ void load(const std::filesystem::path& path) { m_window_size_W = toml::find_or(gui, "mw_width", 0); m_window_size_H = toml::find_or(gui, "mw_height", 0); + // TODO Migration code, after a major release this should be removed. auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {}); if (!old_game_install_dir.empty()) { - settings_install_dirs.push_back(old_game_install_dir); - data.as_table().erase("installDir"); - } - - const auto install_dir_array = - toml::find_or>(gui, "installDirs", {}); - for (const auto& dir : install_dir_array) { - bool not_already_included = - std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) == - settings_install_dirs.end(); - if (not_already_included) { + settings_install_dirs.emplace_back(std::filesystem::path{old_game_install_dir}); + } else { + const auto install_dir_array = + toml::find_or>(gui, "installDirs", {}); + for (const auto& dir : install_dir_array) { settings_install_dirs.emplace_back(std::filesystem::path{dir}); } } @@ -639,6 +644,9 @@ void save(const std::filesystem::path& path) { data["Settings"]["consoleLanguage"] = m_language; + // TODO Migration code, after a major release this should be removed. + data.at("GUI").as_table().erase("installDir"); + std::ofstream file(path, std::ios::out); file << data; file.close(); diff --git a/src/common/config.h b/src/common/config.h index 8e799b55d..591d6dced 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -84,7 +84,8 @@ bool vkCrashDiagnosticEnabled(); // Gui void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h); -void setGameInstallDirs(const std::vector& dir); +bool addGameInstallDir(const std::filesystem::path& dir); +void removeGameInstallDir(const std::filesystem::path& dir); void setAddonInstallDir(const std::filesystem::path& dir); void setMainWindowTheme(u32 theme); void setIconSize(u32 size); @@ -103,7 +104,7 @@ u32 getMainWindowGeometryX(); u32 getMainWindowGeometryY(); u32 getMainWindowGeometryW(); u32 getMainWindowGeometryH(); -std::vector getGameInstallDirs(); +const std::vector& getGameInstallDirs(); std::filesystem::path getAddonInstallDir(); u32 getMainWindowTheme(); u32 getIconSize(); diff --git a/src/qt_gui/game_install_dialog.cpp b/src/qt_gui/game_install_dialog.cpp index 4418d9a48..e53c58315 100644 --- a/src/qt_gui/game_install_dialog.cpp +++ b/src/qt_gui/game_install_dialog.cpp @@ -126,10 +126,7 @@ void GameInstallDialog::Save() { return; } } - - std::vector install_dirs; - install_dirs.emplace_back(Common::FS::PathFromQString(gamesDirectory)); - Config::setGameInstallDirs(install_dirs); + Config::addGameInstallDir(Common::FS::PathFromQString(gamesDirectory)); Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory)); const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); Config::save(config_dir / "config.toml"); diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 1cc5a85e4..efc2cd3eb 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -218,19 +218,12 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge // PATH TAB { - ui->removeFolderButton->setEnabled(false); - connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() { const auto config_dir = Config::getGameInstallDirs(); QString file_path_string = QFileDialog::getExistingDirectory(this, tr("Directory to install games")); auto file_path = Common::FS::PathFromQString(file_path_string); - bool not_already_included = - std::find(config_dir.begin(), config_dir.end(), file_path) == config_dir.end(); - if (!file_path.empty() && not_already_included) { - std::vector install_dirs = config_dir; - install_dirs.push_back(file_path); - Config::setGameInstallDirs(install_dirs); + if (!file_path.empty() && Config::addGameInstallDir(file_path)) { QListWidgetItem* item = new QListWidgetItem(file_path_string); ui->gameFoldersListWidget->addItem(item); } @@ -246,17 +239,8 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge QString item_path_string = selected_item ? selected_item->text() : QString(); if (!item_path_string.isEmpty()) { auto file_path = Common::FS::PathFromQString(item_path_string); - std::vector install_dirs = Config::getGameInstallDirs(); - - auto iterator = std::remove_if( - install_dirs.begin(), install_dirs.end(), - [&file_path](const std::filesystem::path& dir) { return file_path == dir; }); - - if (iterator != install_dirs.end()) { - install_dirs.erase(iterator, install_dirs.end()); - delete selected_item; - } - Config::setGameInstallDirs(install_dirs); + Config::removeGameInstallDir(file_path); + delete selected_item; } }); } @@ -370,6 +354,8 @@ void SettingsDialog::LoadValuesFromConfig() { QString backButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior()); int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior); ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0); + + ui->removeFolderButton->setEnabled(!ui->gameFoldersListWidget->selectedItems().isEmpty()); } void SettingsDialog::InitializeEmulatorLanguages() { From dbdbb40c0bbe68215b9239efabc0a7b10893ede8 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 11 Oct 2024 10:37:36 +0300 Subject: [PATCH 09/11] Network libs fixes , stubs and more (#1324) * some rework on netctl calls * added libs stubs using from RE6 * added ORBIS_NET_CTL_INFO_IP_ADDRESS case in sceNetCtlGetInfo * added sceNetInetPton * some dummy functions and change some functions to debug level * clang format fix * fix for sceNetInetPton * posix OS fix? * linux + macOS fixes? * fix? * sceSharePlayGetCurrentConnectionInfo --- CMakeLists.txt | 8 + src/common/logging/filter.cpp | 4 + src/common/logging/types.h | 128 ++++--- .../game_live_streaming/gamelivestreaming.cpp | 354 ++++++++++++++++++ .../game_live_streaming/gamelivestreaming.h | 81 ++++ src/core/libraries/ime/ime.cpp | 340 +++++++++++++++++ src/core/libraries/ime/ime.h | 70 ++++ src/core/libraries/libs.cpp | 9 +- src/core/libraries/network/net.cpp | 13 +- src/core/libraries/network/net.h | 2 +- src/core/libraries/network/net_ctl_codes.h | 8 + src/core/libraries/network/net_obj.cpp | 0 src/core/libraries/network/net_obj.h | 0 src/core/libraries/network/netctl.cpp | 39 +- src/core/libraries/network/netctl.h | 1 + src/core/libraries/pad/pad.cpp | 2 +- src/core/libraries/remote_play/remoteplay.cpp | 309 +++++++++++++++ src/core/libraries/remote_play/remoteplay.h | 62 +++ src/core/libraries/share_play/shareplay.cpp | 186 +++++++++ src/core/libraries/share_play/shareplay.h | 54 +++ src/core/libraries/system/userservice.cpp | 2 +- 21 files changed, 1599 insertions(+), 73 deletions(-) create mode 100644 src/core/libraries/game_live_streaming/gamelivestreaming.cpp create mode 100644 src/core/libraries/game_live_streaming/gamelivestreaming.h create mode 100644 src/core/libraries/ime/ime.cpp create mode 100644 src/core/libraries/ime/ime.h create mode 100644 src/core/libraries/network/net_obj.cpp create mode 100644 src/core/libraries/network/net_obj.h create mode 100644 src/core/libraries/remote_play/remoteplay.cpp create mode 100644 src/core/libraries/remote_play/remoteplay.h create mode 100644 src/core/libraries/share_play/shareplay.cpp create mode 100644 src/core/libraries/share_play/shareplay.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f3d7fcff..37021746d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,6 +282,14 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp src/core/libraries/audio3d/audio3d_error.h src/core/libraries/audio3d/audio3d_impl.cpp src/core/libraries/audio3d/audio3d_impl.h + src/core/libraries/ime/ime.cpp + src/core/libraries/ime/ime.h + src/core/libraries/game_live_streaming/gamelivestreaming.cpp + src/core/libraries/game_live_streaming/gamelivestreaming.h + src/core/libraries/remote_play/remoteplay.cpp + src/core/libraries/remote_play/remoteplay.h + src/core/libraries/share_play/shareplay.cpp + src/core/libraries/share_play/shareplay.h ) set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 2ff2a9003..051bbd79e 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -114,6 +114,10 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, AvPlayer) \ SUB(Lib, Ngs2) \ SUB(Lib, Audio3d) \ + SUB(Lib, Ime) \ + SUB(Lib, GameLiveStreaming) \ + SUB(Lib, Remoteplay) \ + SUB(Lib, SharePlay) \ SUB(Lib, Fiber) \ CLS(Frontend) \ CLS(Render) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 54388e590..39319d0dc 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -29,68 +29,72 @@ enum class Level : u8 { * filter.cpp. */ enum class Class : u8 { - Log, ///< Messages about the log system itself - Common, ///< Library routines - Common_Filesystem, ///< Filesystem interface library - Common_Memory, ///< Memory mapping and management functions - Core, ///< LLE emulation core - Core_Linker, ///< The module linker - Config, ///< Emulator configuration (including commandline) - Debug, ///< Debugging tools - Kernel, ///< The HLE implementation of the PS4 kernel. - Kernel_Pthread, ///< The pthread implementation of the kernel. - Kernel_Fs, ///< The filesystem implementation of the kernel. - Kernel_Vmm, ///< The virtual memory implementation of the kernel. - Kernel_Event, ///< The event management implementation of the kernel. - Kernel_Sce, ///< The sony specific interfaces provided by the kernel. - Lib, ///< HLE implementation of system library. Each major library - ///< should have its own subclass. - Lib_LibC, ///< The LibC implementation. - Lib_Kernel, ///< The LibKernel implementation. - Lib_Pad, ///< The LibScePad implementation. - Lib_GnmDriver, ///< The LibSceGnmDriver implementation. - Lib_SystemService, ///< The LibSceSystemService implementation. - Lib_UserService, ///< The LibSceUserService implementation. - Lib_VideoOut, ///< The LibSceVideoOut implementation. - Lib_CommonDlg, ///< The LibSceCommonDialog implementation. - Lib_MsgDlg, ///< The LibSceMsgDialog implementation. - Lib_AudioOut, ///< The LibSceAudioOut implementation. - Lib_AudioIn, ///< The LibSceAudioIn implementation. - Lib_Net, ///< The LibSceNet implementation. - Lib_NetCtl, ///< The LibSecNetCtl implementation. - Lib_SaveData, ///< The LibSceSaveData implementation. - Lib_SaveDataDialog, ///< The LibSceSaveDataDialog implementation. - Lib_Ssl, ///< The LibSceSsl implementation. - Lib_Http, ///< The LibSceHttp implementation. - Lib_SysModule, ///< The LibSceSysModule implementation - Lib_NpManager, ///< The LibSceNpManager implementation - Lib_NpScore, ///< The LibSceNpScore implementation - Lib_NpTrophy, ///< The LibSceNpTrophy implementation - Lib_Screenshot, ///< The LibSceScreenshot implementation - Lib_LibCInternal, ///< The LibCInternal implementation. - Lib_AppContent, ///< The LibSceAppContent implementation. - Lib_Rtc, ///< The LibSceRtc implementation. - Lib_DiscMap, ///< The LibSceDiscMap implementation. - Lib_Png, ///< The LibScePng implementation. - Lib_PlayGo, ///< The LibScePlayGo implementation. - Lib_Random, ///< The libSceRandom implementation. - Lib_Usbd, ///< The LibSceUsbd implementation. - Lib_Ajm, ///< The LibSceAjm implementation. - Lib_ErrorDialog, ///< The LibSceErrorDialog implementation. - Lib_ImeDialog, ///< The LibSceImeDialog implementation. - Lib_AvPlayer, ///< The LibSceAvPlayer implementation. - Lib_Ngs2, ///< The LibSceNgs2 implementation. - Lib_Audio3d, ///< The LibSceAudio3d implementation. - Lib_Fiber, ///< The LibSceFiber implementation. - Frontend, ///< Emulator UI - Render, ///< Video Core - Render_Vulkan, ///< Vulkan backend - Render_Recompiler, ///< Shader recompiler - ImGui, ///< ImGui - Loader, ///< ROM loader - Input, ///< Input emulation - Tty, ///< Debug output from emu - Count ///< Total number of logging classes + Log, ///< Messages about the log system itself + Common, ///< Library routines + Common_Filesystem, ///< Filesystem interface library + Common_Memory, ///< Memory mapping and management functions + Core, ///< LLE emulation core + Core_Linker, ///< The module linker + Config, ///< Emulator configuration (including commandline) + Debug, ///< Debugging tools + Kernel, ///< The HLE implementation of the PS4 kernel. + Kernel_Pthread, ///< The pthread implementation of the kernel. + Kernel_Fs, ///< The filesystem implementation of the kernel. + Kernel_Vmm, ///< The virtual memory implementation of the kernel. + Kernel_Event, ///< The event management implementation of the kernel. + Kernel_Sce, ///< The sony specific interfaces provided by the kernel. + Lib, ///< HLE implementation of system library. Each major library + ///< should have its own subclass. + Lib_LibC, ///< The LibC implementation. + Lib_Kernel, ///< The LibKernel implementation. + Lib_Pad, ///< The LibScePad implementation. + Lib_GnmDriver, ///< The LibSceGnmDriver implementation. + Lib_SystemService, ///< The LibSceSystemService implementation. + Lib_UserService, ///< The LibSceUserService implementation. + Lib_VideoOut, ///< The LibSceVideoOut implementation. + Lib_CommonDlg, ///< The LibSceCommonDialog implementation. + Lib_MsgDlg, ///< The LibSceMsgDialog implementation. + Lib_AudioOut, ///< The LibSceAudioOut implementation. + Lib_AudioIn, ///< The LibSceAudioIn implementation. + Lib_Net, ///< The LibSceNet implementation. + Lib_NetCtl, ///< The LibSecNetCtl implementation. + Lib_SaveData, ///< The LibSceSaveData implementation. + Lib_SaveDataDialog, ///< The LibSceSaveDataDialog implementation. + Lib_Ssl, ///< The LibSceSsl implementation. + Lib_Http, ///< The LibSceHttp implementation. + Lib_SysModule, ///< The LibSceSysModule implementation + Lib_NpManager, ///< The LibSceNpManager implementation + Lib_NpScore, ///< The LibSceNpScore implementation + Lib_NpTrophy, ///< The LibSceNpTrophy implementation + Lib_Screenshot, ///< The LibSceScreenshot implementation + Lib_LibCInternal, ///< The LibCInternal implementation. + Lib_AppContent, ///< The LibSceAppContent implementation. + Lib_Rtc, ///< The LibSceRtc implementation. + Lib_DiscMap, ///< The LibSceDiscMap implementation. + Lib_Png, ///< The LibScePng implementation. + Lib_PlayGo, ///< The LibScePlayGo implementation. + Lib_Random, ///< The libSceRandom implementation. + Lib_Usbd, ///< The LibSceUsbd implementation. + Lib_Ajm, ///< The LibSceAjm implementation. + Lib_ErrorDialog, ///< The LibSceErrorDialog implementation. + Lib_ImeDialog, ///< The LibSceImeDialog implementation. + Lib_AvPlayer, ///< The LibSceAvPlayer implementation. + Lib_Ngs2, ///< The LibSceNgs2 implementation. + Lib_Audio3d, ///< The LibSceAudio3d implementation. + Lib_Ime, ///< The LibSceIme implementation + Lib_GameLiveStreaming, ///< The LibSceGameLiveStreaming implementation + Lib_Remoteplay, ///< The LibSceRemotePlay implementation + Lib_SharePlay, ///< The LibSceSharePlay implemenation + Lib_Fiber, ///< The LibSceFiber implementation. + Frontend, ///< Emulator UI + Render, ///< Video Core + Render_Vulkan, ///< Vulkan backend + Render_Recompiler, ///< Shader recompiler + ImGui, ///< ImGui + Loader, ///< ROM loader + Input, ///< Input emulation + Tty, ///< Debug output from emu + Count ///< Total number of logging classes }; } // namespace Common::Log diff --git a/src/core/libraries/game_live_streaming/gamelivestreaming.cpp b/src/core/libraries/game_live_streaming/gamelivestreaming.cpp new file mode 100644 index 000000000..a1ebddfbf --- /dev/null +++ b/src/core/libraries/game_live_streaming/gamelivestreaming.cpp @@ -0,0 +1,354 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gamelivestreaming.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" + +namespace Libraries::GameLiveStreaming { + +int PS4_SYSV_ABI sceGameLiveStreamingStartDebugBroadcast() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingStopDebugBroadcast() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingApplySocialFeedbackMessageFilter() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingCheckCallback() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingClearPresetSocialFeedbackCommands() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingClearSocialFeedbackMessages() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingClearSpoilerTag() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingEnableLiveStreaming() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingEnableSocialFeedback() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingGetCurrentBroadcastScreenLayout() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingGetCurrentStatus(OrbisGameLiveStreamingStatus* status) { + memset(status, 0, sizeof(*status)); + status->isOnAir = false; + LOG_DEBUG(Lib_GameLiveStreaming, "(STUBBED) called userid = {}", status->userId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingGetCurrentStatus2() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingGetProgramInfo() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingGetSocialFeedbackMessages() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingGetSocialFeedbackMessagesCount() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingInitialize() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingLaunchLiveViewer() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingLaunchLiveViewerA() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingPermitLiveStreaming() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingPermitServerSideRecording() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingPostSocialMessage() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingRegisterCallback() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenCloseSeparateMode() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenConfigureSeparateMode() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenInitialize() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenInitializeSeparateModeParameter() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenOpenSeparateMode() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenSetMode() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingScreenTerminate() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetCameraFrameSetting() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetDefaultServiceProviderPermission() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetGuardAreas() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetInvitationSessionId() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetLinkCommentPreset() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetMaxBitrate() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetMetadata() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetPresetSocialFeedbackCommands() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetPresetSocialFeedbackCommandsDescription() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetServiceProviderPermission() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetSpoilerTag() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingSetStandbyScreenResource() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingStartGenerateStandbyScreenResource() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingStartSocialFeedbackMessageFiltering() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingStopGenerateStandbyScreenResource() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingStopSocialFeedbackMessageFiltering() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingTerminate() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceGameLiveStreamingUnregisterCallback() { + LOG_ERROR(Lib_GameLiveStreaming, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceGameLiveStreaming(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("caqgDl+V9qA", "libSceGameLiveStreaming_debug", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingStartDebugBroadcast); + LIB_FUNCTION("0i8Lrllxwow", "libSceGameLiveStreaming_debug", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingStopDebugBroadcast); + LIB_FUNCTION("NqkTzemliC0", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingApplySocialFeedbackMessageFilter); + LIB_FUNCTION("PC4jq87+YQI", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingCheckCallback); + LIB_FUNCTION("FcHBfHjFXkA", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingClearPresetSocialFeedbackCommands); + LIB_FUNCTION("lZ2Sd0uEvpo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingClearSocialFeedbackMessages); + LIB_FUNCTION("6c2zGtThFww", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingClearSpoilerTag); + LIB_FUNCTION("dWM80AX39o4", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingEnableLiveStreaming); + LIB_FUNCTION("wBOQWjbWMfU", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingEnableSocialFeedback); + LIB_FUNCTION("aRSQNqbats4", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetCurrentBroadcastScreenLayout); + LIB_FUNCTION("CoPMx369EqM", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetCurrentStatus); + LIB_FUNCTION("lK8dLBNp9OE", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetCurrentStatus2); + LIB_FUNCTION("OIIm19xu+NM", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetProgramInfo); + LIB_FUNCTION("PMx7N4WqNdo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetSocialFeedbackMessages); + LIB_FUNCTION("yeQKjHETi40", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetSocialFeedbackMessagesCount); + LIB_FUNCTION("kvYEw2lBndk", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingInitialize); + LIB_FUNCTION("ysWfX5PPbfc", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingLaunchLiveViewer); + LIB_FUNCTION("cvRCb7DTAig", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingLaunchLiveViewerA); + LIB_FUNCTION("K0QxEbD7q+c", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingPermitLiveStreaming); + LIB_FUNCTION("-EHnU68gExU", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingPermitServerSideRecording); + LIB_FUNCTION("hggKhPySVgI", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingPostSocialMessage); + LIB_FUNCTION("nFP8qT9YXbo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingRegisterCallback); + LIB_FUNCTION("b5RaMD2J0So", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenCloseSeparateMode); + LIB_FUNCTION("hBdd8n6kuvE", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenConfigureSeparateMode); + LIB_FUNCTION("uhCmn81s-mU", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenInitialize); + LIB_FUNCTION("fo5B8RUaBxQ", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenInitializeSeparateModeParameter); + LIB_FUNCTION("iorzW0pKOiA", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenOpenSeparateMode); + LIB_FUNCTION("gDSvt78H3Oo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenSetMode); + LIB_FUNCTION("HE93dr-5rx4", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingScreenTerminate); + LIB_FUNCTION("3PSiwAzFISE", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetCameraFrameSetting); + LIB_FUNCTION("TwuUzTKKeek", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetDefaultServiceProviderPermission); + LIB_FUNCTION("Gw6S4oqlY7E", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetGuardAreas); + LIB_FUNCTION("QmQYwQ7OTJI", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetInvitationSessionId); + LIB_FUNCTION("Sb5bAXyUt5c", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetLinkCommentPreset); + LIB_FUNCTION("q-kxuaF7URU", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetMaxBitrate); + LIB_FUNCTION("hUY-mSOyGL0", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetMetadata); + LIB_FUNCTION("ycodiP2I0xo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetPresetSocialFeedbackCommands); + LIB_FUNCTION("x6deXUpQbBo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetPresetSocialFeedbackCommandsDescription); + LIB_FUNCTION("mCoz3k3zPmA", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetServiceProviderPermission); + LIB_FUNCTION("ZuX+zzz2DkA", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetSpoilerTag); + LIB_FUNCTION("MLvYI86FFAo", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingSetStandbyScreenResource); + LIB_FUNCTION("y0KkAydy9xE", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingStartGenerateStandbyScreenResource); + LIB_FUNCTION("Y1WxX7dPMCw", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingStartSocialFeedbackMessageFiltering); + LIB_FUNCTION("D7dg5QJ4FlE", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingStopGenerateStandbyScreenResource); + LIB_FUNCTION("bYuGUBuIsaY", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingStopSocialFeedbackMessageFiltering); + LIB_FUNCTION("9yK6Fk8mKOQ", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingTerminate); + LIB_FUNCTION("5XHaH3kL+bA", "libSceGameLiveStreaming", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingUnregisterCallback); + LIB_FUNCTION("caqgDl+V9qA", "libSceGameLiveStreaming_direct_streaming", 1, + "libSceGameLiveStreaming", 1, 1, sceGameLiveStreamingStartDebugBroadcast); + LIB_FUNCTION("0i8Lrllxwow", "libSceGameLiveStreaming_direct_streaming", 1, + "libSceGameLiveStreaming", 1, 1, sceGameLiveStreamingStopDebugBroadcast); + LIB_FUNCTION("CoPMx369EqM", "libSceGameLiveStreamingCompat", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingGetCurrentStatus); + LIB_FUNCTION("ysWfX5PPbfc", "libSceGameLiveStreamingCompat", 1, "libSceGameLiveStreaming", 1, 1, + sceGameLiveStreamingLaunchLiveViewer); +}; + +} // namespace Libraries::GameLiveStreaming \ No newline at end of file diff --git a/src/core/libraries/game_live_streaming/gamelivestreaming.h b/src/core/libraries/game_live_streaming/gamelivestreaming.h new file mode 100644 index 000000000..468750fd1 --- /dev/null +++ b/src/core/libraries/game_live_streaming/gamelivestreaming.h @@ -0,0 +1,81 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::GameLiveStreaming { + +struct OrbisGameLiveStreamingStatus { + bool isOnAir; + u8 align[3]; + u32 spectatorCounts; + s32 userId; + u8 reserved[60]; +}; +struct OrbisGameLiveStreamingStatus2 { + s32 userId; + bool isOnAir; + u8 align[3]; + u32 spectatorCounts; + u32 textMessageCounts; + u32 commandMessageCounts; + u32 broadcastVideoResolution; + u8 reserved[48]; +}; + +int PS4_SYSV_ABI sceGameLiveStreamingStartDebugBroadcast(); +int PS4_SYSV_ABI sceGameLiveStreamingStopDebugBroadcast(); +int PS4_SYSV_ABI sceGameLiveStreamingApplySocialFeedbackMessageFilter(); +int PS4_SYSV_ABI sceGameLiveStreamingCheckCallback(); +int PS4_SYSV_ABI sceGameLiveStreamingClearPresetSocialFeedbackCommands(); +int PS4_SYSV_ABI sceGameLiveStreamingClearSocialFeedbackMessages(); +int PS4_SYSV_ABI sceGameLiveStreamingClearSpoilerTag(); +int PS4_SYSV_ABI sceGameLiveStreamingEnableLiveStreaming(); +int PS4_SYSV_ABI sceGameLiveStreamingEnableSocialFeedback(); +int PS4_SYSV_ABI sceGameLiveStreamingGetCurrentBroadcastScreenLayout(); +int PS4_SYSV_ABI sceGameLiveStreamingGetCurrentStatus(OrbisGameLiveStreamingStatus* status); +int PS4_SYSV_ABI sceGameLiveStreamingGetCurrentStatus2(); +int PS4_SYSV_ABI sceGameLiveStreamingGetProgramInfo(); +int PS4_SYSV_ABI sceGameLiveStreamingGetSocialFeedbackMessages(); +int PS4_SYSV_ABI sceGameLiveStreamingGetSocialFeedbackMessagesCount(); +int PS4_SYSV_ABI sceGameLiveStreamingInitialize(); +int PS4_SYSV_ABI sceGameLiveStreamingLaunchLiveViewer(); +int PS4_SYSV_ABI sceGameLiveStreamingLaunchLiveViewerA(); +int PS4_SYSV_ABI sceGameLiveStreamingPermitLiveStreaming(); +int PS4_SYSV_ABI sceGameLiveStreamingPermitServerSideRecording(); +int PS4_SYSV_ABI sceGameLiveStreamingPostSocialMessage(); +int PS4_SYSV_ABI sceGameLiveStreamingRegisterCallback(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenCloseSeparateMode(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenConfigureSeparateMode(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenInitialize(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenInitializeSeparateModeParameter(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenOpenSeparateMode(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenSetMode(); +int PS4_SYSV_ABI sceGameLiveStreamingScreenTerminate(); +int PS4_SYSV_ABI sceGameLiveStreamingSetCameraFrameSetting(); +int PS4_SYSV_ABI sceGameLiveStreamingSetDefaultServiceProviderPermission(); +int PS4_SYSV_ABI sceGameLiveStreamingSetGuardAreas(); +int PS4_SYSV_ABI sceGameLiveStreamingSetInvitationSessionId(); +int PS4_SYSV_ABI sceGameLiveStreamingSetLinkCommentPreset(); +int PS4_SYSV_ABI sceGameLiveStreamingSetMaxBitrate(); +int PS4_SYSV_ABI sceGameLiveStreamingSetMetadata(); +int PS4_SYSV_ABI sceGameLiveStreamingSetPresetSocialFeedbackCommands(); +int PS4_SYSV_ABI sceGameLiveStreamingSetPresetSocialFeedbackCommandsDescription(); +int PS4_SYSV_ABI sceGameLiveStreamingSetServiceProviderPermission(); +int PS4_SYSV_ABI sceGameLiveStreamingSetSpoilerTag(); +int PS4_SYSV_ABI sceGameLiveStreamingSetStandbyScreenResource(); +int PS4_SYSV_ABI sceGameLiveStreamingStartGenerateStandbyScreenResource(); +int PS4_SYSV_ABI sceGameLiveStreamingStartSocialFeedbackMessageFiltering(); +int PS4_SYSV_ABI sceGameLiveStreamingStopGenerateStandbyScreenResource(); +int PS4_SYSV_ABI sceGameLiveStreamingStopSocialFeedbackMessageFiltering(); +int PS4_SYSV_ABI sceGameLiveStreamingTerminate(); +int PS4_SYSV_ABI sceGameLiveStreamingUnregisterCallback(); + +void RegisterlibSceGameLiveStreaming(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::GameLiveStreaming \ No newline at end of file diff --git a/src/core/libraries/ime/ime.cpp b/src/core/libraries/ime/ime.cpp new file mode 100644 index 000000000..13a70acf7 --- /dev/null +++ b/src/core/libraries/ime/ime.cpp @@ -0,0 +1,340 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ime.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" + +namespace Libraries::Ime { + +int PS4_SYSV_ABI FinalizeImeModule() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI InitializeImeModule() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeCheckFilterText() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeCheckRemoteEventParam() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeCheckUpdateTextInfo() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeClose() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeConfigGet() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeConfigSet() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeConfirmCandidate() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDicAddWord() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDicDeleteLearnDics() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDicDeleteUserDics() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDicDeleteWord() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDicGetWords() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDicReplaceWord() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeDisableController() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeFilterText() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeForTestFunction() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeGetPanelPositionAndForm() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeGetPanelSize() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardClose() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardGetInfo() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardGetResourceId() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardOpen() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardOpenInternal() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardSetMode() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeKeyboardUpdate() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeOpen() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeOpenInternal() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeParamInit() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeSetCandidateIndex() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeSetCaret() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeSetText() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeSetTextGeometry() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeUpdate() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshClearPreedit() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshClose() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshConfirmPreedit() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshDisableController() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshGetPanelPositionAndForm() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshInformConfirmdString() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshInformConfirmdString2() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshOpen() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSendTextInfo() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetCaretGeometry() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetCaretIndexInPreedit() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetPanelPosition() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetParam() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetPreeditGeometry() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetSelectGeometry() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshSetSelectionText() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshUpdate() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshUpdateContext() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceImeVshUpdateContext2() { + LOG_ERROR(Lib_Ime, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("mN+ZoSN-8hQ", "libSceIme", 1, "libSceIme", 1, 1, FinalizeImeModule); + LIB_FUNCTION("uTW+63goeJs", "libSceIme", 1, "libSceIme", 1, 1, InitializeImeModule); + LIB_FUNCTION("Lf3DeGWC6xg", "libSceIme", 1, "libSceIme", 1, 1, sceImeCheckFilterText); + LIB_FUNCTION("zHuMUGb-AQI", "libSceIme", 1, "libSceIme", 1, 1, sceImeCheckRemoteEventParam); + LIB_FUNCTION("OTb0Mg+1i1k", "libSceIme", 1, "libSceIme", 1, 1, sceImeCheckUpdateTextInfo); + LIB_FUNCTION("TmVP8LzcFcY", "libSceIme", 1, "libSceIme", 1, 1, sceImeClose); + LIB_FUNCTION("Ho5NVQzpKHo", "libSceIme", 1, "libSceIme", 1, 1, sceImeConfigGet); + LIB_FUNCTION("P5dPeiLwm-M", "libSceIme", 1, "libSceIme", 1, 1, sceImeConfigSet); + LIB_FUNCTION("tKLmVIUkpyM", "libSceIme", 1, "libSceIme", 1, 1, sceImeConfirmCandidate); + LIB_FUNCTION("NYDsL9a0oEo", "libSceIme", 1, "libSceIme", 1, 1, sceImeDicAddWord); + LIB_FUNCTION("l01GKoyiQrY", "libSceIme", 1, "libSceIme", 1, 1, sceImeDicDeleteLearnDics); + LIB_FUNCTION("E2OcGgi-FPY", "libSceIme", 1, "libSceIme", 1, 1, sceImeDicDeleteUserDics); + LIB_FUNCTION("JAiMBkOTYKI", "libSceIme", 1, "libSceIme", 1, 1, sceImeDicDeleteWord); + LIB_FUNCTION("JoPdCUXOzMU", "libSceIme", 1, "libSceIme", 1, 1, sceImeDicGetWords); + LIB_FUNCTION("FuEl46uHDyo", "libSceIme", 1, "libSceIme", 1, 1, sceImeDicReplaceWord); + LIB_FUNCTION("E+f1n8e8DAw", "libSceIme", 1, "libSceIme", 1, 1, sceImeDisableController); + LIB_FUNCTION("evjOsE18yuI", "libSceIme", 1, "libSceIme", 1, 1, sceImeFilterText); + LIB_FUNCTION("wVkehxutK-U", "libSceIme", 1, "libSceIme", 1, 1, sceImeForTestFunction); + LIB_FUNCTION("T6FYjZXG93o", "libSceIme", 1, "libSceIme", 1, 1, sceImeGetPanelPositionAndForm); + LIB_FUNCTION("ziPDcIjO0Vk", "libSceIme", 1, "libSceIme", 1, 1, sceImeGetPanelSize); + LIB_FUNCTION("PMVehSlfZ94", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardClose); + LIB_FUNCTION("VkqLPArfFdc", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardGetInfo); + LIB_FUNCTION("dKadqZFgKKQ", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardGetResourceId); + LIB_FUNCTION("eaFXjfJv3xs", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardOpen); + LIB_FUNCTION("oYkJlMK51SA", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardOpenInternal); + LIB_FUNCTION("ua+13Hk9kKs", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardSetMode); + LIB_FUNCTION("3Hx2Uw9xnv8", "libSceIme", 1, "libSceIme", 1, 1, sceImeKeyboardUpdate); + LIB_FUNCTION("RPydv-Jr1bc", "libSceIme", 1, "libSceIme", 1, 1, sceImeOpen); + LIB_FUNCTION("16UI54cWRQk", "libSceIme", 1, "libSceIme", 1, 1, sceImeOpenInternal); + LIB_FUNCTION("WmYDzdC4EHI", "libSceIme", 1, "libSceIme", 1, 1, sceImeParamInit); + LIB_FUNCTION("TQaogSaqkEk", "libSceIme", 1, "libSceIme", 1, 1, sceImeSetCandidateIndex); + LIB_FUNCTION("WLxUN2WMim8", "libSceIme", 1, "libSceIme", 1, 1, sceImeSetCaret); + LIB_FUNCTION("ieCNrVrzKd4", "libSceIme", 1, "libSceIme", 1, 1, sceImeSetText); + LIB_FUNCTION("TXYHFRuL8UY", "libSceIme", 1, "libSceIme", 1, 1, sceImeSetTextGeometry); + LIB_FUNCTION("-4GCfYdNF1s", "libSceIme", 1, "libSceIme", 1, 1, sceImeUpdate); + LIB_FUNCTION("oOwl47ouxoM", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshClearPreedit); + LIB_FUNCTION("gtoTsGM9vEY", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshClose); + LIB_FUNCTION("wTKF4mUlSew", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshConfirmPreedit); + LIB_FUNCTION("rM-1hkuOhh0", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshDisableController); + LIB_FUNCTION("42xMaQ+GLeQ", "libSceIme", 1, "libSceIme", 1, 1, + sceImeVshGetPanelPositionAndForm); + LIB_FUNCTION("ZmmV6iukhyo", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshInformConfirmdString); + LIB_FUNCTION("EQBusz6Uhp8", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshInformConfirmdString2); + LIB_FUNCTION("LBicRa-hj3A", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshOpen); + LIB_FUNCTION("-IAOwd2nO7g", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSendTextInfo); + LIB_FUNCTION("qDagOjvJdNk", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetCaretGeometry); + LIB_FUNCTION("tNOlmxee-Nk", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetCaretIndexInPreedit); + LIB_FUNCTION("rASXozKkQ9g", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetPanelPosition); + LIB_FUNCTION("idvMaIu5H+k", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetParam); + LIB_FUNCTION("ga5GOgThbjo", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetPreeditGeometry); + LIB_FUNCTION("RuSca8rS6yA", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetSelectGeometry); + LIB_FUNCTION("J7COZrgSFRA", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshSetSelectionText); + LIB_FUNCTION("WqAayyok5p0", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshUpdate); + LIB_FUNCTION("O7Fdd+Oc-qQ", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshUpdateContext); + LIB_FUNCTION("fwcPR7+7Rks", "libSceIme", 1, "libSceIme", 1, 1, sceImeVshUpdateContext2); +}; + +} // namespace Libraries::Ime \ No newline at end of file diff --git a/src/core/libraries/ime/ime.h b/src/core/libraries/ime/ime.h new file mode 100644 index 000000000..807616f14 --- /dev/null +++ b/src/core/libraries/ime/ime.h @@ -0,0 +1,70 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::Ime { + +int PS4_SYSV_ABI FinalizeImeModule(); +int PS4_SYSV_ABI InitializeImeModule(); +int PS4_SYSV_ABI sceImeCheckFilterText(); +int PS4_SYSV_ABI sceImeCheckRemoteEventParam(); +int PS4_SYSV_ABI sceImeCheckUpdateTextInfo(); +int PS4_SYSV_ABI sceImeClose(); +int PS4_SYSV_ABI sceImeConfigGet(); +int PS4_SYSV_ABI sceImeConfigSet(); +int PS4_SYSV_ABI sceImeConfirmCandidate(); +int PS4_SYSV_ABI sceImeDicAddWord(); +int PS4_SYSV_ABI sceImeDicDeleteLearnDics(); +int PS4_SYSV_ABI sceImeDicDeleteUserDics(); +int PS4_SYSV_ABI sceImeDicDeleteWord(); +int PS4_SYSV_ABI sceImeDicGetWords(); +int PS4_SYSV_ABI sceImeDicReplaceWord(); +int PS4_SYSV_ABI sceImeDisableController(); +int PS4_SYSV_ABI sceImeFilterText(); +int PS4_SYSV_ABI sceImeForTestFunction(); +int PS4_SYSV_ABI sceImeGetPanelPositionAndForm(); +int PS4_SYSV_ABI sceImeGetPanelSize(); +int PS4_SYSV_ABI sceImeKeyboardClose(); +int PS4_SYSV_ABI sceImeKeyboardGetInfo(); +int PS4_SYSV_ABI sceImeKeyboardGetResourceId(); +int PS4_SYSV_ABI sceImeKeyboardOpen(); +int PS4_SYSV_ABI sceImeKeyboardOpenInternal(); +int PS4_SYSV_ABI sceImeKeyboardSetMode(); +int PS4_SYSV_ABI sceImeKeyboardUpdate(); +int PS4_SYSV_ABI sceImeOpen(); +int PS4_SYSV_ABI sceImeOpenInternal(); +int PS4_SYSV_ABI sceImeParamInit(); +int PS4_SYSV_ABI sceImeSetCandidateIndex(); +int PS4_SYSV_ABI sceImeSetCaret(); +int PS4_SYSV_ABI sceImeSetText(); +int PS4_SYSV_ABI sceImeSetTextGeometry(); +int PS4_SYSV_ABI sceImeUpdate(); +int PS4_SYSV_ABI sceImeVshClearPreedit(); +int PS4_SYSV_ABI sceImeVshClose(); +int PS4_SYSV_ABI sceImeVshConfirmPreedit(); +int PS4_SYSV_ABI sceImeVshDisableController(); +int PS4_SYSV_ABI sceImeVshGetPanelPositionAndForm(); +int PS4_SYSV_ABI sceImeVshInformConfirmdString(); +int PS4_SYSV_ABI sceImeVshInformConfirmdString2(); +int PS4_SYSV_ABI sceImeVshOpen(); +int PS4_SYSV_ABI sceImeVshSendTextInfo(); +int PS4_SYSV_ABI sceImeVshSetCaretGeometry(); +int PS4_SYSV_ABI sceImeVshSetCaretIndexInPreedit(); +int PS4_SYSV_ABI sceImeVshSetPanelPosition(); +int PS4_SYSV_ABI sceImeVshSetParam(); +int PS4_SYSV_ABI sceImeVshSetPreeditGeometry(); +int PS4_SYSV_ABI sceImeVshSetSelectGeometry(); +int PS4_SYSV_ABI sceImeVshSetSelectionText(); +int PS4_SYSV_ABI sceImeVshUpdate(); +int PS4_SYSV_ABI sceImeVshUpdateContext(); +int PS4_SYSV_ABI sceImeVshUpdateContext2(); + +void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::Ime \ No newline at end of file diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index fb771bc22..caa254fd8 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -11,8 +11,9 @@ #include "core/libraries/dialogs/error_dialog.h" #include "core/libraries/dialogs/ime_dialog.h" #include "core/libraries/disc_map/disc_map.h" -#include "core/libraries/fiber/fiber.h" +#include "core/libraries/game_live_streaming/gamelivestreaming.h" #include "core/libraries/gnmdriver/gnmdriver.h" +#include "core/libraries/ime/ime.h" #include "core/libraries/kernel/libkernel.h" #include "core/libraries/libc_internal/libc_internal.h" #include "core/libraries/libpng/pngdec.h" @@ -27,10 +28,12 @@ #include "core/libraries/pad/pad.h" #include "core/libraries/playgo/playgo.h" #include "core/libraries/random/random.h" +#include "core/libraries/remote_play/remoteplay.h" #include "core/libraries/rtc/rtc.h" #include "core/libraries/save_data/dialog/savedatadialog.h" #include "core/libraries/save_data/savedata.h" #include "core/libraries/screenshot/screenshot.h" +#include "core/libraries/share_play/shareplay.h" #include "core/libraries/system/commondialog.h" #include "core/libraries/system/msgdialog.h" #include "core/libraries/system/posix.h" @@ -78,6 +81,10 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::ImeDialog::RegisterlibSceImeDialog(sym); Libraries::AvPlayer::RegisterlibSceAvPlayer(sym); Libraries::Audio3d::RegisterlibSceAudio3d(sym); + Libraries::Ime::RegisterlibSceIme(sym); + Libraries::GameLiveStreaming::RegisterlibSceGameLiveStreaming(sym); + Libraries::SharePlay::RegisterlibSceSharePlay(sym); + Libraries::Remoteplay::RegisterlibSceRemoteplay(sym); } } // namespace Libraries diff --git a/src/core/libraries/network/net.cpp b/src/core/libraries/network/net.cpp index 35d5851ea..161fc5214 100644 --- a/src/core/libraries/network/net.cpp +++ b/src/core/libraries/network/net.cpp @@ -734,9 +734,16 @@ int PS4_SYSV_ABI sceNetInetNtopWithScopeId() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNetInetPton() { - LOG_ERROR(Lib_Net, "(STUBBED) called"); - return ORBIS_OK; +int PS4_SYSV_ABI sceNetInetPton(int af, const char* src, void* dst) { +#ifdef WIN32 + int res = InetPtonA(af, src, dst); +#else + int res = inet_pton(af, src, dst); +#endif + if (res < 0) { + UNREACHABLE(); + } + return res; } int PS4_SYSV_ABI sceNetInetPtonEx() { diff --git a/src/core/libraries/network/net.h b/src/core/libraries/network/net.h index 3f010f685..beef38b56 100644 --- a/src/core/libraries/network/net.h +++ b/src/core/libraries/network/net.h @@ -169,7 +169,7 @@ u64 PS4_SYSV_ABI sceNetHtonll(u64 host64); u16 PS4_SYSV_ABI sceNetHtons(u16 host16); const char* PS4_SYSV_ABI sceNetInetNtop(int af, const void* src, char* dst, u32 size); int PS4_SYSV_ABI sceNetInetNtopWithScopeId(); -int PS4_SYSV_ABI sceNetInetPton(); +int PS4_SYSV_ABI sceNetInetPton(int af, const char* src, void* dst); int PS4_SYSV_ABI sceNetInetPtonEx(); int PS4_SYSV_ABI sceNetInetPtonWithScopeId(); int PS4_SYSV_ABI sceNetInfoDumpStart(); diff --git a/src/core/libraries/network/net_ctl_codes.h b/src/core/libraries/network/net_ctl_codes.h index a38565c1e..0dac4201e 100644 --- a/src/core/libraries/network/net_ctl_codes.h +++ b/src/core/libraries/network/net_ctl_codes.h @@ -26,3 +26,11 @@ constexpr int ORBIS_NET_CTL_STATE_IPOBTAINED = 3; constexpr int ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED = 1; constexpr int ORBIS_SCE_NET_CTL_EVENT_TYPE_DISCONNECT_REQ_FINISHED = 2; constexpr int ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED = 3; + +// get info codes +// device +constexpr int ORBIS_NET_CTL_DEVICE_WIRED = 0; +constexpr int ORBIS_NET_CTL_DEVICE_WIRELESS = 1; +// link +constexpr int ORBIS_NET_CTL_LINK_DISCONNECTED = 0; +constexpr int ORBIS_NET_CTL_LINK_CONNECTED = 1; diff --git a/src/core/libraries/network/net_obj.cpp b/src/core/libraries/network/net_obj.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/core/libraries/network/net_obj.h b/src/core/libraries/network/net_obj.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/core/libraries/network/netctl.cpp b/src/core/libraries/network/netctl.cpp index 3ecdde773..e7a69611e 100644 --- a/src/core/libraries/network/netctl.cpp +++ b/src/core/libraries/network/netctl.cpp @@ -1,6 +1,17 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#ifdef WIN32 +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#include +#include +#include +#else +#include +#include +#include +#endif + #include "common/logging/log.h" #include "common/singleton.h" #include "core/libraries/error_codes.h" @@ -149,15 +160,32 @@ int PS4_SYSV_ABI sceNetCtlGetIfStat() { int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) { switch (code) { case ORBIS_NET_CTL_INFO_DEVICE: - info->device = 0; + info->device = ORBIS_NET_CTL_DEVICE_WIRED; break; case ORBIS_NET_CTL_INFO_LINK: - info->link = 0; // disconnected + info->link = ORBIS_NET_CTL_LINK_DISCONNECTED; break; + case ORBIS_NET_CTL_INFO_IP_ADDRESS: { + strcpy(info->ip_address, + "127.0.0.1"); // placeholder in case gethostbyname can't find another ip + char devname[80]; + gethostname(devname, 80); + struct hostent* resolved = gethostbyname(devname); + for (int i = 0; resolved->h_addr_list[i] != nullptr; ++i) { + struct in_addr addrIn; + memcpy(&addrIn, resolved->h_addr_list[i], sizeof(u32)); + char* addr = inet_ntoa(addrIn); + if (strcmp(addr, "127.0.0.1") != 0) { + strcpy(info->ip_address, addr); + break; + } + } + break; + } default: LOG_ERROR(Lib_NetCtl, "{} unsupported code", code); } - LOG_ERROR(Lib_NetCtl, "(STUBBED) called"); + LOG_DEBUG(Lib_NetCtl, "(STUBBED) called"); return ORBIS_OK; } @@ -187,7 +215,10 @@ int PS4_SYSV_ABI sceNetCtlGetNetEvConfigInfoIpcInt() { } int PS4_SYSV_ABI sceNetCtlGetResult(int eventType, int* errorCode) { - LOG_ERROR(Lib_NetCtl, "(STUBBED) called eventType = {} ", eventType); + if (!errorCode) { + return ORBIS_NET_CTL_ERROR_INVALID_ADDR; + } + LOG_DEBUG(Lib_NetCtl, "(STUBBED) called eventType = {} ", eventType); *errorCode = 0; return ORBIS_OK; } diff --git a/src/core/libraries/network/netctl.h b/src/core/libraries/network/netctl.h index 850650f97..89ba34c31 100644 --- a/src/core/libraries/network/netctl.h +++ b/src/core/libraries/network/netctl.h @@ -50,6 +50,7 @@ typedef union OrbisNetCtlInfo { // GetInfo codes constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1; constexpr int ORBIS_NET_CTL_INFO_LINK = 4; +constexpr int ORBIS_NET_CTL_INFO_IP_ADDRESS = 14; int PS4_SYSV_ABI sceNetBweCheckCallbackIpcInt(); int PS4_SYSV_ABI sceNetBweClearEventIpcInt(); diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index b671e0077..d786647c2 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -88,7 +88,7 @@ int PS4_SYSV_ABI scePadGetCapability() { } int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) { - LOG_INFO(Lib_Pad, "called handle = {}", handle); + LOG_DEBUG(Lib_Pad, "called handle = {}", handle); if (handle < 0) { pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.resolution.x = 1920; diff --git a/src/core/libraries/remote_play/remoteplay.cpp b/src/core/libraries/remote_play/remoteplay.cpp new file mode 100644 index 000000000..b7402173e --- /dev/null +++ b/src/core/libraries/remote_play/remoteplay.cpp @@ -0,0 +1,309 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "remoteplay.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" + +namespace Libraries::Remoteplay { + +int PS4_SYSV_ABI sceRemoteplayApprove() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayChangeEnterKey() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayClearAllRegistData() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayClearConnectHistory() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayConfirmDeviceRegist() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayDisconnect() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGeneratePinCode() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetApMode() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetConnectHistory() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetConnectionStatus(s32 userId, int* pStatus) { + *pStatus = ORBIS_REMOTEPLAY_CONNECTION_STATUS_DISCONNECT; + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetConnectUserId() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetMbusDeviceInfo() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetOperationStatus() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetRemoteplayStatus() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayGetRpMode() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeClose() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeFilterResult() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeGetEvent() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeNotify() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeNotifyEventResult() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeOpen() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeSetCaret() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayImeSetText() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayInitialize() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayIsRemoteOskReady() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayIsRemotePlaying() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayNotifyMbusDeviceRegistComplete() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayNotifyNpPushWakeup() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayNotifyPinCodeError() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayNotifyUserDelete() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayPrintAllRegistData() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayProhibit() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayProhibitStreaming() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayServerLock() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayServerUnLock() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplaySetApMode() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplaySetLogLevel() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplaySetProhibition() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplaySetProhibitionForVsh() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplaySetRpMode() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceRemoteplayTerminate() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_1D5EE365ED5FADB3() { + LOG_ERROR(Lib_Remoteplay, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceRemoteplay(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("xQeIryTX7dY", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayApprove); + LIB_FUNCTION("IYZ+Mu+8tPo", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayChangeEnterKey); + LIB_FUNCTION("ZYUsJtcAnqA", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayClearAllRegistData); + LIB_FUNCTION("cCheyCbF7qw", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayClearConnectHistory); + LIB_FUNCTION("tPYT-kGbZh8", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayConfirmDeviceRegist); + LIB_FUNCTION("6Lg4BNleJWc", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayDisconnect); + LIB_FUNCTION("j98LdSGy4eY", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGeneratePinCode); + LIB_FUNCTION("L+cL-M-DP3w", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetApMode); + LIB_FUNCTION("g4K51cY+PEw", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetConnectHistory); + LIB_FUNCTION("g3PNjYKWqnQ", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetConnectionStatus); + LIB_FUNCTION("3eBNV9A0BUM", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetConnectUserId); + LIB_FUNCTION("ufesWMVX6iU", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetMbusDeviceInfo); + LIB_FUNCTION("DxU4JGh4S2k", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetOperationStatus); + LIB_FUNCTION("n5OxFJEvPlc", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetRemoteplayStatus); + LIB_FUNCTION("Cekhs6LSHC0", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayGetRpMode); + LIB_FUNCTION("ig1ocbR7Ptw", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeClose); + LIB_FUNCTION("gV9-8cJPM3I", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeFilterResult); + LIB_FUNCTION("cMk57DZXe6c", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeGetEvent); + LIB_FUNCTION("-gwkQpOCl68", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeNotify); + LIB_FUNCTION("58v9tSlRxc8", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeNotifyEventResult); + LIB_FUNCTION("C3r2zT5ebMg", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeOpen); + LIB_FUNCTION("oB730zwoz0s", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeSetCaret); + LIB_FUNCTION("rOTg1Nljp8w", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayImeSetText); + LIB_FUNCTION("k1SwgkMSOM8", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayInitialize); + LIB_FUNCTION("R8RZC1ZIkzU", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayIsRemoteOskReady); + LIB_FUNCTION("uYhiELUtLgA", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayIsRemotePlaying); + LIB_FUNCTION("d-BBSEq1nfc", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayNotifyMbusDeviceRegistComplete); + LIB_FUNCTION("Yytq7NE38R8", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayNotifyNpPushWakeup); + LIB_FUNCTION("Wg-w8xjMZA4", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayNotifyPinCodeError); + LIB_FUNCTION("yheulqylKwI", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayNotifyUserDelete); + LIB_FUNCTION("t5ZvUiZ1hpE", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayPrintAllRegistData); + LIB_FUNCTION("mrNh78tBpmg", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayProhibit); + LIB_FUNCTION("7QLrixwVHcU", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayProhibitStreaming); + LIB_FUNCTION("-ThIlThsN80", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayServerLock); + LIB_FUNCTION("0Z-Pm5rZJOI", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayServerUnLock); + LIB_FUNCTION("xSrhtSLIjOc", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplaySetApMode); + LIB_FUNCTION("5-2agAeaE+c", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplaySetLogLevel); + LIB_FUNCTION("Rf0XMVR7xPw", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplaySetProhibition); + LIB_FUNCTION("n4l3FTZtNQM", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplaySetProhibitionForVsh); + LIB_FUNCTION("-BPcEQ1w8xc", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplaySetRpMode); + LIB_FUNCTION("BOwybKVa3Do", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + sceRemoteplayTerminate); + LIB_FUNCTION("HV7jZe1frbM", "libSceRemoteplay", 1, "libSceRemoteplay", 0, 0, + Func_1D5EE365ED5FADB3); +}; + +} // namespace Libraries::Remoteplay \ No newline at end of file diff --git a/src/core/libraries/remote_play/remoteplay.h b/src/core/libraries/remote_play/remoteplay.h new file mode 100644 index 000000000..979f73a9e --- /dev/null +++ b/src/core/libraries/remote_play/remoteplay.h @@ -0,0 +1,62 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +// returning codes in sceRemoteplayGetConnectionStatus pstatus +constexpr int ORBIS_REMOTEPLAY_CONNECTION_STATUS_DISCONNECT = 0; +constexpr int ORBIS_REMOTEPLAY_CONNECTION_STATUS_CONNECT = 1; + +namespace Libraries::Remoteplay { + +int PS4_SYSV_ABI sceRemoteplayApprove(); +int PS4_SYSV_ABI sceRemoteplayChangeEnterKey(); +int PS4_SYSV_ABI sceRemoteplayClearAllRegistData(); +int PS4_SYSV_ABI sceRemoteplayClearConnectHistory(); +int PS4_SYSV_ABI sceRemoteplayConfirmDeviceRegist(); +int PS4_SYSV_ABI sceRemoteplayDisconnect(); +int PS4_SYSV_ABI sceRemoteplayGeneratePinCode(); +int PS4_SYSV_ABI sceRemoteplayGetApMode(); +int PS4_SYSV_ABI sceRemoteplayGetConnectHistory(); +int PS4_SYSV_ABI sceRemoteplayGetConnectionStatus(s32 userId, int* pStatus); +int PS4_SYSV_ABI sceRemoteplayGetConnectUserId(); +int PS4_SYSV_ABI sceRemoteplayGetMbusDeviceInfo(); +int PS4_SYSV_ABI sceRemoteplayGetOperationStatus(); +int PS4_SYSV_ABI sceRemoteplayGetRemoteplayStatus(); +int PS4_SYSV_ABI sceRemoteplayGetRpMode(); +int PS4_SYSV_ABI sceRemoteplayImeClose(); +int PS4_SYSV_ABI sceRemoteplayImeFilterResult(); +int PS4_SYSV_ABI sceRemoteplayImeGetEvent(); +int PS4_SYSV_ABI sceRemoteplayImeNotify(); +int PS4_SYSV_ABI sceRemoteplayImeNotifyEventResult(); +int PS4_SYSV_ABI sceRemoteplayImeOpen(); +int PS4_SYSV_ABI sceRemoteplayImeSetCaret(); +int PS4_SYSV_ABI sceRemoteplayImeSetText(); +int PS4_SYSV_ABI sceRemoteplayInitialize(); +int PS4_SYSV_ABI sceRemoteplayIsRemoteOskReady(); +int PS4_SYSV_ABI sceRemoteplayIsRemotePlaying(); +int PS4_SYSV_ABI sceRemoteplayNotifyMbusDeviceRegistComplete(); +int PS4_SYSV_ABI sceRemoteplayNotifyNpPushWakeup(); +int PS4_SYSV_ABI sceRemoteplayNotifyPinCodeError(); +int PS4_SYSV_ABI sceRemoteplayNotifyUserDelete(); +int PS4_SYSV_ABI sceRemoteplayPrintAllRegistData(); +int PS4_SYSV_ABI sceRemoteplayProhibit(); +int PS4_SYSV_ABI sceRemoteplayProhibitStreaming(); +int PS4_SYSV_ABI sceRemoteplayServerLock(); +int PS4_SYSV_ABI sceRemoteplayServerUnLock(); +int PS4_SYSV_ABI sceRemoteplaySetApMode(); +int PS4_SYSV_ABI sceRemoteplaySetLogLevel(); +int PS4_SYSV_ABI sceRemoteplaySetProhibition(); +int PS4_SYSV_ABI sceRemoteplaySetProhibitionForVsh(); +int PS4_SYSV_ABI sceRemoteplaySetRpMode(); +int PS4_SYSV_ABI sceRemoteplayTerminate(); +int PS4_SYSV_ABI Func_1D5EE365ED5FADB3(); + +void RegisterlibSceRemoteplay(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::Remoteplay \ No newline at end of file diff --git a/src/core/libraries/share_play/shareplay.cpp b/src/core/libraries/share_play/shareplay.cpp new file mode 100644 index 000000000..8370438b9 --- /dev/null +++ b/src/core/libraries/share_play/shareplay.cpp @@ -0,0 +1,186 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "shareplay.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" + +namespace Libraries::SharePlay { + +int PS4_SYSV_ABI sceSharePlayCrashDaemon() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayGetCurrentConnectionInfo(OrbisSharePlayConnectionInfo* pInfo) { + memset(pInfo, 0, sizeof(*pInfo)); + pInfo->status = ORBIS_SHARE_PLAY_CONNECTION_STATUS_DORMANT; + LOG_DEBUG(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayGetCurrentConnectionInfoA() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayGetCurrentInfo() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayGetEvent() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayInitialize() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayNotifyDialogOpen() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayNotifyForceCloseForCdlg() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayNotifyOpenQuickMenu() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayResumeScreenForCdlg() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayServerLock() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayServerUnLock() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlaySetMode() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlaySetProhibition() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlaySetProhibitionModeWithAppId() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayStartStandby() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayStartStreaming() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayStopStandby() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayStopStreaming() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSharePlayTerminate() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_2E93C0EA6A6B67C4() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_C1C236728D88E177() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_E9E80C474781F115() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_F3DD6199DA15ED44() { + LOG_ERROR(Lib_SharePlay, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceSharePlay(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("ggnCfalLU-8", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayCrashDaemon); + LIB_FUNCTION("OOrLKB0bSDs", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayGetCurrentConnectionInfo); + LIB_FUNCTION("+MCXJlWdi+s", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayGetCurrentConnectionInfoA); + LIB_FUNCTION("vUMkWXQff3w", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayGetCurrentInfo); + LIB_FUNCTION("Md7Mdkr8LBc", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayGetEvent); + LIB_FUNCTION("isruqthpYcw", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayInitialize); + LIB_FUNCTION("9zwJpai7jGc", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayNotifyDialogOpen); + LIB_FUNCTION("VUW2V9cUTP4", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayNotifyForceCloseForCdlg); + LIB_FUNCTION("XL0WwUJoQPg", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayNotifyOpenQuickMenu); + LIB_FUNCTION("6-1fKaa5HlY", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayResumeScreenForCdlg); + LIB_FUNCTION("U28jAuLHj6c", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayServerLock); + LIB_FUNCTION("3Oaux9ITEtY", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayServerUnLock); + LIB_FUNCTION("QZy+KmyqKPU", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, sceSharePlaySetMode); + LIB_FUNCTION("co2NCj--pnc", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlaySetProhibition); + LIB_FUNCTION("KADsbjNCgPo", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlaySetProhibitionModeWithAppId); + LIB_FUNCTION("-F6NddfUsa4", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayStartStandby); + LIB_FUNCTION("rWVNHNnEx6g", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayStartStreaming); + LIB_FUNCTION("zEDkUWLVwFI", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayStopStandby); + LIB_FUNCTION("aGlema+JxUU", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayStopStreaming); + LIB_FUNCTION("UaLjloJinow", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + sceSharePlayTerminate); + LIB_FUNCTION("LpPA6mprZ8Q", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + Func_2E93C0EA6A6B67C4); + LIB_FUNCTION("wcI2co2I4Xc", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + Func_C1C236728D88E177); + LIB_FUNCTION("6egMR0eB8RU", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + Func_E9E80C474781F115); + LIB_FUNCTION("891hmdoV7UQ", "libSceSharePlay", 1, "libSceSharePlay", 0, 0, + Func_F3DD6199DA15ED44); + LIB_FUNCTION("OOrLKB0bSDs", "libSceSharePlayCompat", 1, "libSceSharePlay", 0, 0, + sceSharePlayGetCurrentConnectionInfo); +}; + +} // namespace Libraries::SharePlay \ No newline at end of file diff --git a/src/core/libraries/share_play/shareplay.h b/src/core/libraries/share_play/shareplay.h new file mode 100644 index 000000000..8b1ad5f47 --- /dev/null +++ b/src/core/libraries/share_play/shareplay.h @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::SharePlay { + +constexpr int ORBIS_SHARE_PLAY_CONNECTION_STATUS_DORMANT = 0x00; +constexpr int ORBIS_SHARE_PLAY_CONNECTION_STATUS_READY = 0x01; +constexpr int ORBIS_SHARE_PLAY_CONNECTION_STATUS_CONNECTED = 0x02; + +struct OrbisSharePlayConnectionInfo { + int status; + int mode; + Libraries::NpManager::OrbisNpOnlineId hostOnlineId; + Libraries::NpManager::OrbisNpOnlineId visitorOnlineId; + s32 hostUserId; + s32 visitorUserId; +}; + +int PS4_SYSV_ABI sceSharePlayCrashDaemon(); +int PS4_SYSV_ABI sceSharePlayGetCurrentConnectionInfo(OrbisSharePlayConnectionInfo* pInfo); +int PS4_SYSV_ABI sceSharePlayGetCurrentConnectionInfoA(); +int PS4_SYSV_ABI sceSharePlayGetCurrentInfo(); +int PS4_SYSV_ABI sceSharePlayGetEvent(); +int PS4_SYSV_ABI sceSharePlayInitialize(); +int PS4_SYSV_ABI sceSharePlayNotifyDialogOpen(); +int PS4_SYSV_ABI sceSharePlayNotifyForceCloseForCdlg(); +int PS4_SYSV_ABI sceSharePlayNotifyOpenQuickMenu(); +int PS4_SYSV_ABI sceSharePlayResumeScreenForCdlg(); +int PS4_SYSV_ABI sceSharePlayServerLock(); +int PS4_SYSV_ABI sceSharePlayServerUnLock(); +int PS4_SYSV_ABI sceSharePlaySetMode(); +int PS4_SYSV_ABI sceSharePlaySetProhibition(); +int PS4_SYSV_ABI sceSharePlaySetProhibitionModeWithAppId(); +int PS4_SYSV_ABI sceSharePlayStartStandby(); +int PS4_SYSV_ABI sceSharePlayStartStreaming(); +int PS4_SYSV_ABI sceSharePlayStopStandby(); +int PS4_SYSV_ABI sceSharePlayStopStreaming(); +int PS4_SYSV_ABI sceSharePlayTerminate(); +int PS4_SYSV_ABI Func_2E93C0EA6A6B67C4(); +int PS4_SYSV_ABI Func_C1C236728D88E177(); +int PS4_SYSV_ABI Func_E9E80C474781F115(); +int PS4_SYSV_ABI Func_F3DD6199DA15ED44(); + +void RegisterlibSceSharePlay(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::SharePlay \ No newline at end of file diff --git a/src/core/libraries/system/userservice.cpp b/src/core/libraries/system/userservice.cpp index 560855474..140ca8921 100644 --- a/src/core/libraries/system/userservice.cpp +++ b/src/core/libraries/system/userservice.cpp @@ -491,7 +491,7 @@ int PS4_SYSV_ABI sceUserServiceGetImeRunCount() { } s32 PS4_SYSV_ABI sceUserServiceGetInitialUser(int* user_id) { - LOG_INFO(Lib_UserService, "called"); + LOG_DEBUG(Lib_UserService, "called"); if (user_id == nullptr) { LOG_ERROR(Lib_UserService, "user_id is null"); return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT; From 169b641bd1e0147a02b453d0a027e62d94a68441 Mon Sep 17 00:00:00 2001 From: "Daniel R." <47796739+polybiusproxy@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:48:32 +0200 Subject: [PATCH 10/11] hotfix: map rasterizer memory on pool commit --- src/core/memory.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index dd63522fc..644f9389f 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -245,6 +245,7 @@ int MemoryManager::PoolCommit(VAddr virtual_addr, size_t size, MemoryProt prot) new_vma.is_exec = false; new_vma.phys_base = 0; + rasterizer->MapMemory(mapped_addr, size); return ORBIS_OK; } From cd085ea2de5e63fecef848b7acee33c3fedcac2d Mon Sep 17 00:00:00 2001 From: adjonesey Date: Fri, 11 Oct 2024 15:52:48 +0100 Subject: [PATCH 11/11] Use GetSystemTimePreciseAsFileTime to fix fps timing issues (#1344) -ws --- src/core/libraries/kernel/time_management.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/libraries/kernel/time_management.cpp b/src/core/libraries/kernel/time_management.cpp index 5fa26b789..853f8d54c 100644 --- a/src/core/libraries/kernel/time_management.cpp +++ b/src/core/libraries/kernel/time_management.cpp @@ -148,7 +148,7 @@ int PS4_SYSV_ABI sceKernelGettimeofday(OrbisKernelTimeval* tp) { #ifdef _WIN64 FILETIME filetime; - GetSystemTimeAsFileTime(&filetime); + GetSystemTimePreciseAsFileTime(&filetime); constexpr u64 UNIX_TIME_START = 0x295E9648864000; constexpr u64 TICKS_PER_SECOND = 1000000;