core: More style changes

This commit is contained in:
IndecisiveTurtle 2024-11-30 17:15:25 +02:00
parent ba78dc5552
commit 53f3ca0040
44 changed files with 635 additions and 829 deletions

View file

@ -176,10 +176,6 @@ if(ENABLE_QT_GUI)
qt_add_resources(TRANSLATIONS ${TRANSLATIONS_QRC})
endif()
set(AUDIO_CORE src/audio_core/sdl_audio.cpp
src/audio_core/sdl_audio.h
)
set(AJM_LIB src/core/libraries/ajm/ajm.cpp
src/core/libraries/ajm/ajm.h
src/core/libraries/ajm/ajm_at9.cpp
@ -199,6 +195,9 @@ set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
src/core/libraries/audio/audioin.h
src/core/libraries/audio/audioout.cpp
src/core/libraries/audio/audioout.h
src/core/libraries/audio/sdl_audio.cpp
src/core/libraries/audio/sdl_audio.h
src/core/libraries/audio/audioout_error.h
src/core/libraries/ngs2/ngs2.cpp
src/core/libraries/ngs2/ngs2.h
)
@ -240,6 +239,8 @@ set(KERNEL_LIB src/core/libraries/kernel/threads/condvar.cpp
src/core/libraries/kernel/threads.h
src/core/libraries/kernel/time.cpp
src/core/libraries/kernel/time.h
src/core/libraries/kernel/orbis_error.h
src/core/libraries/kernel/posix_error.h
)
set(NETWORK_LIBS src/core/libraries/network/http.cpp
@ -255,6 +256,21 @@ set(NETWORK_LIBS src/core/libraries/network/http.cpp
src/core/libraries/network/ssl.h
)
set(AVPLAYER_LIB src/core/libraries/avplayer/avplayer_common.cpp
src/core/libraries/avplayer/avplayer_common.h
src/core/libraries/avplayer/avplayer_file_streamer.cpp
src/core/libraries/avplayer/avplayer_file_streamer.h
src/core/libraries/avplayer/avplayer_impl.cpp
src/core/libraries/avplayer/avplayer_impl.h
src/core/libraries/avplayer/avplayer_source.cpp
src/core/libraries/avplayer/avplayer_source.h
src/core/libraries/avplayer/avplayer_state.cpp
src/core/libraries/avplayer/avplayer_state.h
src/core/libraries/avplayer/avplayer.cpp
src/core/libraries/avplayer/avplayer.h
src/core/libraries/avplayer/avplayer_error.h
)
set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/system/commondialog.h
src/core/libraries/system/msgdialog.cpp
@ -279,28 +295,19 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/system/system_error.h
src/core/libraries/system/systemservice.cpp
src/core/libraries/system/systemservice.h
src/core/libraries/system/systemservice_error.h
src/core/libraries/system/userservice.cpp
src/core/libraries/system/userservice.h
src/core/libraries/system/userservice_error.h
src/core/libraries/app_content/app_content.cpp
src/core/libraries/app_content/app_content.h
src/core/libraries/app_content/app_content_error.h
src/core/libraries/rtc/rtc.cpp
src/core/libraries/rtc/rtc.h
src/core/libraries/rtc/rtc_error.h
src/core/libraries/disc_map/disc_map.cpp
src/core/libraries/disc_map/disc_map.h
src/core/libraries/disc_map/disc_map_codes.h
src/core/libraries/avplayer/avplayer_common.cpp
src/core/libraries/avplayer/avplayer_common.h
src/core/libraries/avplayer/avplayer_file_streamer.cpp
src/core/libraries/avplayer/avplayer_file_streamer.h
src/core/libraries/avplayer/avplayer_impl.cpp
src/core/libraries/avplayer/avplayer_impl.h
src/core/libraries/avplayer/avplayer_source.cpp
src/core/libraries/avplayer/avplayer_source.h
src/core/libraries/avplayer/avplayer_state.cpp
src/core/libraries/avplayer/avplayer_state.h
src/core/libraries/avplayer/avplayer.cpp
src/core/libraries/avplayer/avplayer.h
src/core/libraries/ngs2/ngs2.cpp
src/core/libraries/ngs2/ngs2.h
src/core/libraries/ngs2/ngs2_error.h
@ -327,6 +334,7 @@ set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
src/core/libraries/videoout/driver.h
src/core/libraries/videoout/video_out.cpp
src/core/libraries/videoout/video_out.h
src/core/libraries/videoout/videoout_error.h
)
set(LIBC_SOURCES src/core/libraries/libc_internal/libc_internal.cpp
@ -344,14 +352,17 @@ set(IME_LIB src/core/libraries/ime/error_dialog.cpp
src/core/libraries/ime/ime_ui.h
src/core/libraries/ime/ime.cpp
src/core/libraries/ime/ime.h
src/core/libraries/ime/ime_error.h
)
set(PAD_LIB src/core/libraries/pad/pad.cpp
src/core/libraries/pad/pad.h
src/core/libraries/pad/pad_errors.h
)
set(PNG_LIB src/core/libraries/libpng/pngdec.cpp
src/core/libraries/libpng/pngdec.h
src/core/libraries/libpng/pngdec_error.h
)
set(JPEG_LIB src/core/libraries/jpeg/jpeg_error.h
@ -375,6 +386,7 @@ set(USBD_LIB src/core/libraries/usbd/usbd.cpp
set(FIBER_LIB src/core/libraries/fiber/fiber.cpp
src/core/libraries/fiber/fiber.h
src/core/libraries/fiber/fiber_error.h
)
set(VDEC_LIB src/core/libraries/videodec/videodec2_impl.cpp
@ -384,6 +396,7 @@ set(VDEC_LIB src/core/libraries/videodec/videodec2_impl.cpp
src/core/libraries/videodec/videodec2_avc.h
src/core/libraries/videodec/videodec.cpp
src/core/libraries/videodec/videodec.h
src/core/libraries/videodec/videodec_error.h
src/core/libraries/videodec/videodec_impl.cpp
src/core/libraries/videodec/videodec_impl.h
)
@ -396,6 +409,7 @@ set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp
src/core/libraries/np_trophy/np_trophy.h
src/core/libraries/np_trophy/trophy_ui.cpp
src/core/libraries/np_trophy/trophy_ui.h
src/core/libraries/np_trophy/np_trophy_error.h
)
set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp
@ -527,10 +541,10 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/loader/elf.h
src/core/loader/symbols_resolver.h
src/core/loader/symbols_resolver.cpp
src/core/libraries/error_codes.h
src/core/libraries/libs.h
src/core/libraries/libs.cpp
${AJM_LIB}
${AVPLAYER_LIB}
${AUDIO_LIB}
${GNM_LIB}
${KERNEL_LIB}
@ -565,8 +579,6 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/thread.h
src/core/tls.cpp
src/core/tls.h
src/core/virtual_memory.cpp
src/core/virtual_memory.h
)
if (ARCHITECTURE STREQUAL "x86_64")

View file

@ -28,7 +28,7 @@ std::string g_game_serial;
std::string patchFile;
std::vector<patchInfo> pending_patches;
std::string toHex(unsigned long long value, size_t byteSize) {
std::string toHex(u64 value, size_t byteSize) {
std::stringstream ss;
ss << std::hex << std::setfill('0') << std::setw(byteSize * 2) << value;
return ss.str();
@ -38,16 +38,16 @@ std::string convertValueToHex(const std::string type, const std::string valueStr
std::string result;
if (type == "byte") {
unsigned int value = std::stoul(valueStr, nullptr, 16);
const u32 value = std::stoul(valueStr, nullptr, 16);
result = toHex(value, 1);
} else if (type == "bytes16") {
unsigned int value = std::stoul(valueStr, nullptr, 16);
const u32 value = std::stoul(valueStr, nullptr, 16);
result = toHex(value, 2);
} else if (type == "bytes32") {
unsigned long value = std::stoul(valueStr, nullptr, 16);
const u32 value = std::stoul(valueStr, nullptr, 16);
result = toHex(value, 4);
} else if (type == "bytes64") {
unsigned long long value = std::stoull(valueStr, nullptr, 16);
const u64 value = std::stoull(valueStr, nullptr, 16);
result = toHex(value, 8);
} else if (type == "float32") {
union {

View file

@ -3,6 +3,8 @@
#pragma once
#include "common/types.h"
namespace Core {
/// Initializes a stack for the current thread for use by patch implementations.

View file

@ -458,7 +458,7 @@ struct MemoryEditor {
data_write = data_next = true;
if (data_editing_addr_next != (size_t)-1)
data_write = data_next = false;
unsigned int data_input_value = 0;
u32 data_input_value = 0;
if (!ReadOnly && data_write &&
sscanf(DataInputBuf, "%X", &data_input_value) == 1) {
if (WriteFn)

View file

@ -131,7 +131,7 @@ static int UTF8CharLength(TextEditor::Char c) {
}
// "Borrowed" from ImGui source
static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c) {
static inline int ImTextCharToUtf8(char* buf, int buf_size, u32 c) {
if (c < 0x80) {
buf[0] = (char)c;
return 1;

View file

@ -105,7 +105,7 @@ int PS4_SYSV_ABI sceAppContentSmallSharedDataMount();
int PS4_SYSV_ABI sceAppContentSmallSharedDataUnmount();
int PS4_SYSV_ABI sceAppContentTemporaryDataFormat();
int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb(
const OrbisAppContentMountPoint* mountPoint, u64* availableSpaceKb);
const OrbisAppContentMountPoint* mountPoint, size_t* availableSpaceKb);
int PS4_SYSV_ABI sceAppContentTemporaryDataMount();
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
OrbisAppContentMountPoint* mountPoint);

View file

@ -1,19 +1,15 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "audio3d.h"
#include "audio3d_error.h"
#include "audio3d_impl.h"
#include "common/logging/log.h"
#include "core/libraries/audio/audioout.h"
#include "core/libraries/audio3d/audio3d.h"
#include "core/libraries/audio3d/audio3d_error.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
namespace Libraries::Audio3d {
// Audio3d
int PS4_SYSV_ABI sceAudio3dInitialize(s64 iReserved) {
LOG_INFO(Lib_Audio3d, "iReserved = {}", iReserved);
return ORBIS_OK;
@ -25,18 +21,19 @@ int PS4_SYSV_ABI sceAudio3dTerminate() {
return ORBIS_OK;
}
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters) {
if (sParameters != NULL) {
sParameters->szSizeThis = sizeof(OrbisAudio3dOpenParameters);
sParameters->uiGranularity = 256;
sParameters->eRate = ORBIS_AUDIO3D_RATE_48000;
sParameters->uiMaxObjects = 512;
sParameters->uiQueueDepth = 2;
sParameters->eBufferMode = ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH;
sParameters->uiNumBeds = 2;
} else {
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* parameters) {
if (parameters == nullptr) {
LOG_ERROR(Lib_Audio3d, "Invalid OpenParameters ptr");
return;
}
parameters->size_this = sizeof(OrbisAudio3dOpenParameters);
parameters->granularity = 256;
parameters->rate = OrbisAudio3dRate::Rate48000;
parameters->max_objects = 512;
parameters->queue_depth = 2;
parameters->buffer_mode = OrbisAudio3dBufferMode::AdvanceAndPush;
parameters->num_beds = 2;
}
int PS4_SYSV_ABI sceAudio3dPortOpen(OrbisUserServiceUserId iUserId,
@ -76,13 +73,13 @@ int PS4_SYSV_ABI sceAudio3dPortPush(OrbisAudio3dPortId uiPortId, OrbisAudio3dBlo
int PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported(OrbisAudio3dPortId uiPortId,
OrbisAudio3dAttributeId* pCapabilities,
unsigned int* pNumCapabilities) {
u32* pNumCapabilities) {
LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId);
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId uiPortId, unsigned int* pQueueLevel,
unsigned int* pQueueAvailable) {
int PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId uiPortId, u32* pQueueLevel,
u32* pQueueAvailable) {
LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId);
return ORBIS_OK;
}
@ -107,24 +104,24 @@ int PS4_SYSV_ABI sceAudio3dObjectSetAttributes(OrbisAudio3dPortId uiPortId,
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId uiPortId, unsigned int uiNumChannels,
int PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId uiPortId, u32 uiNumChannels,
OrbisAudio3dFormat eFormat, const void* pBuffer,
unsigned int uiNumSamples) {
u32 uiNumSamples) {
LOG_TRACE(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}", uiPortId,
uiNumChannels, uiNumSamples);
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId uiPortId, unsigned int uiNumChannels,
int PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId uiPortId, u32 uiNumChannels,
OrbisAudio3dFormat eFormat, const void* pBuffer,
unsigned int uiNumSamples,
OrbisAudio3dOutputRoute eOutputRoute, bool bRestricted) {
u32 uiNumSamples, OrbisAudio3dOutputRoute eOutputRoute,
bool bRestricted) {
LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}, bRestricted = {}",
uiPortId, uiNumChannels, uiNumSamples, bRestricted);
return ORBIS_OK;
}
size_t PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(unsigned int uiNumSpeakers, bool bIs3d) {
size_t PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(u32 uiNumSpeakers, bool bIs3d) {
LOG_INFO(Lib_Audio3d, "uiNumSpeakers = {}, bIs3d = {}", uiNumSpeakers, bIs3d);
return ORBIS_OK;
}
@ -152,7 +149,7 @@ int PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray(OrbisAudio3dSpeakerArrayHandle han
int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArrayHandle handle,
OrbisAudio3dPosition pos, float fSpread,
float* pCoefficients,
unsigned int uiNumCoefficients) {
u32 uiNumCoefficients) {
LOG_INFO(Lib_Audio3d, "fSpread = {}, uiNumCoefficients = {}", fSpread, uiNumCoefficients);
if (handle == nullptr) {
LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle");
@ -164,8 +161,7 @@ int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArr
int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2(OrbisAudio3dSpeakerArrayHandle handle,
OrbisAudio3dPosition pos, float fSpread,
float* pCoefficients,
unsigned int uiNumCoefficients,
bool bHeightAware,
u32 uiNumCoefficients, bool bHeightAware,
float fDownmixSpreadRadius) {
LOG_INFO(Lib_Audio3d,
"fSpread = {}, uiNumCoefficients = {}, bHeightAware = {}, fDownmixSpreadRadius = {}",
@ -209,8 +205,8 @@ s32 PS4_SYSV_ABI sceAudio3dAudioOutOutputs(::Libraries::AudioOut::OrbisAudioOutO
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAudio3dPortCreate(unsigned int uiGranularity, OrbisAudio3dRate eRate,
s64 iReserved, OrbisAudio3dPortId* pId) {
int PS4_SYSV_ABI sceAudio3dPortCreate(u32 uiGranularity, OrbisAudio3dRate eRate, s64 iReserved,
OrbisAudio3dPortId* pId) {
LOG_INFO(Lib_Audio3d, "uiGranularity = {}, iReserved = {}", uiGranularity, iReserved);
return ORBIS_OK;
}
@ -341,4 +337,4 @@ void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym) {
sceAudio3dSetGpuRenderer);
};
} // namespace Libraries::Audio3d
} // namespace Libraries::Audio3d

View file

@ -15,56 +15,57 @@ namespace Libraries::Audio3d {
class Audio3d;
typedef int OrbisUserServiceUserId;
typedef unsigned int OrbisAudio3dPortId;
typedef unsigned int OrbisAudio3dObjectId;
typedef unsigned int OrbisAudio3dAttributeId;
using OrbisUserServiceUserId = s32;
using OrbisAudio3dPortId = u32;
using OrbisAudio3dObjectId = u32;
using OrbisAudio3dAttributeId = u32;
enum OrbisAudio3dFormat {
ORBIS_AUDIO3D_FORMAT_S16 = 0, // s16
ORBIS_AUDIO3D_FORMAT_FLOAT = 1 // f32
enum class OrbisAudio3dFormat {
S16 = 0,
Float = 1,
};
enum OrbisAudio3dRate { ORBIS_AUDIO3D_RATE_48000 = 0 };
enum OrbisAudio3dBufferMode {
ORBIS_AUDIO3D_BUFFER_NO_ADVANCE = 0,
ORBIS_AUDIO3D_BUFFER_ADVANCE_NO_PUSH = 1,
ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH = 2
enum class OrbisAudio3dRate {
Rate48000 = 0,
};
enum OrbisAudio3dBlocking { ORBIS_AUDIO3D_BLOCKING_ASYNC = 0, ORBIS_AUDIO3D_BLOCKING_SYNC = 1 };
enum class OrbisAudio3dBufferMode { NoAdvance = 0, AdvanceNoPush = 1, AdvanceAndPush = 2 };
enum OrbisAudio3dPassthrough {
ORBIS_AUDIO3D_PASSTHROUGH_NONE = 0,
ORBIS_AUDIO3D_PASSTHROUGH_LEFT = 1,
ORBIS_AUDIO3D_PASSTHROUGH_RIGHT = 2
enum class OrbisAudio3dBlocking {
Async = 0,
Sync = 1,
};
enum OrbisAudio3dOutputRoute {
ORBIS_AUDIO3D_OUTPUT_BOTH = 0,
ORBIS_AUDIO3D_OUTPUT_HMU_ONLY = 1,
ORBIS_AUDIO3D_OUTPUT_TV_ONLY = 2
enum class OrbisAudio3dPassthrough {
None = 0,
Left = 1,
Right = 2,
};
enum OrbisAudio3dAmbisonics {
ORBIS_AUDIO3D_AMBISONICS_NONE = ~0,
ORBIS_AUDIO3D_AMBISONICS_W = 0,
ORBIS_AUDIO3D_AMBISONICS_X = 1,
ORBIS_AUDIO3D_AMBISONICS_Y = 2,
ORBIS_AUDIO3D_AMBISONICS_Z = 3,
ORBIS_AUDIO3D_AMBISONICS_R = 4,
ORBIS_AUDIO3D_AMBISONICS_S = 5,
ORBIS_AUDIO3D_AMBISONICS_T = 6,
ORBIS_AUDIO3D_AMBISONICS_U = 7,
ORBIS_AUDIO3D_AMBISONICS_V = 8,
ORBIS_AUDIO3D_AMBISONICS_K = 9,
ORBIS_AUDIO3D_AMBISONICS_L = 10,
ORBIS_AUDIO3D_AMBISONICS_M = 11,
ORBIS_AUDIO3D_AMBISONICS_N = 12,
ORBIS_AUDIO3D_AMBISONICS_O = 13,
ORBIS_AUDIO3D_AMBISONICS_P = 14,
ORBIS_AUDIO3D_AMBISONICS_Q = 15
enum class OrbisAudio3dOutputRoute {
Both = 0,
HmuOnly = 1,
TvOnly = 2,
};
enum class OrbisAudio3dAmbisonics : u32 {
None = ~0U,
W = 0,
X = 1,
Y = 2,
Z = 3,
R = 4,
S = 5,
T = 6,
U = 7,
V = 8,
K = 9,
L = 10,
M = 11,
N = 12,
O = 13,
P = 14,
Q = 15
};
static const OrbisAudio3dAttributeId s_sceAudio3dAttributePcm = 0x00000001;
@ -86,21 +87,21 @@ struct OrbisAudio3dSpeakerArray;
using OrbisAudio3dSpeakerArrayHandle = OrbisAudio3dSpeakerArray*; // head
struct OrbisAudio3dOpenParameters {
size_t szSizeThis;
unsigned int uiGranularity;
OrbisAudio3dRate eRate;
unsigned int uiMaxObjects;
unsigned int uiQueueDepth;
OrbisAudio3dBufferMode eBufferMode;
size_t size_this;
u32 granularity;
OrbisAudio3dRate rate;
u32 max_objects;
u32 queue_depth;
OrbisAudio3dBufferMode buffer_mode;
char padding[32];
unsigned int uiNumBeds;
u32 num_beds;
};
struct OrbisAudio3dAttribute {
OrbisAudio3dAttributeId uiAttributeId;
OrbisAudio3dAttributeId attribute_id;
char padding[32];
const void* pValue;
size_t szValue;
const void* p_value;
size_t value;
};
struct OrbisAudio3dPosition {
@ -110,25 +111,25 @@ struct OrbisAudio3dPosition {
};
struct OrbisAudio3dPcm {
OrbisAudio3dFormat eFormat;
const void* pSampleBuffer;
unsigned int uiNumSamples;
OrbisAudio3dFormat format;
const void* sample_buffer;
u32 num_samples;
};
struct OrbisAudio3dSpeakerArrayParameters {
OrbisAudio3dPosition* pSpeakerPosition;
unsigned int uiNumSpeakers;
bool bIs3d;
void* pBuffer;
size_t szSize;
OrbisAudio3dPosition* speaker_position;
u32 num_speakers;
bool is_3d;
void* buffer;
size_t size;
};
struct OrbisAudio3dApplicationSpecific {
size_t szSizeThis;
u8 cApplicationSpecific[32];
size_t size_this;
u8 application_specific[32];
};
void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters);
void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Audio3d
} // namespace Libraries::Audio3d

View file

@ -10,7 +10,7 @@ namespace Libraries::Audio3d {
class Audio3d {
public:
private:
typedef unsigned int OrbisAudio3dPluginId;
using OrbisAudio3dPluginId = u32;
};
} // namespace Libraries::Audio3d

View file

@ -18,17 +18,26 @@ class AvPlayer;
using SceAvPlayerHandle = AvPlayer*;
enum SceAvPlayerUriType { SCE_AVPLAYER_URI_TYPE_SOURCE = 0 };
enum class SceAvPlayerUriType : u32 {
Source = 0,
};
struct SceAvPlayerUri {
const char* name;
u32 length;
};
enum SceAvPlayerSourceType {
SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN = 0,
SCE_AVPLAYER_SOURCE_TYPE_FILE_MP4 = 1,
SCE_AVPLAYER_SOURCE_TYPE_HLS = 8
enum class SceAvPlayerSourceType {
Unknown = 0,
FileMp4 = 1,
Hls = 8,
};
enum class SceAvPlayerStreamType : u32 {
Video,
Audio,
TimedText,
Unknown,
};
struct SceAvPlayerSourceDetails {
@ -50,7 +59,7 @@ struct SceAvPlayerVideo {
u32 width;
u32 height;
f32 aspect_ratio;
u8 language_code[4];
char language_code[4];
};
struct SceAvPlayerTextPosition {
@ -82,7 +91,7 @@ struct SceAvPlayerFrameInfo {
};
struct SceAvPlayerStreamInfo {
u32 type;
SceAvPlayerStreamType type;
u8 reserved[4];
SceAvPlayerStreamDetails details;
u64 duration;
@ -135,10 +144,10 @@ struct SceAvPlayerFrameInfoEx {
SceAvPlayerStreamDetailsEx details;
};
typedef void* PS4_SYSV_ABI (*SceAvPlayerAllocate)(void* p, u32 align, u32 size);
typedef void PS4_SYSV_ABI (*SceAvPlayerDeallocate)(void* p, void* mem);
typedef void* PS4_SYSV_ABI (*SceAvPlayerAllocateTexture)(void* p, u32 align, u32 size);
typedef void PS4_SYSV_ABI (*SceAvPlayerDeallocateTexture)(void* p, void* mem);
using SceAvPlayerAllocate = void* PS4_SYSV_ABI (*)(void* p, u32 align, u32 size);
using SceAvPlayerDeallocate = void PS4_SYSV_ABI (*)(void* p, void* mem);
using SceAvPlayerAllocateTexture = void* PS4_SYSV_ABI (*)(void* p, u32 align, u32 size);
using SceAvPlayerDeallocateTexture = void PS4_SYSV_ABI (*)(void* p, void* mem);
struct SceAvPlayerMemAllocator {
void* object_ptr;
@ -148,10 +157,10 @@ struct SceAvPlayerMemAllocator {
SceAvPlayerDeallocateTexture deallocate_texture;
};
typedef s32 PS4_SYSV_ABI (*SceAvPlayerOpenFile)(void* p, const char* name);
typedef s32 PS4_SYSV_ABI (*SceAvPlayerCloseFile)(void* p);
typedef s32 PS4_SYSV_ABI (*SceAvPlayerReadOffsetFile)(void* p, u8* buf, u64 pos, u32 len);
typedef u64 PS4_SYSV_ABI (*SceAvPlayerSizeFile)(void* p);
using SceAvPlayerOpenFile = s32 PS4_SYSV_ABI (*)(void* p, const char* name);
using SceAvPlayerCloseFile = s32 PS4_SYSV_ABI (*)(void* p);
using SceAvPlayerReadOffsetFile = s32 PS4_SYSV_ABI (*)(void* p, u8* buf, u64 pos, u32 len);
using SceAvPlayerSizeFile = u64 PS4_SYSV_ABI (*)(void* p);
struct SceAvPlayerFileReplacement {
void* object_ptr;
@ -161,31 +170,31 @@ struct SceAvPlayerFileReplacement {
SceAvPlayerSizeFile size;
};
enum SceAvPlayerEvents {
SCE_AVPLAYER_STATE_STOP = 0x01,
SCE_AVPLAYER_STATE_READY = 0x02,
SCE_AVPLAYER_STATE_PLAY = 0x03,
SCE_AVPLAYER_STATE_PAUSE = 0x04,
SCE_AVPLAYER_STATE_BUFFERING = 0x05,
SCE_AVPLAYER_TIMED_TEXT_DELIVERY = 0x10,
SCE_AVPLAYER_WARNING_ID = 0x20,
SCE_AVPLAYER_ENCRYPTION = 0x30,
SCE_AVPLAYER_DRM_ERROR = 0x40
enum class SceAvPlayerEvents {
StateStop = 0x01,
StateReady = 0x02,
StatePlay = 0x03,
StatePause = 0x04,
StateBuffering = 0x05,
TimedTextDelivery = 0x10,
WarningId = 0x20,
Encryption = 0x30,
DrmError = 0x40,
};
typedef void PS4_SYSV_ABI (*SceAvPlayerEventCallback)(void* p, SceAvPlayerEvents event, s32 src_id,
void* data);
using SceAvPlayerEventCallback = void PS4_SYSV_ABI (*)(void* p, SceAvPlayerEvents event, s32 src_id,
void* data);
struct SceAvPlayerEventReplacement {
void* object_ptr;
SceAvPlayerEventCallback event_callback;
};
enum SceAvPlayerDebuglevels {
SCE_AVPLAYER_DBG_NONE,
SCE_AVPLAYER_DBG_INFO,
SCE_AVPLAYER_DBG_WARNINGS,
SCE_AVPLAYER_DBG_ALL
enum class SceAvPlayerDebuglevels {
None,
Info,
Warnings,
All,
};
struct SceAvPlayerInitData {
@ -224,24 +233,17 @@ struct SceAvPlayerInitDataEx {
u8 reserved[3];
};
enum SceAvPlayerStreamType {
SCE_AVPLAYER_VIDEO,
SCE_AVPLAYER_AUDIO,
SCE_AVPLAYER_TIMEDTEXT,
SCE_AVPLAYER_UNKNOWN
enum class SceAvPlayerVideoDecoderType {
Default = 0,
Reserved1,
Software,
Software2,
};
enum SceAvPlayerVideoDecoderType {
SCE_AVPLAYER_VIDEO_DECODER_TYPE_DEFAULT = 0,
SCE_AVPLAYER_VIDEO_DECODER_TYPE_RESERVED1,
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE,
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE2
};
enum SceAvPlayerAudioDecoderType {
SCE_AVPLAYER_AUDIO_DECODER_TYPE_DEFAULT = 0,
SCE_AVPLAYER_AUDIO_DECODER_TYPE_RESERVED1,
SCE_AVPLAYER_AUDIO_DECODER_TYPE_RESERVED2
enum class SceAvPlayerAudioDecoderType {
Default = 0,
Reserved1,
Reserved2,
};
struct SceAvPlayerDecoderInit {
@ -281,12 +283,12 @@ struct SceAvPlayerPostInitData {
u8 reserved[56];
};
enum SceAvPlayerAvSyncMode {
SCE_AVPLAYER_AV_SYNC_MODE_DEFAULT = 0,
SCE_AVPLAYER_AV_SYNC_MODE_NONE
enum class SceAvPlayerAvSyncMode {
Default = 0,
None,
};
typedef int PS4_SYSV_ABI (*SceAvPlayerLogCallback)(void* p, const char* format, va_list args);
using SceAvPlayerLogCallback = int PS4_SYSV_ABI (*)(void* p, const char* format, va_list args);
void RegisterlibSceAvPlayer(Core::Loader::SymbolsResolver* sym);

View file

@ -15,7 +15,7 @@ static bool iequals(std::string_view l, std::string_view r) {
SceAvPlayerSourceType GetSourceType(std::string_view path) {
if (path.empty()) {
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
return SceAvPlayerSourceType::Unknown;
}
std::string_view name = path;
@ -25,14 +25,14 @@ SceAvPlayerSourceType GetSourceType(std::string_view path) {
// -> schema://server.domain/path/to/file.ext/and/beyond
name = path.substr(0, path.find_first_of("?#"));
if (name.empty()) {
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
return SceAvPlayerSourceType::Unknown;
}
}
// schema://server.domain/path/to/file.ext/and/beyond -> .ext/and/beyond
auto ext = name.substr(name.rfind('.'));
if (ext.empty()) {
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
return SceAvPlayerSourceType::Unknown;
}
// .ext/and/beyond -> .ext
@ -40,14 +40,14 @@ SceAvPlayerSourceType GetSourceType(std::string_view path) {
if (iequals(ext, ".mp4") || iequals(ext, ".m4v") || iequals(ext, ".m3d") ||
iequals(ext, ".m4a") || iequals(ext, ".mov")) {
return SCE_AVPLAYER_SOURCE_TYPE_FILE_MP4;
return SceAvPlayerSourceType::FileMp4;
}
if (iequals(ext, ".m3u8")) {
return SCE_AVPLAYER_SOURCE_TYPE_HLS;
return SceAvPlayerSourceType::Hls;
}
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
return SceAvPlayerSourceType::Unknown;
}
} // namespace Libraries::AvPlayer

View file

@ -85,17 +85,17 @@ s32 AvPlayerSource::GetStreamCount() {
return m_avformat_context->nb_streams;
}
static s32 CodecTypeToStreamType(AVMediaType codec_type) {
static SceAvPlayerStreamType CodecTypeToStreamType(AVMediaType codec_type) {
switch (codec_type) {
case AVMediaType::AVMEDIA_TYPE_VIDEO:
return SCE_AVPLAYER_VIDEO;
return SceAvPlayerStreamType::Video;
case AVMediaType::AVMEDIA_TYPE_AUDIO:
return SCE_AVPLAYER_AUDIO;
return SceAvPlayerStreamType::Audio;
case AVMediaType::AVMEDIA_TYPE_SUBTITLE:
return SCE_AVPLAYER_TIMEDTEXT;
return SceAvPlayerStreamType::TimedText;
default:
LOG_ERROR(Lib_AvPlayer, "Unexpected AVMediaType {}", magic_enum::enum_name(codec_type));
return -1;
return SceAvPlayerStreamType::Unknown;
}
}
@ -124,7 +124,7 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
LOG_WARNING(Lib_AvPlayer, "Stream {} language is unknown", stream_index);
}
switch (info.type) {
case SCE_AVPLAYER_VIDEO: {
case SceAvPlayerStreamType::Video: {
LOG_INFO(Lib_AvPlayer, "Stream {} is a video stream.", stream_index);
info.details.video.aspect_ratio =
f32(p_stream->codecpar->width) / p_stream->codecpar->height;
@ -142,7 +142,7 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
}
break;
}
case SCE_AVPLAYER_AUDIO: {
case SceAvPlayerStreamType::Audio: {
LOG_INFO(Lib_AvPlayer, "Stream {} is an audio stream.", stream_index);
info.details.audio.channel_count = p_stream->codecpar->ch_layout.nb_channels;
info.details.audio.sample_rate = p_stream->codecpar->sample_rate;
@ -153,7 +153,7 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
}
break;
}
case SCE_AVPLAYER_TIMEDTEXT: {
case SceAvPlayerStreamType::TimedText: {
LOG_WARNING(Lib_AvPlayer, "Stream {} is a timedtext stream.", stream_index);
info.details.subs.font_size = 12;
info.details.subs.text_size = 12;
@ -164,7 +164,8 @@ bool AvPlayerSource::GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info
break;
}
default: {
LOG_ERROR(Lib_AvPlayer, "Stream {} type is unknown: {}.", stream_index, info.type);
LOG_ERROR(Lib_AvPlayer, "Stream {} type is unknown: {}.", stream_index,
magic_enum::enum_name(info.type));
return false;
}
}

View file

@ -16,7 +16,7 @@ void PS4_SYSV_ABI AvPlayerState::AutoPlayEventCallback(void* opaque, SceAvPlayer
s32 source_id, void* event_data) {
auto const self = reinterpret_cast<AvPlayerState*>(opaque);
if (event_id == SCE_AVPLAYER_STATE_READY) {
if (event_id == SceAvPlayerEvents::StateReady) {
s32 video_stream_index = -1;
s32 audio_stream_index = -1;
s32 timedtext_stream_index = -1;
@ -36,36 +36,37 @@ void PS4_SYSV_ABI AvPlayerState::AutoPlayEventCallback(void* opaque, SceAvPlayer
return;
}
const std::string_view default_language(
reinterpret_cast<char*>(self->m_default_language));
const std::string_view default_language{self->m_default_language};
switch (info.type) {
case SCE_AVPLAYER_VIDEO:
case SceAvPlayerStreamType::Video:
if (video_stream_index == -1) {
video_stream_index = stream_index;
}
if (!default_language.empty() &&
default_language == reinterpret_cast<char*>(info.details.video.language_code)) {
default_language == info.details.video.language_code) {
video_stream_index = stream_index;
}
break;
case SCE_AVPLAYER_AUDIO:
case SceAvPlayerStreamType::Audio:
if (audio_stream_index == -1) {
audio_stream_index = stream_index;
}
if (!default_language.empty() &&
default_language == reinterpret_cast<char*>(info.details.video.language_code)) {
default_language == info.details.video.language_code) {
audio_stream_index = stream_index;
}
break;
case SCE_AVPLAYER_TIMEDTEXT:
case SceAvPlayerStreamType::TimedText:
if (default_language.empty()) {
timedtext_stream_index = stream_index;
break;
}
if (default_language == reinterpret_cast<char*>(info.details.video.language_code)) {
if (default_language == info.details.video.language_code) {
timedtext_stream_index = stream_index;
}
break;
default:
break;
}
}
@ -141,7 +142,7 @@ bool AvPlayerState::AddSource(std::string_view path, SceAvPlayerSourceType sourc
m_up_source = std::make_unique<AvPlayerSource>(
*this, m_post_init_data.video_decoder_init.decoderType.video_type ==
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE2);
SceAvPlayerVideoDecoderType::Software2);
if (!m_up_source->Init(m_init_data, path)) {
SetState(AvState::Error);
m_up_source.reset();
@ -317,23 +318,23 @@ void AvPlayerState::OnEOF() {
void AvPlayerState::OnPlaybackStateChanged(AvState state) {
switch (state) {
case AvState::Ready: {
EmitEvent(SCE_AVPLAYER_STATE_READY);
EmitEvent(SceAvPlayerEvents::StateReady);
break;
}
case AvState::Play: {
EmitEvent(SCE_AVPLAYER_STATE_PLAY);
EmitEvent(SceAvPlayerEvents::StatePlay);
break;
}
case AvState::Stop: {
EmitEvent(SCE_AVPLAYER_STATE_STOP);
EmitEvent(SceAvPlayerEvents::StateStop);
break;
}
case AvState::Pause: {
EmitEvent(SCE_AVPLAYER_STATE_PAUSE);
EmitEvent(SceAvPlayerEvents::StatePause);
break;
}
case AvState::Buffering: {
EmitEvent(SCE_AVPLAYER_STATE_BUFFERING);
EmitEvent(SceAvPlayerEvents::StateBuffering);
break;
}
default:

View file

@ -69,7 +69,7 @@ private:
SceAvPlayerPostInitData m_post_init_data{};
SceAvPlayerEventReplacement m_event_replacement{};
bool m_auto_start{};
u8 m_default_language[4]{};
char m_default_language[4]{};
std::atomic<AvState> m_current_state;
std::atomic<AvState> m_previous_state;

View file

@ -35,7 +35,7 @@ public:
// Open an event to let the game know the IME has started
OrbisImeEvent openEvent{};
openEvent.id = (ime_mode ? OrbisImeEventId::OPEN : OrbisImeEventId::KEYBOARD_OPEN);
openEvent.id = (ime_mode ? OrbisImeEventId::Open : OrbisImeEventId::KeyboardOpen);
if (ime_mode) {
sceImeGetPanelSize(&m_param.ime, &openEvent.param.rect.width,
@ -43,8 +43,8 @@ public:
openEvent.param.rect.x = m_param.ime.posx;
openEvent.param.rect.y = m_param.ime.posy;
} else {
openEvent.param.resourceIdArray.userId = 1;
openEvent.param.resourceIdArray.resourceId[0] = 1;
openEvent.param.resource_id_array.userId = 1;
openEvent.param.resource_id_array.resource_id[0] = 1;
}
Execute(nullptr, &openEvent, true);
@ -213,15 +213,15 @@ s32 PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32*
}
switch (param->type) {
case OrbisImeType::DEFAULT:
case OrbisImeType::BASIC_LATIN:
case OrbisImeType::URL:
case OrbisImeType::MAIL:
case OrbisImeType::Default:
case OrbisImeType::BasicLatin:
case OrbisImeType::Url:
case OrbisImeType::Mail:
// We set our custom sizes, commented sizes are the original ones
*width = 500; // 793
*height = 100; // 408
break;
case OrbisImeType::NUMBER:
case OrbisImeType::Number:
*width = 370;
*height = 402;
break;
@ -313,7 +313,7 @@ void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param) {
}
memset(param, 0, sizeof(OrbisImeParam));
param->userId = -1;
param->user_id = -1;
}
int PS4_SYSV_ABI sceImeSetCandidateIndex() {

View file

@ -3,9 +3,9 @@
#pragma once
#include "common/enum.h"
#include "common/types.h"
#include "ime_common.h"
#include "core/libraries/ime/ime_common.h"
namespace Core::Loader {
class SymbolsResolver;
@ -16,13 +16,13 @@ namespace Libraries::Ime {
constexpr u32 ORBIS_IME_MAX_TEXT_LENGTH = 2048;
enum class OrbisImeKeyboardOption : u32 {
DEFAULT = 0,
REPEAT = 1,
REPEAT_EACH_KEY = 2,
ADD_OSK = 4,
EFFECTIVE_WITH_TIME = 8,
DISABLE_RESUME = 16,
DISABLE_CAPSLOCK_WITHOUT_SHIFT = 32,
Default = 0,
Repeat = 1,
RepeatEachKey = 2,
AddOsk = 4,
EffectiveWithTime = 8,
DisableResume = 16,
DisableCapslockWithoutShift = 32,
};
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeKeyboardOption)
@ -35,19 +35,19 @@ struct OrbisImeKeyboardParam {
};
struct OrbisImeParam {
s32 userId;
s32 user_id;
OrbisImeType type;
u64 supportedLanguages;
OrbisImeEnterLabel enterLabel;
OrbisImeInputMethod inputMethod;
u64 supported_languages;
OrbisImeEnterLabel enter_label;
OrbisImeInputMethod input_method;
OrbisImeTextFilter filter;
u32 option;
u32 maxTextLength;
char16_t* inputTextBuffer;
u32 max_text_length;
char16_t* input_text_buffer;
float posx;
float posy;
OrbisImeHorizontalAlignment horizontalAlignment;
OrbisImeVerticalAlignment verticalAlignment;
OrbisImeHorizontalAlignment horizontal_alignment;
OrbisImeVerticalAlignment vertical_alignment;
void* work;
void* arg;
OrbisImeEventHandler handler;
@ -117,4 +117,5 @@ int PS4_SYSV_ABI sceImeVshUpdateContext();
int PS4_SYSV_ABI sceImeVshUpdateContext2();
void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Ime
} // namespace Libraries::Ime

View file

@ -2,65 +2,64 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <sys/types.h>
#include "common/enum.h"
#include "common/types.h"
#include "core/libraries/rtc/rtc.h"
enum class OrbisImeType : u32 {
DEFAULT = 0,
BASIC_LATIN = 1,
URL = 2,
MAIL = 3,
NUMBER = 4,
Default = 0,
BasicLatin = 1,
Url = 2,
Mail = 3,
Number = 4,
};
enum class OrbisImeHorizontalAlignment : u32 {
LEFT = 0,
CENTER = 1,
RIGHT = 2,
Left = 0,
Center = 1,
Right = 2,
};
enum class OrbisImeVerticalAlignment : u32 {
TOP = 0,
CENTER = 1,
BOTTOM = 2,
Top = 0,
Center = 1,
Bottom = 2,
};
enum class OrbisImeEnterLabel : u32 {
DEFAULT = 0,
SEND = 1,
SEARCH = 2,
GO = 3,
Default = 0,
Send = 1,
Search = 2,
Go = 3,
};
enum class OrbisImeInputMethod : u32 {
DEFAULT = 0,
Default = 0,
};
enum class OrbisImeEventId : u32 {
OPEN = 0,
UPDATE_TEXT = 1,
UPDATE_CARET = 2,
PRESS_CLOSE = 4,
PRESS_ENTER = 5,
ABORT = 6,
CANDIDATE_LIST_START = 7,
CANDIDATE_LIST_END = 8,
CANDIDATE_WORD = 9,
CANDIDATE_INDEX = 10,
CANDIDATE_DONE = 11,
CANDIDATE_CANCEL = 12,
CHANGE_DEVICE = 14,
CHANGE_INPUT_METHOD_STATE = 18,
Open = 0,
UpdateText = 1,
UpdateCaret = 2,
PressClose = 4,
PressEnter = 5,
Abort = 6,
CandidateListStart = 7,
CandidateListEnd = 8,
CandidateWord = 9,
CandidateIndex = 10,
CandidateDone = 11,
CandidateCancel = 12,
ChangeDevice = 14,
ChangeInputMethodState = 18,
KEYBOARD_OPEN = 256,
KEYBOARD_KEYCODE_DOWN = 257,
KEYBOARD_KEYCODE_UP = 258,
KEYBOARD_KEYCODE_REPEAT = 259,
KEYBOARD_CONNECTION = 260,
KEYBOARD_DISCONNECTION = 261,
KEYBOARD_ABORT = 262,
KeyboardOpen = 256,
KeyboardKeycodeDoen = 257,
KeyboardKeycodeUp = 258,
KeyboardKeycodeRepeat = 259,
KeyboardConnection = 260,
KeyboardDisconnection = 261,
KeyboardAbort = 262,
};
enum class OrbisImeKeyboardType : u32 {
@ -105,10 +104,10 @@ enum class OrbisImeKeyboardType : u32 {
};
enum class OrbisImeDeviceType : u32 {
NONE = 0,
CONTROLLER = 1,
EXT_KEYBOARD = 2,
REMOTE_OSK = 3,
None = 0,
Controller = 1,
ExtKeyboard = 2,
RemoteOsk = 3,
};
struct OrbisImeRect {
@ -126,9 +125,9 @@ struct OrbisImeTextAreaProperty {
struct OrbisImeEditText {
char16_t* str;
u32 caretIndex;
u32 areaNum;
OrbisImeTextAreaProperty textArea[4];
u32 caret_index;
u32 area_num;
OrbisImeTextAreaProperty text_area[4];
};
struct OrbisImeKeycode {
@ -136,40 +135,40 @@ struct OrbisImeKeycode {
char16_t character;
u32 status;
OrbisImeKeyboardType type;
s32 userId;
u32 resourceId;
s32 user_id;
u32 resource_id;
Libraries::Rtc::OrbisRtcTick timestamp;
};
struct OrbisImeKeyboardResourceIdArray {
s32 userId;
u32 resourceId[6];
u32 resource_id[6];
};
enum class OrbisImeCaretMovementDirection : u32 {
STILL = 0,
LEFT = 1,
RIGHT = 2,
UP = 3,
DOWN = 4,
HOME = 5,
END = 6,
PAGE_UP = 7,
PAGE_DOWN = 8,
TOP = 9,
BOTTOM = 10,
Still = 0,
Left = 1,
Right = 2,
Up = 3,
Down = 4,
Home = 5,
End = 6,
PageUp = 7,
PageDown = 8,
Top = 9,
Bottom = 10,
};
union OrbisImeEventParam {
OrbisImeRect rect;
OrbisImeEditText text;
OrbisImeCaretMovementDirection caretMove;
OrbisImeCaretMovementDirection caret_move;
OrbisImeKeycode keycode;
OrbisImeKeyboardResourceIdArray resourceIdArray;
char16_t* candidateWord;
s32 candidateIndex;
OrbisImeDeviceType deviceType;
u32 inputMethodState;
OrbisImeKeyboardResourceIdArray resource_id_array;
char16_t* candidate_word;
s32 candidate_index;
OrbisImeDeviceType device_type;
u32 input_method_state;
s8 reserved[64];
};
@ -178,7 +177,7 @@ struct OrbisImeEvent {
OrbisImeEventParam param;
};
typedef PS4_SYSV_ABI int (*OrbisImeTextFilter)(char16_t* outText, u32* outTextLength,
const char16_t* srcText, u32 srcTextLength);
using OrbisImeTextFilter = PS4_SYSV_ABI int (*)(char16_t* outText, u32* outTextLength,
const char16_t* srcText, u32 srcTextLength);
typedef PS4_SYSV_ABI void (*OrbisImeEventHandler)(void* arg, const OrbisImeEvent* e);
using OrbisImeEventHandler = PS4_SYSV_ABI void (*)(void* arg, const OrbisImeEvent* e);

View file

@ -4,7 +4,7 @@
#include <array>
#include <magic_enum.hpp>
#include "common/logging/log.h"
#include "core/libraries/ime/ime_error.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "ime_dialog.h"
#include "ime_dialog_ui.h"
@ -14,24 +14,24 @@ static constexpr std::array<float, 2> MAX_Y_POSITIONS = {2160.0f, 1080.0f};
namespace Libraries::ImeDialog {
static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::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;
static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
if (False(~option &
(OrbisImeDialogOption::MULTILINE | OrbisImeDialogOption::NO_AUTO_COMPLETION))) {
(OrbisImeDialogOption::Multiline | OrbisImeDialogOption::NoAutoCompletion))) {
return false;
}
if (True(option & OrbisImeDialogOption::MULTILINE) && type != OrbisImeType::DEFAULT &&
type != OrbisImeType::BASIC_LATIN) {
if (True(option & OrbisImeDialogOption::Multiline) && type != OrbisImeType::Default &&
type != OrbisImeType::BasicLatin) {
return false;
}
if (True(option & OrbisImeDialogOption::NO_AUTO_COMPLETION) && type != OrbisImeType::NUMBER &&
type != OrbisImeType::BASIC_LATIN) {
if (True(option & OrbisImeDialogOption::NoAutoCompletion) && type != OrbisImeType::Number &&
type != OrbisImeType::BasicLatin) {
return false;
}
@ -39,29 +39,29 @@ static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
}
Error PS4_SYSV_ABI sceImeDialogAbort() {
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
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) {
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;
g_ime_dlg_status = OrbisImeDialogStatus::Finished;
g_ime_dlg_result.endstatus = OrbisImeDialogEndStatus::Aborted;
return Error::OK;
}
Error PS4_SYSV_ABI sceImeDialogForceClose() {
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
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_status = OrbisImeDialogStatus::None;
g_ime_dlg_ui = ImeDialogUi();
g_ime_dlg_state = ImeDialogState();
@ -93,7 +93,7 @@ int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended() {
}
Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
LOG_INFO(Lib_ImeDialog, "IME dialog is not running");
return Error::DIALOG_NOT_IN_USE;
}
@ -105,7 +105,7 @@ Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
result->endstatus = g_ime_dlg_result.endstatus;
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
return Error::DIALOG_NOT_FINISHED;
}
@ -114,7 +114,7 @@ Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
}
OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
g_ime_dlg_state.CallTextFilter();
}
@ -122,7 +122,7 @@ OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
}
Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) {
if (g_ime_dlg_status != OrbisImeDialogStatus::NONE) {
if (g_ime_dlg_status != OrbisImeDialogStatus::None) {
LOG_INFO(Lib_ImeDialog, "IME dialog is already running");
return Error::BUSY;
}
@ -142,24 +142,24 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
if (param->posx < 0.0f ||
param->posx >=
MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) {
MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LargeResolution)]) {
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)]) {
MAX_Y_POSITIONS[False(param->option & OrbisImeDialogOption::LargeResolution)]) {
LOG_INFO(Lib_ImeDialog, "Invalid param->posy");
return Error::INVALID_POSY;
}
if (!magic_enum::enum_contains(param->horizontalAlignment)) {
if (!magic_enum::enum_contains(param->horizontal_alignment)) {
LOG_INFO(Lib_ImeDialog, "Invalid param->horizontalAlignment");
return Error::INVALID_HORIZONTALIGNMENT;
}
if (!magic_enum::enum_contains(param->verticalAlignment)) {
if (!magic_enum::enum_contains(param->vertical_alignment)) {
LOG_INFO(Lib_ImeDialog, "Invalid param->verticalAlignment");
return Error::INVALID_VERTICALALIGNMENT;
}
@ -169,7 +169,7 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
return Error::INVALID_PARAM;
}
if (param->inputTextBuffer == nullptr) {
if (param->input_text_buffer == nullptr) {
LOG_INFO(Lib_ImeDialog, "Invalid param->inputTextBuffer");
return Error::INVALID_INPUT_TEXT_BUFFER;
}
@ -182,25 +182,25 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
// TODO: do correct extended->option validation
if ((extended->extKeyboardMode & 0xe3fffffc) != 0) {
if ((extended->ext_keyboard_mode & 0xe3fffffc) != 0) {
LOG_INFO(Lib_ImeDialog, "Invalid extended->extKeyboardMode");
return Error::INVALID_EXTENDED;
}
if (extended->disableDevice > 7) {
if (extended->disable_device > 7) {
LOG_INFO(Lib_ImeDialog, "Invalid extended->disableDevice");
return Error::INVALID_EXTENDED;
}
}
if (param->maxTextLength > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
if (param->max_text_length > 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_status = OrbisImeDialogStatus::Running;
g_ime_dlg_ui = ImeDialogUi(&g_ime_dlg_state, &g_ime_dlg_status, &g_ime_dlg_result);
return Error::OK;
@ -227,17 +227,17 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition() {
}
Error PS4_SYSV_ABI sceImeDialogTerm() {
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
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) {
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_status = OrbisImeDialogStatus::None;
g_ime_dlg_ui = ImeDialogUi();
g_ime_dlg_state = ImeDialogState();

View file

@ -58,32 +58,32 @@ enum class Error : u32 {
};
enum class OrbisImeDialogStatus : u32 {
NONE = 0,
RUNNING = 1,
FINISHED = 2,
None = 0,
Running = 1,
Finished = 2,
};
enum class OrbisImeDialogEndStatus : u32 {
OK = 0,
USER_CANCELED = 1,
ABORTED = 2,
Ok = 0,
UserCanceled = 1,
Aborted = 2,
};
enum class OrbisImeDialogOption : u32 {
DEFAULT = 0,
MULTILINE = 1,
NO_AUTO_CORRECTION = 2,
NO_AUTO_COMPLETION = 4,
Default = 0,
Multiline = 1,
NoAutoCorrection = 2,
NoAutoCompletion = 4,
// TODO: Document missing options
LARGE_RESOLUTION = 1024,
LargeResolution = 1024,
};
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDialogOption)
enum class OrbisImePanelPriority : u32 {
DEFAULT = 0,
ALPHABET = 1,
SYMBOL = 2,
ACCENT = 3,
Default = 0,
Alphabet = 1,
Symbol = 2,
Accent = 3,
};
struct OrbisImeColor {
@ -103,29 +103,29 @@ struct OrbisImeKeycode {
char16_t character;
u32 status;
OrbisImeKeyboardType type;
s32 userId;
u32 resourceId;
s32 user_id;
u32 resource_id;
u64 timestamp;
};
typedef PS4_SYSV_ABI int (*OrbisImeExtKeyboardFilter)(const OrbisImeKeycode* srcKeycode,
u16* outKeycode, u32* outStatus,
void* reserved);
using OrbisImeExtKeyboardFilter = PS4_SYSV_ABI int (*)(const OrbisImeKeycode* srcKeycode,
u16* outKeycode, u32* outStatus,
void* reserved);
struct OrbisImeDialogParam {
s32 userId;
s32 user_id;
OrbisImeType type;
u64 supportedLanguages;
OrbisImeEnterLabel enterLabel;
OrbisImeInputMethod inputMethod;
u64 supported_languages;
OrbisImeEnterLabel enter_label;
OrbisImeInputMethod input_method;
OrbisImeTextFilter filter;
OrbisImeDialogOption option;
u32 maxTextLength;
char16_t* inputTextBuffer;
u32 max_text_length;
char16_t* input_text_buffer;
float posx;
float posy;
OrbisImeHorizontalAlignment horizontalAlignment;
OrbisImeVerticalAlignment verticalAlignment;
OrbisImeHorizontalAlignment horizontal_alignment;
OrbisImeVerticalAlignment vertical_alignment;
const char16_t* placeholder;
const char16_t* title;
s8 reserved[16];
@ -133,20 +133,20 @@ struct OrbisImeDialogParam {
struct OrbisImeParamExtended {
u32 option; // OrbisImeDialogOptionExtended
OrbisImeColor colorBase;
OrbisImeColor colorLine;
OrbisImeColor colorTextField;
OrbisImeColor colorPreedit;
OrbisImeColor colorButtonDefault;
OrbisImeColor colorButtonFunction;
OrbisImeColor colorButtonSymbol;
OrbisImeColor colorText;
OrbisImeColor colorSpecial;
OrbisImeColor color_base;
OrbisImeColor color_line;
OrbisImeColor color_text_field;
OrbisImeColor color_preedit;
OrbisImeColor color_button_default;
OrbisImeColor color_button_function;
OrbisImeColor color_button_symbol;
OrbisImeColor color_text;
OrbisImeColor color_special;
OrbisImePanelPriority priority;
char* additionalDictionaryPath;
OrbisImeExtKeyboardFilter extKeyboardFilter;
uint32_t disableDevice;
uint32_t extKeyboardMode;
char* additional_dictionary_path;
OrbisImeExtKeyboardFilter ext_keyboard_filter;
uint32_t disable_device;
uint32_t ext_keyboard_mode;
int8_t reserved[60];
};
@ -167,4 +167,4 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition();
Error PS4_SYSV_ABI sceImeDialogTerm();
void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::ImeDialog
} // namespace Libraries::ImeDialog

View file

@ -8,7 +8,6 @@
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/singleton.h"
#include "core/libraries/ime/ime_dialog.h"
#include "core/libraries/ime/ime_dialog_ui.h"
#include "core/tls.h"
@ -26,15 +25,15 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
return;
}
userId = param->userId;
is_multiLine = True(param->option & OrbisImeDialogOption::MULTILINE);
is_numeric = param->type == OrbisImeType::NUMBER;
user_id = param->user_id;
is_multi_line = True(param->option & OrbisImeDialogOption::Multiline);
is_numeric = param->type == OrbisImeType::Number;
type = param->type;
enter_label = param->enterLabel;
enter_label = param->enter_label;
text_filter = param->filter;
keyboard_filter = extended ? extended->extKeyboardFilter : nullptr;
max_text_length = param->maxTextLength;
text_buffer = param->inputTextBuffer;
keyboard_filter = extended ? extended->ext_keyboard_filter : nullptr;
max_text_length = param->max_text_length;
text_buffer = param->input_text_buffer;
if (param->title) {
std::size_t title_len = std::char_traits<char16_t>::length(param->title);
@ -65,12 +64,12 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
}
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) {
: input_changed(other.input_changed), user_id(other.user_id),
is_multi_line(other.is_multi_line), 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;
}
@ -78,8 +77,8 @@ ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept
ImeDialogState& ImeDialogState::operator=(ImeDialogState&& other) {
if (this != &other) {
input_changed = other.input_changed;
userId = other.userId;
is_multiLine = other.is_multiLine;
user_id = other.user_id;
is_multi_line = other.is_multi_line;
is_numeric = other.is_numeric;
type = other.type;
enter_label = other.enter_label;
@ -171,7 +170,7 @@ ImeDialogUi::ImeDialogUi(ImeDialogState* state, OrbisImeDialogStatus* status,
OrbisImeDialogResult* result)
: state(state), status(status), result(result) {
if (state && *status == OrbisImeDialogStatus::RUNNING) {
if (state && *status == OrbisImeDialogStatus::Running) {
AddLayer(this);
}
}
@ -191,7 +190,7 @@ ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
other.status = nullptr;
other.result = nullptr;
if (state && *status == OrbisImeDialogStatus::RUNNING) {
if (state && *status == OrbisImeDialogStatus::Running) {
AddLayer(this);
}
}
@ -208,7 +207,7 @@ ImeDialogUi& ImeDialogUi::operator=(ImeDialogUi&& other) {
other.status = nullptr;
other.result = nullptr;
if (state && *status == OrbisImeDialogStatus::RUNNING) {
if (state && *status == OrbisImeDialogStatus::Running) {
AddLayer(this);
}
@ -226,7 +225,7 @@ void ImeDialogUi::Draw() {
return;
}
if (!status || *status != OrbisImeDialogStatus::RUNNING) {
if (!status || *status != OrbisImeDialogStatus::Running) {
return;
}
@ -235,7 +234,7 @@ void ImeDialogUi::Draw() {
ImVec2 window_size;
if (state->is_multiLine) {
if (state->is_multi_line) {
window_size = {500.0f, 300.0f};
} else {
window_size = {500.0f, 150.0f};
@ -259,7 +258,7 @@ void ImeDialogUi::Draw() {
SetWindowFontScale(1.0f);
}
if (state->is_multiLine) {
if (state->is_multi_line) {
DrawMultiLineInputText();
} else {
DrawInputText();
@ -270,16 +269,16 @@ void ImeDialogUi::Draw() {
const char* button_text;
switch (state->enter_label) {
case OrbisImeEnterLabel::GO:
case OrbisImeEnterLabel::Go:
button_text = "Go##ImeDialogOK";
break;
case OrbisImeEnterLabel::SEARCH:
case OrbisImeEnterLabel::Search:
button_text = "Search##ImeDialogOK";
break;
case OrbisImeEnterLabel::SEND:
case OrbisImeEnterLabel::Send:
button_text = "Send##ImeDialogOK";
break;
case OrbisImeEnterLabel::DEFAULT:
case OrbisImeEnterLabel::Default:
default:
button_text = "OK##ImeDialogOK";
break;
@ -292,16 +291,16 @@ void ImeDialogUi::Draw() {
SetCursorPosX(button_start_pos);
if (Button(button_text, BUTTON_SIZE) ||
(!state->is_multiLine && IsKeyPressed(ImGuiKey_Enter))) {
*status = OrbisImeDialogStatus::FINISHED;
result->endstatus = OrbisImeDialogEndStatus::OK;
(!state->is_multi_line && 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;
*status = OrbisImeDialogStatus::Finished;
result->endstatus = OrbisImeDialogEndStatus::UserCanceled;
}
}
End();
@ -362,9 +361,10 @@ int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
.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};
.user_id = ui->state->user_id,
.resource_id = 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");

View file

@ -20,8 +20,8 @@ class ImeDialogState final {
bool input_changed = false;
s32 userId{};
bool is_multiLine{};
s32 user_id{};
bool is_multi_line{};
bool is_numeric{};
OrbisImeType type{};
OrbisImeEnterLabel enter_label{};

View file

@ -16,7 +16,7 @@ ImeState::ImeState(const OrbisImeParam* param) {
}
work_buffer = param->work;
text_buffer = param->inputTextBuffer;
text_buffer = param->input_text_buffer;
std::size_t text_len = std::char_traits<char16_t>::length(text_buffer);
if (!ConvertOrbisToUTF8(text_buffer, text_len, current_text.begin(),
@ -52,13 +52,13 @@ void ImeState::SendEvent(OrbisImeEvent* event) {
void ImeState::SendEnterEvent() {
OrbisImeEvent enterEvent{};
enterEvent.id = OrbisImeEventId::PRESS_ENTER;
enterEvent.id = OrbisImeEventId::PressEnter;
SendEvent(&enterEvent);
}
void ImeState::SendCloseEvent() {
OrbisImeEvent closeEvent{};
closeEvent.id = OrbisImeEventId::PRESS_CLOSE;
closeEvent.id = OrbisImeEventId::PressClose;
closeEvent.param.text.str = reinterpret_cast<char16_t*>(work_buffer);
SendEvent(&closeEvent);
}
@ -180,7 +180,7 @@ void ImeUi::DrawInputText() {
if (first_render) {
SetKeyboardFocusHere();
}
if (InputTextEx("##ImeInput", nullptr, state->current_text.begin(), ime_param->maxTextLength,
if (InputTextEx("##ImeInput", nullptr, state->current_text.begin(), ime_param->max_text_length,
input_size, ImGuiInputTextFlags_CallbackAlways, InputTextCallback, this)) {
state->input_changed = true;
}
@ -194,16 +194,16 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
if (lastCaretPos == -1) {
lastCaretPos = data->CursorPos;
} else if (data->CursorPos != lastCaretPos) {
OrbisImeCaretMovementDirection caretDirection = OrbisImeCaretMovementDirection::STILL;
OrbisImeCaretMovementDirection caretDirection = OrbisImeCaretMovementDirection::Still;
if (data->CursorPos < lastCaretPos) {
caretDirection = OrbisImeCaretMovementDirection::LEFT;
caretDirection = OrbisImeCaretMovementDirection::Left;
} else if (data->CursorPos > lastCaretPos) {
caretDirection = OrbisImeCaretMovementDirection::RIGHT;
caretDirection = OrbisImeCaretMovementDirection::Right;
}
OrbisImeEvent event{};
event.id = OrbisImeEventId::UPDATE_CARET;
event.param.caretMove = caretDirection;
event.id = OrbisImeEventId::UpdateCaret;
event.param.caret_move = caretDirection;
lastCaretPos = data->CursorPos;
ui->state->SendEvent(&event);
@ -214,28 +214,28 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
if (currentText != lastText) {
OrbisImeEditText eventParam{};
eventParam.str = reinterpret_cast<char16_t*>(ui->ime_param->work);
eventParam.caretIndex = data->CursorPos;
eventParam.areaNum = 1;
eventParam.caret_index = data->CursorPos;
eventParam.area_num = 1;
eventParam.textArea[0].mode = 1; // Edit mode
eventParam.textArea[0].index = data->CursorPos;
eventParam.textArea[0].length = data->BufTextLen;
eventParam.text_area[0].mode = 1; // Edit mode
eventParam.text_area[0].index = data->CursorPos;
eventParam.text_area[0].length = data->BufTextLen;
if (!ui->state->ConvertUTF8ToOrbis(data->Buf, data->BufTextLen, eventParam.str,
ui->ime_param->maxTextLength)) {
ui->ime_param->max_text_length)) {
LOG_ERROR(Lib_ImeDialog, "Failed to convert Orbis char to UTF-8");
return 0;
}
if (!ui->state->ConvertUTF8ToOrbis(data->Buf, data->BufTextLen,
ui->ime_param->inputTextBuffer,
ui->ime_param->maxTextLength)) {
ui->ime_param->input_text_buffer,
ui->ime_param->max_text_length)) {
LOG_ERROR(Lib_ImeDialog, "Failed to convert Orbis char to UTF-8");
return 0;
}
OrbisImeEvent event{};
event.id = OrbisImeEventId::UPDATE_TEXT;
event.id = OrbisImeEventId::UpdateText;
event.param.text = eventParam;
lastText = currentText;
@ -249,4 +249,4 @@ void ImeUi::Free() {
RemoveLayer(this);
}
}; // namespace Libraries::Ime
}; // namespace Libraries::Ime

View file

@ -77,9 +77,8 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
bool has_found = false;
{
std::scoped_lock lock{m_mutex};
for (auto& event : m_events) {
if ((event.event.ident == ident) && (event.event.filter == filter)) {
if (event.event.ident == ident && event.event.filter == filter) {
event.Trigger(trigger_data);
has_found = true;
}
@ -91,7 +90,6 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
int EqueueInternal::GetTriggeredEvents(SceKernelEvent* ev, int num) {
int count = 0;
for (auto& event : m_events) {
if (event.IsTriggered()) {
if (event.event.flags & SceKernelEvent::Flags::Clear) {

View file

@ -37,8 +37,8 @@ struct OrbisKernelStat {
u32 st_gen;
s32 st_lspare;
OrbisKernelTimespec st_birthtim;
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
u32 : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
u32 : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
};
struct OrbisKernelDirent {

View file

@ -21,6 +21,10 @@
#include "core/libraries/kernel/time.h"
#include "core/libraries/libs.h"
#ifdef _WIN64
#include <Rpc.h>
#endif
namespace Libraries::Kernel {
static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; // dummy return

View file

@ -231,7 +231,7 @@ int PS4_SYSV_ABI sceKernelDeleteSema(OrbisKernelSema sem) {
return ORBIS_OK;
}
int PS4_SYSV_ABI posix_sem_init(PthreadSem** sem, int pshared, unsigned int value) {
int PS4_SYSV_ABI posix_sem_init(PthreadSem** sem, int pshared, u32 value) {
if (value > ORBIS_KERNEL_SEM_VALUE_MAX) {
*__Error() = POSIX_EINVAL;
return -1;

View file

@ -2,14 +2,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <forward_list>
#include <list>
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/list_hook.hpp>
#include "common/types.h"
namespace Libraries::Kernel {
struct Pthread;
struct SleepQueue;
using ListBaseHook =
boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::auto_unlink>>;
@ -17,7 +16,7 @@ using ListBaseHook =
using SleepqList = boost::intrusive::list<SleepQueue, boost::intrusive::constant_time_size<false>>;
struct SleepQueue : public ListBaseHook {
std::list<Pthread*> sq_blocked;
std::forward_list<Pthread*> sq_blocked;
SleepqList sq_freeq;
void* sq_wchan;
int sq_type;
@ -35,4 +34,4 @@ int SleepqRemove(SleepQueue* sq, Pthread* td);
void SleepqDrop(SleepQueue* sq, void (*callback)(Pthread*, void*), void* arg);
} // namespace Libraries::Kernel
} // namespace Libraries::Kernel

View file

@ -254,7 +254,7 @@ Common::NativeClock* GetClock() {
} // namespace Dev
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
struct OrbisTimesec* st, unsigned long* dst_sec) {
struct OrbisTimesec* st, u64* dst_sec) {
LOG_TRACE(Kernel, "Called");
#ifdef __APPLE__
// std::chrono::current_zone() not available yet.

View file

@ -81,7 +81,7 @@ int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2,
OrbisKernelTimezone* timezone, int* dst_seconds);
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time, OrbisTimesec* st,
unsigned long* dst_sec);
u64* dst_sec);
void RegisterTime(Core::Loader::SymbolsResolver* sym);

View file

@ -15,6 +15,12 @@ struct PngHandler {
png_infop info_ptr;
};
struct PngStruct {
const u8* data;
size_t size;
u64 offset;
};
static inline OrbisPngDecColorSpace MapPngColor(int color) {
switch (color) {
case PNG_COLOR_TYPE_GRAY:
@ -49,8 +55,8 @@ s32 PS4_SYSV_ABI scePngDecCreate(const OrbisPngDecCreateParam* param, void* memo
LOG_ERROR(Lib_Png, "Invalid memory address!");
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
}
if (param->maxImageWidth - 1 > 1000000) {
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->maxImageWidth);
if (param->max_image_width - 1 > 1000000) {
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->max_image_width);
return ORBIS_PNG_DEC_ERROR_INVALID_SIZE;
}
auto pngh = (PngHandler*)memoryAddress;
@ -81,7 +87,7 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
LOG_ERROR(Lib_Png, "Invalid param!");
return ORBIS_PNG_DEC_ERROR_INVALID_PARAM;
}
if (param->pngMemAddr == nullptr || param->pngMemAddr == nullptr) {
if (param->png_mem_addr == nullptr || param->image_mem_addr == nullptr) {
LOG_ERROR(Lib_Png, "invalid image address!");
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
}
@ -93,22 +99,16 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
auto pngh = (PngHandler*)handle;
struct pngstruct {
const u8* data;
size_t size;
u64 offset;
} pngdata = {
.data = (const u8*)param->pngMemAddr,
.size = param->pngMemSize,
const auto pngdata = PngStruct{
.data = param->png_mem_addr,
.size = param->png_mem_size,
.offset = 0,
};
// Read png from memory
png_set_read_fn(pngh->png_ptr, (void*)&pngdata,
[](png_structp ps, png_bytep data, png_size_t len) {
if (len == 0)
return;
auto pngdata = (pngstruct*)png_get_io_ptr(ps);
auto pngdata = (PngStruct*)png_get_io_ptr(ps);
::memcpy(data, pngdata->data + pngdata->offset, len);
pngdata->offset += len;
});
@ -120,16 +120,16 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
const auto bit_depth = png_get_bit_depth(pngh->png_ptr, pngh->info_ptr);
if (imageInfo != nullptr) {
imageInfo->bitDepth = bit_depth;
imageInfo->imageWidth = width;
imageInfo->imageHeight = height;
imageInfo->colorSpace = color_type;
imageInfo->imageFlag = OrbisPngDecImageFlag::None;
imageInfo->bit_depth = bit_depth;
imageInfo->image_width = width;
imageInfo->image_height = height;
imageInfo->color_space = color_type;
imageInfo->image_flag = OrbisPngDecImageFlag::None;
if (png_get_interlace_type(pngh->png_ptr, pngh->info_ptr) == 1) {
imageInfo->imageFlag |= OrbisPngDecImageFlag::Adam7Interlace;
imageInfo->image_flag |= OrbisPngDecImageFlag::Adam7Interlace;
}
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
imageInfo->imageFlag |= OrbisPngDecImageFlag::TrnsChunkExist;
imageInfo->image_flag |= OrbisPngDecImageFlag::TrnsChunkExist;
}
}
@ -149,13 +149,13 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
color_type == OrbisPngDecColorSpace::GrayscaleAlpha) {
png_set_gray_to_rgb(pngh->png_ptr);
}
if (param->pixelFormat == OrbisPngDecPixelFormat::B8G8R8A8) {
if (param->pixel_format == OrbisPngDecPixelFormat::B8G8R8A8) {
png_set_bgr(pngh->png_ptr);
}
if (color_type == OrbisPngDecColorSpace::Rgb ||
color_type == OrbisPngDecColorSpace::Grayscale ||
color_type == OrbisPngDecColorSpace::Clut) {
png_set_add_alpha(pngh->png_ptr, param->alphaValue, PNG_FILLER_AFTER);
png_set_add_alpha(pngh->png_ptr, param->alpha_value, PNG_FILLER_AFTER);
}
const s32 pass = png_set_interlace_handling(pngh->png_ptr);
@ -163,10 +163,10 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
const s32 num_channels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
const s32 horizontal_bytes = num_channels * width;
const s32 stride = param->imagePitch > 0 ? param->imagePitch : horizontal_bytes;
const s32 stride = param->image_pitch > 0 ? param->image_pitch : horizontal_bytes;
for (int j = 0; j < pass; j++) {
auto ptr = reinterpret_cast<png_bytep>(param->imageMemAddr);
auto ptr = reinterpret_cast<png_bytep>(param->image_mem_addr);
for (int y = 0; y < height; y++) {
png_read_row(pngh->png_ptr, ptr, nullptr);
ptr += stride;
@ -195,7 +195,7 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
}
u8 header[8];
memcpy(header, param->pngMemAddr, 8);
memcpy(header, param->png_mem_addr, 8);
// Check if the header indicates a valid PNG file
if (png_sig_cmp(header, 0, 8)) {
LOG_ERROR(Lib_Png, "Memory doesn't contain a valid png file");
@ -208,18 +208,14 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
// Create a libpng info structure
auto info_ptr = png_create_info_struct(png_ptr);
struct pngstruct {
const u8* data;
size_t size;
u64 offset;
} pngdata = {
.data = (const u8*)param->pngMemAddr,
.size = param->pngMemSize,
const auto pngdata = PngStruct{
.data = param->png_mem_addr,
.size = param->png_mem_size,
.offset = 0,
};
png_set_read_fn(png_ptr, (void*)&pngdata, [](png_structp ps, png_bytep data, png_size_t len) {
auto pngdata = (pngstruct*)png_get_io_ptr(ps);
auto pngdata = (PngStruct*)png_get_io_ptr(ps);
::memcpy(data, pngdata->data + pngdata->offset, len);
pngdata->offset += len;
});
@ -228,16 +224,16 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
// info.
png_read_info(png_ptr, info_ptr);
imageInfo->imageWidth = png_get_image_width(png_ptr, info_ptr);
imageInfo->imageHeight = png_get_image_height(png_ptr, info_ptr);
imageInfo->colorSpace = MapPngColor(png_get_color_type(png_ptr, info_ptr));
imageInfo->bitDepth = png_get_bit_depth(png_ptr, info_ptr);
imageInfo->imageFlag = OrbisPngDecImageFlag::None;
imageInfo->image_width = png_get_image_width(png_ptr, info_ptr);
imageInfo->image_height = png_get_image_height(png_ptr, info_ptr);
imageInfo->color_space = MapPngColor(png_get_color_type(png_ptr, info_ptr));
imageInfo->bit_depth = png_get_bit_depth(png_ptr, info_ptr);
imageInfo->image_flag = OrbisPngDecImageFlag::None;
if (png_get_interlace_type(png_ptr, info_ptr) == 1) {
imageInfo->imageFlag |= OrbisPngDecImageFlag::Adam7Interlace;
imageInfo->image_flag |= OrbisPngDecImageFlag::Adam7Interlace;
}
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
imageInfo->imageFlag |= OrbisPngDecImageFlag::TrnsChunkExist;
imageInfo->image_flag |= OrbisPngDecImageFlag::TrnsChunkExist;
}
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
@ -258,8 +254,8 @@ s32 PS4_SYSV_ABI scePngDecQueryMemorySize(const OrbisPngDecCreateParam* param) {
LOG_ERROR(Lib_Png, "Invalid attribute! attribute = {}", param->attribute);
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
}
if (param->maxImageWidth - 1 > 1000000) {
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->maxImageWidth);
if (param->max_image_width - 1 > 1000000) {
LOG_ERROR(Lib_Png, "Invalid size! width = {}", param->max_image_width);
return ORBIS_PNG_DEC_ERROR_INVALID_SIZE;
}
return sizeof(PngHandler);

View file

@ -12,45 +12,61 @@ class SymbolsResolver;
namespace Libraries::PngDec {
enum class OrbisPngDecColorSpace : u16 { Grayscale = 2, Rgb, Clut, GrayscaleAlpha = 18, Rgba };
enum class OrbisPngDecColorSpace : u16 {
Grayscale = 2,
Rgb,
Clut,
GrayscaleAlpha = 18,
Rgba,
};
enum class OrbisPngDecImageFlag : u32 { None = 0, Adam7Interlace = 1, TrnsChunkExist = 2 };
enum class OrbisPngDecImageFlag : u32 {
None = 0,
Adam7Interlace = 1,
TrnsChunkExist = 2,
};
DECLARE_ENUM_FLAG_OPERATORS(OrbisPngDecImageFlag)
enum class OrbisPngDecPixelFormat : u16 { R8G8B8A8 = 0, B8G8R8A8 };
enum class OrbisPngDecPixelFormat : u16 {
R8G8B8A8 = 0,
B8G8R8A8,
};
enum class OrbisPngDecAttribute { None = 0, BitDepth16 };
enum class OrbisPngDecAttribute {
None = 0,
BitDepth16,
};
struct OrbisPngDecParseParam {
const void* pngMemAddr;
u32 pngMemSize;
const u8* png_mem_addr;
u32 png_mem_size;
u32 reserved;
};
struct OrbisPngDecImageInfo {
u32 imageWidth;
u32 imageHeight;
OrbisPngDecColorSpace colorSpace;
u16 bitDepth;
OrbisPngDecImageFlag imageFlag;
u32 image_width;
u32 image_height;
OrbisPngDecColorSpace color_space;
u16 bit_depth;
OrbisPngDecImageFlag image_flag;
};
struct OrbisPngDecCreateParam {
u32 thisSize;
u32 this_size;
u32 attribute;
u32 maxImageWidth;
u32 max_image_width;
};
using OrbisPngDecHandle = void*;
struct OrbisPngDecDecodeParam {
const void* pngMemAddr;
void* imageMemAddr;
u32 pngMemSize;
u32 imageMemSize;
OrbisPngDecPixelFormat pixelFormat;
u16 alphaValue;
u32 imagePitch;
const u8* png_mem_addr;
u8* image_mem_addr;
u32 png_mem_size;
u32 image_mem_size;
OrbisPngDecPixelFormat pixel_format;
u16 alpha_value;
u32 image_pitch;
};
s32 PS4_SYSV_ABI scePngDecCreate(const OrbisPngDecCreateParam* param, void* memoryAddress,

View file

@ -1,13 +1,12 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "ngs2.h"
#include "ngs2_error.h"
#include "ngs2_impl.h"
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "core/libraries/ngs2/ngs2.h"
#include "core/libraries/ngs2/ngs2_error.h"
#include "core/libraries/ngs2/ngs2_impl.h"
namespace Libraries::Ngs2 {
@ -416,4 +415,4 @@ void RegisterlibSceNgs2(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("AbYvTOZ8Pts", "libSceNgs2", 1, "libSceNgs2", 1, 1, sceNgs2VoiceRunCommands);
};
} // namespace Libraries::Ngs2
} // namespace Libraries::Ngs2

View file

@ -3,10 +3,8 @@
#pragma once
#include "common/types.h"
#include <atomic>
#include <memory>
#include "common/types.h"
namespace Core::Loader {
class SymbolsResolver;
@ -18,7 +16,9 @@ class Ngs2;
using SceNgs2Handle = Ngs2*;
enum SceNgs2HandleType { SCE_NGS2_HANDLE_TYPE_SYSTEM = 0 };
enum class SceNgs2HandleType : u32 {
System = 0,
};
struct Ngs2Handle {
void* selfPointer;
@ -69,4 +69,5 @@ struct StackBuffer {
};
void RegisterlibSceNgs2(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Ngs2
} // namespace Libraries::Ngs2

View file

@ -10,9 +10,11 @@ class SymbolsResolver;
}
namespace Libraries::Random {
constexpr int32_t SCE_RANDOM_MAX_SIZE = 64;
constexpr s32 SCE_RANDOM_MAX_SIZE = 64;
s32 PS4_SYSV_ABI sceRandomGetRandomNumber(u8* buf, std::size_t size);
void RegisterlibSceRandom(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Random
} // namespace Libraries::Random

View file

@ -575,7 +575,7 @@ int PS4_SYSV_ABI sceRtcGetDaysInMonth(int year, int month) {
return lastDay;
}
int PS4_SYSV_ABI sceRtcGetDosTime(OrbisRtcDateTime* pTime, unsigned int* dosTime) {
int PS4_SYSV_ABI sceRtcGetDosTime(OrbisRtcDateTime* pTime, u32* dosTime) {
LOG_TRACE(Lib_Rtc, "called");
if (pTime == nullptr || dosTime == nullptr)
@ -631,7 +631,7 @@ int PS4_SYSV_ABI sceRtcGetTick(OrbisRtcDateTime* pTime, OrbisRtcTick* pTick) {
return ORBIS_OK;
}
unsigned int PS4_SYSV_ABI sceRtcGetTickResolution() {
u32 PS4_SYSV_ABI sceRtcGetTickResolution() {
LOG_TRACE(Lib_Rtc, "called");
return 1000000;

View file

@ -3,6 +3,7 @@
#pragma once
#include <sys/types.h>
#include "common/types.h"
namespace Core::Loader {
@ -19,21 +20,21 @@ constexpr int ORBIS_RTC_DAYOFWEEK_THURSDAY = 4;
constexpr int ORBIS_RTC_DAYOFWEEK_FRIDAY = 5;
constexpr int ORBIS_RTC_DAYOFWEEK_SATURDAY = 6;
constexpr int64_t UNIX_EPOCH_TICKS = 0xdcbffeff2bc000;
constexpr int64_t WIN32_FILETIME_EPOCH_TICKS = 0xb36168b6a58000;
constexpr s64 UNIX_EPOCH_TICKS = 0xdcbffeff2bc000;
constexpr s64 WIN32_FILETIME_EPOCH_TICKS = 0xb36168b6a58000;
struct OrbisRtcTick {
uint64_t tick;
u64 tick;
};
struct OrbisRtcDateTime {
uint16_t year;
uint16_t month;
uint16_t day;
uint16_t hour;
uint16_t minute;
uint16_t second;
uint32_t microsecond;
u16 year;
u16 month;
u16 day;
u16 hour;
u16 minute;
u16 second;
u32 microsecond;
};
int PS4_SYSV_ABI sceRtcCheckValid(OrbisRtcDateTime* pTime);
@ -58,9 +59,9 @@ int PS4_SYSV_ABI sceRtcGetCurrentRawNetworkTick(OrbisRtcTick* pTick);
int PS4_SYSV_ABI sceRtcGetCurrentTick(OrbisRtcTick* pTick);
int PS4_SYSV_ABI sceRtcGetDayOfWeek(int year, int month, int day);
int PS4_SYSV_ABI sceRtcGetDaysInMonth(int year, int month);
int PS4_SYSV_ABI sceRtcGetDosTime(OrbisRtcDateTime* pTime, unsigned int* dosTime);
int PS4_SYSV_ABI sceRtcGetDosTime(OrbisRtcDateTime* pTime, u32* dosTime);
int PS4_SYSV_ABI sceRtcGetTick(OrbisRtcDateTime* pTime, OrbisRtcTick* pTick);
unsigned int PS4_SYSV_ABI sceRtcGetTickResolution();
u32 PS4_SYSV_ABI sceRtcGetTickResolution();
int PS4_SYSV_ABI sceRtcGetTime_t(OrbisRtcDateTime* pTime, time_t* llTime);
int PS4_SYSV_ABI sceRtcGetWin32FileTime(OrbisRtcDateTime* pTime, uint64_t* ulWin32Time);
int PS4_SYSV_ABI sceRtcInit();
@ -88,4 +89,4 @@ int PS4_SYSV_ABI sceRtcTickAddWeeks(OrbisRtcTick* pTick1, OrbisRtcTick* pTick2,
int PS4_SYSV_ABI sceRtcTickAddYears(OrbisRtcTick* pTick1, OrbisRtcTick* pTick2, int32_t lAdd);
void RegisterlibSceRtc(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Rtc
} // namespace Libraries::Rtc

View file

@ -1772,14 +1772,12 @@ s32 PS4_SYSV_ABI sceSystemServiceGetStatus(OrbisSystemServiceStatus* status) {
LOG_ERROR(Lib_SystemService, "OrbisSystemServiceStatus is null");
return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER;
}
OrbisSystemServiceStatus st = {};
st.eventNum = 0;
st.isSystemUiOverlaid = false;
st.isInBackgroundExecution = false;
st.isCpuMode7CpuNormal = true;
st.isGameLiveStreamingOnAir = false;
st.isOutOfVrPlayArea = false;
*status = st;
status->event_num = 0;
status->is_system_ui_overlaid = false;
status->is_in_background_execution = false;
status->is_cpu_mode7_cpu_normal = true;
status->is_game_live_streaming_on_air = false;
status->is_out_of_vr_play_area = false;
return ORBIS_OK;
}

View file

@ -20,12 +20,19 @@ enum class OrbisSystemServiceParamId {
Summertime = 5,
SystemName = 6,
GameParentalLevel = 7,
EnterButtonAssign = 1000
EnterButtonAssign = 1000,
};
enum class OrbisSystemParamDateFormat { FmtYYYYMMDD = 0, FmtDDMMYYYY = 1, FmtMMDDYYYY = 2 };
enum class OrbisSystemParamDateFormat {
FmtYYYYMMDD = 0,
FmtDDMMYYYY = 1,
FmtMMDDYYYY = 2,
};
enum class OrbisSystemParamTimeFormat { Fmt12Hour = 0, Fmt24Hour = 1 };
enum class OrbisSystemParamTimeFormat {
Fmt12Hour = 0,
Fmt24Hour = 1,
};
enum class OrbisSystemParamGameParentalLevel {
Off = 0,
@ -39,10 +46,13 @@ enum class OrbisSystemParamGameParentalLevel {
Level08 = 8,
Level09 = 9,
Level10 = 10,
Level11 = 11
Level11 = 11,
};
enum class OrbisSystemParamEnterButtonAssign { Circle = 0, Cross = 1 };
enum class OrbisSystemParamEnterButtonAssign {
Circle = 0,
Cross = 1,
};
enum class OrbisSystemServiceEventType {
Invalid = -1,
@ -71,12 +81,12 @@ enum class OrbisSystemServiceEventType {
};
struct OrbisSystemServiceStatus {
s32 eventNum;
bool isSystemUiOverlaid;
bool isInBackgroundExecution;
bool isCpuMode7CpuNormal;
bool isGameLiveStreamingOnAir;
bool isOutOfVrPlayArea;
s32 event_num;
bool is_system_ui_overlaid;
bool is_in_background_execution;
bool is_cpu_mode7_cpu_normal;
bool is_game_live_streaming_on_air;
bool is_out_of_vr_play_area;
u8 reserved[];
};
@ -86,36 +96,36 @@ struct OrbisSystemServiceDisplaySafeAreaInfo {
};
struct OrbisSystemServiceEvent {
OrbisSystemServiceEventType eventType;
OrbisSystemServiceEventType event_type;
union {
char param[8192];
struct {
char source[1024];
char url[4096];
} urlOpen;
} url_open;
struct {
u32 size;
u8 arg[8188];
} launchApp;
} launch_app;
struct {
u32 size;
u8 arg[2020];
} appLaunchLink;
} app_launch_link;
struct {
s32 userId;
char eventId[37];
char bootArgument[7169];
} joinEvent;
s32 user_id;
char event_id[37];
char boot_argument[7169];
} join_event;
struct {
s32 userId;
u32 npServiceLabel;
s32 user_id;
u32 np_service_label;
u8 reserved[8184];
} serviceEntitlementUpdate;
} service_entitlement_update;
struct {
s32 userId;
u32 npServiceLabel;
s32 user_id;
u32 np_service_label;
u8 reserved[8184];
} unifiedEntitlementUpdate;
} unified_entitlement_update;
u8 reserved[8192];
};
};

View file

@ -41,10 +41,10 @@ constexpr u32 PixelFormatBpp(PixelFormat pixel_format) {
}
VideoOutDriver::VideoOutDriver(u32 width, u32 height) {
main_port.resolution.fullWidth = width;
main_port.resolution.fullHeight = height;
main_port.resolution.paneWidth = width;
main_port.resolution.paneHeight = height;
main_port.resolution.full_width = width;
main_port.resolution.full_height = height;
main_port.resolution.pane_width = width;
main_port.resolution.pane_height = height;
present_thread = std::jthread([&](std::stop_token token) { PresentThread(token); });
}
@ -173,20 +173,21 @@ void VideoOutDriver::Flip(const Request& req) {
std::unique_lock lock{port->port_mutex};
auto& flip_status = port->flip_status;
flip_status.count++;
flip_status.processTime = Libraries::Kernel::sceKernelGetProcessTime();
flip_status.process_time = Libraries::Kernel::sceKernelGetProcessTime();
flip_status.tsc = Libraries::Kernel::sceKernelReadTsc();
flip_status.flipArg = req.flip_arg;
flip_status.currentBuffer = req.index;
flip_status.flip_arg = req.flip_arg;
flip_status.current_buffer = req.index;
if (req.eop) {
--flip_status.gcQueueNum;
--flip_status.gc_queue_num;
}
--flip_status.flipPendingNum;
--flip_status.flip_pending_num;
}
// Trigger flip events for the port.
for (auto& event : port->flip_events) {
if (event != nullptr) {
event->TriggerEvent(SCE_VIDEO_OUT_EVENT_FLIP, Kernel::SceKernelEvent::Filter::VideoOut,
event->TriggerEvent(u64(OrbisVideoOutEventId::Flip),
Kernel::SceKernelEvent::Filter::VideoOut,
reinterpret_cast<void*>(req.flip_arg));
}
}
@ -210,16 +211,16 @@ bool VideoOutDriver::SubmitFlip(VideoOutPort* port, s32 index, s64 flip_arg,
bool is_eop /*= false*/) {
{
std::unique_lock lock{port->port_mutex};
if (index != -1 && port->flip_status.flipPendingNum >= port->NumRegisteredBuffers()) {
if (index != -1 && port->flip_status.flip_pending_num >= port->NumRegisteredBuffers()) {
LOG_ERROR(Lib_VideoOut, "Flip queue is full");
return false;
}
if (is_eop) {
++port->flip_status.gcQueueNum;
++port->flip_status.gc_queue_num;
}
++port->flip_status.flipPendingNum; // integral GPU and CPU pending flips counter
port->flip_status.submitTsc = Libraries::Kernel::sceKernelReadTsc();
++port->flip_status.flip_pending_num; // integral GPU and CPU pending flips counter
port->flip_status.submit_tsc = Libraries::Kernel::sceKernelReadTsc();
}
if (!is_eop) {
@ -299,7 +300,7 @@ void VideoOutDriver::PresentThread(std::stop_token token) {
// Needs lock here as can be concurrently read by `sceVideoOutGetVblankStatus`
std::scoped_lock lock{main_port.vo_mutex};
vblank_status.count++;
vblank_status.processTime = Libraries::Kernel::sceKernelGetProcessTime();
vblank_status.process_time = Libraries::Kernel::sceKernelGetProcessTime();
vblank_status.tsc = Libraries::Kernel::sceKernelReadTsc();
main_port.vblank_cv.notify_all();
}
@ -307,7 +308,7 @@ void VideoOutDriver::PresentThread(std::stop_token token) {
// Trigger flip events for the port.
for (auto& event : main_port.vblank_events) {
if (event != nullptr) {
event->TriggerEvent(SCE_VIDEO_OUT_EVENT_VBLANK,
event->TriggerEvent(u64(OrbisVideoOutEventId::Vblank),
Kernel::SceKernelEvent::Filter::VideoOut, nullptr);
}
}

View file

@ -50,7 +50,7 @@ s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(Kernel::SceKernelEqueue eq, s32 handle,
}
Kernel::EqueueEvent event{};
event.event.ident = SCE_VIDEO_OUT_EVENT_FLIP;
event.event.ident = u64(OrbisVideoOutEventId::Flip);
event.event.filter = Kernel::SceKernelEvent::Filter::VideoOut;
// The library only sets EV_ADD but kernel driver forces EV_CLEAR
event.event.flags = Kernel::SceKernelEvent::Flags::Clear;
@ -77,7 +77,7 @@ s32 PS4_SYSV_ABI sceVideoOutAddVblankEvent(Kernel::SceKernelEqueue eq, s32 handl
}
Kernel::EqueueEvent event{};
event.event.ident = SCE_VIDEO_OUT_EVENT_VBLANK;
event.event.ident = u64(OrbisVideoOutEventId::Vblank);
event.event.filter = Kernel::SceKernelEvent::Filter::VideoOut;
// The library only sets EV_ADD but kernel driver forces EV_CLEAR
event.event.flags = Kernel::SceKernelEvent::Flags::Clear;
@ -117,7 +117,7 @@ s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle) {
LOG_TRACE(Lib_VideoOut, "called");
auto* port = driver->GetPort(handle);
std::unique_lock lock{port->port_mutex};
s32 pending = port->flip_status.flipPendingNum;
s32 pending = port->flip_status.flip_pending_num;
return pending;
}

View file

@ -40,36 +40,32 @@ constexpr int SCE_VIDEO_OUT_BUFFER_ATTRIBUTE_OPTION_NONE = 0;
constexpr int SCE_VIDEO_OUT_BUFFER_ATTRIBUTE_OPTION_VR = 7;
constexpr int SCE_VIDEO_OUT_BUFFER_ATTRIBUTE_OPTION_STRICT_COLORIMETRY = 8;
enum SceVideoOutEventId : s16 {
SCE_VIDEO_OUT_EVENT_FLIP = 0,
SCE_VIDEO_OUT_EVENT_VBLANK = 1,
SCE_VIDEO_OUT_EVENT_PRE_VBLANK_START = 2
};
enum class OrbisVideoOutEventId : s16 { Flip = 0, Vblank = 1, PreVblankStart = 2 };
enum AspectRatioMode : s32 {
SCE_VIDEO_OUT_ASPECT_RATIO_16_9 = 0,
enum class AspectRatioMode : s32 {
Ratio16_9 = 0,
};
struct FlipStatus {
u64 count = 0;
u64 processTime = 0;
u64 process_time = 0;
u64 tsc = 0;
s64 flipArg = -1;
u64 submitTsc = 0;
s64 flip_arg = -1;
u64 submit_tsc = 0;
u64 reserved0 = 0;
s32 gcQueueNum = 0;
s32 flipPendingNum = 0;
s32 currentBuffer = -1;
s32 gc_queue_num = 0;
s32 flip_pending_num = 0;
s32 current_buffer = -1;
u32 reserved1 = 0;
};
struct SceVideoOutResolutionStatus {
s32 fullWidth = 1280;
s32 fullHeight = 720;
s32 paneWidth = 1280;
s32 paneHeight = 720;
u64 refreshRate = SCE_VIDEO_OUT_REFRESH_RATE_59_94HZ;
float screenSizeInInch = 50;
s32 full_width = 1280;
s32 full_height = 720;
s32 pane_width = 1280;
s32 pane_height = 720;
u64 refresh_rate = SCE_VIDEO_OUT_REFRESH_RATE_59_94HZ;
float screen_size_in_inch = 50;
u16 flags = 0;
u16 reserved0 = 0;
u32 reserved1[3] = {0};
@ -77,7 +73,7 @@ struct SceVideoOutResolutionStatus {
struct SceVideoOutVblankStatus {
u64 count = 0;
u64 processTime = 0;
u64 process_time = 0;
u64 tsc = 0;
u64 reserved[1] = {0};
u8 flags = 0;

View file

@ -16,7 +16,6 @@
#include "core/linker.h"
#include "core/memory.h"
#include "core/tls.h"
#include "core/virtual_memory.h"
namespace Core {
@ -211,7 +210,7 @@ void Linker::Relocate(Module* module) {
}
if (rel_is_resolved) {
VirtualMemory::memory_patch(rel_virtual_addr, rel_value);
std::memcpy(reinterpret_cast<void*>(rel_virtual_addr), &rel_value, sizeof(rel_value));
} else {
LOG_INFO(Core_Linker, "Function not patched! {}", rel_name);
}
@ -297,8 +296,6 @@ void* Linker::TlsGetAddr(u64 module_index, u64 offset) {
u8* addr = dtv_table[module_index + 1].pointer;
Module* module = m_modules[module_index - 1].get();
// LOG_INFO(Core_Linker, "Got DTV addr {} from module index {} with name {}",
// fmt::ptr(addr), module_index, module->file.filename().string());
if (!addr) {
// Module was just loaded by above code. Allocate TLS block for it.
const u32 init_image_size = module->tls.init_image_size;

View file

@ -1,180 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/assert.h"
#include "common/error.h"
#include "common/logging/log.h"
#include "core/virtual_memory.h"
#ifdef _WIN64
#include <windows.h>
#else
#include <sys/mman.h>
#endif
#if !defined(_WIN64)
enum PosixPageProtection {
PAGE_NOACCESS = 0,
PAGE_READONLY = PROT_READ,
PAGE_READWRITE = PROT_READ | PROT_WRITE,
PAGE_EXECUTE = PROT_EXEC,
PAGE_EXECUTE_READ = PROT_EXEC | PROT_READ,
PAGE_EXECUTE_READWRITE = PROT_EXEC | PROT_READ | PROT_WRITE
};
#endif
namespace VirtualMemory {
static u32 convertMemoryMode(MemoryMode mode) {
switch (mode) {
case MemoryMode::Read:
return PAGE_READONLY;
case MemoryMode::Write:
case MemoryMode::ReadWrite:
return PAGE_READWRITE;
case MemoryMode::Execute:
return PAGE_EXECUTE;
case MemoryMode::ExecuteRead:
return PAGE_EXECUTE_READ;
case MemoryMode::ExecuteWrite:
case MemoryMode::ExecuteReadWrite:
return PAGE_EXECUTE_READWRITE;
case MemoryMode::NoAccess:
return PAGE_NOACCESS;
default:
return PAGE_NOACCESS;
}
}
static MemoryMode convertMemoryMode(u32 mode) {
switch (mode) {
case PAGE_NOACCESS:
return MemoryMode::NoAccess;
case PAGE_READONLY:
return MemoryMode::Read;
case PAGE_READWRITE:
return MemoryMode::ReadWrite;
case PAGE_EXECUTE:
return MemoryMode::Execute;
case PAGE_EXECUTE_READ:
return MemoryMode::ExecuteRead;
case PAGE_EXECUTE_READWRITE:
return MemoryMode::ExecuteReadWrite;
default:
return MemoryMode::NoAccess;
}
}
u64 memory_alloc(u64 address, u64 size, MemoryMode mode) {
#ifdef _WIN64
auto ptr = reinterpret_cast<uintptr_t>(VirtualAlloc(
reinterpret_cast<LPVOID>(static_cast<uintptr_t>(address)), size,
static_cast<DWORD>(MEM_COMMIT) | static_cast<DWORD>(MEM_RESERVE), convertMemoryMode(mode)));
if (ptr == 0) {
auto err = static_cast<u32>(GetLastError());
LOG_ERROR(Common_Memory, "VirtualAlloc() failed: 0x{:X}", err);
}
#else
auto ptr = reinterpret_cast<uintptr_t>(
mmap(reinterpret_cast<void*>(static_cast<uintptr_t>(address)), size,
PROT_EXEC | PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0));
if (ptr == reinterpret_cast<uintptr_t> MAP_FAILED) {
LOG_ERROR(Common_Memory, "mmap() failed: {}", std::strerror(errno));
}
#endif
return ptr;
}
bool memory_protect(u64 address, u64 size, MemoryMode mode, MemoryMode* old_mode) {
#ifdef _WIN64
DWORD old_protect = 0;
if (VirtualProtect(reinterpret_cast<LPVOID>(static_cast<uintptr_t>(address)), size,
convertMemoryMode(mode), &old_protect) == 0) {
auto err = static_cast<u32>(GetLastError());
LOG_ERROR(Common_Memory, "VirtualProtect() failed: 0x{:X}", err);
return false;
}
if (old_mode != nullptr) {
*old_mode = convertMemoryMode(old_protect);
}
return true;
#else
int ret = mprotect(reinterpret_cast<void*>(address), size, convertMemoryMode(mode));
if (ret != 0) {
const auto error = Common::GetLastErrorMsg();
ASSERT(false);
}
return true;
#endif
}
bool memory_flush(u64 address, u64 size) {
#ifdef _WIN64
if (::FlushInstructionCache(GetCurrentProcess(),
reinterpret_cast<LPVOID>(static_cast<uintptr_t>(address)),
size) == 0) {
auto err = static_cast<u32>(GetLastError());
LOG_ERROR(Common_Memory, "FlushInstructionCache() failed: 0x{:X}", err);
return false;
}
return true;
#else // linux probably doesn't have something similar
return true;
#endif
}
bool memory_patch(u64 vaddr, u64 value) {
MemoryMode old_mode{};
// memory_protect(vaddr, 8, MemoryMode::ReadWrite, &old_mode);
auto* ptr = reinterpret_cast<uint64_t*>(vaddr);
bool ret = (*ptr != value);
*ptr = value;
// memory_protect(vaddr, 8, old_mode, nullptr);
// if mode is executable flush it so insure that cpu finds it
if (containsExecuteMode(old_mode)) {
memory_flush(vaddr, 8);
}
return ret;
}
static u64 AlignUp(u64 pos, u64 align) {
return (align != 0 ? (pos + (align - 1)) & ~(align - 1) : pos);
}
u64 memory_alloc_aligned(u64 address, u64 size, MemoryMode mode, u64 alignment) {
#ifdef _WIN64
// try allocate aligned address inside user area
MEM_ADDRESS_REQUIREMENTS req{};
MEM_EXTENDED_PARAMETER param{};
req.LowestStartingAddress =
(address == 0 ? reinterpret_cast<PVOID>(USER_MIN)
: reinterpret_cast<PVOID>(AlignUp(address, alignment)));
req.HighestEndingAddress = reinterpret_cast<PVOID>(USER_MAX);
req.Alignment = alignment;
param.Type = MemExtendedParameterAddressRequirements;
param.Pointer = &req;
auto ptr = reinterpret_cast<uintptr_t>(
VirtualAlloc2(GetCurrentProcess(), nullptr, size,
static_cast<DWORD>(MEM_COMMIT) | static_cast<DWORD>(MEM_RESERVE),
convertMemoryMode(mode), &param, 1));
if (ptr == 0) {
auto err = static_cast<u32>(GetLastError());
LOG_ERROR(Common_Memory, "VirtualAlloc2() failed: 0x{:X}", err);
}
return ptr;
#else
void* hint_address = address == 0 ? reinterpret_cast<void*>(USER_MIN)
: reinterpret_cast<void*>(AlignUp(address, alignment));
void* ptr = mmap(hint_address, size, convertMemoryMode(mode), MAP_ANON | MAP_PRIVATE, -1, 0);
ASSERT(ptr != MAP_FAILED);
return reinterpret_cast<u64>(ptr);
#endif
}
} // namespace VirtualMemory

View file

@ -1,47 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/types.h"
constexpr u64 SYSTEM_RESERVED = 0x800000000u;
constexpr u64 CODE_BASE_OFFSET = 0x100000000u;
constexpr u64 SYSTEM_MANAGED_MIN = 0x0000040000u;
constexpr u64 SYSTEM_MANAGED_MAX = 0x07FFFFBFFFu;
constexpr u64 USER_MIN = 0x1000000000u;
constexpr u64 USER_MAX = 0xFBFFFFFFFFu;
namespace VirtualMemory {
enum class MemoryMode : u32 {
NoAccess = 0,
Read = 1,
Write = 2,
ReadWrite = 3,
Execute = 4,
ExecuteRead = 5,
ExecuteWrite = 6,
ExecuteReadWrite = 7,
};
u64 memory_alloc(u64 address, u64 size, MemoryMode mode);
u64 memory_alloc_aligned(u64 address, u64 size, MemoryMode mode, u64 alignment);
bool memory_protect(u64 address, u64 size, MemoryMode mode, MemoryMode* old_mode);
bool memory_flush(u64 address, u64 size);
bool memory_patch(u64 vaddr, u64 value);
inline bool containsExecuteMode(MemoryMode mode) {
switch (mode) {
case MemoryMode::Execute:
return true;
case MemoryMode::ExecuteRead:
return true;
case MemoryMode::ExecuteWrite:
return true;
case MemoryMode::ExecuteReadWrite:
return true;
default:
return false;
}
}
} // namespace VirtualMemory