core: Bring structs and enums to codebase style

This commit is contained in:
IndecisiveTurtle 2024-11-30 03:20:58 +02:00
parent d1c3aeb8a4
commit ba78dc5552
35 changed files with 787 additions and 881 deletions

View file

@ -1,164 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <mutex>
#include <SDL3/SDL_audio.h>
#include <SDL3/SDL_init.h>
#include <SDL3/SDL_timer.h>
#include "audio_core/sdl_audio.h"
#include "common/assert.h"
#include "core/libraries/audio/audioout_error.h"
namespace Audio {
constexpr int AUDIO_STREAM_BUFFER_THRESHOLD = 65536; // Define constant for buffer threshold
s32 SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
Libraries::AudioOut::OrbisAudioOutParamFormat format) {
using Libraries::AudioOut::OrbisAudioOutParamFormat;
std::scoped_lock lock{m_mutex};
for (int id = 0; id < portsOut.size(); id++) {
auto& port = portsOut[id];
if (!port.isOpen) {
port.isOpen = true;
port.type = type;
port.samples_num = samples_num;
port.freq = freq;
port.format = format;
SDL_AudioFormat sampleFormat;
switch (format) {
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
sampleFormat = SDL_AUDIO_S16;
port.channels_num = 1;
port.sample_size = 2;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
sampleFormat = SDL_AUDIO_F32;
port.channels_num = 1;
port.sample_size = 4;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
sampleFormat = SDL_AUDIO_S16;
port.channels_num = 2;
port.sample_size = 2;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
sampleFormat = SDL_AUDIO_F32;
port.channels_num = 2;
port.sample_size = 4;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
sampleFormat = SDL_AUDIO_S16;
port.channels_num = 8;
port.sample_size = 2;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
sampleFormat = SDL_AUDIO_F32;
port.channels_num = 8;
port.sample_size = 4;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
sampleFormat = SDL_AUDIO_S16;
port.channels_num = 8;
port.sample_size = 2;
break;
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD:
sampleFormat = SDL_AUDIO_F32;
port.channels_num = 8;
port.sample_size = 4;
break;
default:
UNREACHABLE_MSG("Unknown format");
}
for (int i = 0; i < port.channels_num; i++) {
port.volume[i] = Libraries::AudioOut::SCE_AUDIO_OUT_VOLUME_0DB;
}
SDL_AudioSpec fmt;
SDL_zero(fmt);
fmt.format = sampleFormat;
fmt.channels = port.channels_num;
fmt.freq = freq; // Set frequency from the argument
port.stream =
SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &fmt, NULL, NULL);
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port.stream));
return id + 1;
}
}
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
return ORBIS_AUDIO_OUT_ERROR_PORT_FULL; // all ports are used
}
s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
std::shared_lock lock{m_mutex};
auto& port = portsOut[handle - 1];
if (!port.isOpen) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
const size_t data_size = port.samples_num * port.sample_size * port.channels_num;
bool result = SDL_PutAudioStreamData(port.stream, ptr, data_size);
lock.unlock(); // Unlock only after necessary operations
while (SDL_GetAudioStreamAvailable(port.stream) > AUDIO_STREAM_BUFFER_THRESHOLD) {
SDL_Delay(0);
}
return result ? ORBIS_OK : -1;
}
s32 SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
using Libraries::AudioOut::OrbisAudioOutParamFormat;
std::shared_lock lock{m_mutex};
auto& port = portsOut[handle - 1];
if (!port.isOpen) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
for (int i = 0; i < port.channels_num; i++, bitflag >>= 1u) {
auto bit = bitflag & 0x1u;
if (bit == 1) {
int src_index = i;
if (port.format ==
OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD ||
port.format == OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD) {
switch (i) {
case 4:
src_index = 6;
break;
case 5:
src_index = 7;
break;
case 6:
src_index = 4;
break;
case 7:
src_index = 5;
break;
default:
break;
}
}
port.volume[i] = volume[src_index];
}
}
return ORBIS_OK;
}
s32 SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) {
std::shared_lock lock{m_mutex};
auto& port = portsOut[handle - 1];
*type = port.type;
*channels_num = port.channels_num;
return ORBIS_OK;
}
} // namespace Audio

View file

@ -1,39 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <shared_mutex>
#include <SDL3/SDL_audio.h>
#include "core/libraries/audio/audioout.h"
namespace Audio {
class SDLAudio {
public:
SDLAudio() = default;
virtual ~SDLAudio() = default;
s32 AudioOutOpen(int type, u32 samples_num, u32 freq,
Libraries::AudioOut::OrbisAudioOutParamFormat format);
s32 AudioOutOutput(s32 handle, const void* ptr);
s32 AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume);
s32 AudioOutGetStatus(s32 handle, int* type, int* channels_num);
private:
struct PortOut {
SDL_AudioStream* stream = nullptr;
u32 samples_num = 0;
u32 freq = 0;
u32 format = -1;
int type = 0;
int channels_num = 0;
int volume[8] = {};
u8 sample_size = 0;
bool isOpen = false;
};
std::shared_mutex m_mutex;
std::array<PortOut, Libraries::AudioOut::SCE_AUDIO_OUT_NUM_PORTS> portsOut;
};
} // namespace Audio

View file

