mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
core: Bring structs and enums to codebase style
This commit is contained in:
parent
d1c3aeb8a4
commit
ba78dc5552
@ -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
|
|
@ -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
|
|
@ -97,24 +97,23 @@ struct PlaygoChunk {
|
|||||||
|
|
||||||
class PlaygoFile {
|
class PlaygoFile {
|
||||||
public:
|
public:
|
||||||
bool initialized;
|
bool initialized = false;
|
||||||
OrbisPlayGoHandle handle;
|
OrbisPlayGoHandle handle = 0;
|
||||||
OrbisPlayGoChunkId id;
|
OrbisPlayGoChunkId id = 0;
|
||||||
OrbisPlayGoLocus locus;
|
OrbisPlayGoLocus locus = OrbisPlayGoLocus::NotDownloaded;
|
||||||
OrbisPlayGoInstallSpeed speed;
|
OrbisPlayGoInstallSpeed speed = OrbisPlayGoInstallSpeed::Trickle;
|
||||||
s64 speed_tick;
|
s64 speed_tick = 0;
|
||||||
OrbisPlayGoEta eta;
|
OrbisPlayGoEta eta = 0;
|
||||||
OrbisPlayGoLanguageMask langMask;
|
OrbisPlayGoLanguageMask langMask = 0;
|
||||||
std::vector<PlaygoChunk> chunks;
|
std::vector<PlaygoChunk> chunks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlaygoFile()
|
explicit PlaygoFile() = default;
|
||||||
: initialized(false), handle(0), id(0), locus(0), speed(ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE),
|
|
||||||
speed_tick(0), eta(0), langMask(0), playgoHeader{0} {}
|
|
||||||
~PlaygoFile() = default;
|
~PlaygoFile() = default;
|
||||||
|
|
||||||
bool Open(const std::filesystem::path& filepath);
|
bool Open(const std::filesystem::path& filepath);
|
||||||
bool LoadChunks(const Common::FS::IOFile& file);
|
bool LoadChunks(const Common::FS::IOFile& file);
|
||||||
|
|
||||||
PlaygoHeader& GetPlaygoHeader() {
|
PlaygoHeader& GetPlaygoHeader() {
|
||||||
return playgoHeader;
|
return playgoHeader;
|
||||||
}
|
}
|
||||||
|
@ -15,22 +15,21 @@
|
|||||||
|
|
||||||
namespace Libraries::AppContent {
|
namespace Libraries::AppContent {
|
||||||
|
|
||||||
int32_t addcont_count = 0;
|
|
||||||
|
|
||||||
struct AddContInfo {
|
struct AddContInfo {
|
||||||
char entitlementLabel[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
|
char entitlement_label[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
|
||||||
OrbisAppContentAddcontDownloadStatus status;
|
OrbisAppContentAddcontDownloadStatus status;
|
||||||
OrbisAppContentGetEntitlementKey key;
|
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",
|
{"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, 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() {
|
int PS4_SYSV_ABI _Z5dummyv() {
|
||||||
LOG_ERROR(Lib_AppContent, "(STUBBED) called");
|
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();
|
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||||
|
|
||||||
for (int i = 0; i < addcont_count; i++) {
|
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) {
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (addcont_info[i].status != OrbisAppContentAddcontDownloadStatus::Installed) {
|
||||||
if (addcont_info[i].status != ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED) {
|
|
||||||
return ORBIS_APP_CONTENT_ERROR_NOT_FOUND;
|
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++) {
|
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) {
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Lib_AppContent, "found DLC {}", entitlementLabel->data);
|
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);
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
|
||||||
info->status = addcont_info[i].status;
|
info->status = addcont_info[i].status;
|
||||||
return ORBIS_OK;
|
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;
|
int dlcs_to_list = addcont_count < list_num ? addcont_count : list_num;
|
||||||
for (int i = 0; i < dlcs_to_list; i++) {
|
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);
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
|
||||||
list[i].status = addcont_info[i].status;
|
list[i].status = addcont_info[i].status;
|
||||||
}
|
}
|
||||||
@ -221,7 +219,7 @@ int PS4_SYSV_ABI sceAppContentGetEntitlementKey(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < addcont_count; i++) {
|
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) {
|
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -249,21 +247,19 @@ int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initPar
|
|||||||
} else {
|
} else {
|
||||||
UNREACHABLE_MSG("Failed to get TITLE_ID");
|
UNREACHABLE_MSG("Failed to get TITLE_ID");
|
||||||
}
|
}
|
||||||
auto addon_path = addons_dir / title_id;
|
const auto addon_path = addons_dir / title_id;
|
||||||
if (std::filesystem::exists(addon_path)) {
|
if (!std::filesystem::exists(addon_path)) {
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
|
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
|
||||||
if (entry.is_directory()) {
|
if (entry.is_directory()) {
|
||||||
auto entitlement_label = entry.path().filename().string();
|
auto entitlement_label = entry.path().filename().string();
|
||||||
|
auto& info = addcont_info[addcont_count++];
|
||||||
AddContInfo info{};
|
info.status = OrbisAppContentAddcontDownloadStatus::Installed;
|
||||||
info.status = ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED;
|
entitlement_label.copy(info.entitlement_label, sizeof(info.entitlement_label));
|
||||||
entitlement_label.copy(info.entitlementLabel, sizeof(info.entitlementLabel));
|
|
||||||
|
|
||||||
addcont_info[addcont_count++] = info;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,9 +307,11 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataMount() {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
|
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
|
||||||
OrbisAppContentMountPoint* mountPoint) {
|
OrbisAppContentMountPoint* mountPoint) {
|
||||||
if (mountPoint == nullptr)
|
if (mountPoint == nullptr) {
|
||||||
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
|
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 = {}",
|
LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}",
|
||||||
option, mountPoint->data);
|
option, mountPoint->data);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
|
@ -30,7 +30,7 @@ struct OrbisAppContentBootParam {
|
|||||||
char reserved2[32];
|
char reserved2[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef u32 OrbisAppContentTemporaryDataOption;
|
using OrbisAppContentTemporaryDataOption = u32;
|
||||||
|
|
||||||
constexpr int ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE = 16;
|
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_ENTITLEMENT_KEY_SIZE = 16;
|
||||||
constexpr int ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE = 2500;
|
constexpr int ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE = 2500;
|
||||||
|
|
||||||
enum OrbisAppContentAddcontDownloadStatus : u32 {
|
enum class OrbisAppContentAddcontDownloadStatus : u32 {
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_EXTRA_DATA = 0,
|
NoExtraData = 0,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_IN_QUEUE = 1,
|
NoInQueue = 1,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOADING = 2,
|
Downloading = 2,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOAD_SUSPENDED = 3,
|
DownloadSuspended = 3,
|
||||||
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED = 4
|
Installed = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisNpUnifiedEntitlementLabel {
|
struct OrbisNpUnifiedEntitlementLabel {
|
||||||
@ -57,11 +57,11 @@ struct OrbisNpUnifiedEntitlementLabel {
|
|||||||
char padding[3];
|
char padding[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef u32 OrbisAppContentAppParamId;
|
using OrbisAppContentAppParamId = u32;
|
||||||
|
|
||||||
struct OrbisAppContentAddcontInfo {
|
struct OrbisAppContentAddcontInfo {
|
||||||
OrbisNpUnifiedEntitlementLabel entitlement_label;
|
OrbisNpUnifiedEntitlementLabel entitlement_label;
|
||||||
u32 status;
|
OrbisAppContentAddcontDownloadStatus status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisAppContentGetEntitlementKey {
|
struct OrbisAppContentGetEntitlementKey {
|
||||||
@ -105,7 +105,7 @@ int PS4_SYSV_ABI sceAppContentSmallSharedDataMount();
|
|||||||
int PS4_SYSV_ABI sceAppContentSmallSharedDataUnmount();
|
int PS4_SYSV_ABI sceAppContentSmallSharedDataUnmount();
|
||||||
int PS4_SYSV_ABI sceAppContentTemporaryDataFormat();
|
int PS4_SYSV_ABI sceAppContentTemporaryDataFormat();
|
||||||
int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb(
|
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 sceAppContentTemporaryDataMount();
|
||||||
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
|
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
|
||||||
OrbisAppContentMountPoint* mountPoint);
|
OrbisAppContentMountPoint* mountPoint);
|
||||||
|
@ -4,30 +4,30 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
#include "audio_core/sdl_audio.h"
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/audio/audioout.h"
|
#include "core/libraries/audio/audioout.h"
|
||||||
#include "core/libraries/audio/audioout_error.h"
|
#include "core/libraries/audio/audioout_error.h"
|
||||||
|
#include "core/libraries/audio/sdl_audio.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
namespace Libraries::AudioOut {
|
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) {
|
switch (port) {
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
|
case OrbisAudioOutPort::Main:
|
||||||
return "MAIN";
|
return "MAIN";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
|
case OrbisAudioOutPort::Bgm:
|
||||||
return "BGM";
|
return "BGM";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
|
case OrbisAudioOutPort::Voice:
|
||||||
return "VOICE";
|
return "VOICE";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
|
case OrbisAudioOutPort::Personal:
|
||||||
return "PERSONAL";
|
return "PERSONAL";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
|
case OrbisAudioOutPort::Padspk:
|
||||||
return "PADSPK";
|
return "PADSPK";
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
|
case OrbisAudioOutPort::Aux:
|
||||||
return "AUX";
|
return "AUX";
|
||||||
default:
|
default:
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
@ -36,21 +36,21 @@ static std::string_view GetAudioOutPort(u32 port) {
|
|||||||
|
|
||||||
static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
|
static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
|
case OrbisAudioOutParamFormat::S16Mono:
|
||||||
return "S16_MONO";
|
return "S16_MONO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
|
case OrbisAudioOutParamFormat::S16Stereo:
|
||||||
return "S16_STEREO";
|
return "S16_STEREO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
|
case OrbisAudioOutParamFormat::S16_8CH:
|
||||||
return "S16_8CH";
|
return "S16_8CH";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
|
case OrbisAudioOutParamFormat::FloatMono:
|
||||||
return "FLOAT_MONO";
|
return "FLOAT_MONO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
|
case OrbisAudioOutParamFormat::FloatStereo:
|
||||||
return "FLOAT_STEREO";
|
return "FLOAT_STEREO";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
|
case OrbisAudioOutParamFormat::Float_8CH:
|
||||||
return "FLOAT_8CH";
|
return "FLOAT_8CH";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
|
case OrbisAudioOutParamFormat::S16_8CH_Std:
|
||||||
return "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";
|
return "FLOAT_8CH_STD";
|
||||||
default:
|
default:
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
@ -59,11 +59,11 @@ static std::string_view GetAudioOutParamFormat(OrbisAudioOutParamFormat param) {
|
|||||||
|
|
||||||
static std::string_view GetAudioOutParamAttr(OrbisAudioOutParamAttr attr) {
|
static std::string_view GetAudioOutParamAttr(OrbisAudioOutParamAttr attr) {
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case ORBIS_AUDIO_OUT_PARAM_ATTR_NONE:
|
case OrbisAudioOutParamAttr::None:
|
||||||
return "NONE";
|
return "NONE";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_ATTR_RESTRICTED:
|
case OrbisAudioOutParamAttr::Restricted:
|
||||||
return "RESTRICTED";
|
return "RESTRICTED";
|
||||||
case ORBIS_AUDIO_OUT_PARAM_ATTR_MIX_TO_MAIN:
|
case OrbisAudioOutParamAttr::MixToMain:
|
||||||
return "MIX_TO_MAIN";
|
return "MIX_TO_MAIN";
|
||||||
default:
|
default:
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
@ -180,29 +180,23 @@ int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* sta
|
|||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int type = 0;
|
const auto [type, channels_num] = audio->GetStatus(handle);
|
||||||
int channels_num = 0;
|
|
||||||
|
|
||||||
if (const auto err = audio->AudioOutGetStatus(handle, &type, &channels_num); err != ORBIS_OK) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
state->rerouteCounter = 0;
|
state->rerouteCounter = 0;
|
||||||
state->volume = 127; // max volume
|
state->volume = 127;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
|
case OrbisAudioOutPort::Main:
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
|
case OrbisAudioOutPort::Bgm:
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
|
case OrbisAudioOutPort::Voice:
|
||||||
state->output = 1;
|
state->output = 1;
|
||||||
state->channel = (channels_num > 2 ? 2 : channels_num);
|
state->channel = (channels_num > 2 ? 2 : channels_num);
|
||||||
break;
|
break;
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
|
case OrbisAudioOutPort::Personal:
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
|
case OrbisAudioOutPort::Padspk:
|
||||||
state->output = 4;
|
state->output = 4;
|
||||||
state->channel = 1;
|
state->channel = 1;
|
||||||
break;
|
break;
|
||||||
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
|
case OrbisAudioOutPort::Aux:
|
||||||
state->output = 0;
|
state->output = 0;
|
||||||
state->channel = 0;
|
state->channel = 0;
|
||||||
break;
|
break;
|
||||||
@ -243,7 +237,7 @@ int PS4_SYSV_ABI sceAudioOutInit() {
|
|||||||
if (audio != nullptr) {
|
if (audio != nullptr) {
|
||||||
return ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT;
|
return ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT;
|
||||||
}
|
}
|
||||||
audio = std::make_unique<Audio::SDLAudio>();
|
audio = std::make_unique<SDLAudioOut>();
|
||||||
return ORBIS_OK;
|
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,
|
user_id, GetAudioOutPort(port_type), index, length, sample_rate,
|
||||||
GetAudioOutParamFormat(param_type.data_format),
|
GetAudioOutParamFormat(param_type.data_format),
|
||||||
GetAudioOutParamAttr(param_type.attributes));
|
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");
|
LOG_ERROR(Lib_AudioOut, "Invalid port type");
|
||||||
return ORBIS_AUDIO_OUT_ERROR_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) {
|
if (index != 0) {
|
||||||
LOG_ERROR(Lib_AudioOut, "index is not valid !=0 {}", index);
|
LOG_ERROR(Lib_AudioOut, "index is not valid !=0 {}", index);
|
||||||
}
|
}
|
||||||
OrbisAudioOutParamFormat format = param_type.data_format;
|
const auto format = param_type.data_format.Value();
|
||||||
if (format < 0 || format > 7) {
|
if (format < OrbisAudioOutParamFormat::S16Mono ||
|
||||||
|
format > OrbisAudioOutParamFormat::Float_8CH_Std) {
|
||||||
LOG_ERROR(Lib_AudioOut, "Invalid format");
|
LOG_ERROR(Lib_AudioOut, "Invalid format");
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
||||||
}
|
}
|
||||||
OrbisAudioOutParamAttr attr = param_type.attributes;
|
const auto attr = param_type.attributes;
|
||||||
if (attr < 0 || attr > 2) {
|
if (attr < OrbisAudioOutParamAttr::None || attr > OrbisAudioOutParamAttr::MixToMain) {
|
||||||
// TODO Handle attributes in output audio device
|
// TODO Handle attributes in output audio device
|
||||||
LOG_ERROR(Lib_AudioOut, "Invalid format attribute");
|
LOG_ERROR(Lib_AudioOut, "Invalid format attribute");
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
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() {
|
int PS4_SYSV_ABI sceAudioOutOpenEx() {
|
||||||
@ -330,7 +326,7 @@ s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr) {
|
|||||||
// Nothing to output
|
// Nothing to output
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
return audio->AudioOutOutput(handle, ptr);
|
return audio->Output(handle, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num) {
|
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) {
|
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
}
|
}
|
||||||
return audio->AudioOutSetVolume(handle, flag, vol);
|
return audio->SetVolume(handle, flag, vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
||||||
|
@ -9,47 +9,37 @@
|
|||||||
|
|
||||||
namespace Libraries::AudioOut {
|
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
|
// 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_NUM_PORTS = 22;
|
||||||
|
constexpr int SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value
|
||||||
|
|
||||||
enum OrbisAudioOutPort {
|
enum class OrbisAudioOutPort { Main = 0, Bgm = 1, Voice = 2, Personal = 3, Padspk = 4, Aux = 127 };
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_MAIN = 0,
|
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_BGM = 1,
|
enum class OrbisAudioOutParamFormat {
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_VOICE = 2,
|
S16Mono = 0,
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL = 3,
|
S16Stereo = 1,
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK = 4,
|
S16_8CH = 2,
|
||||||
ORBIS_AUDIO_OUT_PORT_TYPE_AUX = 127
|
FloatMono = 3,
|
||||||
|
FloatStereo = 4,
|
||||||
|
Float_8CH = 5,
|
||||||
|
S16_8CH_Std = 6,
|
||||||
|
Float_8CH_Std = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisAudioOutParamFormat {
|
enum class OrbisAudioOutParamAttr {
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO = 0,
|
None = 0,
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO = 1,
|
Restricted = 1,
|
||||||
ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH = 2,
|
MixToMain = 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 OrbisAudioOutParamAttr {
|
union OrbisAudioOutParamExtendedInformation {
|
||||||
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<0, 8, OrbisAudioOutParamFormat> data_format;
|
||||||
BitField<8, 8, u32> reserve0;
|
BitField<8, 8, u32> reserve0;
|
||||||
BitField<16, 4, OrbisAudioOutParamAttr> attributes;
|
BitField<16, 4, OrbisAudioOutParamAttr> attributes;
|
||||||
BitField<20, 10, u32> reserve1;
|
BitField<20, 10, u32> reserve1;
|
||||||
BitField<31, 1, u32> unused;
|
BitField<31, 1, u32> unused;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisAudioOutOutputParam {
|
struct OrbisAudioOutOutputParam {
|
||||||
s32 handle;
|
s32 handle;
|
||||||
|
141
src/core/libraries/audio/sdl_audio.cpp
Normal file
141
src/core/libraries/audio/sdl_audio.cpp
Normal 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
|
42
src/core/libraries/audio/sdl_audio.h
Normal file
42
src/core/libraries/audio/sdl_audio.h
Normal 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
|
@ -26,17 +26,12 @@ struct SceFiber {
|
|||||||
u64 signature;
|
u64 signature;
|
||||||
FiberState state;
|
FiberState state;
|
||||||
SceFiberEntry entry;
|
SceFiberEntry entry;
|
||||||
|
|
||||||
u64 argOnInitialize;
|
u64 argOnInitialize;
|
||||||
|
|
||||||
u64 argRun;
|
u64 argRun;
|
||||||
u64* pArgRun;
|
u64* pArgRun;
|
||||||
|
|
||||||
u64 argReturn;
|
u64 argReturn;
|
||||||
u64* pArgReturn;
|
u64* pArgReturn;
|
||||||
|
|
||||||
u64 sizeContext;
|
u64 sizeContext;
|
||||||
|
|
||||||
char name[ORBIS_FIBER_MAX_NAME_LENGTH];
|
char name[ORBIS_FIBER_MAX_NAME_LENGTH];
|
||||||
void* handle;
|
void* handle;
|
||||||
};
|
};
|
||||||
@ -53,7 +48,7 @@ struct SceFiberInfo {
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(SceFiberInfo) <= 128);
|
static_assert(sizeof(SceFiberInfo) <= 128);
|
||||||
|
|
||||||
typedef void* SceFiberOptParam;
|
using SceFiberOptParam = void*;
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceFiberInitialize(SceFiber* fiber, const char* name, SceFiberEntry entry,
|
s32 PS4_SYSV_ABI sceFiberInitialize(SceFiber* fiber, const char* name, SceFiberEntry entry,
|
||||||
u64 argOnInitialize, void* addrContext, u64 sizeContext,
|
u64 argOnInitialize, void* addrContext, u64 sizeContext,
|
||||||
|
@ -18,21 +18,16 @@ struct PngHandler {
|
|||||||
static inline OrbisPngDecColorSpace MapPngColor(int color) {
|
static inline OrbisPngDecColorSpace MapPngColor(int color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case PNG_COLOR_TYPE_GRAY:
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE;
|
return OrbisPngDecColorSpace::Grayscale;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_GRAYSCALE_ALPHA;
|
return OrbisPngDecColorSpace::GrayscaleAlpha;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_PALETTE:
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_CLUT;
|
return OrbisPngDecColorSpace::Clut;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB:
|
case PNG_COLOR_TYPE_RGB:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_RGB;
|
return OrbisPngDecColorSpace::Rgb;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
return OrbisPngDecColorSpace::ORBIS_PNG_DEC_COLOR_SPACE_RGBA;
|
return OrbisPngDecColorSpace::Rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNREACHABLE_MSG("unknown png color type");
|
UNREACHABLE_MSG("unknown png color type");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,56 +113,60 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
pngdata->offset += len;
|
pngdata->offset += len;
|
||||||
});
|
});
|
||||||
|
|
||||||
u32 width, height;
|
|
||||||
int color_type, bit_depth;
|
|
||||||
png_read_info(pngh->png_ptr, pngh->info_ptr);
|
png_read_info(pngh->png_ptr, pngh->info_ptr);
|
||||||
|
const u32 width = png_get_image_width(pngh->png_ptr, pngh->info_ptr);
|
||||||
width = png_get_image_width(pngh->png_ptr, pngh->info_ptr);
|
const u32 height = png_get_image_height(pngh->png_ptr, pngh->info_ptr);
|
||||||
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));
|
||||||
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);
|
||||||
bit_depth = png_get_bit_depth(pngh->png_ptr, pngh->info_ptr);
|
|
||||||
|
|
||||||
if (imageInfo != nullptr) {
|
if (imageInfo != nullptr) {
|
||||||
imageInfo->bitDepth = bit_depth;
|
imageInfo->bitDepth = bit_depth;
|
||||||
imageInfo->imageWidth = width;
|
imageInfo->imageWidth = width;
|
||||||
imageInfo->imageHeight = height;
|
imageInfo->imageHeight = height;
|
||||||
imageInfo->colorSpace = color_type;
|
imageInfo->colorSpace = color_type;
|
||||||
imageInfo->imageFlag = 0;
|
imageInfo->imageFlag = OrbisPngDecImageFlag::None;
|
||||||
if (png_get_interlace_type(pngh->png_ptr, pngh->info_ptr) == 1) {
|
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)) {
|
if (png_get_valid(pngh->png_ptr, pngh->info_ptr, PNG_INFO_tRNS)) {
|
||||||
|
imageInfo->imageFlag |= OrbisPngDecImageFlag::TrnsChunkExist;
|
||||||
imageInfo->imageFlag |= ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16) {
|
||||||
png_set_strip_16(pngh->png_ptr);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
png_read_update_info(pngh->png_ptr, pngh->info_ptr);
|
||||||
|
|
||||||
auto const numChannels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
|
const s32 num_channels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
|
||||||
auto horizontal_bytes = numChannels * width;
|
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++) {
|
||||||
|
auto ptr = reinterpret_cast<png_bytep>(param->imageMemAddr);
|
||||||
for (int j = 0; j < pass; j++) { // interlaced
|
|
||||||
auto ptr = (png_bytep)param->imageMemAddr;
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
png_read_row(pngh->png_ptr, ptr, nullptr);
|
png_read_row(pngh->png_ptr, ptr, nullptr);
|
||||||
ptr += stride;
|
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->imageHeight = png_get_image_height(png_ptr, info_ptr);
|
||||||
imageInfo->colorSpace = MapPngColor(png_get_color_type(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->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) {
|
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)) {
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
|
||||||
|
imageInfo->imageFlag |= OrbisPngDecImageFlag::TrnsChunkExist;
|
||||||
imageInfo->imageFlag |= ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/enum.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
@ -11,28 +12,14 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::PngDec {
|
namespace Libraries::PngDec {
|
||||||
|
|
||||||
enum OrbisPngDecColorSpace {
|
enum class OrbisPngDecColorSpace : u16 { Grayscale = 2, Rgb, Clut, GrayscaleAlpha = 18, Rgba };
|
||||||
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 OrbisPngDecImageFlag {
|
enum class OrbisPngDecImageFlag : u32 { None = 0, Adam7Interlace = 1, TrnsChunkExist = 2 };
|
||||||
ORBIS_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE = 1,
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisPngDecImageFlag)
|
||||||
ORBIS_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OrbisPngDecPixelFormat {
|
enum class OrbisPngDecPixelFormat : u16 { R8G8B8A8 = 0, B8G8R8A8 };
|
||||||
ORBIS_PNG_DEC_PIXEL_FORMAT_R8G8B8A8 = 0,
|
|
||||||
ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OrbisPngDecAttribute {
|
enum class OrbisPngDecAttribute { None = 0, BitDepth16 };
|
||||||
ORBIS_PNG_DEC_ATTRIBUTE_NONE = 0,
|
|
||||||
ORBIS_PNG_DEC_ATTRIBUTE_BIT_DEPTH_16
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisPngDecParseParam {
|
struct OrbisPngDecParseParam {
|
||||||
const void* pngMemAddr;
|
const void* pngMemAddr;
|
||||||
@ -43,9 +30,9 @@ struct OrbisPngDecParseParam {
|
|||||||
struct OrbisPngDecImageInfo {
|
struct OrbisPngDecImageInfo {
|
||||||
u32 imageWidth;
|
u32 imageWidth;
|
||||||
u32 imageHeight;
|
u32 imageHeight;
|
||||||
u16 colorSpace;
|
OrbisPngDecColorSpace colorSpace;
|
||||||
u16 bitDepth;
|
u16 bitDepth;
|
||||||
u32 imageFlag;
|
OrbisPngDecImageFlag imageFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisPngDecCreateParam {
|
struct OrbisPngDecCreateParam {
|
||||||
@ -54,14 +41,14 @@ struct OrbisPngDecCreateParam {
|
|||||||
u32 maxImageWidth;
|
u32 maxImageWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void* OrbisPngDecHandle;
|
using OrbisPngDecHandle = void*;
|
||||||
|
|
||||||
struct OrbisPngDecDecodeParam {
|
struct OrbisPngDecDecodeParam {
|
||||||
const void* pngMemAddr;
|
const void* pngMemAddr;
|
||||||
void* imageMemAddr;
|
void* imageMemAddr;
|
||||||
u32 pngMemSize;
|
u32 pngMemSize;
|
||||||
u32 imageMemSize;
|
u32 imageMemSize;
|
||||||
u16 pixelFormat;
|
OrbisPngDecPixelFormat pixelFormat;
|
||||||
u16 alphaValue;
|
u16 alphaValue;
|
||||||
u32 imagePitch;
|
u32 imagePitch;
|
||||||
};
|
};
|
||||||
|
@ -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_AUTH_NAME_LEN = 127 + 1;
|
||||||
constexpr int ORBIS_NET_CTL_IPV4_ADDR_STR_LEN = 16;
|
constexpr int ORBIS_NET_CTL_IPV4_ADDR_STR_LEN = 16;
|
||||||
|
|
||||||
typedef union OrbisNetCtlInfo {
|
union OrbisNetCtlInfo {
|
||||||
u32 device;
|
u32 device;
|
||||||
OrbisNetEtherAddr ether_addr;
|
OrbisNetEtherAddr ether_addr;
|
||||||
u32 mtu;
|
u32 mtu;
|
||||||
@ -45,7 +45,7 @@ typedef union OrbisNetCtlInfo {
|
|||||||
u32 http_proxy_config;
|
u32 http_proxy_config;
|
||||||
char http_proxy_server[ORBIS_NET_CTL_HOSTNAME_LEN];
|
char http_proxy_server[ORBIS_NET_CTL_HOSTNAME_LEN];
|
||||||
u16 http_proxy_port;
|
u16 http_proxy_port;
|
||||||
} SceNetCtlInfo;
|
};
|
||||||
|
|
||||||
// GetInfo codes
|
// GetInfo codes
|
||||||
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;
|
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;
|
||||||
|
@ -971,12 +971,11 @@ int PS4_SYSV_ABI sceNpGetGamePresenceStatusA() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId userId, OrbisNpId* npId) {
|
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId user_id, OrbisNpId* np_id) {
|
||||||
LOG_INFO(Lib_NpManager, "userId {}", userId);
|
LOG_INFO(Lib_NpManager, "user_id {}", user_id);
|
||||||
std::string name = Config::getUserName();
|
const auto name = Config::getUserName();
|
||||||
// Fill the unused stuffs to 0
|
std::memset(np_id, 0, sizeof(OrbisNpId));
|
||||||
memset(npId, 0, sizeof(*npId));
|
name.copy(np_id->handle.data, sizeof(np_id->handle.data));
|
||||||
strcpy(npId->handle.data, name.c_str());
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,12 +984,11 @@ int PS4_SYSV_ABI sceNpGetNpReachabilityState() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpGetOnlineId(s32 userId, OrbisNpOnlineId* onlineId) {
|
int PS4_SYSV_ABI sceNpGetOnlineId(s32 user_id, OrbisNpOnlineId* online_id) {
|
||||||
LOG_DEBUG(Lib_NpManager, "userId {}", userId);
|
LOG_DEBUG(Lib_NpManager, "user_id {}", user_id);
|
||||||
std::string name = Config::getUserName();
|
const auto name = Config::getUserName();
|
||||||
// Fill the unused stuffs to 0
|
std::memset(online_id, 0, sizeof(OrbisNpOnlineId));
|
||||||
memset(onlineId, 0, sizeof(*onlineId));
|
name.copy(online_id->data, sizeof(online_id->data));
|
||||||
strcpy(onlineId->data, name.c_str());
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,7 +1003,7 @@ int PS4_SYSV_ABI sceNpGetParentalControlInfoA() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state) {
|
int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state) {
|
||||||
*state = ORBIS_NP_STATE_SIGNED_OUT;
|
*state = OrbisNpState::SignedOut;
|
||||||
LOG_DEBUG(Lib_NpManager, "Signed out");
|
LOG_DEBUG(Lib_NpManager, "Signed out");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -2518,7 +2516,7 @@ struct NpStateCallbackForNpToolkit {
|
|||||||
NpStateCallbackForNpToolkit NpStateCbForNp;
|
NpStateCallbackForNpToolkit NpStateCbForNp;
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpCheckCallbackForLib() {
|
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;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,18 +13,14 @@ namespace Libraries::NpManager {
|
|||||||
|
|
||||||
constexpr int ORBIS_NP_ERROR_SIGNED_OUT = 0x80550006;
|
constexpr int ORBIS_NP_ERROR_SIGNED_OUT = 0x80550006;
|
||||||
|
|
||||||
enum OrbisNpState {
|
enum class OrbisNpState : u32 { Unknown = 0, SignedOut, SignedIn };
|
||||||
ORBIS_NP_STATE_UNKNOWN = 0,
|
|
||||||
ORBIS_NP_STATE_SIGNED_OUT,
|
|
||||||
ORBIS_NP_STATE_SIGNED_IN
|
|
||||||
};
|
|
||||||
|
|
||||||
using OrbisNpStateCallbackForNpToolkit = PS4_SYSV_ABI void (*)(s32 userId, OrbisNpState state,
|
using OrbisNpStateCallbackForNpToolkit = PS4_SYSV_ABI void (*)(s32 userId, OrbisNpState state,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
|
||||||
constexpr int ORBIS_NP_ONLINEID_MAX_LENGTH = 16;
|
constexpr int ORBIS_NP_ONLINEID_MAX_LENGTH = 16;
|
||||||
|
|
||||||
typedef int OrbisUserServiceUserId;
|
using OrbisUserServiceUserId = s32;
|
||||||
|
|
||||||
struct OrbisNpOnlineId {
|
struct OrbisNpOnlineId {
|
||||||
char data[ORBIS_NP_ONLINEID_MAX_LENGTH];
|
char data[ORBIS_NP_ONLINEID_MAX_LENGTH];
|
||||||
|
@ -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_CONTEXT = -1;
|
||||||
constexpr int ORBIS_NP_TROPHY_INVALID_TROPHY_ID = -1;
|
constexpr int ORBIS_NP_TROPHY_INVALID_TROPHY_ID = -1;
|
||||||
|
|
||||||
typedef int32_t OrbisNpTrophyHandle;
|
using OrbisNpTrophyHandle = s32;
|
||||||
typedef int32_t OrbisNpTrophyContext;
|
using OrbisNpTrophyContext = s32;
|
||||||
typedef int32_t OrbisNpTrophyId;
|
using OrbisNpTrophyId = s32;
|
||||||
typedef uint32_t OrbisNpTrophyFlagMask;
|
using OrbisNpTrophyFlagMask = u32;
|
||||||
|
|
||||||
struct OrbisNpTrophyFlagArray {
|
struct OrbisNpTrophyFlagArray {
|
||||||
OrbisNpTrophyFlagMask
|
static constexpr int NumMasks = ORBIS_NP_TROPHY_FLAG_SETSIZE >> ORBIS_NP_TROPHY_FLAG_BITS_SHIFT;
|
||||||
flag_bits[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);
|
void ORBIS_NP_TROPHY_FLAG_ZERO(OrbisNpTrophyFlagArray* p);
|
||||||
@ -49,18 +49,18 @@ struct OrbisNpTrophyData {
|
|||||||
size_t size;
|
size_t size;
|
||||||
OrbisNpTrophyId trophy_id;
|
OrbisNpTrophyId trophy_id;
|
||||||
bool unlocked;
|
bool unlocked;
|
||||||
uint8_t reserved[3];
|
u8 reserved[3];
|
||||||
Rtc::OrbisRtcTick timestamp;
|
Rtc::OrbisRtcTick timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int32_t OrbisNpTrophyGrade;
|
using OrbisNpTrophyGrade = s32;
|
||||||
constexpr int ORBIS_NP_TROPHY_GRADE_UNKNOWN = 0;
|
constexpr int ORBIS_NP_TROPHY_GRADE_UNKNOWN = 0;
|
||||||
constexpr int ORBIS_NP_TROPHY_GRADE_PLATINUM = 1;
|
constexpr int ORBIS_NP_TROPHY_GRADE_PLATINUM = 1;
|
||||||
constexpr int ORBIS_NP_TROPHY_GRADE_GOLD = 2;
|
constexpr int ORBIS_NP_TROPHY_GRADE_GOLD = 2;
|
||||||
constexpr int ORBIS_NP_TROPHY_GRADE_SILVER = 3;
|
constexpr int ORBIS_NP_TROPHY_GRADE_SILVER = 3;
|
||||||
constexpr int ORBIS_NP_TROPHY_GRADE_BRONZE = 4;
|
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_BASE_GAME_GROUP_ID = -1;
|
||||||
constexpr int ORBIS_NP_TROPHY_INVALID_GROUP_ID = -2;
|
constexpr int ORBIS_NP_TROPHY_INVALID_GROUP_ID = -2;
|
||||||
|
|
||||||
@ -70,29 +70,29 @@ struct OrbisNpTrophyDetails {
|
|||||||
OrbisNpTrophyGrade trophy_grade;
|
OrbisNpTrophyGrade trophy_grade;
|
||||||
OrbisNpTrophyGroupId group_id;
|
OrbisNpTrophyGroupId group_id;
|
||||||
bool hidden;
|
bool hidden;
|
||||||
uint8_t reserved[3];
|
u8 reserved[3];
|
||||||
char name[ORBIS_NP_TROPHY_NAME_MAX_SIZE];
|
char name[ORBIS_NP_TROPHY_NAME_MAX_SIZE];
|
||||||
char description[ORBIS_NP_TROPHY_DESCR_MAX_SIZE];
|
char description[ORBIS_NP_TROPHY_DESCR_MAX_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisNpTrophyGameData {
|
struct OrbisNpTrophyGameData {
|
||||||
size_t size;
|
size_t size;
|
||||||
uint32_t unlocked_trophies;
|
u32 unlocked_trophies;
|
||||||
uint32_t unlocked_platinum;
|
u32 unlocked_platinum;
|
||||||
uint32_t unlocked_gold;
|
u32 unlocked_gold;
|
||||||
uint32_t unlocked_silver;
|
u32 unlocked_silver;
|
||||||
uint32_t unlocked_bronze;
|
u32 unlocked_bronze;
|
||||||
uint32_t progress_percentage;
|
u32 progress_percentage;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisNpTrophyGameDetails {
|
struct OrbisNpTrophyGameDetails {
|
||||||
size_t size;
|
size_t size;
|
||||||
uint32_t num_groups;
|
u32 num_groups;
|
||||||
uint32_t num_trophies;
|
u32 num_trophies;
|
||||||
uint32_t num_platinum;
|
u32 num_platinum;
|
||||||
uint32_t num_gold;
|
u32 num_gold;
|
||||||
uint32_t num_silver;
|
u32 num_silver;
|
||||||
uint32_t num_bronze;
|
u32 num_bronze;
|
||||||
char title[ORBIS_NP_TROPHY_GAME_TITLE_MAX_SIZE];
|
char title[ORBIS_NP_TROPHY_GAME_TITLE_MAX_SIZE];
|
||||||
char description[ORBIS_NP_TROPHY_GAME_DESCR_MAX_SIZE];
|
char description[ORBIS_NP_TROPHY_GAME_DESCR_MAX_SIZE];
|
||||||
};
|
};
|
||||||
@ -100,23 +100,23 @@ struct OrbisNpTrophyGameDetails {
|
|||||||
struct OrbisNpTrophyGroupData {
|
struct OrbisNpTrophyGroupData {
|
||||||
size_t size;
|
size_t size;
|
||||||
OrbisNpTrophyGroupId group_id;
|
OrbisNpTrophyGroupId group_id;
|
||||||
uint32_t unlocked_trophies;
|
u32 unlocked_trophies;
|
||||||
uint32_t unlocked_platinum;
|
u32 unlocked_platinum;
|
||||||
uint32_t unlocked_gold;
|
u32 unlocked_gold;
|
||||||
uint32_t unlocked_silver;
|
u32 unlocked_silver;
|
||||||
uint32_t unlocked_bronze;
|
u32 unlocked_bronze;
|
||||||
uint32_t progress_percentage;
|
u32 progress_percentage;
|
||||||
uint8_t reserved[4];
|
uint8_t reserved[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisNpTrophyGroupDetails {
|
struct OrbisNpTrophyGroupDetails {
|
||||||
size_t size;
|
size_t size;
|
||||||
OrbisNpTrophyGroupId group_id;
|
OrbisNpTrophyGroupId group_id;
|
||||||
uint32_t num_trophies;
|
u32 num_trophies;
|
||||||
uint32_t num_platinum;
|
u32 num_platinum;
|
||||||
uint32_t num_gold;
|
u32 num_gold;
|
||||||
uint32_t num_silver;
|
u32 num_silver;
|
||||||
uint32_t num_bronze;
|
u32 num_bronze;
|
||||||
char title[ORBIS_NP_TROPHY_GROUP_TITLE_MAX_SIZE];
|
char title[ORBIS_NP_TROPHY_GROUP_TITLE_MAX_SIZE];
|
||||||
char description[ORBIS_NP_TROPHY_GROUP_DESCR_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 sceNpTrophyConfigGetTrophyTitleDetails();
|
||||||
int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature();
|
int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature();
|
||||||
s32 PS4_SYSV_ABI sceNpTrophyCreateContext(OrbisNpTrophyContext* context, int32_t user_id,
|
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);
|
s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(OrbisNpTrophyHandle* handle);
|
||||||
int PS4_SYSV_ABI sceNpTrophyDestroyContext(OrbisNpTrophyContext context);
|
int PS4_SYSV_ABI sceNpTrophyDestroyContext(OrbisNpTrophyContext context);
|
||||||
s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(OrbisNpTrophyHandle handle);
|
s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(OrbisNpTrophyHandle handle);
|
||||||
|
@ -98,7 +98,7 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
|
|||||||
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
|
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
|
||||||
pInfo->connectedCount = 1;
|
pInfo->connectedCount = 1;
|
||||||
pInfo->connected = false;
|
pInfo->connected = false;
|
||||||
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
|
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
pInfo->touchPadInfo.pixelDensity = 1;
|
pInfo->touchPadInfo.pixelDensity = 1;
|
||||||
@ -109,7 +109,7 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
|
|||||||
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
|
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
|
||||||
pInfo->connectedCount = 1;
|
pInfo->connectedCount = 1;
|
||||||
pInfo->connected = true;
|
pInfo->connected = true;
|
||||||
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
|
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
|
||||||
if (Config::getUseSpecialPad()) {
|
if (Config::getUseSpecialPad()) {
|
||||||
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
|
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
|
||||||
pInfo->deviceClass = (OrbisPadDeviceClass)Config::getSpecialPadClass();
|
pInfo->deviceClass = (OrbisPadDeviceClass)Config::getSpecialPadClass();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/enum.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Loader {
|
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_SPECIAL = 2;
|
||||||
constexpr int ORBIS_PAD_PORT_TYPE_REMOTE_CONTROL = 16;
|
constexpr int ORBIS_PAD_PORT_TYPE_REMOTE_CONTROL = 16;
|
||||||
|
|
||||||
enum OrbisPadDeviceClass {
|
enum class OrbisPadDeviceClass {
|
||||||
ORBIS_PAD_DEVICE_CLASS_INVALID = -1,
|
Invalid = -1,
|
||||||
ORBIS_PAD_DEVICE_CLASS_STANDARD = 0,
|
Standard = 0,
|
||||||
ORBIS_PAD_DEVICE_CLASS_GUITAR = 1,
|
Guitar = 1,
|
||||||
ORBIS_PAD_DEVICE_CLASS_DRUM = 2,
|
Drum = 2,
|
||||||
ORBIS_PAD_DEVICE_CLASS_DJ_TURNTABLE = 3,
|
DjTurntable = 3,
|
||||||
ORBIS_PAD_DEVICE_CLASS_DANCEMAT = 4,
|
Dancemat = 4,
|
||||||
ORBIS_PAD_DEVICE_CLASS_NAVIGATION = 5,
|
Navigation = 5,
|
||||||
ORBIS_PAD_DEVICE_CLASS_STEERING_WHEEL = 6,
|
SteeringWheel = 6,
|
||||||
ORBIS_PAD_DEVICE_CLASS_STICK = 7,
|
Stick = 7,
|
||||||
ORBIS_PAD_DEVICE_CLASS_FLIGHT_STICK = 8,
|
FightStick = 8,
|
||||||
ORBIS_PAD_DEVICE_CLASS_GUN = 9,
|
Gun = 9,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisPadDeviceClassExtendedInformation {
|
struct OrbisPadDeviceClassExtendedInformation {
|
||||||
@ -123,25 +124,27 @@ struct OrbisPadAnalogStick {
|
|||||||
u8 y;
|
u8 y;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisPadButtonDataOffset {
|
enum class OrbisPadButtonDataOffset : u32 {
|
||||||
ORBIS_PAD_BUTTON_L3 = 0x00000002,
|
None = 0,
|
||||||
ORBIS_PAD_BUTTON_R3 = 0x00000004,
|
L3 = 0x2,
|
||||||
ORBIS_PAD_BUTTON_OPTIONS = 0x00000008,
|
R3 = 0x4,
|
||||||
ORBIS_PAD_BUTTON_UP = 0x00000010,
|
Options = 0x8,
|
||||||
ORBIS_PAD_BUTTON_RIGHT = 0x00000020,
|
Up = 0x10,
|
||||||
ORBIS_PAD_BUTTON_DOWN = 0x00000040,
|
Right = 0x20,
|
||||||
ORBIS_PAD_BUTTON_LEFT = 0x00000080,
|
Down = 0x40,
|
||||||
ORBIS_PAD_BUTTON_L2 = 0x00000100,
|
Left = 0x80,
|
||||||
ORBIS_PAD_BUTTON_R2 = 0x00000200,
|
L2 = 0x100,
|
||||||
ORBIS_PAD_BUTTON_L1 = 0x00000400,
|
R2 = 0x200,
|
||||||
ORBIS_PAD_BUTTON_R1 = 0x00000800,
|
L1 = 0x400,
|
||||||
ORBIS_PAD_BUTTON_TRIANGLE = 0x00001000,
|
R1 = 0x800,
|
||||||
ORBIS_PAD_BUTTON_CIRCLE = 0x00002000,
|
Triangle = 0x1000,
|
||||||
ORBIS_PAD_BUTTON_CROSS = 0x00004000,
|
Circle = 0x2000,
|
||||||
ORBIS_PAD_BUTTON_SQUARE = 0x00008000,
|
Cross = 0x4000,
|
||||||
ORBIS_PAD_BUTTON_TOUCH_PAD = 0x00100000,
|
Square = 0x8000,
|
||||||
ORBIS_PAD_BUTTON_INTERCEPTED = 0x80000000,
|
TouchPad = 0x100000,
|
||||||
|
Intercepted = 0x80000000,
|
||||||
};
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OrbisPadButtonDataOffset)
|
||||||
|
|
||||||
struct OrbisFQuaternion {
|
struct OrbisFQuaternion {
|
||||||
float x, y, z, w;
|
float x, y, z, w;
|
||||||
@ -173,7 +176,7 @@ struct OrbisPadExtensionUnitData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisPadData {
|
struct OrbisPadData {
|
||||||
u32 buttons;
|
OrbisPadButtonDataOffset buttons;
|
||||||
OrbisPadAnalogStick leftStick;
|
OrbisPadAnalogStick leftStick;
|
||||||
OrbisPadAnalogStick rightStick;
|
OrbisPadAnalogStick rightStick;
|
||||||
OrbisPadAnalogButtons analogButtons;
|
OrbisPadAnalogButtons analogButtons;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/singleton.h"
|
|
||||||
#include "core/file_format/playgo_chunk.h"
|
#include "core/file_format/playgo_chunk.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
@ -11,6 +10,9 @@
|
|||||||
|
|
||||||
namespace Libraries::PlayGo {
|
namespace Libraries::PlayGo {
|
||||||
|
|
||||||
|
static constexpr OrbisPlayGoHandle PlaygoHandle = 1;
|
||||||
|
static std::unique_ptr<PlaygoFile> playgo;
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceDbgPlayGoRequestNextChunk() {
|
s32 PS4_SYSV_ABI sceDbgPlayGoRequestNextChunk() {
|
||||||
LOG_ERROR(Lib_PlayGo, "(STUBBED)called");
|
LOG_ERROR(Lib_PlayGo, "(STUBBED)called");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -24,57 +26,63 @@ s32 PS4_SYSV_ABI sceDbgPlayGoSnapshot() {
|
|||||||
s32 PS4_SYSV_ABI scePlayGoClose(OrbisPlayGoHandle handle) {
|
s32 PS4_SYSV_ABI scePlayGoClose(OrbisPlayGoHandle handle) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
playgo.reset();
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePlayGoGetChunkId(OrbisPlayGoHandle handle, OrbisPlayGoChunkId* outChunkIdList,
|
s32 PS4_SYSV_ABI scePlayGoGetChunkId(OrbisPlayGoHandle handle, OrbisPlayGoChunkId* outChunkIdList,
|
||||||
u32 numberOfEntries, u32* outEntries) {
|
u32 numberOfEntries, u32* outEntries) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
|
||||||
|
|
||||||
if (handle != 1)
|
if (handle != PlaygoHandle) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (outEntries == nullptr)
|
}
|
||||||
|
if (outEntries == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (outChunkIdList != nullptr && numberOfEntries == 0)
|
}
|
||||||
|
if (outChunkIdList != nullptr && numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
if (playgo->GetPlaygoHeader().file_size == 0) {
|
if (playgo->GetPlaygoHeader().file_size == 0) {
|
||||||
*outEntries = 0;
|
*outEntries = 0;
|
||||||
} else {
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (outChunkIdList == nullptr) {
|
if (outChunkIdList == nullptr) {
|
||||||
*outEntries = playgo->chunks.size();
|
*outEntries = playgo->chunks.size();
|
||||||
} else {
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (numberOfEntries > playgo->chunks.size()) {
|
if (numberOfEntries > playgo->chunks.size()) {
|
||||||
numberOfEntries = playgo->chunks.size();
|
numberOfEntries = playgo->chunks.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numberOfEntries != 0) {
|
|
||||||
for (u32 i = 0; i < numberOfEntries; i++) {
|
for (u32 i = 0; i < numberOfEntries; i++) {
|
||||||
outChunkIdList[i] = i;
|
outChunkIdList[i] = i;
|
||||||
}
|
}
|
||||||
*outEntries = numberOfEntries;
|
*outEntries = numberOfEntries;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePlayGoGetEta(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds,
|
s32 PS4_SYSV_ABI scePlayGoGetEta(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds,
|
||||||
u32 numberOfEntries, OrbisPlayGoEta* outEta) {
|
u32 numberOfEntries, OrbisPlayGoEta* outEta) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
if (handle != 1)
|
if (handle != PlaygoHandle) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (chunkIds == nullptr || outEta == nullptr)
|
}
|
||||||
|
if (chunkIds == nullptr || outEta == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (numberOfEntries == 0)
|
}
|
||||||
|
if (numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
*outEta = 0; // all is loaded
|
*outEta = 0; // all is loaded
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -84,22 +92,23 @@ s32 PS4_SYSV_ABI scePlayGoGetInstallSpeed(OrbisPlayGoHandle handle,
|
|||||||
OrbisPlayGoInstallSpeed* outSpeed) {
|
OrbisPlayGoInstallSpeed* outSpeed) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (outSpeed == nullptr)
|
}
|
||||||
|
if (outSpeed == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
std::scoped_lock lk{playgo->GetSpeedMutex()};
|
std::scoped_lock lk{playgo->GetSpeedMutex()};
|
||||||
|
|
||||||
if (playgo->speed == 0) {
|
if (playgo->speed == OrbisPlayGoInstallSpeed::Suspended) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
if ((duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count() -
|
if ((duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count() -
|
||||||
playgo->speed_tick) > 30 * 1000) { // 30sec
|
playgo->speed_tick) > 30 * 1000) { // 30sec
|
||||||
playgo->speed = ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE;
|
playgo->speed = OrbisPlayGoInstallSpeed::Trickle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*outSpeed = playgo->speed;
|
*outSpeed = playgo->speed;
|
||||||
@ -111,14 +120,15 @@ s32 PS4_SYSV_ABI scePlayGoGetLanguageMask(OrbisPlayGoHandle handle,
|
|||||||
OrbisPlayGoLanguageMask* outLanguageMask) {
|
OrbisPlayGoLanguageMask* outLanguageMask) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (outLanguageMask == nullptr)
|
}
|
||||||
|
if (outLanguageMask == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
*outLanguageMask = playgo->langMask;
|
*outLanguageMask = playgo->langMask;
|
||||||
return ORBIS_OK;
|
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,
|
LOG_INFO(Lib_PlayGo, "called handle = {}, chunkIds = {}, numberOfEntries = {}", handle,
|
||||||
*chunkIds, numberOfEntries);
|
*chunkIds, numberOfEntries);
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (chunkIds == nullptr || outLoci == nullptr)
|
}
|
||||||
|
if (chunkIds == nullptr || outLoci == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (numberOfEntries == 0)
|
}
|
||||||
|
if (numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_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;
|
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()) {
|
if (chunkIds[i] <= playgo->chunks.size()) {
|
||||||
outLoci[i] = OrbisPlayGoLocusValue::ORBIS_PLAYGO_LOCUS_LOCAL_FAST;
|
outLoci[i] = OrbisPlayGoLocus::LocalFast;
|
||||||
} else {
|
} else {
|
||||||
outLoci[i] = ORBIS_PLAYGO_LOCUS_NOT_DOWNLOADED;
|
outLoci[i] = OrbisPlayGoLocus::NotDownloaded;
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_CHUNK_ID;
|
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,
|
LOG_INFO(Lib_PlayGo, "called handle = {}, chunkIds = {}, numberOfEntries = {}", handle,
|
||||||
*chunkIds, numberOfEntries);
|
*chunkIds, numberOfEntries);
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (chunkIds == nullptr || outProgress == nullptr)
|
}
|
||||||
|
if (chunkIds == nullptr || outProgress == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (numberOfEntries == 0)
|
}
|
||||||
|
if (numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_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;
|
return ORBIS_PLAYGO_ERROR_BAD_CHUNK_ID;
|
||||||
|
}
|
||||||
|
|
||||||
outProgress->progressSize = 0;
|
outProgress->progressSize = 0;
|
||||||
outProgress->totalSize = 0;
|
outProgress->totalSize = 0;
|
||||||
@ -194,16 +210,18 @@ s32 PS4_SYSV_ABI scePlayGoGetToDoList(OrbisPlayGoHandle handle, OrbisPlayGoToDo*
|
|||||||
u32 numberOfEntries, u32* outEntries) {
|
u32 numberOfEntries, u32* outEntries) {
|
||||||
LOG_INFO(Lib_PlayGo, "called handle = {} numberOfEntries = {}", handle, numberOfEntries);
|
LOG_INFO(Lib_PlayGo, "called handle = {} numberOfEntries = {}", handle, numberOfEntries);
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (outTodoList == nullptr || outEntries == nullptr)
|
}
|
||||||
|
if (outTodoList == nullptr || outEntries == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (numberOfEntries == 0)
|
}
|
||||||
|
if (numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
*outEntries = 0; // nothing to do
|
*outEntries = 0; // nothing to do
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -218,19 +236,19 @@ int scePlayGoConvertLanguage(int systemLang) {
|
|||||||
|
|
||||||
s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) {
|
s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) {
|
||||||
LOG_INFO(Lib_PlayGo, "called, bufSize = {}", param->bufSize);
|
LOG_INFO(Lib_PlayGo, "called, bufSize = {}", param->bufSize);
|
||||||
if (param->bufAddr == nullptr)
|
if (param->bufAddr == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (param->bufSize < 0x200000)
|
}
|
||||||
|
if (param->bufSize < 0x200000) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
playgo = std::make_unique<PlaygoFile>();
|
||||||
|
|
||||||
if (!playgo->initialized) {
|
if (!playgo->initialized) {
|
||||||
using namespace SystemService;
|
using namespace SystemService;
|
||||||
// get system lang
|
s32 system_lang = 0;
|
||||||
int systemLang = 0;
|
sceSystemServiceParamGetInt(OrbisSystemServiceParamId::Lang, &system_lang);
|
||||||
sceSystemServiceParamGetInt(ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG, &systemLang);
|
playgo->langMask = scePlayGoConvertLanguage(system_lang);
|
||||||
playgo->langMask = scePlayGoConvertLanguage(systemLang);
|
|
||||||
playgo->initialized = true;
|
playgo->initialized = true;
|
||||||
} else {
|
} else {
|
||||||
return ORBIS_PLAYGO_ERROR_ALREADY_INITIALIZED;
|
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) {
|
s32 PS4_SYSV_ABI scePlayGoOpen(OrbisPlayGoHandle* outHandle, const void* param) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (outHandle == nullptr) {
|
||||||
|
|
||||||
if (outHandle == nullptr)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (param)
|
}
|
||||||
|
if (param) {
|
||||||
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
|
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_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;
|
return ORBIS_PLAYGO_ERROR_NOT_SUPPORT_PLAYGO;
|
||||||
|
}
|
||||||
|
|
||||||
playgo->handle = *outHandle = 1;
|
playgo->handle = *outHandle = PlaygoHandle;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,21 +280,23 @@ s32 PS4_SYSV_ABI scePlayGoPrefetch(OrbisPlayGoHandle handle, const OrbisPlayGoCh
|
|||||||
u32 numberOfEntries, OrbisPlayGoLocus minimumLocus) {
|
u32 numberOfEntries, OrbisPlayGoLocus minimumLocus) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (chunkIds == nullptr)
|
}
|
||||||
|
if (chunkIds == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (numberOfEntries == 0)
|
}
|
||||||
|
if (numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
switch (minimumLocus) {
|
switch (minimumLocus) {
|
||||||
case ORBIS_PLAYGO_LOCUS_NOT_DOWNLOADED:
|
case OrbisPlayGoLocus::NotDownloaded:
|
||||||
case ORBIS_PLAYGO_LOCUS_LOCAL_SLOW:
|
case OrbisPlayGoLocus::LocalSlow:
|
||||||
case ORBIS_PLAYGO_LOCUS_LOCAL_FAST:
|
case OrbisPlayGoLocus::LocalFast:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_LOCUS;
|
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) {
|
s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(OrbisPlayGoHandle handle, OrbisPlayGoInstallSpeed speed) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
switch (speed) {
|
switch (speed) {
|
||||||
case ORBIS_PLAYGO_INSTALL_SPEED_SUSPENDED:
|
case OrbisPlayGoInstallSpeed::Suspended:
|
||||||
case ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE:
|
case OrbisPlayGoInstallSpeed::Trickle:
|
||||||
case ORBIS_PLAYGO_INSTALL_SPEED_FULL:
|
case OrbisPlayGoInstallSpeed::Full:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
|
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::scoped_lock lk{playgo->GetSpeedMutex()};
|
std::scoped_lock lk{playgo->GetSpeedMutex()};
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
playgo->speed = speed;
|
playgo->speed = speed;
|
||||||
playgo->speed_tick =
|
playgo->speed_tick =
|
||||||
@ -314,12 +335,13 @@ s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(OrbisPlayGoHandle handle, OrbisPlayGoI
|
|||||||
s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle,
|
s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle,
|
||||||
OrbisPlayGoLanguageMask languageMask) {
|
OrbisPlayGoLanguageMask languageMask) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
|
||||||
|
|
||||||
if (handle != 1)
|
if (handle != 1) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
playgo->langMask = languageMask;
|
playgo->langMask = languageMask;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -329,23 +351,24 @@ s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayG
|
|||||||
uint32_t numberOfEntries) {
|
uint32_t numberOfEntries) {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
if (handle != PlaygoHandle) {
|
||||||
|
|
||||||
if (handle != 1)
|
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
|
||||||
if (todoList == nullptr)
|
}
|
||||||
|
if (todoList == nullptr) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
|
||||||
if (numberOfEntries == 0)
|
}
|
||||||
|
if (numberOfEntries == 0) {
|
||||||
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
|
||||||
if (!playgo->initialized)
|
}
|
||||||
|
if (!playgo->initialized) {
|
||||||
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePlayGoTerminate() {
|
s32 PS4_SYSV_ABI scePlayGoTerminate() {
|
||||||
LOG_INFO(Lib_PlayGo, "called");
|
LOG_INFO(Lib_PlayGo, "called");
|
||||||
|
|
||||||
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
|
|
||||||
if (playgo->initialized) {
|
if (playgo->initialized) {
|
||||||
playgo->initialized = false;
|
playgo->initialized = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,41 +5,39 @@
|
|||||||
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
typedef u32 OrbisPlayGoHandle;
|
using OrbisPlayGoHandle = u32;
|
||||||
typedef u16 OrbisPlayGoChunkId;
|
using OrbisPlayGoChunkId = u16;
|
||||||
typedef s8 OrbisPlayGoLocus;
|
using OrbisPlayGoEta = s64;
|
||||||
typedef s32 OrbisPlayGoInstallSpeed;
|
using OrbisPlayGoLanguageMask = u64;
|
||||||
typedef s64 OrbisPlayGoEta;
|
|
||||||
typedef u64 OrbisPlayGoLanguageMask;
|
|
||||||
|
|
||||||
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;
|
const void* bufAddr;
|
||||||
u32 bufSize;
|
u32 bufSize;
|
||||||
u32 reserved;
|
u32 reserved;
|
||||||
} OrbisPlayGoInitParams;
|
};
|
||||||
|
|
||||||
typedef struct OrbisPlayGoToDo {
|
struct OrbisPlayGoToDo {
|
||||||
OrbisPlayGoChunkId chunkId;
|
OrbisPlayGoChunkId chunkId;
|
||||||
OrbisPlayGoLocus locus;
|
OrbisPlayGoLocus locus;
|
||||||
s8 reserved;
|
s8 reserved;
|
||||||
} OrbisPlayGoToDo;
|
};
|
||||||
|
|
||||||
typedef struct OrbisPlayGoProgress {
|
struct OrbisPlayGoProgress {
|
||||||
uint64_t progressSize;
|
u64 progressSize;
|
||||||
uint64_t totalSize;
|
u64 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;
|
|
||||||
|
|
||||||
constexpr int ORBIS_PLAYGO_ERROR_UNKNOWN = -2135818239; /* 0x80B20001 */
|
constexpr int ORBIS_PLAYGO_ERROR_UNKNOWN = -2135818239; /* 0x80B20001 */
|
||||||
constexpr int ORBIS_PLAYGO_ERROR_FATAL = -2135818238; /* 0x80B20002 */
|
constexpr int ORBIS_PLAYGO_ERROR_FATAL = -2135818238; /* 0x80B20002 */
|
||||||
|
@ -1889,39 +1889,38 @@ int PS4_SYSV_ABI sceSystemServiceNavigateToGoHome() {
|
|||||||
return ORBIS_OK;
|
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
|
// 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) {
|
if (value == nullptr) {
|
||||||
LOG_ERROR(Lib_SystemService, "value is null");
|
LOG_ERROR(Lib_SystemService, "value is null");
|
||||||
return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER;
|
return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER;
|
||||||
}
|
}
|
||||||
switch (param_id) {
|
switch (param_id) {
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG:
|
case OrbisSystemServiceParamId::Lang:
|
||||||
*value = Config::GetLanguage();
|
*value = Config::GetLanguage();
|
||||||
break;
|
break;
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_DATE_FORMAT:
|
case OrbisSystemServiceParamId::DateFormat:
|
||||||
*value = ORBIS_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY;
|
*value = u32(OrbisSystemParamDateFormat::FmtDDMMYYYY);
|
||||||
break;
|
break;
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_FORMAT:
|
case OrbisSystemServiceParamId::TimeFormat:
|
||||||
*value = ORBIS_SYSTEM_PARAM_TIME_FORMAT_24HOUR;
|
*value = u32(OrbisSystemParamTimeFormat::Fmt24Hour);
|
||||||
break;
|
break;
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_ZONE:
|
case OrbisSystemServiceParamId::TimeZone:
|
||||||
*value = +120;
|
*value = +120;
|
||||||
break;
|
break;
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_SUMMERTIME:
|
case OrbisSystemServiceParamId::Summertime:
|
||||||
*value = 1;
|
*value = 1;
|
||||||
break;
|
break;
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_GAME_PARENTAL_LEVEL:
|
case OrbisSystemServiceParamId::GameParentalLevel:
|
||||||
*value = ORBIS_SYSTEM_PARAM_GAME_PARENTAL_OFF;
|
*value = u32(OrbisSystemParamGameParentalLevel::Off);
|
||||||
break;
|
break;
|
||||||
case ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN:
|
case OrbisSystemServiceParamId::EnterButtonAssign:
|
||||||
*value = ORBIS_SYSTEM_PARAM_ENTER_BUTTON_ASSIGN_CROSS;
|
*value = u32(OrbisSystemParamEnterButtonAssign::Cross);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Lib_SystemService, "param_id {} unsupported!",
|
LOG_ERROR(Lib_SystemService, "param_id {} unsupported!", u32(param_id));
|
||||||
param_id); // shouldn't go there but log it
|
*value = 0;
|
||||||
*value = 0; // return a dummy value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
|
@ -12,105 +12,62 @@ class SymbolsResolver;
|
|||||||
|
|
||||||
namespace Libraries::SystemService {
|
namespace Libraries::SystemService {
|
||||||
|
|
||||||
enum OrbisSystemServiceParamId {
|
enum class OrbisSystemServiceParamId {
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG = 1,
|
Lang = 1,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_DATE_FORMAT = 2,
|
DateFormat = 2,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_FORMAT = 3,
|
TimeFormat = 3,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_TIME_ZONE = 4,
|
TimeZone = 4,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_SUMMERTIME = 5,
|
Summertime = 5,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_SYSTEM_NAME = 6,
|
SystemName = 6,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_GAME_PARENTAL_LEVEL = 7,
|
GameParentalLevel = 7,
|
||||||
ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN = 1000
|
EnterButtonAssign = 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisSystemParamDateFormat {
|
enum class OrbisSystemParamDateFormat { FmtYYYYMMDD = 0, FmtDDMMYYYY = 1, FmtMMDDYYYY = 2 };
|
||||||
ORBIS_SYSTEM_PARAM_DATE_FORMAT_YYYYMMDD = 0,
|
|
||||||
ORBIS_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY = 1,
|
enum class OrbisSystemParamTimeFormat { Fmt12Hour = 0, Fmt24Hour = 1 };
|
||||||
ORBIS_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY = 2
|
|
||||||
|
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 {
|
enum class OrbisSystemParamEnterButtonAssign { Circle = 0, Cross = 1 };
|
||||||
ORBIS_SYSTEM_PARAM_TIME_FORMAT_12HOUR = 0,
|
|
||||||
ORBIS_SYSTEM_PARAM_TIME_FORMAT_24HOUR = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OrbisSystemParamGameParentalLevel {
|
enum class OrbisSystemServiceEventType {
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_OFF = 0,
|
Invalid = -1,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL01 = 1,
|
OnResume = 0x10000000,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL02 = 2,
|
GameLiveStreamingStatusUpdate = 0x10000001,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL03 = 3,
|
SessionInvitation = 0x10000002,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL04 = 4,
|
EntitlementUpdate = 0x10000003,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL05 = 5,
|
GameCustomData = 0x10000004,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL06 = 6,
|
DisplaySafeAreaUpdate = 0x10000005,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL07 = 7,
|
UrlOpen = 0x10000006,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL08 = 8,
|
LaunchApp = 0x10000007,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL09 = 9,
|
AppLaunchLink = 0x10000008,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL10 = 10,
|
AddcontentInstall = 0x10000009,
|
||||||
ORBIS_SYSTEM_PARAM_GAME_PARENTAL_LEVEL11 = 11
|
ResetVrPosition = 0x1000000a,
|
||||||
};
|
JoinEvent = 0x1000000b,
|
||||||
|
PlaygoLocusUpdate = 0x1000000c,
|
||||||
enum OrbisSystemParamEnterButtonAssign {
|
PlayTogetherHost = 0x1000000d,
|
||||||
ORBIS_SYSTEM_PARAM_ENTER_BUTTON_ASSIGN_CIRCLE = 0,
|
ServiceEntitlementUpdate = 0x1000000e,
|
||||||
ORBIS_SYSTEM_PARAM_ENTER_BUTTON_ASSIGN_CROSS = 1
|
EyeToEyeDistanceUpdate = 0x1000000f,
|
||||||
};
|
JoinMatchEvent = 0x10000010,
|
||||||
|
PlayTogetherHostA = 0x10000011,
|
||||||
enum OrbisSystemParamLanguage {
|
WebBrowserClosed = 0x10000012,
|
||||||
ORBIS_SYSTEM_PARAM_LANG_JAPANESE = 0,
|
ControllerSettingsClosed = 0x10000013,
|
||||||
ORBIS_SYSTEM_PARAM_LANG_ENGLISH_US = 1,
|
JoinTeamOnTeamMatchEvent = 0x10000014,
|
||||||
ORBIS_SYSTEM_PARAM_LANG_FRENCH = 2,
|
OpenShareMenu = 0x30000000
|
||||||
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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisSystemServiceStatus {
|
struct OrbisSystemServiceStatus {
|
||||||
@ -537,7 +494,7 @@ int PS4_SYSV_ABI sceSystemServiceNavigateToAnotherApp();
|
|||||||
int PS4_SYSV_ABI sceSystemServiceNavigateToGoBack();
|
int PS4_SYSV_ABI sceSystemServiceNavigateToGoBack();
|
||||||
int PS4_SYSV_ABI sceSystemServiceNavigateToGoBackWithValue();
|
int PS4_SYSV_ABI sceSystemServiceNavigateToGoBackWithValue();
|
||||||
int PS4_SYSV_ABI sceSystemServiceNavigateToGoHome();
|
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 sceSystemServiceParamGetString();
|
||||||
int PS4_SYSV_ABI sceSystemServicePowerTick();
|
int PS4_SYSV_ABI sceSystemServicePowerTick();
|
||||||
int PS4_SYSV_ABI sceSystemServiceRaiseExceptionLocalProcess();
|
int PS4_SYSV_ABI sceSystemServiceRaiseExceptionLocalProcess();
|
||||||
|
@ -112,7 +112,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetEvent(OrbisUserServiceEvent* event) {
|
|||||||
|
|
||||||
if (!logged_in) {
|
if (!logged_in) {
|
||||||
logged_in = true;
|
logged_in = true;
|
||||||
event->event = SCE_USER_SERVICE_EVENT_TYPE_LOGIN;
|
event->event = OrbisUserServiceEventType::Login;
|
||||||
event->userId = 1;
|
event->userId = 1;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
@ -1041,14 +1041,14 @@ int PS4_SYSV_ABI sceUserServiceGetTraditionalChineseInputType() {
|
|||||||
return ORBIS_OK;
|
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
|
// TODO fix me better
|
||||||
LOG_INFO(Lib_UserService, "called user_id = {}", user_id);
|
LOG_INFO(Lib_UserService, "called user_id = {}", user_id);
|
||||||
if (color == nullptr) {
|
if (color == nullptr) {
|
||||||
LOG_ERROR(Lib_UserService, "color is null");
|
LOG_ERROR(Lib_UserService, "color is null");
|
||||||
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
*color = ORBIS_USER_SERVICE_USER_COLOR_BLUE;
|
*color = OrbisUserServiceUserColor::Blue;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,16 +40,16 @@ struct OrbisUserServiceRegisteredUserIdList {
|
|||||||
OrbisUserServiceUserId userId[ORBIS_USER_SERVICE_MAX_REGISTER_USERS];
|
OrbisUserServiceUserId userId[ORBIS_USER_SERVICE_MAX_REGISTER_USERS];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisUserServiceUserColor {
|
enum class OrbisUserServiceUserColor {
|
||||||
ORBIS_USER_SERVICE_USER_COLOR_BLUE = 0,
|
Blue = 0,
|
||||||
ORBIS_USER_SERVICE_USER_COLOR_RED = 1,
|
Red = 1,
|
||||||
ORBIS_USER_SERVICE_USER_COLOR_GREEN = 2,
|
Green = 2,
|
||||||
ORBIS_USER_SERVICE_USER_COLOR_PINK = 3,
|
Pink = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OrbisUserServiceEventType {
|
enum class OrbisUserServiceEventType {
|
||||||
SCE_USER_SERVICE_EVENT_TYPE_LOGIN = 0, // Login event
|
Login = 0, // Login event
|
||||||
SCE_USER_SERVICE_EVENT_TYPE_LOGOUT = 1, // Logout event
|
Logout = 1, // Logout event
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisUserServiceEvent {
|
struct OrbisUserServiceEvent {
|
||||||
@ -258,7 +258,7 @@ int PS4_SYSV_ABI sceUserServiceGetTopMenuLimitItem();
|
|||||||
int PS4_SYSV_ABI sceUserServiceGetTopMenuNotificationFlag();
|
int PS4_SYSV_ABI sceUserServiceGetTopMenuNotificationFlag();
|
||||||
int PS4_SYSV_ABI sceUserServiceGetTopMenuTutorialFlag();
|
int PS4_SYSV_ABI sceUserServiceGetTopMenuTutorialFlag();
|
||||||
int PS4_SYSV_ABI sceUserServiceGetTraditionalChineseInputType();
|
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 sceUserServiceGetUserGroupName();
|
||||||
int PS4_SYSV_ABI sceUserServiceGetUserGroupNameList();
|
int PS4_SYSV_ABI sceUserServiceGetUserGroupNameList();
|
||||||
int PS4_SYSV_ABI sceUserServiceGetUserGroupNum();
|
int PS4_SYSV_ABI sceUserServiceGetUserGroupNum();
|
||||||
|
@ -15,7 +15,7 @@ namespace Libraries::Vdec2 {
|
|||||||
class VdecDecoder;
|
class VdecDecoder;
|
||||||
|
|
||||||
using OrbisVideodec2Decoder = VdecDecoder*;
|
using OrbisVideodec2Decoder = VdecDecoder*;
|
||||||
typedef void* OrbisVideodec2ComputeQueue;
|
using OrbisVideodec2ComputeQueue = void*;
|
||||||
|
|
||||||
struct OrbisVideodec2DecoderConfigInfo {
|
struct OrbisVideodec2DecoderConfigInfo {
|
||||||
u64 thisSize;
|
u64 thisSize;
|
||||||
|
@ -257,9 +257,9 @@ void Emulator::Run(const std::filesystem::path& file) {
|
|||||||
|
|
||||||
linker->Execute();
|
linker->Execute();
|
||||||
|
|
||||||
window->initTimers();
|
window->InitTimers();
|
||||||
while (window->isOpen()) {
|
while (window->IsOpen()) {
|
||||||
window->waitEvent();
|
window->WaitEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_QT_GUI
|
#ifdef ENABLE_QT_GUI
|
||||||
|
@ -49,7 +49,7 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
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
|
PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f); // Makes the window edges rounded
|
||||||
|
|
||||||
auto path = config_path.u8string();
|
auto path = config_path.u8string();
|
||||||
@ -83,7 +83,7 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
|
|||||||
StyleColorsDark();
|
StyleColorsDark();
|
||||||
|
|
||||||
::Core::Devtools::Layer::SetupSettings();
|
::Core::Devtools::Layer::SetupSettings();
|
||||||
Sdl::Init(window.GetSdlWindow());
|
Sdl::Init(window.GetSDLWindow());
|
||||||
|
|
||||||
const Vulkan::InitInfo vk_info{
|
const Vulkan::InitInfo vk_info{
|
||||||
.instance = instance.GetInstance(),
|
.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);
|
ImFormatString(label, IM_ARRAYSIZE(label), "WindowOverViewport_%08X", GetMainViewport()->ID);
|
||||||
dock_id = ImHashStr(label);
|
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;
|
GetIO().FontGlobalScale = dpi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "controller.h"
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "core/libraries/kernel/time.h"
|
#include "core/libraries/kernel/time.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
|
#include "input/controller.h"
|
||||||
#include <SDL3/SDL.h>
|
|
||||||
|
|
||||||
namespace Input {
|
namespace Input {
|
||||||
|
|
||||||
@ -59,9 +56,7 @@ State GameController::GetLastState() const {
|
|||||||
if (m_states_num == 0) {
|
if (m_states_num == 0) {
|
||||||
return m_last_state;
|
return m_last_state;
|
||||||
}
|
}
|
||||||
|
const u32 last = (m_first_state + m_states_num - 1) % MAX_STATES;
|
||||||
auto last = (m_first_state + m_states_num - 1) % MAX_STATES;
|
|
||||||
|
|
||||||
return m_states[last];
|
return m_states[last];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,19 +66,19 @@ void GameController::AddState(const State& state) {
|
|||||||
m_first_state = (m_first_state + 1) % MAX_STATES;
|
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_states[index] = state;
|
||||||
m_last_state = state;
|
m_last_state = state;
|
||||||
m_private[index].obtained = false;
|
m_private[index].obtained = false;
|
||||||
m_states_num++;
|
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};
|
std::scoped_lock lock{m_mutex};
|
||||||
auto state = GetLastState();
|
auto state = GetLastState();
|
||||||
state.time = Libraries::Kernel::sceKernelGetProcessTime();
|
state.time = Libraries::Kernel::sceKernelGetProcessTime();
|
||||||
if (isPressed) {
|
if (is_pressed) {
|
||||||
state.buttonsState |= button;
|
state.buttonsState |= button;
|
||||||
} else {
|
} else {
|
||||||
state.buttonsState &= ~button;
|
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) {
|
void GameController::Axis(int id, Input::Axis axis, int value) {
|
||||||
|
using Libraries::Pad::OrbisPadButtonDataOffset;
|
||||||
|
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
auto state = GetLastState();
|
auto state = GetLastState();
|
||||||
|
|
||||||
state.time = Libraries::Kernel::sceKernelGetProcessTime();
|
state.time = Libraries::Kernel::sceKernelGetProcessTime();
|
||||||
|
|
||||||
int axis_id = static_cast<int>(axis);
|
int axis_id = static_cast<int>(axis);
|
||||||
|
|
||||||
state.axes[axis_id] = value;
|
state.axes[axis_id] = value;
|
||||||
|
|
||||||
if (axis == Input::Axis::TriggerLeft) {
|
if (axis == Input::Axis::TriggerLeft) {
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
state.buttonsState |= Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
|
state.buttonsState |= OrbisPadButtonDataOffset::L2;
|
||||||
} else {
|
} else {
|
||||||
state.buttonsState &= ~Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
|
state.buttonsState &= ~OrbisPadButtonDataOffset::L2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axis == Input::Axis::TriggerRight) {
|
if (axis == Input::Axis::TriggerRight) {
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
state.buttonsState |= Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
|
state.buttonsState |= OrbisPadButtonDataOffset::R2;
|
||||||
} else {
|
} else {
|
||||||
state.buttonsState &= ~Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
|
state.buttonsState &= ~OrbisPadButtonDataOffset::R2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
#include "core/libraries/pad/pad.h"
|
||||||
|
|
||||||
struct SDL_Gamepad;
|
struct SDL_Gamepad;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ struct TouchpadEntry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
u32 buttonsState = 0;
|
Libraries::Pad::OrbisPadButtonDataOffset buttonsState{};
|
||||||
u64 time = 0;
|
u64 time = 0;
|
||||||
int axes[static_cast<int>(Axis::AxisMax)] = {128, 128, 128, 128, 0, 0};
|
int axes[static_cast<int>(Axis::AxisMax)] = {128, 128, 128, 128, 0, 0};
|
||||||
TouchpadEntry touchpad[2] = {{false, 0, 0}, {false, 0, 0}};
|
TouchpadEntry touchpad[2] = {{false, 0, 0}, {false, 0, 0}};
|
||||||
@ -49,7 +50,7 @@ public:
|
|||||||
void ReadState(State* state, bool* isConnected, int* connectedCount);
|
void ReadState(State* state, bool* isConnected, int* connectedCount);
|
||||||
int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount);
|
int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount);
|
||||||
State GetLastState() const;
|
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 AddState(const State& state);
|
||||||
void Axis(int id, Input::Axis axis, int value);
|
void Axis(int id, Input::Axis axis, int value);
|
||||||
void SetLightBarRGB(u8 r, u8 g, u8 b);
|
void SetLightBarRGB(u8 r, u8 g, u8 b);
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#include <SDL3/SDL_properties.h>
|
#include <SDL3/SDL_properties.h>
|
||||||
#include <SDL3/SDL_timer.h>
|
#include <SDL3/SDL_timer.h>
|
||||||
#include <SDL3/SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/version.h"
|
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
#include "imgui/renderer/imgui_core.h"
|
#include "imgui/renderer/imgui_core.h"
|
||||||
#include "input/controller.h"
|
#include "input/controller.h"
|
||||||
@ -21,6 +21,45 @@
|
|||||||
|
|
||||||
namespace Frontend {
|
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) {
|
static Uint32 SDLCALL PollController(void* userdata, SDL_TimerID timer_id, Uint32 interval) {
|
||||||
auto* controller = reinterpret_cast<Input::GameController*>(userdata);
|
auto* controller = reinterpret_cast<Input::GameController*>(userdata);
|
||||||
return controller->Poll();
|
return controller->Poll();
|
||||||
@ -80,7 +119,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
|
|||||||
|
|
||||||
WindowSDL::~WindowSDL() = default;
|
WindowSDL::~WindowSDL() = default;
|
||||||
|
|
||||||
void WindowSDL::waitEvent() {
|
void WindowSDL::WaitEvent() {
|
||||||
// Called on main thread
|
// Called on main thread
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
@ -96,16 +135,16 @@ void WindowSDL::waitEvent() {
|
|||||||
case SDL_EVENT_WINDOW_RESIZED:
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
case SDL_EVENT_WINDOW_MAXIMIZED:
|
case SDL_EVENT_WINDOW_MAXIMIZED:
|
||||||
case SDL_EVENT_WINDOW_RESTORED:
|
case SDL_EVENT_WINDOW_RESTORED:
|
||||||
onResize();
|
OnResize();
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WINDOW_MINIMIZED:
|
case SDL_EVENT_WINDOW_MINIMIZED:
|
||||||
case SDL_EVENT_WINDOW_EXPOSED:
|
case SDL_EVENT_WINDOW_EXPOSED:
|
||||||
is_shown = event.type == SDL_EVENT_WINDOW_EXPOSED;
|
is_shown = event.type == SDL_EVENT_WINDOW_EXPOSED;
|
||||||
onResize();
|
OnResize();
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_KEY_DOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
case SDL_EVENT_KEY_UP:
|
case SDL_EVENT_KEY_UP:
|
||||||
onKeyPress(&event);
|
OnKeyPress(&event);
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||||
@ -115,7 +154,7 @@ void WindowSDL::waitEvent() {
|
|||||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
||||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||||
onGamepadEvent(&event);
|
OnGamepadEvent(&event);
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
is_open = false;
|
is_open = false;
|
||||||
@ -125,18 +164,16 @@ void WindowSDL::waitEvent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSDL::initTimers() {
|
void WindowSDL::InitTimers() {
|
||||||
SDL_AddTimer(100, &PollController, controller);
|
SDL_AddTimer(100, &PollController, controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSDL::onResize() {
|
void WindowSDL::OnResize() {
|
||||||
SDL_GetWindowSizeInPixels(window, &width, &height);
|
SDL_GetWindowSizeInPixels(window, &width, &height);
|
||||||
ImGui::Core::OnResize();
|
ImGui::Core::OnResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSDL::onKeyPress(const SDL_Event* event) {
|
void WindowSDL::OnKeyPress(const SDL_Event* event) {
|
||||||
using Libraries::Pad::OrbisPadButtonDataOffset;
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Use keys that are more friendly for keyboards without a keypad.
|
// Use keys that are more friendly for keyboards without a keypad.
|
||||||
// Once there are key binding options this won't be necessary.
|
// 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;
|
constexpr SDL_Keycode TriangleKey = SDLK_KP_8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u32 button = 0;
|
auto button = OrbisPadButtonDataOffset::None;
|
||||||
Input::Axis axis = Input::Axis::AxisMax;
|
Input::Axis axis = Input::Axis::AxisMax;
|
||||||
int axisvalue = 0;
|
int axisvalue = 0;
|
||||||
int ax = 0;
|
int ax = 0;
|
||||||
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
||||||
switch (event->key.key) {
|
switch (event->key.key) {
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
|
button = OrbisPadButtonDataOffset::Up;
|
||||||
break;
|
break;
|
||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN;
|
button = OrbisPadButtonDataOffset::Down;
|
||||||
break;
|
break;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT;
|
button = OrbisPadButtonDataOffset::Left;
|
||||||
break;
|
break;
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT;
|
button = OrbisPadButtonDataOffset::Right;
|
||||||
break;
|
break;
|
||||||
case TriangleKey:
|
case TriangleKey:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE;
|
button = OrbisPadButtonDataOffset::Triangle;
|
||||||
break;
|
break;
|
||||||
case CircleKey:
|
case CircleKey:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE;
|
button = OrbisPadButtonDataOffset::Circle;
|
||||||
break;
|
break;
|
||||||
case CrossKey:
|
case CrossKey:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS;
|
button = OrbisPadButtonDataOffset::Cross;
|
||||||
break;
|
break;
|
||||||
case SquareKey:
|
case SquareKey:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE;
|
button = OrbisPadButtonDataOffset::Square;
|
||||||
break;
|
break;
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS;
|
button = OrbisPadButtonDataOffset::Options;
|
||||||
break;
|
break;
|
||||||
case SDLK_A:
|
case SDLK_A:
|
||||||
axis = Input::Axis::LeftX;
|
axis = Input::Axis::LeftX;
|
||||||
@ -257,19 +294,19 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||||
break;
|
break;
|
||||||
case SDLK_X:
|
case SDLK_X:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3;
|
button = OrbisPadButtonDataOffset::L3;
|
||||||
break;
|
break;
|
||||||
case SDLK_M:
|
case SDLK_M:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3;
|
button = OrbisPadButtonDataOffset::R3;
|
||||||
break;
|
break;
|
||||||
case SDLK_Q:
|
case SDLK_Q:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1;
|
button = OrbisPadButtonDataOffset::L1;
|
||||||
break;
|
break;
|
||||||
case SDLK_U:
|
case SDLK_U:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1;
|
button = OrbisPadButtonDataOffset::R1;
|
||||||
break;
|
break;
|
||||||
case SDLK_E:
|
case SDLK_E:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
|
button = OrbisPadButtonDataOffset::L2;
|
||||||
axis = Input::Axis::TriggerLeft;
|
axis = Input::Axis::TriggerLeft;
|
||||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||||
axisvalue += 255;
|
axisvalue += 255;
|
||||||
@ -279,7 +316,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||||||
ax = Input::GetAxis(0, 0x80, axisvalue);
|
ax = Input::GetAxis(0, 0x80, axisvalue);
|
||||||
break;
|
break;
|
||||||
case SDLK_O:
|
case SDLK_O:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
|
button = OrbisPadButtonDataOffset::R2;
|
||||||
axis = Input::Axis::TriggerRight;
|
axis = Input::Axis::TriggerRight;
|
||||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||||
axisvalue += 255;
|
axisvalue += 255;
|
||||||
@ -294,9 +331,9 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||||||
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
controller->SetTouchpadState(0, true, x, 0.5f);
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
|
button = OrbisPadButtonDataOffset::TouchPad;
|
||||||
} else {
|
} else {
|
||||||
button = 0;
|
button = {};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDLK_F11:
|
case SDLK_F11:
|
||||||
@ -317,7 +354,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (button != 0) {
|
if (button != OrbisPadButtonDataOffset::None) {
|
||||||
controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
||||||
}
|
}
|
||||||
if (axis != Input::Axis::AxisMax) {
|
if (axis != Input::Axis::AxisMax) {
|
||||||
@ -325,10 +362,8 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSDL::onGamepadEvent(const SDL_Event* event) {
|
void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
|
||||||
using Libraries::Pad::OrbisPadButtonDataOffset;
|
auto button = OrbisPadButtonDataOffset::None;
|
||||||
|
|
||||||
u32 button = 0;
|
|
||||||
Input::Axis axis = Input::Axis::AxisMax;
|
Input::Axis axis = Input::Axis::AxisMax;
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_EVENT_GAMEPAD_ADDED:
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
@ -343,25 +378,25 @@ void WindowSDL::onGamepadEvent(const SDL_Event* event) {
|
|||||||
event->gtouchpad.x, event->gtouchpad.y);
|
event->gtouchpad.x, event->gtouchpad.y);
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
case SDL_EVENT_GAMEPAD_BUTTON_UP: {
|
||||||
button = sdlGamepadToOrbisButton(event->gbutton.button);
|
button = SDLGamepadToOrbisButton(event->gbutton.button);
|
||||||
if (button != 0) {
|
if (button == OrbisPadButtonDataOffset::None) {
|
||||||
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_BACK) {
|
break;
|
||||||
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
}
|
||||||
|
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") {
|
if (backButtonBehavior != "none") {
|
||||||
float x = backButtonBehavior == "left"
|
float x = backButtonBehavior == "left" ? 0.25f
|
||||||
? 0.25f
|
|
||||||
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
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);
|
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
axis = event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTX ? Input::Axis::LeftX
|
axis = event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTX ? Input::Axis::LeftX
|
||||||
: event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTY ? Input::Axis::LeftY
|
: 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
|
} // namespace Frontend
|
||||||
|
@ -46,36 +46,33 @@ public:
|
|||||||
std::string_view window_title);
|
std::string_view window_title);
|
||||||
~WindowSDL();
|
~WindowSDL();
|
||||||
|
|
||||||
s32 getWidth() const {
|
s32 GetWidth() const {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 getHeight() const {
|
s32 GetHeight() const {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOpen() const {
|
bool IsOpen() const {
|
||||||
return is_open;
|
return is_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] SDL_Window* GetSdlWindow() const {
|
[[nodiscard]] SDL_Window* GetSDLWindow() const {
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowSystemInfo getWindowInfo() const {
|
WindowSystemInfo GetWindowInfo() const {
|
||||||
return window_info;
|
return window_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitEvent();
|
void WaitEvent();
|
||||||
|
void InitTimers();
|
||||||
void initTimers();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onResize();
|
void OnResize();
|
||||||
void onKeyPress(const SDL_Event* event);
|
void OnKeyPress(const SDL_Event* event);
|
||||||
void onGamepadEvent(const SDL_Event* event);
|
void OnGamepadEvent(const SDL_Event* event);
|
||||||
|
|
||||||
int sdlGamepadToOrbisButton(u8 button);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
s32 width;
|
s32 width;
|
||||||
|
@ -95,7 +95,7 @@ Instance::Instance(bool enable_validation, bool enable_crash_diagnostic)
|
|||||||
|
|
||||||
Instance::Instance(Frontend::WindowSDL& window, s32 physical_device_index,
|
Instance::Instance(Frontend::WindowSDL& window, s32 physical_device_index,
|
||||||
bool enable_validation /*= false*/, bool enable_crash_diagnostic /*= false*/)
|
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)},
|
enable_crash_diagnostic)},
|
||||||
physical_devices{EnumeratePhysicalDevices(instance)} {
|
physical_devices{EnumeratePhysicalDevices(instance)} {
|
||||||
if (enable_validation) {
|
if (enable_validation) {
|
||||||
|
@ -73,7 +73,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback(
|
|||||||
}
|
}
|
||||||
|
|
||||||
vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::WindowSDL& emu_window) {
|
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{};
|
vk::SurfaceKHR surface{};
|
||||||
|
|
||||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||||
|
@ -629,9 +629,9 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop)
|
|||||||
|
|
||||||
void Presenter::Present(Frame* frame) {
|
void Presenter::Present(Frame* frame) {
|
||||||
// Recreate the swapchain if the window was resized.
|
// Recreate the swapchain if the window was resized.
|
||||||
if (window.getWidth() != swapchain.GetExtent().width ||
|
if (window.GetWidth() != swapchain.GetExtent().width ||
|
||||||
window.getHeight() != swapchain.GetExtent().height) {
|
window.GetHeight() != swapchain.GetExtent().height) {
|
||||||
swapchain.Recreate(window.getWidth(), window.getHeight());
|
swapchain.Recreate(window.GetWidth(), window.GetHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Core::NewFrame();
|
ImGui::Core::NewFrame();
|
||||||
@ -776,8 +776,8 @@ Frame* Presenter::GetRenderFrame() {
|
|||||||
device.resetFences(frame->present_done);
|
device.resetFences(frame->present_done);
|
||||||
|
|
||||||
// If the window dimensions changed, recreate this frame
|
// If the window dimensions changed, recreate this frame
|
||||||
if (frame->width != window.getWidth() || frame->height != window.getHeight()) {
|
if (frame->width != window.GetWidth() || frame->height != window.GetHeight()) {
|
||||||
RecreateFrame(frame, window.getWidth(), window.getHeight());
|
RecreateFrame(frame, window.GetWidth(), window.GetHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
|
@ -14,7 +14,7 @@ namespace Vulkan {
|
|||||||
Swapchain::Swapchain(const Instance& instance_, const Frontend::WindowSDL& window)
|
Swapchain::Swapchain(const Instance& instance_, const Frontend::WindowSDL& window)
|
||||||
: instance{instance_}, surface{CreateSurface(instance.GetInstance(), window)} {
|
: instance{instance_}, surface{CreateSurface(instance.GetInstance(), window)} {
|
||||||
FindPresentFormat();
|
FindPresentFormat();
|
||||||
Create(window.getWidth(), window.getHeight(), surface);
|
Create(window.GetWidth(), window.GetHeight(), surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
Swapchain::~Swapchain() {
|
Swapchain::~Swapchain() {
|
||||||
|
Loading…
Reference in New Issue
Block a user