@ -97,24 +97,23 @@ struct PlaygoChunk {
class PlaygoFile {
public:
bool initialized;
OrbisPlayGoHandle handle;
OrbisPlayGoChunkId id;
OrbisPlayGoLocus locus;
OrbisPlayGoInstallSpeed speed;
s64 speed_tick;
OrbisPlayGoEta eta;
OrbisPlayGoLanguageMask langMask;
bool initialized = false;
OrbisPlayGoHandle handle = 0;
OrbisPlayGoChunkId id = 0;
OrbisPlayGoLocus locus = OrbisPlayGoLocus::NotDownloaded;
OrbisPlayGoInstallSpeed speed = OrbisPlayGoInstallSpeed::Trickle;
s64 speed_tick = 0;
OrbisPlayGoEta eta = 0;
OrbisPlayGoLanguageMask langMask = 0;
std::vector<PlaygoChunk> chunks;
public:
PlaygoFile()
: initialized(false), handle(0), id(0), locus(0), speed(ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE),
speed_tick(0), eta(0), langMask(0), playgoHeader{0} {}
explicit PlaygoFile() = default;
~PlaygoFile() = default;
bool Open(const std::filesystem::path& filepath);
bool LoadChunks(const Common::FS::IOFile& file);
PlaygoHeader& GetPlaygoHeader() {
return playgoHeader;
}

View file

@ -15,22 +15,21 @@
namespace Libraries::AppContent {
int32_t addcont_count = 0;
struct AddContInfo {
char entitlementLabel[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
char entitlement_label[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
OrbisAppContentAddcontDownloadStatus status;
OrbisAppContentGetEntitlementKey key;
};
std::array<AddContInfo, ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE> addcont_info = {{
static std::array<AddContInfo, ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE> addcont_info = {{
{"0000000000000000",
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED,
OrbisAppContentAddcontDownloadStatus::Installed,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}},
}};
std::string title_id;
static s32 addcont_count = 0;
static std::string title_id;
int PS4_SYSV_ABI _Z5dummyv() {
LOG_ERROR(Lib_AppContent, "(STUBBED) called");
@ -61,12 +60,11 @@ int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
for (int i = 0; i < addcont_count; i++) {
if (strncmp(entitlement_label->data, addcont_info[i].entitlementLabel,
if (strncmp(entitlement_label->data, addcont_info[i].entitlement_label,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
continue;
}
if (addcont_info[i].status != ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED) {
if (addcont_info[i].status != OrbisAppContentAddcontDownloadStatus::Installed) {
return ORBIS_APP_CONTENT_ERROR_NOT_FOUND;
}
@ -167,14 +165,14 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfo(u32 service_label,
}
for (auto i = 0; i < addcont_count; i++) {
if (strncmp(entitlementLabel->data, addcont_info[i].entitlementLabel,
if (strncmp(entitlementLabel->data, addcont_info[i].entitlement_label,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
continue;
}
LOG_INFO(Lib_AppContent, "found DLC {}", entitlementLabel->data);
strncpy(info->entitlement_label.data, addcont_info[i].entitlementLabel,
strncpy(info->entitlement_label.data, addcont_info[i].entitlement_label,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
info->status = addcont_info[i].status;
return ORBIS_OK;
@ -199,7 +197,7 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfoList(u32 service_label,
int dlcs_to_list = addcont_count < list_num ? addcont_count : list_num;
for (int i = 0; i < dlcs_to_list; i++) {
strncpy(list[i].entitlement_label.data, addcont_info[i].entitlementLabel,
strncpy(list[i].entitlement_label.data, addcont_info[i].entitlement_label,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
list[i].status = addcont_info[i].status;
}
@ -221,7 +219,7 @@ int PS4_SYSV_ABI sceAppContentGetEntitlementKey(
}
for (int i = 0; i < addcont_count; i++) {
if (strncmp(entitlement_label->data, addcont_info[i].entitlementLabel,
if (strncmp(entitlement_label->data, addcont_info[i].entitlement_label,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
continue;
}
@ -249,21 +247,19 @@ int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initPar
} else {
UNREACHABLE_MSG("Failed to get TITLE_ID");
}
auto addon_path = addons_dir / title_id;
if (std::filesystem::exists(addon_path)) {
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
if (entry.is_directory()) {
auto entitlement_label = entry.path().filename().string();
AddContInfo info{};
info.status = ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED;
entitlement_label.copy(info.entitlementLabel, sizeof(info.entitlementLabel));
addcont_info[addcont_count++] = info;
}
}
const auto addon_path = addons_dir / title_id;
if (!std::filesystem::exists(addon_path)) {
return ORBIS_OK;
}
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
if (entry.is_directory()) {
auto entitlement_label = entry.path().filename().string();
auto& info = addcont_info[addcont_count++];
info.status = OrbisAppContentAddcontDownloadStatus::Installed;
entitlement_label.copy(info.entitlement_label, sizeof(info.entitlement_label));
}
}
return ORBIS_OK;
}
@ -311,9 +307,11 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataMount() {
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
OrbisAppContentMountPoint* mountPoint) {
if (mountPoint == nullptr)
if (mountPoint == nullptr) {
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
strncpy(mountPoint->data, "/temp0", 16);
}
static constexpr std::string_view TmpMount = "/temp0";
TmpMount.copy(mountPoint->data, sizeof(mountPoint->data));
LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}",
option, mountPoint->data);
return ORBIS_OK;

View file

@ -30,7 +30,7 @@ struct OrbisAppContentBootParam {
char reserved2[32];
};
typedef u32 OrbisAppContentTemporaryDataOption;
using OrbisAppContentTemporaryDataOption = u32;
constexpr int ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE = 16;
@ -44,12 +44,12 @@ constexpr int ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE = 17;
constexpr int ORBIS_APP_CONTENT_ENTITLEMENT_KEY_SIZE = 16;
constexpr int ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE = 2500;
enum OrbisAppContentAddcontDownloadStatus : u32 {
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_EXTRA_DATA = 0,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_IN_QUEUE = 1,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOADING = 2,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOAD_SUSPENDED = 3,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED = 4
enum class OrbisAppContentAddcontDownloadStatus : u32 {
NoExtraData = 0,
NoInQueue = 1,
Downloading = 2,
DownloadSuspended = 3,
Installed = 4
};
struct OrbisNpUnifiedEntitlementLabel {
@ -57,11 +57,11 @@ struct OrbisNpUnifiedEntitlementLabel {
char padding[3];
};
typedef u32 OrbisAppContentAppParamId;
using OrbisAppContentAppParamId = u32;
struct OrbisAppContentAddcontInfo {
OrbisNpUnifiedEntitlementLabel entitlement_label;
u32 status;
OrbisAppContentAddcontDownloadStatus status;
};
struct OrbisAppContentGetEntitlementKey {
@ -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, size_t* availableSpaceKb);
const OrbisAppContentMountPoint* mountPoint, u64* availableSpaceKb);
int PS4_SYSV_ABI sceAppContentTemporaryDataMount();
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
OrbisAppContentMountPoint* mountPoint);
@ -119,4 +119,4 @@ int PS4_SYSV_ABI sceAppContentGetAddcontInfoListByIroTag();
int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry();
void RegisterlibSceAppContent(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::AppContent
} // namespace Libraries::AppContent

View file

@ -4,30 +4,30 @@
#include <memory>
#include <magic_enum.hpp>
#include "audio_core/sdl_audio.h"
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/libraries/audio/audioout.h"
#include "core/libraries/audio/audioout_error.h"
#include "core/libraries/audio/sdl_audio.h"
#include "core/libraries/libs.h"
namespace Libraries::AudioOut {
static std::unique_ptr<Audio::SDLAudio> audio;
static std::unique_ptr<SDLAudioOut> audio;
static std::string_view GetAudioOutPort(u32 port) {
static std::string_view GetAudioOutPort(OrbisAudioOutPort port) {
switch (port) {
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
case OrbisAudioOutPort::Main:
return "MAIN";
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
case OrbisAudioOutPort::Bgm:
return "BGM";
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
case OrbisAudioOutPort::Voice:
return "VOICE";
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
case OrbisAudioOutPort::Personal:
return "PERSONAL";
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
case OrbisAudioOutPort::Padspk:
return "PADSPK";
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
case OrbisAudioOutPort::Aux:
return "AUX";
default:
return "INVALID";
@ -36,21 +36,21 @@ static std::string_view GetAudioOutPort(u32 port) {
static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
switch (param) {
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
case OrbisAudioOutParamFormat::S16Mono:
return "S16_MONO";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
case OrbisAudioOutParamFormat::S16Stereo:
return "S16_STEREO";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
case OrbisAudioOutParamFormat::S16_8CH:
return "S16_8CH";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
case OrbisAudioOutParamFormat::FloatMono:
return "FLOAT_MONO";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
case OrbisAudioOutParamFormat::FloatStereo:
return "FLOAT_STEREO";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
case OrbisAudioOutParamFormat::Float_8CH:
return "FLOAT_8CH";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
case OrbisAudioOutParamFormat::S16_8CH_Std:
return "S16_8CH_STD";
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD:
case OrbisAudioOutParamFormat::Float_8CH_Std:
return "FLOAT_8CH_STD";
default:
return "INVALID";
@ -59,11 +59,11 @@ static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
static std::string_view GetAudioOutParamAttr(OrbisAudioOutParamAttr attr) {
switch (attr) {
case ORBIS_AUDIO_OUT_PARAM_ATTR_NONE:
case OrbisAudioOutParamAttr::None:
return "NONE";
case ORBIS_AUDIO_OUT_PARAM_ATTR_RESTRICTED:
case OrbisAudioOutParamAttr::Restricted:
return "RESTRICTED";
case ORBIS_AUDIO_OUT_PARAM_ATTR_MIX_TO_MAIN:
case OrbisAudioOutParamAttr::MixToMain:
return "MIX_TO_MAIN";
default:
return "INVALID";
@ -180,29 +180,23 @@ int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* sta
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
int type = 0;
int channels_num = 0;
if (const auto err = audio->AudioOutGetStatus(handle, &type, &channels_num); err != ORBIS_OK) {
return err;
}
const auto [type, channels_num] = audio->GetStatus(handle);
state->rerouteCounter = 0;
state->volume = 127; // max volume
state->volume = 127;
switch (type) {
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
case OrbisAudioOutPort::Main:
case OrbisAudioOutPort::Bgm:
case OrbisAudioOutPort::Voice:
state->output = 1;
state->channel = (channels_num > 2 ? 2 : channels_num);
break;
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
case OrbisAudioOutPort::Personal:
case OrbisAudioOutPort::Padspk:
state->output = 4;
state->channel = 1;
break;
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
case OrbisAudioOutPort::Aux:
state->output = 0;
state->channel = 0;
break;
@ -243,7 +237,7 @@ int PS4_SYSV_ABI sceAudioOutInit() {
if (audio != nullptr) {
return ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT;
}
audio = std::make_unique<Audio::SDLAudio>();
audio = std::make_unique<SDLAudioOut>();
return ORBIS_OK;
}
@ -287,7 +281,8 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
user_id, GetAudioOutPort(port_type), index, length, sample_rate,
GetAudioOutParamFormat(param_type.data_format),
GetAudioOutParamAttr(param_type.attributes));
if ((port_type < 0 || port_type > 4) && (port_type != 127)) {
if ((port_type < OrbisAudioOutPort::Main || port_type > OrbisAudioOutPort::Padspk) &&
(port_type != OrbisAudioOutPort::Aux)) {
LOG_ERROR(Lib_AudioOut, "Invalid port type");
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT_TYPE;
}
@ -303,18 +298,19 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
if (index != 0) {
LOG_ERROR(Lib_AudioOut, "index is not valid !=0 {}", index);
}
OrbisAudioOutParamFormat format = param_type.data_format;
if (format < 0 || format > 7) {
const auto format = param_type.data_format.Value();
if (format < OrbisAudioOutParamFormat::S16Mono ||
format > OrbisAudioOutParamFormat::Float_8CH_Std) {
LOG_ERROR(Lib_AudioOut, "Invalid format");
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
}
OrbisAudioOutParamAttr attr = param_type.attributes;
if (attr < 0 || attr > 2) {
const auto attr = param_type.attributes;
if (attr < OrbisAudioOutParamAttr::None || attr > OrbisAudioOutParamAttr::MixToMain) {
// TODO Handle attributes in output audio device
LOG_ERROR(Lib_AudioOut, "Invalid format attribute");
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
}
return audio->AudioOutOpen(port_type, length, sample_rate, format);
return audio->Open(port_type, length, sample_rate, format);
}
int PS4_SYSV_ABI sceAudioOutOpenEx() {
@ -330,7 +326,7 @@ s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr) {
// Nothing to output
return ORBIS_OK;
}
return audio->AudioOutOutput(handle, ptr);
return audio->Output(handle, ptr);
}
int PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num) {
@ -435,7 +431,7 @@ s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
return audio->AudioOutSetVolume(handle, flag, vol);
return audio->SetVolume(handle, flag, vol);
}
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {

View file

@ -9,46 +9,36 @@
namespace Libraries::AudioOut {
constexpr int SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value
// main up to 8 ports, BGM 1 port, voice up to 4 ports,
// Main up to 8 ports, BGM 1 port, voice up to 4 ports,
// personal up to 4 ports, padspk up to 5 ports, aux 1 port
constexpr int SCE_AUDIO_OUT_NUM_PORTS = 22;
constexpr int SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value
enum OrbisAudioOutPort {
ORBIS_AUDIO_OUT_PORT_TYPE_MAIN = 0,
ORBIS_AUDIO_OUT_PORT_TYPE_BGM = 1,
ORBIS_AUDIO_OUT_PORT_TYPE_VOICE = 2,
ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL = 3,
ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK = 4,
ORBIS_AUDIO_OUT_PORT_TYPE_AUX = 127
enum class OrbisAudioOutPort { Main = 0, Bgm = 1, Voice = 2, Personal = 3, Padspk = 4, Aux = 127 };
enum class OrbisAudioOutParamFormat {
S16Mono = 0,
S16Stereo = 1,
S16_8CH = 2,
FloatMono = 3,
FloatStereo = 4,
Float_8CH = 5,
S16_8CH_Std = 6,
Float_8CH_Std = 7
};
enum OrbisAudioOutParamFormat {
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO = 0,
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO = 1,
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH = 2,
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO = 3,
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO = 4,
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH = 5,
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD = 6,
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD = 7
enum class OrbisAudioOutParamAttr {
None = 0,
Restricted = 1,
MixToMain = 2,
};
enum OrbisAudioOutParamAttr {
ORBIS_AUDIO_OUT_PARAM_ATTR_NONE = 0,
ORBIS_AUDIO_OUT_PARAM_ATTR_RESTRICTED = 1,
ORBIS_AUDIO_OUT_PARAM_ATTR_MIX_TO_MAIN = 2,
};
struct OrbisAudioOutParamExtendedInformation {
union {
BitField<0, 8, OrbisAudioOutParamFormat> data_format;
BitField<8, 8, u32> reserve0;
BitField<16, 4, OrbisAudioOutParamAttr> attributes;
BitField<20, 10, u32> reserve1;
BitField<31, 1, u32> unused;
};
union OrbisAudioOutParamExtendedInformation {
BitField<0, 8, OrbisAudioOutParamFormat> data_format;
BitField<8, 8, u32> reserve0;
BitField<16, 4, OrbisAudioOutParamAttr> attributes;
BitField<20, 10, u32> reserve1;
BitField<31, 1, u32> unused;
};
struct OrbisAudioOutOutputParam {

View file

@ -0,0 +1,141 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <mutex>
#include <SDL3/SDL_audio.h>
#include <SDL3/SDL_init.h>
#include <SDL3/SDL_timer.h>
#include "common/assert.h"
#include "core/libraries/audio/audioout_error.h"
#include "core/libraries/audio/sdl_audio.h"
namespace Libraries::AudioOut {
constexpr int AUDIO_STREAM_BUFFER_THRESHOLD = 65536; // Define constant for buffer threshold
s32 SDLAudioOut::Open(OrbisAudioOutPort type, u32 samples_num, u32 freq,
OrbisAudioOutParamFormat format) {
std::scoped_lock lock{m_mutex};
const auto port = std::ranges::find(ports_out, false, &PortOut::is_open);
if (port == ports_out.end()) {
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
return ORBIS_AUDIO_OUT_ERROR_PORT_FULL;
}
port->is_open = true;
port->type = type;
port->samples_num = samples_num;
port->freq = freq;
port->format = format;
SDL_AudioFormat sampleFormat;
switch (format) {
case OrbisAudioOutParamFormat::S16Mono:
sampleFormat = SDL_AUDIO_S16;
port->channels_num = 1;
port->sample_size = 2;
break;
case OrbisAudioOutParamFormat::FloatMono:
sampleFormat = SDL_AUDIO_F32;
port->channels_num = 1;
port->sample_size = 4;
break;
case OrbisAudioOutParamFormat::S16Stereo:
sampleFormat = SDL_AUDIO_S16;
port->channels_num = 2;
port->sample_size = 2;
break;
case OrbisAudioOutParamFormat::FloatStereo:
sampleFormat = SDL_AUDIO_F32;
port->channels_num = 2;
port->sample_size = 4;
break;
case OrbisAudioOutParamFormat::S16_8CH:
sampleFormat = SDL_AUDIO_S16;
port->channels_num = 8;
port->sample_size = 2;
break;
case OrbisAudioOutParamFormat::Float_8CH:
sampleFormat = SDL_AUDIO_F32;
port->channels_num = 8;
port->sample_size = 4;
break;
case OrbisAudioOutParamFormat::S16_8CH_Std:
sampleFormat = SDL_AUDIO_S16;
port->channels_num = 8;
port->sample_size = 2;
break;
case OrbisAudioOutParamFormat::Float_8CH_Std:
sampleFormat = SDL_AUDIO_F32;
port->channels_num = 8;
port->sample_size = 4;
break;
default:
UNREACHABLE_MSG("Unknown format");
}
port->volume.fill(Libraries::AudioOut::SCE_AUDIO_OUT_VOLUME_0DB);
SDL_AudioSpec fmt;
SDL_zero(fmt);
fmt.format = sampleFormat;
fmt.channels = port->channels_num;
fmt.freq = freq;
port->stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &fmt, NULL, NULL);
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port->stream));
return std::distance(ports_out.begin(), port) + 1;
}
s32 SDLAudioOut::Output(s32 handle, const void* ptr) {
auto& port = ports_out.at(handle - 1);
if (!port.is_open) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
const size_t data_size = port.samples_num * port.sample_size * port.channels_num;
bool result = SDL_PutAudioStreamData(port.stream, ptr, data_size);
while (SDL_GetAudioStreamAvailable(port.stream) > AUDIO_STREAM_BUFFER_THRESHOLD) {
SDL_Delay(0);
}
return result ? ORBIS_OK : -1;
}
s32 SDLAudioOut::SetVolume(s32 handle, s32 bitflag, s32* volume) {
using Libraries::AudioOut::OrbisAudioOutParamFormat;
auto& port = ports_out.at(handle - 1);
if (!port.is_open) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
for (int i = 0; i < port.channels_num; i++, bitflag >>= 1u) {
auto bit = bitflag & 0x1u;
if (bit == 1) {
int src_index = i;
if (port.format == OrbisAudioOutParamFormat::Float_8CH_Std ||
port.format == OrbisAudioOutParamFormat::S16_8CH_Std) {
switch (i) {
case 4:
src_index = 6;
break;
case 5:
src_index = 7;
break;
case 6:
src_index = 4;
break;
case 7:
src_index = 5;
break;
default:
break;
}
}
port.volume[i] = volume[src_index];
}
}
return ORBIS_OK;
}
} // namespace Libraries::AudioOut

View file

@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <shared_mutex>
#include <SDL3/SDL_audio.h>
#include "core/libraries/audio/audioout.h"
namespace Libraries::AudioOut {
class SDLAudioOut {
public:
explicit SDLAudioOut() = default;
~SDLAudioOut() = default;
s32 Open(OrbisAudioOutPort type, u32 samples_num, u32 freq, OrbisAudioOutParamFormat format);
s32 Output(s32 handle, const void* ptr);
s32 SetVolume(s32 handle, s32 bitflag, s32* volume);
constexpr std::pair<OrbisAudioOutPort, int> GetStatus(s32 handle) const {
const auto& port = ports_out.at(handle - 1);
return std::make_pair(port.type, port.channels_num);
}
private:
struct PortOut {
SDL_AudioStream* stream;
u32 samples_num;
u32 freq;
OrbisAudioOutParamFormat format;
OrbisAudioOutPort type;
int channels_num;
std::array<int, 8> volume;
u8 sample_size;
bool is_open;
};
std::shared_mutex m_mutex;
std::array<PortOut, Libraries::AudioOut::SCE_AUDIO_OUT_NUM_PORTS> ports_out{};
};
} // namespace Libraries::AudioOut

View file

@ -26,17 +26,12 @@ struct SceFiber {
u64 signature;
FiberState state;
SceFiberEntry entry;
u64 argOnInitialize;
u64 argRun;
u64* pArgRun;
u64 argReturn;
u64* pArgReturn;
u64 sizeContext;
char name[ORBIS_FIBER_MAX_NAME_LENGTH];
void* handle;
};
@ -53,7 +48,7 @@ struct SceFiberInfo {
};
static_assert(sizeof(SceFiberInfo) <= 128);
typedef void* SceFiberOptParam;
using SceFiberOptParam = void*;
s32 PS4_SYSV_ABI sceFiberInitialize(SceFiber* fiber, const char* name, SceFiberEntry entry,
u64 argOnInitialize, void* addrContext, u64 sizeContext,

View file

@ -18,21 +18,16 @@ struct PngHandler {
static inline OrbisPngDecColorSpace MapPngColor(int color) {
switch (color) {
case PNG_COLOR_TYPE_GRAY:
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE;
return OrbisPngDecColorSpace::Grayscale;
case PNG_COLOR_TYPE_GRAY_ALPHA:
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE_ALPHA;
return OrbisPngDecColorSpace::GrayscaleAlpha;
case PNG_COLOR_TYPE_PALETTE:
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_CLUT;
return OrbisPngDecColorSpace::Clut;
case PNG_COLOR_TYPE_RGB:
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_RGB;
return OrbisPngDecColorSpace::Rgb;
case PNG_COLOR_TYPE_RGB_ALPHA:
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_RGBA;
return OrbisPngDecColorSpace::Rgba;
}
UNREACHABLE_MSG("unknown png color type");
}
@ -118,56 +113,60 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
pngdata->offset += len;
});
u32 width, height;
int color_type, bit_depth;
png_read_info(pngh->png_ptr, pngh->info_ptr);
width = png_get_image_width(pngh->png_ptr, pngh->info_ptr);
height = png_get_image_height(pngh->png_ptr, pngh->info_ptr);
color_type = MapPngColor(png_get_color_type(pngh->png_ptr, pngh->info_ptr));
bit_depth = png_get_bit_depth(pngh->png_ptr, pngh->info_ptr);
const u32 width = png_get_image_width(pngh->png_ptr, pngh->info_ptr);
const u32 height = png_get_image_height(pngh->png_ptr, pngh->info_ptr);
const auto color_type = MapPngColor(png_get_color_type(pngh->png_ptr, pngh->info_ptr));
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 = 0;
imageInfo->imageFlag = OrbisPngDecImageFlag::None;
if (png_get_interlace_type(pngh->png_ptr, pngh->info_ptr) == 1) {
imageInfo->imageFlag |= OrbisPngDecImageFlag::ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE;
imageInfo->imageFlag |= OrbisPngDecImageFlag::Adam7Interlace;
}
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
imageInfo->imageFlag |= ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
imageInfo->imageFlag |= OrbisPngDecImageFlag::TrnsChunkExist;
}
}
if (bit_depth == 16)
if (bit_depth == 16) {
png_set_strip_16(pngh->png_ptr);
if (color_type == PNG_COLOR_TYPE_PALETTE)
}
if (color_type == OrbisPngDecColorSpace::Clut) {
png_set_palette_to_rgb(pngh->png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
}
if (color_type == OrbisPngDecColorSpace::Grayscale && bit_depth < 8) {
png_set_expand_gray_1_2_4_to_8(pngh->png_ptr);
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS))
}
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
png_set_tRNS_to_alpha(pngh->png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
}
if (color_type == OrbisPngDecColorSpace::Grayscale ||
color_type == OrbisPngDecColorSpace::GrayscaleAlpha) {
png_set_gray_to_rgb(pngh->png_ptr);
if (param->pixelFormat == OrbisPngDecPixelFormat::ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8)
}
if (param->pixelFormat == OrbisPngDecPixelFormat::B8G8R8A8) {
png_set_bgr(pngh->png_ptr);
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_PALETTE)
}
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);
}
int pass = png_set_interlace_handling(pngh->png_ptr);
const s32 pass = png_set_interlace_handling(pngh->png_ptr);
png_read_update_info(pngh->png_ptr, pngh->info_ptr);
auto const numChannels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
auto horizontal_bytes = numChannels * width;
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;
int stride = param->imagePitch > 0 ? param->imagePitch : horizontal_bytes;
for (int j = 0; j < pass; j++) { // interlaced
auto ptr = (png_bytep)param->imageMemAddr;
for (int j = 0; j < pass; j++) {
auto ptr = reinterpret_cast<png_bytep>(param->imageMemAddr);
for (int y = 0; y < height; y++) {
png_read_row(pngh->png_ptr, ptr, nullptr);
ptr += stride;
@ -233,13 +232,12 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
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 = 0;
imageInfo->imageFlag = OrbisPngDecImageFlag::None;
if (png_get_interlace_type(png_ptr, info_ptr) == 1) {
imageInfo->imageFlag |= OrbisPngDecImageFlag::ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE;
imageInfo->imageFlag |= OrbisPngDecImageFlag::Adam7Interlace;
}
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
imageInfo->imageFlag |= ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
imageInfo->imageFlag |= OrbisPngDecImageFlag::TrnsChunkExist;
}
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);

View file

@ -3,6 +3,7 @@
#pragma once
#include "common/enum.h"
#include "common/types.h"
namespace Core::Loader {
@ -11,28 +12,14 @@ class SymbolsResolver;
namespace Libraries::PngDec {
enum OrbisPngDecColorSpace {
ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE = 2,
ORBIS_PNG_DEC_COLOR_SPACE_RGB,
ORBIS_PNG_DEC_COLOR_SPACE_CLUT,
ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE_ALPHA = 18,
ORBIS_PNG_DEC_COLOR_SPACE_RGBA
};
enum class OrbisPngDecColorSpace : u16 { Grayscale = 2, Rgb, Clut, GrayscaleAlpha = 18, Rgba };
enum OrbisPngDecImageFlag {
ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE = 1,
ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST = 2
};
enum class OrbisPngDecImageFlag : u32 { None = 0, Adam7Interlace = 1, TrnsChunkExist = 2 };
DECLARE_ENUM_FLAG_OPERATORS(OrbisPngDecImageFlag)
enum OrbisPngDecPixelFormat {
ORBIS_PNG_DEC_PIXEL_FORMAT_R8G8B8A8 = 0,
ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8
};
enum class OrbisPngDecPixelFormat : u16 { R8G8B8A8 = 0, B8G8R8A8 };
enum OrbisPngDecAttribute {
ORBIS_PNG_DEC_ATTRIBUTE_NONE = 0,
ORBIS_PNG_DEC_ATTRIBUTE_BIT_DEPTH_16
};
enum class OrbisPngDecAttribute { None = 0, BitDepth16 };
struct OrbisPngDecParseParam {
const void* pngMemAddr;
@ -43,9 +30,9 @@ struct OrbisPngDecParseParam {
struct OrbisPngDecImageInfo {
u32 imageWidth;
u32 imageHeight;
u16 colorSpace;
OrbisPngDecColorSpace colorSpace;
u16 bitDepth;
u32 imageFlag;
OrbisPngDecImageFlag imageFlag;
};
struct OrbisPngDecCreateParam {
@ -54,14 +41,14 @@ struct OrbisPngDecCreateParam {
u32 maxImageWidth;
};
typedef void* OrbisPngDecHandle;
using OrbisPngDecHandle = void*;
struct OrbisPngDecDecodeParam {
const void* pngMemAddr;
void* imageMemAddr;
u32 pngMemSize;
u32 imageMemSize;
u16 pixelFormat;
OrbisPngDecPixelFormat pixelFormat;
u16 alphaValue;
u32 imagePitch;
};
@ -77,4 +64,4 @@ s32 PS4_SYSV_ABI scePngDecParseHeader(const OrbisPngDecParseParam* param,
s32 PS4_SYSV_ABI scePngDecQueryMemorySize(const OrbisPngDecCreateParam* param);
void RegisterlibScePngDec(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::PngDec
} // namespace Libraries::PngDec

View file

@ -23,7 +23,7 @@ constexpr int ORBIS_NET_CTL_HOSTNAME_LEN = 255 + 1;
constexpr int ORBIS_NET_CTL_AUTH_NAME_LEN = 127 + 1;
constexpr int ORBIS_NET_CTL_IPV4_ADDR_STR_LEN = 16;
typedef union OrbisNetCtlInfo {
union OrbisNetCtlInfo {
u32 device;
OrbisNetEtherAddr ether_addr;
u32 mtu;
@ -45,7 +45,7 @@ typedef union OrbisNetCtlInfo {
u32 http_proxy_config;
char http_proxy_server[ORBIS_NET_CTL_HOSTNAME_LEN];
u16 http_proxy_port;
} SceNetCtlInfo;
};
// GetInfo codes
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;

View file

@ -971,12 +971,11 @@ int PS4_SYSV_ABI sceNpGetGamePresenceStatusA() {
return ORBIS_OK;
}
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId userId, OrbisNpId* npId) {
LOG_INFO(Lib_NpManager, "userId {}", userId);
std::string name = Config::getUserName();
// Fill the unused stuffs to 0
memset(npId, 0, sizeof(*npId));
strcpy(npId->handle.data, name.c_str());
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId user_id, OrbisNpId* np_id) {
LOG_INFO(Lib_NpManager, "user_id {}", user_id);
const auto name = Config::getUserName();
std::memset(np_id, 0, sizeof(OrbisNpId));
name.copy(np_id->handle.data, sizeof(np_id->handle.data));
return ORBIS_OK;
}
@ -985,12 +984,11 @@ int PS4_SYSV_ABI sceNpGetNpReachabilityState() {
return ORBIS_OK;
}
int PS4_SYSV_ABI sceNpGetOnlineId(s32 userId, OrbisNpOnlineId* onlineId) {
LOG_DEBUG(Lib_NpManager, "userId {}", userId);
std::string name = Config::getUserName();
// Fill the unused stuffs to 0
memset(onlineId, 0, sizeof(*onlineId));
strcpy(onlineId->data, name.c_str());
int PS4_SYSV_ABI sceNpGetOnlineId(s32 user_id, OrbisNpOnlineId* online_id) {
LOG_DEBUG(Lib_NpManager, "user_id {}", user_id);
const auto name = Config::getUserName();
std::memset(online_id, 0, sizeof(OrbisNpOnlineId));
name.copy(online_id->data, sizeof(online_id->data));
return ORBIS_OK;
}
@ -1005,7 +1003,7 @@ int PS4_SYSV_ABI sceNpGetParentalControlInfoA() {
}
int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state) {
*state = ORBIS_NP_STATE_SIGNED_OUT;
*state = OrbisNpState::SignedOut;
LOG_DEBUG(Lib_NpManager, "Signed out");
return ORBIS_OK;
}
@ -2518,7 +2516,7 @@ struct NpStateCallbackForNpToolkit {
NpStateCallbackForNpToolkit NpStateCbForNp;
int PS4_SYSV_ABI sceNpCheckCallbackForLib() {
Core::ExecuteGuest(NpStateCbForNp.func, 1, ORBIS_NP_STATE_SIGNED_OUT, NpStateCbForNp.userdata);
Core::ExecuteGuest(NpStateCbForNp.func, 1, OrbisNpState::SignedOut, NpStateCbForNp.userdata);
return ORBIS_OK;
}

View file

@ -13,18 +13,14 @@ namespace Libraries::NpManager {
constexpr int ORBIS_NP_ERROR_SIGNED_OUT = 0x80550006;
enum OrbisNpState {
ORBIS_NP_STATE_UNKNOWN = 0,
ORBIS_NP_STATE_SIGNED_OUT,
ORBIS_NP_STATE_SIGNED_IN
};
enum class OrbisNpState : u32 { Unknown = 0, SignedOut, SignedIn };
using OrbisNpStateCallbackForNpToolkit = PS4_SYSV_ABI void (*)(s32 userId, OrbisNpState state,
void* userdata);
constexpr int ORBIS_NP_ONLINEID_MAX_LENGTH = 16;
typedef int OrbisUserServiceUserId;
using OrbisUserServiceUserId = s32;
struct OrbisNpOnlineId {
char data[ORBIS_NP_ONLINEID_MAX_LENGTH];
@ -542,4 +538,4 @@ int PS4_SYSV_ABI sceNpRegisterStateCallbackForToolkit(OrbisNpStateCallbackForNpT
int PS4_SYSV_ABI sceNpUnregisterStateCallbackForToolkit();
void RegisterlibSceNpManager(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::NpManager
} // namespace Libraries::NpManager

View file

@ -29,14 +29,14 @@ constexpr int ORBIS_NP_TROPHY_INVALID_HANDLE = -1;
constexpr int ORBIS_NP_TROPHY_INVALID_CONTEXT = -1;
constexpr int ORBIS_NP_TROPHY_INVALID_TROPHY_ID = -1;
typedef int32_t OrbisNpTrophyHandle;
typedef int32_t OrbisNpTrophyContext;
typedef int32_t OrbisNpTrophyId;
typedef uint32_t OrbisNpTrophyFlagMask;
using OrbisNpTrophyHandle = s32;
using OrbisNpTrophyContext = s32;
using OrbisNpTrophyId = s32;
using OrbisNpTrophyFlagMask = u32;
struct OrbisNpTrophyFlagArray {
OrbisNpTrophyFlagMask
flag_bits[ORBIS_NP_TROPHY_FLAG_SETSIZE >> ORBIS_NP_TROPHY_FLAG_BITS_SHIFT];
static constexpr int NumMasks = ORBIS_NP_TROPHY_FLAG_SETSIZE >> ORBIS_NP_TROPHY_FLAG_BITS_SHIFT;
std::array<OrbisNpTrophyFlagMask, NumMasks> flag_bits;
};
void ORBIS_NP_TROPHY_FLAG_ZERO(OrbisNpTrophyFlagArray* p);
@ -49,18 +49,18 @@ struct OrbisNpTrophyData {
size_t size;
OrbisNpTrophyId trophy_id;
bool unlocked;
uint8_t reserved[3];
u8 reserved[3];
Rtc::OrbisRtcTick timestamp;
};
typedef int32_t OrbisNpTrophyGrade;
using OrbisNpTrophyGrade = s32;
constexpr int ORBIS_NP_TROPHY_GRADE_UNKNOWN = 0;
constexpr int ORBIS_NP_TROPHY_GRADE_PLATINUM = 1;
constexpr int ORBIS_NP_TROPHY_GRADE_GOLD = 2;
constexpr int ORBIS_NP_TROPHY_GRADE_SILVER = 3;
constexpr int ORBIS_NP_TROPHY_GRADE_BRONZE = 4;
typedef int32_t OrbisNpTrophyGroupId;
using OrbisNpTrophyGroupId = s32;
constexpr int ORBIS_NP_TROPHY_BASE_GAME_GROUP_ID = -1;
constexpr int ORBIS_NP_TROPHY_INVALID_GROUP_ID = -2;
@ -70,29 +70,29 @@ struct OrbisNpTrophyDetails {
OrbisNpTrophyGrade trophy_grade;
OrbisNpTrophyGroupId group_id;
bool hidden;
uint8_t reserved[3];
u8 reserved[3];
char name[ORBIS_NP_TROPHY_NAME_MAX_SIZE];
char description[ORBIS_NP_TROPHY_DESCR_MAX_SIZE];
};
struct OrbisNpTrophyGameData {
size_t size;
uint32_t unlocked_trophies;
uint32_t unlocked_platinum;
uint32_t unlocked_gold;
uint32_t unlocked_silver;
uint32_t unlocked_bronze;
uint32_t progress_percentage;
u32 unlocked_trophies;
u32 unlocked_platinum;
u32 unlocked_gold;
u32 unlocked_silver;
u32 unlocked_bronze;
u32 progress_percentage;
};
struct OrbisNpTrophyGameDetails {
size_t size;
uint32_t num_groups;
uint32_t num_trophies;
uint32_t num_platinum;
uint32_t num_gold;
uint32_t num_silver;
uint32_t num_bronze;
u32 num_groups;
u32 num_trophies;
u32 num_platinum;
u32 num_gold;
u32 num_silver;
u32 num_bronze;
char title[ORBIS_NP_TROPHY_GAME_TITLE_MAX_SIZE];
char description[ORBIS_NP_TROPHY_GAME_DESCR_MAX_SIZE];
};
@ -100,23 +100,23 @@ struct OrbisNpTrophyGameDetails {
struct OrbisNpTrophyGroupData {
size_t size;
OrbisNpTrophyGroupId group_id;
uint32_t unlocked_trophies;
uint32_t unlocked_platinum;
uint32_t unlocked_gold;
uint32_t unlocked_silver;
uint32_t unlocked_bronze;
uint32_t progress_percentage;
u32 unlocked_trophies;
u32 unlocked_platinum;
u32 unlocked_gold;
u32 unlocked_silver;
u32 unlocked_bronze;
u32 progress_percentage;
uint8_t reserved[4];
};
struct OrbisNpTrophyGroupDetails {
size_t size;
OrbisNpTrophyGroupId group_id;
uint32_t num_trophies;
uint32_t num_platinum;
uint32_t num_gold;
uint32_t num_silver;
uint32_t num_bronze;
u32 num_trophies;
u32 num_platinum;
u32 num_gold;
u32 num_silver;
u32 num_bronze;
char title[ORBIS_NP_TROPHY_GROUP_TITLE_MAX_SIZE];
char description[ORBIS_NP_TROPHY_GROUP_DESCR_MAX_SIZE];
};
@ -133,7 +133,7 @@ int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetVersion();
int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyTitleDetails();
int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature();
s32 PS4_SYSV_ABI sceNpTrophyCreateContext(OrbisNpTrophyContext* context, int32_t user_id,
uint32_t service_label, uint64_t options);
u32 service_label, uint64_t options);
s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(OrbisNpTrophyHandle* handle);
int PS4_SYSV_ABI sceNpTrophyDestroyContext(OrbisNpTrophyContext context);
s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(OrbisNpTrophyHandle handle);

View file

@ -98,7 +98,7 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
pInfo->connectedCount = 1;
pInfo->connected = false;
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
return ORBIS_OK;
}
pInfo->touchPadInfo.pixelDensity = 1;
@ -109,7 +109,7 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
pInfo->connectedCount = 1;
pInfo->connected = true;
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
if (Config::getUseSpecialPad()) {
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
pInfo->deviceClass = (OrbisPadDeviceClass)Config::getSpecialPadClass();

View file

@ -3,6 +3,7 @@
#pragma once
#include "common/enum.h"
#include "common/types.h"
namespace Core::Loader {
@ -18,18 +19,18 @@ constexpr int ORBIS_PAD_PORT_TYPE_STANDARD = 0;
constexpr int ORBIS_PAD_PORT_TYPE_SPECIAL = 2;
constexpr int ORBIS_PAD_PORT_TYPE_REMOTE_CONTROL = 16;
enum OrbisPadDeviceClass {
ORBIS_PAD_DEVICE_CLASS_INVALID = -1,
ORBIS_PAD_DEVICE_CLASS_STANDARD = 0,
ORBIS_PAD_DEVICE_CLASS_GUITAR = 1,
ORBIS_PAD_DEVICE_CLASS_DRUM = 2,
ORBIS_PAD_DEVICE_CLASS_DJ_TURNTABLE = 3,
ORBIS_PAD_DEVICE_CLASS_DANCEMAT = 4,
ORBIS_PAD_DEVICE_CLASS_NAVIGATION = 5,
ORBIS_PAD_DEVICE_CLASS_STEERING_WHEEL = 6,
ORBIS_PAD_DEVICE_CLASS_STICK = 7,
ORBIS_PAD_DEVICE_CLASS_FLIGHT_STICK = 8,
ORBIS_PAD_DEVICE_CLASS_GUN = 9,
enum class OrbisPadDeviceClass {
Invalid = -1,
Standard = 0,
Guitar = 1,
Drum = 2,
DjTurntable = 3,
Dancemat = 4,
Navigation = 5,
SteeringWheel = 6,
Stick = 7,
FightStick = 8,
Gun = 9,
};
struct OrbisPadDeviceClassExtendedInformation {
@ -123,25 +124,27 @@ struct OrbisPadAnalogStick {
u8 y;
};
enum OrbisPadButtonDataOffset {
ORBIS_PAD_BUTTON_L3 = 0x00000002,
ORBIS_PAD_BUTTON_R3 = 0x00000004,
ORBIS_PAD_BUTTON_OPTIONS = 0x00000008,
ORBIS_PAD_BUTTON_UP = 0x00000010,
ORBIS_PAD_BUTTON_RIGHT = 0x00000020,
ORBIS_PAD_BUTTON_DOWN = 0x00000040,
ORBIS_PAD_BUTTON_LEFT = 0x00000080,
ORBIS_PAD_BUTTON_L2 = 0x00000100,
ORBIS_PAD_BUTTON_R2 = 0x00000200,
ORBIS_PAD_BUTTON_L1 = 0x00000400,
ORBIS_PAD_BUTTON_R1 = 0x00000800,
ORBIS_PAD_BUTTON_TRIANGLE = 0x00001000,
ORBIS_PAD_BUTTON_CIRCLE = 0x00002000,
ORBIS_PAD_BUTTON_CROSS = 0x00004000,
ORBIS_PAD_BUTTON_SQUARE = 0x00008000,
ORBIS_PAD_BUTTON_TOUCH_PAD = 0x00100000,
ORBIS_PAD_BUTTON_INTERCEPTED = 0x80000000,
enum class OrbisPadButtonDataOffset : u32 {
None = 0,
L3 = 0x2,
R3 = 0x4,
Options = 0x8,
Up = 0x10,
Right = 0x20,
Down = 0x40,
Left = 0x80,
L2 = 0x100,
R2 = 0x200,
L1 = 0x400,
R1 = 0x800,
Triangle = 0x1000,
Circle = 0x2000,
Cross = 0x4000,
Square = 0x8000,
TouchPad = 0x100000,
Intercepted = 0x80000000,
};
DECLARE_ENUM_FLAG_OPERATORS(OrbisPadButtonDataOffset)
struct OrbisFQuaternion {
float x, y, z, w;
@ -173,7 +176,7 @@ struct OrbisPadExtensionUnitData {
};
struct OrbisPadData {
u32 buttons;
OrbisPadButtonDataOffset buttons;
OrbisPadAnalogStick leftStick;
OrbisPadAnalogStick rightStick;
OrbisPadAnalogButtons analogButtons;
@ -346,4 +349,4 @@ int PS4_SYSV_ABI Func_89C9237E393DA243();
int PS4_SYSV_ABI Func_EF103E845B6F0420();
void RegisterlibScePad(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Pad
} // namespace Libraries::Pad

View file

@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h"
#include "common/singleton.h"
#include "core/file_format/playgo_chunk.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
@ -11,6 +10,9 @@
namespace Libraries::PlayGo {
static constexpr OrbisPlayGoHandle PlaygoHandle = 1;
static std::unique_ptr<PlaygoFile> playgo;
s32 PS4_SYSV_ABI sceDbgPlayGoRequestNextChunk() {
LOG_ERROR(Lib_PlayGo, "(STUBBED)called");
return ORBIS_OK;
@ -24,57 +26,63 @@ s32 PS4_SYSV_ABI sceDbgPlayGoSnapshot() {
s32 PS4_SYSV_ABI scePlayGoClose(OrbisPlayGoHandle handle) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
playgo.reset();
return ORBIS_OK;
}
s32 PS4_SYSV_ABI scePlayGoGetChunkId(OrbisPlayGoHandle handle, OrbisPlayGoChunkId* outChunkIdList,
u32 numberOfEntries, u32* outEntries) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (outEntries == nullptr)
}
if (outEntries == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (outChunkIdList != nullptr && numberOfEntries == 0)
}
if (outChunkIdList != nullptr && numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
}
if (playgo->GetPlaygoHeader().file_size == 0) {
*outEntries = 0;
} else {
if (outChunkIdList == nullptr) {
*outEntries = playgo->chunks.size();
} else {
if (numberOfEntries > playgo->chunks.size()) {
numberOfEntries = playgo->chunks.size();
}
if (numberOfEntries != 0) {
for (u32 i = 0; i < numberOfEntries; i++) {
outChunkIdList[i] = i;
}
*outEntries = numberOfEntries;
}
}
return ORBIS_OK;
}
if (outChunkIdList == nullptr) {
*outEntries = playgo->chunks.size();
return ORBIS_OK;
}
if (numberOfEntries > playgo->chunks.size()) {
numberOfEntries = playgo->chunks.size();
}
for (u32 i = 0; i < numberOfEntries; i++) {
outChunkIdList[i] = i;
}
*outEntries = numberOfEntries;
return ORBIS_OK;
}
s32 PS4_SYSV_ABI scePlayGoGetEta(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds,
u32 numberOfEntries, OrbisPlayGoEta* outEta) {
LOG_INFO(Lib_PlayGo, "called");
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (chunkIds == nullptr || outEta == nullptr)
}
if (chunkIds == nullptr || outEta == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (numberOfEntries == 0)
}
if (numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
}
*outEta = 0; // all is loaded
return ORBIS_OK;
@ -84,22 +92,23 @@ s32 PS4_SYSV_ABI scePlayGoGetInstallSpeed(OrbisPlayGoHandle handle,
OrbisPlayGoInstallSpeed* outSpeed) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (outSpeed == nullptr)
}
if (outSpeed == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
std::scoped_lock lk{playgo->GetSpeedMutex()};
if (playgo->speed == 0) {
if (playgo->speed == OrbisPlayGoInstallSpeed::Suspended) {
using namespace std::chrono;
if ((duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count() -
playgo->speed_tick) > 30 * 1000) { // 30sec
playgo->speed = ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE;
playgo->speed = OrbisPlayGoInstallSpeed::Trickle;
}
}
*outSpeed = playgo->speed;
@ -111,14 +120,15 @@ s32 PS4_SYSV_ABI scePlayGoGetLanguageMask(OrbisPlayGoHandle handle,
OrbisPlayGoLanguageMask* outLanguageMask) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (outLanguageMask == nullptr)
}
if (outLanguageMask == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
*outLanguageMask = playgo->langMask;
return ORBIS_OK;
@ -129,24 +139,27 @@ s32 PS4_SYSV_ABI scePlayGoGetLocus(OrbisPlayGoHandle handle, const OrbisPlayGoCh
LOG_INFO(Lib_PlayGo, "called handle = {}, chunkIds = {}, numberOfEntries = {}", handle,
*chunkIds, numberOfEntries);
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (chunkIds == nullptr || outLoci == nullptr)
}
if (chunkIds == nullptr || outLoci == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (numberOfEntries == 0)
}
if (numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
if (playgo->GetPlaygoHeader().file_size == 0)
}
if (playgo->GetPlaygoHeader().file_size == 0) {
return ORBIS_PLAYGO_ERROR_NOT_SUPPORT_PLAYGO;
}
for (uint32_t i = 0; i < numberOfEntries; i++) {
for (int i = 0; i < numberOfEntries; i++) {
if (chunkIds[i] <= playgo->chunks.size()) {
outLoci[i] = OrbisPlayGoLocusValue::ORBIS_PLAYGO_LOCUS_LOCAL_FAST;
outLoci[i] = OrbisPlayGoLocus::LocalFast;
} else {
outLoci[i] = ORBIS_PLAYGO_LOCUS_NOT_DOWNLOADED;
outLoci[i] = OrbisPlayGoLocus::NotDownloaded;
return ORBIS_PLAYGO_ERROR_BAD_CHUNK_ID;
}
}
@ -158,18 +171,21 @@ s32 PS4_SYSV_ABI scePlayGoGetProgress(OrbisPlayGoHandle handle, const OrbisPlayG
LOG_INFO(Lib_PlayGo, "called handle = {}, chunkIds = {}, numberOfEntries = {}", handle,
*chunkIds, numberOfEntries);
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (chunkIds == nullptr || outProgress == nullptr)
}
if (chunkIds == nullptr || outProgress == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (numberOfEntries == 0)
}
if (numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
if (playgo->GetPlaygoHeader().file_size == 0)
}
if (playgo->GetPlaygoHeader().file_size == 0) {
return ORBIS_PLAYGO_ERROR_BAD_CHUNK_ID;
}
outProgress->progressSize = 0;
outProgress->totalSize = 0;
@ -194,16 +210,18 @@ s32 PS4_SYSV_ABI scePlayGoGetToDoList(OrbisPlayGoHandle handle, OrbisPlayGoToDo*
u32 numberOfEntries, u32* outEntries) {
LOG_INFO(Lib_PlayGo, "called handle = {} numberOfEntries = {}", handle, numberOfEntries);
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (outTodoList == nullptr || outEntries == nullptr)
}
if (outTodoList == nullptr || outEntries == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (numberOfEntries == 0)
}
if (numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
*outEntries = 0; // nothing to do
return ORBIS_OK;
}
@ -218,19 +236,19 @@ int scePlayGoConvertLanguage(int systemLang) {
s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) {
LOG_INFO(Lib_PlayGo, "called, bufSize = {}", param->bufSize);
if (param->bufAddr == nullptr)
if (param->bufAddr == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (param->bufSize < 0x200000)
}
if (param->bufSize < 0x200000) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
}
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
playgo = std::make_unique<PlaygoFile>();
if (!playgo->initialized) {
using namespace SystemService;
// get system lang
int systemLang = 0;
sceSystemServiceParamGetInt(ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG, &systemLang);
playgo->langMask = scePlayGoConvertLanguage(systemLang);
s32 system_lang = 0;
sceSystemServiceParamGetInt(OrbisSystemServiceParamId::Lang, &system_lang);
playgo->langMask = scePlayGoConvertLanguage(system_lang);
playgo->initialized = true;
} else {
return ORBIS_PLAYGO_ERROR_ALREADY_INITIALIZED;
@ -241,18 +259,20 @@ s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) {
s32 PS4_SYSV_ABI scePlayGoOpen(OrbisPlayGoHandle* outHandle, const void* param) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (outHandle == nullptr)
if (outHandle == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (param)
}
if (param) {
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
if (playgo->GetPlaygoHeader().file_size == 0)
}
if (playgo->GetPlaygoHeader().file_size == 0) {
return ORBIS_PLAYGO_ERROR_NOT_SUPPORT_PLAYGO;
}
playgo->handle = *outHandle = 1;
playgo->handle = *outHandle = PlaygoHandle;
return ORBIS_OK;
}
@ -260,21 +280,23 @@ s32 PS4_SYSV_ABI scePlayGoPrefetch(OrbisPlayGoHandle handle, const OrbisPlayGoCh
u32 numberOfEntries, OrbisPlayGoLocus minimumLocus) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (chunkIds == nullptr)
}
if (chunkIds == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (numberOfEntries == 0)
}
if (numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
switch (minimumLocus) {
case ORBIS_PLAYGO_LOCUS_NOT_DOWNLOADED:
case ORBIS_PLAYGO_LOCUS_LOCAL_SLOW:
case ORBIS_PLAYGO_LOCUS_LOCAL_FAST:
case OrbisPlayGoLocus::NotDownloaded:
case OrbisPlayGoLocus::LocalSlow:
case OrbisPlayGoLocus::LocalFast:
break;
default:
return ORBIS_PLAYGO_ERROR_BAD_LOCUS;
@ -285,24 +307,23 @@ s32 PS4_SYSV_ABI scePlayGoPrefetch(OrbisPlayGoHandle handle, const OrbisPlayGoCh
s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(OrbisPlayGoHandle handle, OrbisPlayGoInstallSpeed speed) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
switch (speed) {
case ORBIS_PLAYGO_INSTALL_SPEED_SUSPENDED:
case ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE:
case ORBIS_PLAYGO_INSTALL_SPEED_FULL:
case OrbisPlayGoInstallSpeed::Suspended:
case OrbisPlayGoInstallSpeed::Trickle:
case OrbisPlayGoInstallSpeed::Full:
break;
default:
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
}
std::scoped_lock lk{playgo->GetSpeedMutex()};
using namespace std::chrono;
playgo->speed = speed;
playgo->speed_tick =
@ -314,12 +335,13 @@ s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(OrbisPlayGoHandle handle, OrbisPlayGoI
s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle,
OrbisPlayGoLanguageMask languageMask) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != 1) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
playgo->langMask = languageMask;
return ORBIS_OK;
@ -329,23 +351,24 @@ s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayG
uint32_t numberOfEntries) {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (handle != 1)
if (handle != PlaygoHandle) {
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
if (todoList == nullptr)
}
if (todoList == nullptr) {
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
if (numberOfEntries == 0)
}
if (numberOfEntries == 0) {
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
if (!playgo->initialized)
}
if (!playgo->initialized) {
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
}
return ORBIS_OK;
}
s32 PS4_SYSV_ABI scePlayGoTerminate() {
LOG_INFO(Lib_PlayGo, "called");
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
if (playgo->initialized) {
playgo->initialized = false;
} else {

View file

@ -5,41 +5,39 @@
#include "common/types.h"
typedef u32 OrbisPlayGoHandle;
typedef u16 OrbisPlayGoChunkId;
typedef s8 OrbisPlayGoLocus;
typedef s32 OrbisPlayGoInstallSpeed;
typedef s64 OrbisPlayGoEta;
typedef u64 OrbisPlayGoLanguageMask;
using OrbisPlayGoHandle = u32;
using OrbisPlayGoChunkId = u16;
using OrbisPlayGoEta = s64;
using OrbisPlayGoLanguageMask = u64;
typedef struct OrbisPlayGoInitParams {
enum class OrbisPlayGoLocus : s8 {
NotDownloaded = 0,
LocalSlow = 2,
LocalFast = 3,
};
enum class OrbisPlayGoInstallSpeed : s32 {
Suspended = 0,
Trickle = 1,
Full = 2,
};
struct OrbisPlayGoInitParams {
const void* bufAddr;
u32 bufSize;
u32 reserved;
} OrbisPlayGoInitParams;
};
typedef struct OrbisPlayGoToDo {
struct OrbisPlayGoToDo {
OrbisPlayGoChunkId chunkId;
OrbisPlayGoLocus locus;
s8 reserved;
} OrbisPlayGoToDo;
};
typedef struct OrbisPlayGoProgress {
uint64_t progressSize;
uint64_t totalSize;
} OrbisPlayGoProgress;
typedef enum OrbisPlayGoLocusValue {
ORBIS_PLAYGO_LOCUS_NOT_DOWNLOADED = 0,
ORBIS_PLAYGO_LOCUS_LOCAL_SLOW = 2,
ORBIS_PLAYGO_LOCUS_LOCAL_FAST = 3
} OrbisPlayGoLocusValue;
typedef enum OrbisPlayGoInstallSpeedValue {
ORBIS_PLAYGO_INSTALL_SPEED_SUSPENDED = 0,
ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE = 1,
ORBIS_PLAYGO_INSTALL_SPEED_FULL = 2
} OrbisPlayGoInstallSpeedValue;
struct OrbisPlayGoProgress {
u64 progressSize;
u64 totalSize;
};
constexpr int ORBIS_PLAYGO_ERROR_UNKNOWN = -2135818239; /* 0x80B20001 */
constexpr int ORBIS_PLAYGO_ERROR_FATAL = -2135818238; /* 0x80B20002 */

View file

@ -1889,39 +1889,38 @@ int PS4_SYSV_ABI sceSystemServiceNavigateToGoHome() {
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceSystemServiceParamGetInt(int param_id, int* value) {
s32 PS4_SYSV_ABI sceSystemServiceParamGetInt(OrbisSystemServiceParamId param_id, int* value) {
// TODO this probably should be stored in config for UI configuration
LOG_INFO(Lib_SystemService, "called param_id {}", param_id);
LOG_INFO(Lib_SystemService, "called param_id {}", u32(param_id));
if (value == nullptr) {
LOG_ERROR(Lib_SystemService, "value is null");
return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER;
}
switch (param_id) {
case ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG:
case OrbisSystemServiceParamId::Lang:
*value = Config::GetLanguage();
break;
case ORBIS_SYSTEM_SERVICE_PARAM_ID_DATE_FORMAT:
*value = ORBIS_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY;
case OrbisSystemServiceParamId::DateFormat:
*value = u32(OrbisSystemParamDateFormat::FmtDDMMYYYY);
break;
case ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_FORMAT:
*value = ORBIS_SYSTEM_PARAM_TIME_FORMAT_24HOUR;
case OrbisSystemServiceParamId::TimeFormat:
*value = u32(OrbisSystemParamTimeFormat::Fmt24Hour);
break;
case ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_ZONE:
case OrbisSystemServiceParamId::TimeZone:
*value = +120;
break;
case ORBIS_SYSTEM_SERVICE_PARAM_ID_SUMMERTIME:
case OrbisSystemServiceParamId::Summertime:
*value = 1;
break;
case ORBIS_SYSTEM_SERVICE_PARAM_ID_GAME_PARENTAL_LEVEL:
*value = ORBIS_SYSTEM_PARAM_GAME_PARENTAL_OFF;
case OrbisSystemServiceParamId::GameParentalLevel:
*value = u32(OrbisSystemParamGameParentalLevel::Off);
break;
case ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN:
*value = ORBIS_SYSTEM_PARAM_ENTER_BUTTON_ASSIGN_CROSS;
case OrbisSystemServiceParamId::EnterButtonAssign:
*value = u32(OrbisSystemParamEnterButtonAssign::Cross);
break;
default:
LOG_ERROR(Lib_SystemService, "param_id {} unsupported!",
param_id); // shouldn't go there but log it
*value = 0; // return a dummy value
LOG_ERROR(Lib_SystemService, "param_id {} unsupported!", u32(param_id));
*value = 0;
}
return ORBIS_OK;

View file

@ -12,105 +12,62 @@ class SymbolsResolver;
namespace Libraries::SystemService {
enum OrbisSystemServiceParamId {
ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG = 1,
ORBIS_SYSTEM_SERVICE_PARAM_ID_DATE_FORMAT = 2,
ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_FORMAT = 3,
ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_ZONE = 4,
ORBIS_SYSTEM_SERVICE_PARAM_ID_SUMMERTIME = 5,
ORBIS_SYSTEM_SERVICE_PARAM_ID_SYSTEM_NAME = 6,
ORBIS_SYSTEM_SERVICE_PARAM_ID_GAME_PARENTAL_LEVEL = 7,
ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN = 1000
enum class OrbisSystemServiceParamId {
Lang = 1,
DateFormat = 2,
TimeFormat = 3,
TimeZone = 4,
Summertime = 5,
SystemName = 6,
GameParentalLevel = 7,
EnterButtonAssign = 1000
};
enum OrbisSystemParamDateFormat {
ORBIS_SYSTEM_PARAM_DATE_FORMAT_YYYYMMDD = 0,
ORBIS_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY = 1,
ORBIS_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY = 2
enum class OrbisSystemParamDateFormat { FmtYYYYMMDD = 0, FmtDDMMYYYY = 1, FmtMMDDYYYY = 2 };
enum class OrbisSystemParamTimeFormat { Fmt12Hour = 0, Fmt24Hour = 1 };
enum class OrbisSystemParamGameParentalLevel {
Off = 0,
Level01 = 1,
Level02 = 2,
Level03 = 3,
Level04 = 4,
Level05 = 5,
Level06 = 6,
Level07 = 7,
Level08 = 8,
Level09 = 9,
Level10 = 10,
Level11 = 11
};
enum OrbisSystemParamTimeFormat {
ORBIS_SYSTEM_PARAM_TIME_FORMAT_12HOUR = 0,
ORBIS_SYSTEM_PARAM_TIME_FORMAT_24HOUR = 1
};
enum class OrbisSystemParamEnterButtonAssign { Circle = 0, Cross = 1 };
enum OrbisSystemParamGameParentalLevel {
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_OFF = 0,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL01 = 1,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL02 = 2,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL03 = 3,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL04 = 4,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL05 = 5,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL06 = 6,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL07 = 7,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL08 = 8,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL09 = 9,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL10 = 10,
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL11 = 11
};
enum OrbisSystemParamEnterButtonAssign {
ORBIS_SYSTEM_PARAM_ENTER_BUTTON_ASSIGN_CIRCLE = 0,
ORBIS_SYSTEM_PARAM_ENTER_BUTTON_ASSIGN_CROSS = 1
};
enum OrbisSystemParamLanguage {
ORBIS_SYSTEM_PARAM_LANG_JAPANESE = 0,
ORBIS_SYSTEM_PARAM_LANG_ENGLISH_US = 1,
ORBIS_SYSTEM_PARAM_LANG_FRENCH = 2,
ORBIS_SYSTEM_PARAM_LANG_SPANISH = 3,
ORBIS_SYSTEM_PARAM_LANG_GERMAN = 4,
ORBIS_SYSTEM_PARAM_LANG_ITALIAN = 5,
ORBIS_SYSTEM_PARAM_LANG_DUTCH = 6,
ORBIS_SYSTEM_PARAM_LANG_PORTUGUESE_PT = 7,
ORBIS_SYSTEM_PARAM_LANG_RUSSIAN = 8,
ORBIS_SYSTEM_PARAM_LANG_KOREAN = 9,
ORBIS_SYSTEM_PARAM_LANG_CHINESE_T = 10,
ORBIS_SYSTEM_PARAM_LANG_CHINESE_S = 11,
ORBIS_SYSTEM_PARAM_LANG_FINNISH = 12,
ORBIS_SYSTEM_PARAM_LANG_SWEDISH = 13,
ORBIS_SYSTEM_PARAM_LANG_DANISH = 14,
ORBIS_SYSTEM_PARAM_LANG_NORWEGIAN = 15,
ORBIS_SYSTEM_PARAM_LANG_POLISH = 16,
ORBIS_SYSTEM_PARAM_LANG_PORTUGUESE_BR = 17,
ORBIS_SYSTEM_PARAM_LANG_ENGLISH_GB = 18,
ORBIS_SYSTEM_PARAM_LANG_TURKISH = 19,
ORBIS_SYSTEM_PARAM_LANG_SPANISH_LA = 20,
ORBIS_SYSTEM_PARAM_LANG_ARABIC = 21,
ORBIS_SYSTEM_PARAM_LANG_FRENCH_CA = 22,
ORBIS_SYSTEM_PARAM_LANG_CZECH = 23,
ORBIS_SYSTEM_PARAM_LANG_HUNGARIAN = 24,
ORBIS_SYSTEM_PARAM_LANG_GREEK = 25,
ORBIS_SYSTEM_PARAM_LANG_ROMANIAN = 26,
ORBIS_SYSTEM_PARAM_LANG_THAI = 27,
ORBIS_SYSTEM_PARAM_LANG_VIETNAMESE = 28,
ORBIS_SYSTEM_PARAM_LANG_INDONESIAN = 29
};
enum OrbisSystemServiceEventType {
ORBIS_SYSTEM_SERVICE_EVENT_INVALID = -1,
ORBIS_SYSTEM_SERVICE_EVENT_ON_RESUME = 0x10000000,
ORBIS_SYSTEM_SERVICE_EVENT_GAME_LIVE_STREAMING_STATUS_UPDATE = 0x10000001,
ORBIS_SYSTEM_SERVICE_EVENT_SESSION_INVITATION = 0x10000002,
ORBIS_SYSTEM_SERVICE_EVENT_ENTITLEMENT_UPDATE = 0x10000003,
ORBIS_SYSTEM_SERVICE_EVENT_GAME_CUSTOM_DATA = 0x10000004,
ORBIS_SYSTEM_SERVICE_EVENT_DISPLAY_SAFE_AREA_UPDATE = 0x10000005,
ORBIS_SYSTEM_SERVICE_EVENT_URL_OPEN = 0x10000006,
ORBIS_SYSTEM_SERVICE_EVENT_LAUNCH_APP = 0x10000007,
ORBIS_SYSTEM_SERVICE_EVENT_APP_LAUNCH_LINK = 0x10000008,
ORBIS_SYSTEM_SERVICE_EVENT_ADDCONTENT_INSTALL = 0x10000009,
ORBIS_SYSTEM_SERVICE_EVENT_RESET_VR_POSITION = 0x1000000a,
ORBIS_SYSTEM_SERVICE_EVENT_JOIN_EVENT = 0x1000000b,
ORBIS_SYSTEM_SERVICE_EVENT_PLAYGO_LOCUS_UPDATE = 0x1000000c,
ORBIS_SYSTEM_SERVICE_EVENT_PLAY_TOGETHER_HOST = 0x1000000d,
ORBIS_SYSTEM_SERVICE_EVENT_SERVICE_ENTITLEMENT_UPDATE = 0x1000000e,
ORBIS_SYSTEM_SERVICE_EVENT_EYE_TO_EYE_DISTANCE_UPDATE = 0x1000000f,
ORBIS_SYSTEM_SERVICE_EVENT_JOIN_MATCH_EVENT = 0x10000010,
ORBIS_SYSTEM_SERVICE_EVENT_PLAY_TOGETHER_HOST_A = 0x10000011,
ORBIS_SYSTEM_SERVICE_EVENT_WEBBROWSER_CLOSED = 0x10000012,
ORBIS_SYSTEM_SERVICE_EVENT_CONTROLLER_SETTINGS_CLOSED = 0x10000013,
ORBIS_SYSTEM_SERVICE_EVENT_JOIN_TEAM_ON_TEAM_MATCH_EVENT = 0x10000014,
ORBIS_SYSTEM_SERVICE_EVENT_OPEN_SHARE_MENU = 0x30000000
enum class OrbisSystemServiceEventType {
Invalid = -1,
OnResume = 0x10000000,
GameLiveStreamingStatusUpdate = 0x10000001,
SessionInvitation = 0x10000002,
EntitlementUpdate = 0x10000003,
GameCustomData = 0x10000004,
DisplaySafeAreaUpdate = 0x10000005,
UrlOpen = 0x10000006,
LaunchApp = 0x10000007,
AppLaunchLink = 0x10000008,
AddcontentInstall = 0x10000009,
ResetVrPosition = 0x1000000a,
JoinEvent = 0x1000000b,
PlaygoLocusUpdate = 0x1000000c,
PlayTogetherHost = 0x1000000d,
ServiceEntitlementUpdate = 0x1000000e,
EyeToEyeDistanceUpdate = 0x1000000f,
JoinMatchEvent = 0x10000010,
PlayTogetherHostA = 0x10000011,
WebBrowserClosed = 0x10000012,
ControllerSettingsClosed = 0x10000013,
JoinTeamOnTeamMatchEvent = 0x10000014,
OpenShareMenu = 0x30000000
};
struct OrbisSystemServiceStatus {
@ -537,7 +494,7 @@ int PS4_SYSV_ABI sceSystemServiceNavigateToAnotherApp();
int PS4_SYSV_ABI sceSystemServiceNavigateToGoBack();
int PS4_SYSV_ABI sceSystemServiceNavigateToGoBackWithValue();
int PS4_SYSV_ABI sceSystemServiceNavigateToGoHome();
s32 PS4_SYSV_ABI sceSystemServiceParamGetInt(int param_id, int* value);
s32 PS4_SYSV_ABI sceSystemServiceParamGetInt(OrbisSystemServiceParamId param_id, int* value);
int PS4_SYSV_ABI sceSystemServiceParamGetString();
int PS4_SYSV_ABI sceSystemServicePowerTick();
int PS4_SYSV_ABI sceSystemServiceRaiseExceptionLocalProcess();

View file

@ -112,7 +112,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetEvent(OrbisUserServiceEvent* event) {
if (!logged_in) {
logged_in = true;
event->event = SCE_USER_SERVICE_EVENT_TYPE_LOGIN;
event->event = OrbisUserServiceEventType::Login;
event->userId = 1;
return ORBIS_OK;
}
@ -1041,14 +1041,14 @@ int PS4_SYSV_ABI sceUserServiceGetTraditionalChineseInputType() {
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, int* color) {
s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, OrbisUserServiceUserColor* color) {
// TODO fix me better
LOG_INFO(Lib_UserService, "called user_id = {}", user_id);
if (color == nullptr) {
LOG_ERROR(Lib_UserService, "color is null");
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
}
*color = ORBIS_USER_SERVICE_USER_COLOR_BLUE;
*color = OrbisUserServiceUserColor::Blue;
return ORBIS_OK;
}

View file

@ -40,16 +40,16 @@ struct OrbisUserServiceRegisteredUserIdList {
OrbisUserServiceUserId userId[ORBIS_USER_SERVICE_MAX_REGISTER_USERS];
};
enum OrbisUserServiceUserColor {
ORBIS_USER_SERVICE_USER_COLOR_BLUE = 0,
ORBIS_USER_SERVICE_USER_COLOR_RED = 1,
ORBIS_USER_SERVICE_USER_COLOR_GREEN = 2,
ORBIS_USER_SERVICE_USER_COLOR_PINK = 3,
enum class OrbisUserServiceUserColor {
Blue = 0,
Red = 1,
Green = 2,
Pink = 3,
};
enum OrbisUserServiceEventType {
SCE_USER_SERVICE_EVENT_TYPE_LOGIN = 0, // Login event
SCE_USER_SERVICE_EVENT_TYPE_LOGOUT = 1, // Logout event
enum class OrbisUserServiceEventType {
Login = 0, // Login event
Logout = 1, // Logout event
};
struct OrbisUserServiceEvent {
@ -258,7 +258,7 @@ int PS4_SYSV_ABI sceUserServiceGetTopMenuLimitItem();
int PS4_SYSV_ABI sceUserServiceGetTopMenuNotificationFlag();
int PS4_SYSV_ABI sceUserServiceGetTopMenuTutorialFlag();
int PS4_SYSV_ABI sceUserServiceGetTraditionalChineseInputType();
s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, int* color);
s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, OrbisUserServiceUserColor* color);
int PS4_SYSV_ABI sceUserServiceGetUserGroupName();
int PS4_SYSV_ABI sceUserServiceGetUserGroupNameList();
int PS4_SYSV_ABI sceUserServiceGetUserGroupNum();

View file

@ -15,7 +15,7 @@ namespace Libraries::Vdec2 {
class VdecDecoder;
using OrbisVideodec2Decoder = VdecDecoder*;
typedef void* OrbisVideodec2ComputeQueue;
using OrbisVideodec2ComputeQueue = void*;
struct OrbisVideodec2DecoderConfigInfo {
u64 thisSize;

View file

@ -257,9 +257,9 @@ void Emulator::Run(const std::filesystem::path& file) {
linker->Execute();
window->initTimers();
while (window->isOpen()) {
window->waitEvent();
window->InitTimers();
while (window->IsOpen()) {
window->WaitEvent();
}
#ifdef ENABLE_QT_GUI

View file

@ -49,7 +49,7 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.DisplaySize = ImVec2((float)window.getWidth(), (float)window.getHeight());
io.DisplaySize = ImVec2((float)window.GetWidth(), (float)window.GetHeight());
PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f); // Makes the window edges rounded
auto path = config_path.u8string();
@ -83,7 +83,7 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
StyleColorsDark();
::Core::Devtools::Layer::SetupSettings();
Sdl::Init(window.GetSdlWindow());
Sdl::Init(window.GetSDLWindow());
const Vulkan::InitInfo vk_info{
.instance = instance.GetInstance(),
@ -108,7 +108,7 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
ImFormatString(label, IM_ARRAYSIZE(label), "WindowOverViewport_%08X", GetMainViewport()->ID);
dock_id = ImHashStr(label);
if (const auto dpi = SDL_GetWindowDisplayScale(window.GetSdlWindow()); dpi > 0.0f) {
if (const auto dpi = SDL_GetWindowDisplayScale(window.GetSDLWindow()); dpi > 0.0f) {
GetIO().FontGlobalScale = dpi;
}
}

View file

@ -1,13 +1,10 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "controller.h"
#include "common/assert.h"
#include <SDL3/SDL.h>
#include "core/libraries/kernel/time.h"
#include "core/libraries/pad/pad.h"
#include <SDL3/SDL.h>
#include "input/controller.h"
namespace Input {
@ -59,9 +56,7 @@ State GameController::GetLastState() const {
if (m_states_num == 0) {
return m_last_state;
}
auto last = (m_first_state + m_states_num - 1) % MAX_STATES;
const u32 last = (m_first_state + m_states_num - 1) % MAX_STATES;
return m_states[last];
}
@ -71,19 +66,19 @@ void GameController::AddState(const State& state) {
m_first_state = (m_first_state + 1) % MAX_STATES;
}
auto index = (m_first_state + m_states_num) % MAX_STATES;
const u32 index = (m_first_state + m_states_num) % MAX_STATES;
m_states[index] = state;
m_last_state = state;
m_private[index].obtained = false;
m_states_num++;
}
void GameController::CheckButton(int id, u32 button, bool isPressed) {
void GameController::CheckButton(int id, Libraries::Pad::OrbisPadButtonDataOffset button,
bool is_pressed) {
std::scoped_lock lock{m_mutex};
auto state = GetLastState();
state.time = Libraries::Kernel::sceKernelGetProcessTime();
if (isPressed) {
if (is_pressed) {
state.buttonsState |= button;
} else {
state.buttonsState &= ~button;
@ -93,28 +88,28 @@ void GameController::CheckButton(int id, u32 button, bool isPressed) {
}
void GameController::Axis(int id, Input::Axis axis, int value) {
using Libraries::Pad::OrbisPadButtonDataOffset;
std::scoped_lock lock{m_mutex};
auto state = GetLastState();
state.time = Libraries::Kernel::sceKernelGetProcessTime();
int axis_id = static_cast<int>(axis);
state.axes[axis_id] = value;
if (axis == Input::Axis::TriggerLeft) {
if (value > 0) {
state.buttonsState |= Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
state.buttonsState |= OrbisPadButtonDataOffset::L2;
} else {
state.buttonsState &= ~Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
state.buttonsState &= ~OrbisPadButtonDataOffset::L2;
}
}
if (axis == Input::Axis::TriggerRight) {
if (value > 0) {
state.buttonsState |= Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
state.buttonsState |= OrbisPadButtonDataOffset::R2;
} else {
state.buttonsState &= ~Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
state.buttonsState &= ~OrbisPadButtonDataOffset::R2;
}
}

View file

@ -5,6 +5,7 @@
#include <mutex>
#include "common/types.h"
#include "core/libraries/pad/pad.h"
struct SDL_Gamepad;
@ -28,7 +29,7 @@ struct TouchpadEntry {
};
struct State {
u32 buttonsState = 0;
Libraries::Pad::OrbisPadButtonDataOffset buttonsState{};
u64 time = 0;
int axes[static_cast<int>(Axis::AxisMax)] = {128, 128, 128, 128, 0, 0};
TouchpadEntry touchpad[2] = {{false, 0, 0}, {false, 0, 0}};
@ -49,7 +50,7 @@ public:
void ReadState(State* state, bool* isConnected, int* connectedCount);
int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount);
State GetLastState() const;
void CheckButton(int id, u32 button, bool isPressed);
void CheckButton(int id, Libraries::Pad::OrbisPadButtonDataOffset button, bool isPressed);
void AddState(const State& state);
void Axis(int id, Input::Axis axis, int value);
void SetLightBarRGB(u8 r, u8 g, u8 b);

View file

@ -6,9 +6,9 @@
#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_timer.h>
#include <SDL3/SDL_video.h>
#include "common/assert.h"
#include "common/config.h"
#include "common/version.h"
#include "core/libraries/pad/pad.h"
#include "imgui/renderer/imgui_core.h"
#include "input/controller.h"
@ -21,6 +21,45 @@
namespace Frontend {
using namespace Libraries::Pad;
static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) {
switch (button) {
case SDL_GAMEPAD_BUTTON_DPAD_DOWN:
return OrbisPadButtonDataOffset::Down;
case SDL_GAMEPAD_BUTTON_DPAD_UP:
return OrbisPadButtonDataOffset::Up;
case SDL_GAMEPAD_BUTTON_DPAD_LEFT:
return OrbisPadButtonDataOffset::Left;
case SDL_GAMEPAD_BUTTON_DPAD_RIGHT:
return OrbisPadButtonDataOffset::Right;
case SDL_GAMEPAD_BUTTON_SOUTH:
return OrbisPadButtonDataOffset::Cross;
case SDL_GAMEPAD_BUTTON_NORTH:
return OrbisPadButtonDataOffset::Triangle;
case SDL_GAMEPAD_BUTTON_WEST:
return OrbisPadButtonDataOffset::Square;
case SDL_GAMEPAD_BUTTON_EAST:
return OrbisPadButtonDataOffset::Circle;
case SDL_GAMEPAD_BUTTON_START:
return OrbisPadButtonDataOffset::Options;
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
return OrbisPadButtonDataOffset::TouchPad;
case SDL_GAMEPAD_BUTTON_BACK:
return OrbisPadButtonDataOffset::TouchPad;
case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
return OrbisPadButtonDataOffset::L1;
case SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER:
return OrbisPadButtonDataOffset::R1;
case SDL_GAMEPAD_BUTTON_LEFT_STICK:
return OrbisPadButtonDataOffset::L3;
case SDL_GAMEPAD_BUTTON_RIGHT_STICK:
return OrbisPadButtonDataOffset::R3;
default:
return OrbisPadButtonDataOffset::None;
}
}
static Uint32 SDLCALL PollController(void* userdata, SDL_TimerID timer_id, Uint32 interval) {
auto* controller = reinterpret_cast<Input::GameController*>(userdata);
return controller->Poll();
@ -80,7 +119,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
WindowSDL::~WindowSDL() = default;
void WindowSDL::waitEvent() {
void WindowSDL::WaitEvent() {
// Called on main thread
SDL_Event event;
@ -96,16 +135,16 @@ void WindowSDL::waitEvent() {
case SDL_EVENT_WINDOW_RESIZED:
case SDL_EVENT_WINDOW_MAXIMIZED:
case SDL_EVENT_WINDOW_RESTORED:
onResize();
OnResize();
break;
case SDL_EVENT_WINDOW_MINIMIZED:
case SDL_EVENT_WINDOW_EXPOSED:
is_shown = event.type == SDL_EVENT_WINDOW_EXPOSED;
onResize();
OnResize();
break;
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
onKeyPress(&event);
OnKeyPress(&event);
break;
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
case SDL_EVENT_GAMEPAD_BUTTON_UP:
@ -115,7 +154,7 @@ void WindowSDL::waitEvent() {
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
onGamepadEvent(&event);
OnGamepadEvent(&event);
break;
case SDL_EVENT_QUIT:
is_open = false;
@ -125,18 +164,16 @@ void WindowSDL::waitEvent() {
}
}
void WindowSDL::initTimers() {
void WindowSDL::InitTimers() {
SDL_AddTimer(100, &PollController, controller);
}
void WindowSDL::onResize() {
void WindowSDL::OnResize() {
SDL_GetWindowSizeInPixels(window, &width, &height);
ImGui::Core::OnResize();
}
void WindowSDL::onKeyPress(const SDL_Event* event) {
using Libraries::Pad::OrbisPadButtonDataOffset;
void WindowSDL::OnKeyPress(const SDL_Event* event) {
#ifdef __APPLE__
// Use keys that are more friendly for keyboards without a keypad.
// Once there are key binding options this won't be necessary.
@ -151,38 +188,38 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
constexpr SDL_Keycode TriangleKey = SDLK_KP_8;
#endif
u32 button = 0;
auto button = OrbisPadButtonDataOffset::None;
Input::Axis axis = Input::Axis::AxisMax;
int axisvalue = 0;
int ax = 0;
std::string backButtonBehavior = Config::getBackButtonBehavior();
switch (event->key.key) {
case SDLK_UP:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
button = OrbisPadButtonDataOffset::Up;
break;
case SDLK_DOWN:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN;
button = OrbisPadButtonDataOffset::Down;
break;
case SDLK_LEFT:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT;
button = OrbisPadButtonDataOffset::Left;
break;
case SDLK_RIGHT:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT;
button = OrbisPadButtonDataOffset::Right;
break;
case TriangleKey:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE;
button = OrbisPadButtonDataOffset::Triangle;
break;
case CircleKey:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE;
button = OrbisPadButtonDataOffset::Circle;
break;
case CrossKey:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS;
button = OrbisPadButtonDataOffset::Cross;
break;
case SquareKey:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE;
button = OrbisPadButtonDataOffset::Square;
break;
case SDLK_RETURN:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS;
button = OrbisPadButtonDataOffset::Options;
break;
case SDLK_A:
axis = Input::Axis::LeftX;
@ -257,19 +294,19 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_X:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3;
button = OrbisPadButtonDataOffset::L3;
break;
case SDLK_M:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3;
button = OrbisPadButtonDataOffset::R3;
break;
case SDLK_Q:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1;
button = OrbisPadButtonDataOffset::L1;
break;
case SDLK_U:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1;
button = OrbisPadButtonDataOffset::R1;
break;
case SDLK_E:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
button = OrbisPadButtonDataOffset::L2;
axis = Input::Axis::TriggerLeft;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 255;
@ -279,7 +316,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
ax = Input::GetAxis(0, 0x80, axisvalue);
break;
case SDLK_O:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
button = OrbisPadButtonDataOffset::R2;
axis = Input::Axis::TriggerRight;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 255;
@ -294,9 +331,9 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
// trigger a touchpad event so that the touchpad emulation for back button works
controller->SetTouchpadState(0, true, x, 0.5f);
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
button = OrbisPadButtonDataOffset::TouchPad;
} else {
button = 0;
button = {};
}
break;
case SDLK_F11:
@ -317,7 +354,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
default:
break;
}
if (button != 0) {
if (button != OrbisPadButtonDataOffset::None) {
controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
}
if (axis != Input::Axis::AxisMax) {
@ -325,10 +362,8 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
}
}
void WindowSDL::onGamepadEvent(const SDL_Event* event) {
using Libraries::Pad::OrbisPadButtonDataOffset;
u32 button = 0;
void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
auto button = OrbisPadButtonDataOffset::None;
Input::Axis axis = Input::Axis::AxisMax;
switch (event->type) {
case SDL_EVENT_GAMEPAD_ADDED:
@ -343,25 +378,25 @@ void WindowSDL::onGamepadEvent(const SDL_Event* event) {
event->gtouchpad.x, event->gtouchpad.y);
break;
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
case SDL_EVENT_GAMEPAD_BUTTON_UP:
button = sdlGamepadToOrbisButton(event->gbutton.button);
if (button != 0) {
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_BACK) {
std::string backButtonBehavior = Config::getBackButtonBehavior();
if (backButtonBehavior != "none") {
float x = backButtonBehavior == "left"
? 0.25f
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
// trigger a touchpad event so that the touchpad emulation for back button works
controller->SetTouchpadState(0, true, x, 0.5f);
controller->CheckButton(0, button,
event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
}
} else {
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
}
case SDL_EVENT_GAMEPAD_BUTTON_UP: {
button = SDLGamepadToOrbisButton(event->gbutton.button);
if (button == OrbisPadButtonDataOffset::None) {
break;
}
if (event->gbutton.button != SDL_GAMEPAD_BUTTON_BACK) {
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
break;
}
const auto backButtonBehavior = Config::getBackButtonBehavior();
if (backButtonBehavior != "none") {
float x = backButtonBehavior == "left" ? 0.25f
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
// trigger a touchpad event so that the touchpad emulation for back button works
controller->SetTouchpadState(0, true, x, 0.5f);
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
}
break;
}
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
axis = event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTX ? Input::Axis::LeftX
: event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTY ? Input::Axis::LeftY
@ -383,43 +418,4 @@ void WindowSDL::onGamepadEvent(const SDL_Event* event) {
}
}
int WindowSDL::sdlGamepadToOrbisButton(u8 button) {
using Libraries::Pad::OrbisPadButtonDataOffset;
switch (button) {
case SDL_GAMEPAD_BUTTON_DPAD_DOWN:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN;
case SDL_GAMEPAD_BUTTON_DPAD_UP:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
case SDL_GAMEPAD_BUTTON_DPAD_LEFT:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT;
case SDL_GAMEPAD_BUTTON_DPAD_RIGHT:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT;
case SDL_GAMEPAD_BUTTON_SOUTH:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS;
case SDL_GAMEPAD_BUTTON_NORTH:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE;
case SDL_GAMEPAD_BUTTON_WEST:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE;
case SDL_GAMEPAD_BUTTON_EAST:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE;
case SDL_GAMEPAD_BUTTON_START:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS;
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
case SDL_GAMEPAD_BUTTON_BACK:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1;
case SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1;
case SDL_GAMEPAD_BUTTON_LEFT_STICK:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3;
case SDL_GAMEPAD_BUTTON_RIGHT_STICK:
return OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3;
default:
return 0;
}
}
} // namespace Frontend

View file

@ -46,36 +46,33 @@ public:
std::string_view window_title);
~WindowSDL();
s32 getWidth() const {
s32 GetWidth() const {
return width;
}
s32 getHeight() const {
s32 GetHeight() const {
return height;
}
bool isOpen() const {
bool IsOpen() const {
return is_open;
}
[[nodiscard]] SDL_Window* GetSdlWindow() const {
[[nodiscard]] SDL_Window* GetSDLWindow() const {
return window;
}
WindowSystemInfo getWindowInfo() const {
WindowSystemInfo GetWindowInfo() const {
return window_info;
}
void waitEvent();
void initTimers();
void WaitEvent();
void InitTimers();
private:
void onResize();
void onKeyPress(const SDL_Event* event);
void onGamepadEvent(const SDL_Event* event);
int sdlGamepadToOrbisButton(u8 button);
void OnResize();
void OnKeyPress(const SDL_Event* event);
void OnGamepadEvent(const SDL_Event* event);
private:
s32 width;

View file

@ -95,7 +95,7 @@ Instance::Instance(bool enable_validation, bool enable_crash_diagnostic)
Instance::Instance(Frontend::WindowSDL& window, s32 physical_device_index,
bool enable_validation /*= false*/, bool enable_crash_diagnostic /*= false*/)
: instance{CreateInstance(window.getWindowInfo().type, enable_validation,
: instance{CreateInstance(window.GetWindowInfo().type, enable_validation,
enable_crash_diagnostic)},
physical_devices{EnumeratePhysicalDevices(instance)} {
if (enable_validation) {

View file

@ -73,7 +73,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback(
}
vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::WindowSDL& emu_window) {
const auto& window_info = emu_window.getWindowInfo();
const auto& window_info = emu_window.GetWindowInfo();
vk::SurfaceKHR surface{};
#if defined(VK_USE_PLATFORM_WIN32_KHR)

View file

@ -629,9 +629,9 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop)
void Presenter::Present(Frame* frame) {
// Recreate the swapchain if the window was resized.
if (window.getWidth() != swapchain.GetExtent().width ||
window.getHeight() != swapchain.GetExtent().height) {
swapchain.Recreate(window.getWidth(), window.getHeight());
if (window.GetWidth() != swapchain.GetExtent().width ||
window.GetHeight() != swapchain.GetExtent().height) {
swapchain.Recreate(window.GetWidth(), window.GetHeight());
}
ImGui::Core::NewFrame();
@ -776,8 +776,8 @@ Frame* Presenter::GetRenderFrame() {
device.resetFences(frame->present_done);
// If the window dimensions changed, recreate this frame
if (frame->width != window.getWidth() || frame->height != window.getHeight()) {
RecreateFrame(frame, window.getWidth(), window.getHeight());
if (frame->width != window.GetWidth() || frame->height != window.GetHeight()) {
RecreateFrame(frame, window.GetWidth(), window.GetHeight());
}
return frame;

View file

@ -14,7 +14,7 @@ namespace Vulkan {
Swapchain::Swapchain(const Instance& instance_, const Frontend::WindowSDL& window)
: instance{instance_}, surface{CreateSurface(instance.GetInstance(), window)} {
FindPresentFormat();
Create(window.getWidth(), window.getHeight(), surface);
Create(window.GetWidth(), window.GetHeight(), surface);
}
Swapchain::~Swapchain() {