Merge remote-tracking branch 'origin/features' into work

This commit is contained in:
Martin Baliet 2024-04-26 10:49:14 +02:00
commit 74d5339e13
62 changed files with 760 additions and 488 deletions

View File

@ -353,6 +353,9 @@ int condWait(ScePthreadCond* cond, ScePthreadMutex* mutex) {
if (int res = checkCondInit(cond); res != Ok) return res;
LOG_USE_MODULE(pthread);
if ((*mutex)->p.recursion_count < 1) return getErr(ErrCode::_EPERM);
// LOG_DEBUG(L"->Cond: %S mutex:%d", (*cond)->name.c_str(), (*mutex)->id);
(*cond)->p.do_wait_until((*mutex)->p, boost::detail::internal_platform_timepoint::getMax());
@ -474,7 +477,7 @@ int mutexDestroy(ScePthreadMutex* mutex) {
auto mutexInit_intern(const ScePthreadMutexattr* attr) {
auto mutex = std::make_unique<PthreadMutexPrivate>().release();
if (attr != nullptr) mutex->type = (*attr)->type;
if (attr != nullptr && *attr != nullptr) mutex->type = (*attr)->type;
mutex->id = mutexCounter();
LOG_USE_MODULE(pthread);
// LOG_DEBUG(L"mutex ini| id:%llu type:%d", mutex->id, (int)mutex->type);

View File

@ -43,7 +43,8 @@ class INetworking {
* @param info
* @return int32_t
*/
virtual int32_t netCtlGetInfo(int code, SceNetCtlInfo* info) = 0;
virtual int32_t netCtlGetInfo(int32_t code, SceNetCtlInfo* info) = 0;
virtual int32_t netCtlGetState(int32_t* state) = 0;
/* SceNet facility */

View File

@ -36,6 +36,11 @@ int32_t OfflineNet::netCtlGetInfo(int32_t code, SceNetCtlInfo* info) {
return Err::NetCtl::NOT_CONNECTED;
}
int32_t OfflineNet::netCtlGetState(int32_t* state) {
*state = 0; // Network disconnected
return Ok;
}
SceNetId OfflineNet::resolverCreate(const char* name, int memid, int flags) {
static SceNetId id = 0;
return ++id;

View File

@ -13,6 +13,7 @@ class OfflineNet: public INetworking {
* @return int32_t
*/
int32_t netCtlGetInfo(int32_t code, SceNetCtlInfo* info) final;
int32_t netCtlGetState(int32_t* state) final;
/* SceNet facility */

View File

@ -17,6 +17,7 @@ class OnlineNet: public INetworking {
* @return int32_t
*/
int32_t netCtlGetInfo(int32_t code, SceNetCtlInfo* info) final;
int32_t netCtlGetState(int32_t* state) final;
/* SceNet facility */

View File

@ -189,3 +189,8 @@ int32_t OnlineNet::netCtlGetInfo(int32_t code, SceNetCtlInfo* info) {
return Ok;
}
int32_t OnlineNet::netCtlGetState(int32_t* state) {
*state = 3; // IP address obtained
return Ok;
}

View File

@ -652,14 +652,14 @@ int VideoOut::registerBuffers(int handle, int startIndex, void* const* addresses
[[unlikely]] if (setIndex > 15) {
LOG_CRIT(L"buffersSetsCount > 15");
return ::Err::VIDEO_OUT_ERROR_NO_EMPTY_SLOT;
return Err::VideoOut::NO_EMPTY_SLOT;
}
auto& bufferSet = config.bufferSets[setIndex];
bufferSet.buffers.resize(numBuffer);
for (int i = startIndex; i < startIndex + numBuffer; ++i) {
if (config.buffers[i] >= 0) return ::Err::VIDEO_OUT_ERROR_SLOT_OCCUPIED;
if (config.buffers[i] >= 0) return Err::VideoOut::SLOT_OCCUPIED;
config.buffers[i] = setIndex;
}

View File

@ -6,9 +6,11 @@
"type": "string"
},
"device": {
"description": "The name of your sound output device e.g. \"Speakers (Realtek(R) Audio)\".",
"type": "string"
},
"volume": {
"description": "Master volume for every emulator's sound output.",
"type": "number",
"minimum": 0.0,
"maximum": 1.0

View File

@ -1,85 +1,112 @@
{
"type": "object",
"additionalProperties": false,
"definitions": {
"button": {
"type": "string",
"description": "This gamepad button will be pressed when you press the speified button on the keyboard.\n\"gamepad_key\": \"keyboard_key\"\n\nYou can find keyboard key names there: <https://wiki.libsdl.org/SDL2/SDL_Scancode>."
},
"deadzone": {
"type": "object",
"additionalProperties": false,
"properties": {
"x": {
"type": "number",
"minimum": 0.0,
"maximum": 0.9
},
"y": {
"type": "number",
"minimum": 0.0,
"maximum": 0.9
}
},
"required": [
"x",
"y"
]
}
},
"properties": {
"$schema": {
"type": "string"
},
"keybinds": {
"type": "object",
"description": "Information about keybinds for gamepad emulation, hover your cursor on any key inside this object to get more info.",
"additionalProperties": false,
"properties": {
"circle": {
"type": "string"
"$ref": "#/definitions/button"
},
"cross": {
"type": "string"
"$ref": "#/definitions/button"
},
"dpad_down": {
"type": "string"
"$ref": "#/definitions/button"
},
"dpad_left": {
"type": "string"
"$ref": "#/definitions/button"
},
"dpad_right": {
"type": "string"
"$ref": "#/definitions/button"
},
"dpad_up": {
"type": "string"
"$ref": "#/definitions/button"
},
"l1": {
"type": "string"
"$ref": "#/definitions/button"
},
"l2": {
"type": "string"
"$ref": "#/definitions/button"
},
"l3": {
"type": "string"
"$ref": "#/definitions/button"
},
"lx+": {
"type": "string"
"$ref": "#/definitions/button"
},
"lx-": {
"type": "string"
"$ref": "#/definitions/button"
},
"ly+": {
"type": "string"
"$ref": "#/definitions/button"
},
"ly-": {
"type": "string"
"$ref": "#/definitions/button"
},
"options": {
"type": "string"
"$ref": "#/definitions/button"
},
"r1": {
"type": "string"
"$ref": "#/definitions/button"
},
"r2": {
"type": "string"
"$ref": "#/definitions/button"
},
"r3": {
"type": "string"
"$ref": "#/definitions/button"
},
"rx+": {
"type": "string"
"$ref": "#/definitions/button"
},
"rx-": {
"type": "string"
"$ref": "#/definitions/button"
},
"ry+": {
"type": "string"
"$ref": "#/definitions/button"
},
"ry-": {
"type": "string"
"$ref": "#/definitions/button"
},
"square": {
"type": "string"
"$ref": "#/definitions/button"
},
"touchpad": {
"type": "string"
"$ref": "#/definitions/button"
},
"triangle": {
"type": "string"
"$ref": "#/definitions/button"
}
},
"required": [
@ -111,38 +138,24 @@
},
"pads": {
"type": "array",
"description": "This array contains information about connected pads.",
"minItems": 4,
"maxItems": 4,
"items": {
"type": "object",
"description": "The pad information itself.",
"additionalProperties": false,
"properties": {
"deadzones": {
"type": "object",
"description": "Dead zones are WIP, not working for now.",
"additionalProperties": false,
"properties": {
"left_stick": {
"type": "object",
"additionalProperties": false,
"properties": {
"x": {
"type": "number",
"minimum": 0.0,
"maximum": 0.9
},
"y": {
"type": "number",
"minimum": 0.0,
"maximum": 0.9
}
},
"required": [
"x",
"y"
]
"$ref": "#/definitions/deadzone"
},
"right_stick": {
"$ref": "#/properties/pads/items/properties/deadzones/properties/left_stick"
"$ref": "#/definitions/deadzone"
}
},
"required": [
@ -152,6 +165,7 @@
},
"type": {
"type": "string",
"description": "Backend for this gamepad. Possible values:\n* for SDL: sdl; aliases: gamepad\n* for XInput: xinput; aliases: xbox\n* for gamepad emulation: keyboard; aliases: kb, kbd.",
"enum": [
"gamepad",
"sdl",

View File

@ -6,19 +6,23 @@
"type": "string"
},
"netEnabled": {
"type": "boolean"
"type": "boolean",
"description": "Network subsystem state, it is not recomended to enable network, it may cause your emulator to crash."
},
"netMAC": {
"type": "string",
"description": "You should specify your host adapter MAC address here. This adapter will be used for network connection to game's servers. This option is ignored if \"netEnabled\" set to `false`.\n\n00:00:00:00:00:00 means \"first available adapter with IPv4 address\".",
"pattern": "(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$"
},
"onlineUsers": {
"type": "integer",
"description": "This option specifies the number of logged in users. The maximum number of users is 4. Every user must have their own configured gamepad (see controls.json).",
"minimum": 1,
"maximum": 4
},
"profiles": {
"type": "array",
"description": "This array contains information about all the console users. The specified name and lightbar color will be sent to the game on request.",
"minItems": 4,
"maxItems": 4,
"items": {
@ -27,6 +31,7 @@
"properties": {
"color": {
"type": "string",
"description": "The user color, probably unused.",
"enum": [
"blue",
"red",
@ -36,6 +41,7 @@
},
"name": {
"type": "string",
"description": "The displayed user name, the game may draw it somewhere.",
"minLength": 3,
"maxLength": 16
}
@ -48,11 +54,13 @@
},
"systemlang": {
"type": "integer",
"description": "The game language, defaults to EnglishUS. Game must support it.\n Languages list: <https://github.com/SysRay/psOff_public/wiki/Config-files#generaljson>.",
"minimum": 0,
"maximum": 29
},
"userIndex": {
"type": "number",
"description": "Index of the user who launched the game, should be less than \"onlineUsers\" or equal.",
"minimum": 1,
"maximum": 4
}

View File

@ -6,24 +6,30 @@
"type": "string"
},
"display": {
"type": "number"
"type": "number",
"description": "The display index where emulator windows will be shown."
},
"fullscreen": {
"type": "boolean"
"type": "boolean",
"description": "Wether emulator will run in fullscreen mode or not."
},
"width": {
"type": "number",
"description": "The emulator window width, ignored in fullscreen mode.",
"minimum": 400
},
"height": {
"type": "number",
"description": "The emulator window height, ignored in fullscreen mode.",
"minimum": 225
},
"xpos": {
"type": "number"
"type": "number",
"description": "The emulator window horizontal position."
},
"ypos": {
"type": "number"
"type": "number",
"description": "The emulator window vertical position."
}
},
"required": [

View File

@ -7,6 +7,7 @@
},
"sink": {
"type": "string",
"description": "Logging output.",
"enum": [
"Null",
"Auto",
@ -19,8 +20,13 @@
},
"verbosity": {
"type": "integer",
"description": "Verbosity level of logger.\nPossible values:\n0 - Trace\n1 - Debug\n2 - Warning\n3 - Error\n4 - Critical\n5 - None",
"minimum": 0,
"maximum": 5
},
"_customVerb": {
"type": "object",
"description": "Custom verbosity level for each module."
}
},
"required": [

View File

@ -2,38 +2,39 @@
**TL;DR**: If you know yml code, then just check out the [GitHub action workflow](https://github.com/SysRay/psOff_public/blob/main/.github/workflows/build.yml)
* Step 1:
Setting up the environment
### Step 1: Setting up the environment
First things first, you need to download [Git](https://git-scm.com/download/win), [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) or its [Build Tools package](https://aka.ms/vs/17/release/vs_BuildTools.exe), both are fine. The last thing you need is [VulkanSDK](https://vulkan.lunarg.com/sdk/home), on this site you should click on _VulkanSDK-x.x.xxx.x-Installer.exe_ link, then just run the said installer and install it without any changes in its options.
- Step 1.2: Visual Studio installation
#### Step 1.2: Visual Studio installation
When you click on the installer's exe you'll see a window with a bunch of checkboxes. You need to check Desktop development with C++ on the left pane, and then C++ Clang tools for Windows on the right pane, now you all set! Just click the install button and wait for the process to finish.
* Step 2: Clone the psOff repo
### Step 2: Clone the psOff repo
Open any folder you want (I personally prefer %USERPROFILE%\Documents\GitHub) then hold Shift and click RMB on the empty space in this folder. In the new context menu, click "Open in Terminal". Type in the following command:
`git.exe clone --recurse-submodules https://github.com/SysRay/psOff_public.git`
* Step 3: Building the emulator
### Step 3: Building the emulator
- Step 3.1: Configure the project
Type this into your terminal window:
#### Step 3.1: Configure the project
Type this into your terminal window:
`cmake.exe -S. -B_build/_Release -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=_build/_Install -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe`
wait 'til it finishes. There shouldn't be any errors.
- Step 3.2: Build the project
And now type this:
#### Step 3.2: Build the project
And now type this:
`cmake.exe --build _build/_Release -j4` This process could take a while. If you see any red text, then you probably missed something. Ask for help on out discord server.
- Step 3.3: Copying libs
### Step 4: Installing
Finally, type this command:
`cmake.exe --install _build/_Release`
Its execution usually takes under 2 or 3 seconds
- Step 3.4: Obtaining executable
If you believe that you did everything right, then all you have to do is get the executable binary somewhere. You can use the [latest GitHub release](https://github.com/SysRay/psOff_public/releases) for this purpose and hope that it will run with the libraries you just built. When you download the archive with the latest release, open it and copy emulator.exe from it to your emulator folder to the following path: psOff_public/_build/_Install.
Done! Now you can try to modify the emulator's code and see how it works.
Done! Now you can try to modify the emulator's code and see how it works. Just open `_build/_Install/` folder and you'll see `emulator.exe` there.
---
author: [igor](https://github.com/igor725)
---
---

View File

@ -2,7 +2,7 @@
Config json-files are created on first start of the emulator and can be found under "./Config". It's enough to call `emulator.exe --h`.
Versioning is todo, copying old config files may therefore break it.
Our configuration engine automatically fixes your config files when you upgrade to a newer version of psOff-libs. All outdated keys will be deleted automatically and the new ones will be added with the default vaue. The corresponding messages will be displayed in the terminal window.
## controls.json : Gamepad layout

View File

@ -7,35 +7,35 @@ const maxMessageSize = 2000;
const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
const fetchRetry = ({url, fetchOpts = {}, retryDelay = 5000, retries = 5}) => new Promise((resolve, reject) => {
const fetchRetry = ({ url, fetchOpts = {}, retryDelay = 5000, retries = 5 }) => new Promise((resolve, reject) => {
const wrap = (n) => {
fetch(url, fetchOpts)
.then(async (res) => {
if (res.ok) {
const rateRemain = res.headers.get('X-RateLimit-Remaining');
const rateReset = res.headers.get('X-RateLimit-Reset-After');
if (rateRemain !== null) {
if (parseInt(rateRemain) === 1)
await delay((rateReset ? parseInt(rateReset) : 1) * 1500); // Hold on there, cowboy
.then(async (res) => {
if (res.ok) {
const rateRemain = res.headers.get('X-RateLimit-Remaining');
const rateReset = res.headers.get('X-RateLimit-Reset-After');
if (rateRemain !== null) {
if (parseInt(rateRemain) === 1)
await delay((rateReset ? parseInt(rateReset) : 1) * 1500); // Hold on there, cowboy
}
return resolve(res);
}
return resolve(res);
}
if (n === 0) return reject(`Failed after ${retries} retries.`);
if (res.status !== 429) return reject(res);
const jdata = res.json();
if (typeof jdata.retry_after === 'number') {
await delay(jdata.retry_after * 1000);
wrap(--n);
}
})
.catch(async (err) => {
if (n > 0) {
await delay(retryDelay);
wrap(--n);
} else {
reject(`Failed after ${retries} retries.`);
}
});
if (n === 0) return reject(`Failed after ${retries} retries.`);
if (res.status !== 429) return reject(res);
const jdata = res.json();
if (typeof jdata.retry_after === 'number') {
await delay(jdata.retry_after * 1000);
wrap(--n);
}
})
.catch(async (err) => {
if (n > 0) {
await delay(retryDelay);
wrap(--n);
} else {
reject(`Failed after ${retries} retries.`);
}
});
};
wrap(retries);
@ -110,20 +110,20 @@ const guessCategory = (labels) => {
};
const catOpts = {
bugfixes: {display: 'Bugfixes 🪳'},
stubs: {display: 'Stubbed functions 🆒'},
impls: {display: 'Implementations 🥳'},
general: {display: 'General ✅'},
ench: {display: 'Enhancements 🧙'},
contrib: {display: 'Authors 🧑‍💻️', splitter: ', '},
bugfixes: { display: 'Bugfixes 🪳' },
stubs: { display: 'Stubbed functions 🆒' },
impls: { display: 'Implementations 🥳' },
general: { display: 'General ✅' },
ench: { display: 'Enhancements 🧙' },
contrib: { display: 'Authors 🧑‍💻️', splitter: ', ' },
};
octokit.repos.listReleases({repo: r_name, owner: r_owner, per_page: 2, page: 1}).then(({data}) => {
octokit.repos.listReleases({ repo: r_name, owner: r_owner, per_page: 2, page: 1 }).then(({ data }) => {
const lastRelease = data[0], prevRelease = data[1];
return new Promise((resolve, reject) => {
const readPRs = async (pagenum, list = null, retries = 0) => {
const out = list ?? {general: [], bugfixes: [], stubs: [], impls: [], ench: [], contrib: []};
const out = list ?? { general: [], bugfixes: [], stubs: [], impls: [], ench: [], contrib: [] };
const handled_contribs = {};
const query = [];
@ -131,7 +131,7 @@ octokit.repos.listReleases({repo: r_name, owner: r_owner, per_page: 2, page: 1})
query.push('is:pr is:closed base:features sort:author-date-asc');
query.push(`merged:${prevRelease.created_at}..${lastRelease.created_at}`);
return octokit.search.issuesAndPullRequests({q: query.join(' '), per_page: 100, page: pagenum}).then(({data}) => {
return octokit.search.issuesAndPullRequests({ q: query.join(' '), per_page: 100, page: pagenum }).then(({ data }) => {
data.items.forEach((pr) => {
const msg = `* PR #${pr.number}: ${pr.title}`;
if (!handled_contribs[pr.user.login]) {

View File

@ -2,6 +2,7 @@
#include <stdint.h>
namespace Err {
namespace AudioOut {
constexpr int32_t NOT_OPENED = -2144993279;
constexpr int32_t BUSY = -2144993278;
constexpr int32_t INVALID_PORT = -2144993277;
@ -23,6 +24,7 @@ constexpr int32_t INVALID_FLAG = -2144993261;
constexpr int32_t INVALID_MIXLEVEL = -2144993260;
constexpr int32_t INVALID_ARG = -2144993259;
constexpr int32_t INVALID_PARAM = -2144993258;
} // namespace AudioOut
} // namespace Err
constexpr int PORT_OUT_MAX = 6;

View File

@ -72,7 +72,7 @@ extern "C" {
EXPORT const char* MODULE_NAME = "libSceAudioOut";
EXPORT SYSV_ABI int32_t sceAudioOutInit(void) {
if (audioInited) return Err::ALREADY_INIT;
if (audioInited) return Err::AudioOut::ALREADY_INIT;
if (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0) {
audioInited = true;
@ -80,7 +80,7 @@ EXPORT SYSV_ABI int32_t sceAudioOutInit(void) {
return Ok;
}
return Err::OUT_OF_MEMORY;
return Err::AudioOut::OUT_OF_MEMORY;
}
EXPORT SYSV_ABI int32_t sceAudioOutOpen(int32_t userId, SceAudioOutPortType type, int32_t index, uint32_t len, uint32_t freq, SceAudioOutParamFormat format) {
@ -189,7 +189,7 @@ EXPORT SYSV_ABI int32_t sceAudioOutOpen(int32_t userId, SceAudioOutPortType type
return id + 1;
}
return Err::PORT_FULL;
return Err::AudioOut::PORT_FULL;
}
EXPORT SYSV_ABI int32_t sceAudioOutClose(int32_t handle) {
@ -226,7 +226,7 @@ EXPORT SYSV_ABI int32_t sceAudioOutSetVolume(int32_t handle, int32_t flag, int32
boost::unique_lock const lock(pimpl->mutexInt);
auto& port = pimpl->portsOut[handle - 1];
if (!port.open) return Err::INVALID_PORT;
if (!port.open) return Err::AudioOut::INVALID_PORT;
for (int i = 0; i < port.channelsNum; i++, flag >>= 1u) {
bool const bit = flag & 0x1u;
@ -264,7 +264,7 @@ EXPORT SYSV_ABI int32_t sceAudioOutGetLastOutputTime(int32_t handle, uint64_t* o
boost::unique_lock const lock(pimpl->mutexInt);
auto& port = pimpl->portsOut[handle - 1];
if (!port.open) return Err::INVALID_PORT;
if (!port.open) return Err::AudioOut::INVALID_PORT;
*outputTime = port.lastOutputTime;
return Ok;
}
@ -296,4 +296,8 @@ EXPORT SYSV_ABI int32_t sceAudioOutGetSystemState(SceAudioOutSystemState* state)
EXPORT SYSV_ABI int32_t sceAudioOutSetSystemDebugState(SceAudioOutSystemDebugStateElement elem, SceAudioOutSystemDebugStateParam* param) {
return Ok;
}
EXPORT SYSV_ABI int32_t sceAudioOutMasteringTerm() {
return Ok;
}
}

View File

@ -2,6 +2,7 @@
#include <stdint.h>
namespace Err {
namespace AvPlayer {
constexpr int32_t INVALID_PARAMS = -2140536831; /* 0x806A0001 */
constexpr int32_t OPERATION_FAILED = -2140536830; /* 0x806A0002 */
constexpr int32_t NO_MEMORY = -2140536829; /* 0x806A0003 */
@ -13,4 +14,5 @@ constexpr int32_t INFO_MARLIN_ENCRY = -2140536656; /* 0x806A00B0 */
constexpr int32_t INFO_PLAYREADY_ENCRY = -2140536652; /* 0x806A00B4 */
constexpr int32_t INFO_AES_ENCRY = -2140536651; /* 0x806A00B5 */
constexpr int32_t INFO_OTHER_ENCRY = -2140536641; /* 0x806A00BF */
} // namespace Err
} // namespace AvPlayer
} // namespace Err

View File

@ -26,7 +26,7 @@ EXPORT SYSV_ABI int32_t sceAvPlayerClose(IAvplayer* avPlayer) {
EXPORT SYSV_ABI int32_t sceAvPlayerAddSource(IAvplayer* avPlayer, const char* filename) {
if (avPlayer->setFile(filename)) return Ok;
return Err::INVALID_PARAMS;
return Err::AvPlayer::INVALID_PARAMS;
}
EXPORT SYSV_ABI int32_t sceAvPlayerStreamCount(IAvplayer* avPlayer) {
@ -114,4 +114,4 @@ EXPORT SYSV_ABI int32_t sceAvPlayerVprintf(const char* str, va_list args) {
LOG_DEBUG(std::wstring(format.begin(), format.end()).c_str(), args);
return Ok;
}
}
}

View File

@ -19,6 +19,6 @@ EXPORT SYSV_ABI bool sceAvPlayerGetVideoDataEx(IAvplayer* avPlayer, SceAvPlayerF
EXPORT SYSV_ABI int32_t sceAvPlayerAddSourceEx(IAvplayer* avPlayer, SceAvPlayerUriType uriType, SceAvPlayerSourceDetails* sourceDetails) {
if (avPlayer->setFile(sourceDetails->uri.name)) return Ok;
return Err::INVALID_PARAMS;
return Err::AvPlayer::INVALID_PARAMS;
}
}
}

View File

@ -0,0 +1,24 @@
#pragma once
#include <cstdint>
namespace Err {
namespace CommonDialog {
constexpr int32_t NOT_SYSTEM_INITIALIZED = -2135425023; /* 0x80B80001 */
constexpr int32_t ALREADY_SYSTEM_INITIALIZED = -2135425022; /* 0x80B80002 */
constexpr int32_t NOT_INITIALIZED = -2135425021; /* 0x80B80003 */
constexpr int32_t ALREADY_INITIALIZED = -2135425020; /* 0x80B80004 */
constexpr int32_t NOT_FINISHED = -2135425019; /* 0x80B80005 */
constexpr int32_t INVALID_STATE = -2135425018; /* 0x80B80006 */
constexpr int32_t RESULT_NONE = -2135425017; /* 0x80B80007 */
constexpr int32_t BUSY = -2135425016; /* 0x80B80008 */
constexpr int32_t OUT_OF_MEMORY = -2135425015; /* 0x80B80009 */
constexpr int32_t PARAM_INVALID = -2135425014; /* 0x80B8000A */
constexpr int32_t NOT_RUNNING = -2135425013; /* 0x80B8000B */
constexpr int32_t ALREADY_CLOSE = -2135425012; /* 0x80B8000C */
constexpr int32_t ARG_NULL = -2135425011; /* 0x80B8000D */
constexpr int32_t UNEXPECTED_FATAL = -2135425010; /* 0x80B8000E */
constexpr int32_t NOT_SUPPORTED = -2135425009; /* 0x80B8000F */
constexpr int32_t INHIBIT_SHAREPLAY_CLIENT = -2135425008; /* 0x80B80010 */
} // namespace CommonDialog
} // namespace Err

View File

@ -1,5 +1,5 @@
#include "codes.h"
#include "common.h"
#include "errorcodes.h"
#include "logging.h"
LOG_DEFINE_MODULE(libSceCommonDialog);
@ -23,4 +23,4 @@ EXPORT SYSV_ABI bool sceCommonDialogIsUsed() {
return false;
}
}
}

View File

@ -1,20 +0,0 @@
#pragma once
namespace Err {
constexpr int32_t ERROR_NOT_SYSTEM_INITIALIZED = -2135425023; /* 0x80B80001 */
constexpr int32_t ERROR_ALREADY_SYSTEM_INITIALIZED = -2135425022; /* 0x80B80002 */
constexpr int32_t ERROR_NOT_INITIALIZED = -2135425021; /* 0x80B80003 */
constexpr int32_t ERROR_ALREADY_INITIALIZED = -2135425020; /* 0x80B80004 */
constexpr int32_t ERROR_NOT_FINISHED = -2135425019; /* 0x80B80005 */
constexpr int32_t ERROR_INVALID_STATE = -2135425018; /* 0x80B80006 */
constexpr int32_t ERROR_RESULT_NONE = -2135425017; /* 0x80B80007 */
constexpr int32_t ERROR_BUSY = -2135425016; /* 0x80B80008 */
constexpr int32_t ERROR_OUT_OF_MEMORY = -2135425015; /* 0x80B80009 */
constexpr int32_t ERROR_PARAM_INVALID = -2135425014; /* 0x80B8000A */
constexpr int32_t ERROR_NOT_RUNNING = -2135425013; /* 0x80B8000B */
constexpr int32_t ERROR_ALREADY_CLOSE = -2135425012; /* 0x80B8000C */
constexpr int32_t ERROR_ARG_NULL = -2135425011; /* 0x80B8000D */
constexpr int32_t ERROR_UNEXPECTED_FATAL = -2135425010; /* 0x80B8000E */
constexpr int32_t ERROR_NOT_SUPPORTED = -2135425009; /* 0x80B8000F */
constexpr int32_t ERROR_INHIBIT_SHAREPLAY_CLIENT = -2135425008; /* 0x80B80010 */
} // namespace Err

View File

@ -2,12 +2,14 @@
#include <stdint.h>
namespace Err {
constexpr int32_t SCE_DISC_MAP_ERROR_INVALID_ARGUMENT = -2129657855; // 0x81100001
constexpr int32_t SCE_DISC_MAP_ERROR_LOCATION_NOT_MAPPED = -2129657854; // 0x81100002
constexpr int32_t SCE_DISC_MAP_ERROR_FILE_NOT_FOUND = -2129657853; // 0x81100003
constexpr int32_t SCE_DISC_MAP_ERROR_NO_BITMAP_INFO = -2129657852; // 0x81100004
constexpr int32_t SCE_DISC_MAP_ERROR_FATAL = -2129657601; // 0x811000FF
namespace DiscMap {
constexpr int32_t INVALID_ARGUMENT = -2129657855; // 0x81100001
constexpr int32_t LOCATION_NOT_MAPPED = -2129657854; // 0x81100002
constexpr int32_t FILE_NOT_FOUND = -2129657853; // 0x81100003
constexpr int32_t NO_BITMAP_INFO = -2129657852; // 0x81100004
constexpr int32_t FATAL = -2129657601; // 0x811000FF
} // namespace DiscMap
} // namespace Err
constexpr int32_t DM_PATCH_FLAG = 1;
constexpr int32_t DM_APP1_FLAG = 0x100;
constexpr int32_t DM_APP1_FLAG = 0x100;

View File

@ -8,7 +8,7 @@ extern "C" {
EXPORT const char* MODULE_NAME = "libSceDiscMap";
EXPORT SYSV_ABI int sceDiscMapIsRequestOnHDD(const char* file, uint64_t a2, uint64_t a3, int* retVal) {
return Err::SCE_DISC_MAP_ERROR_NO_BITMAP_INFO;
return Err::DiscMap::NO_BITMAP_INFO;
}
EXPORT SYSV_ABI int __NID_HEX(7C980FFB0AA27E7A)() {
@ -16,14 +16,14 @@ EXPORT SYSV_ABI int __NID_HEX(7C980FFB0AA27E7A)() {
}
EXPORT SYSV_ABI int sceDiscMapGetPackageSize(int64_t fflags, void* p1, void* p2) {
return Err::SCE_DISC_MAP_ERROR_NO_BITMAP_INFO;
return Err::DiscMap::NO_BITMAP_INFO;
}
EXPORT SYSV_ABI int __NID_HEX(8A828CAEE7EDD5E9)(const char* file, void* p1, void* p2, int64_t* pFlags, int64_t* p3, int64_t* p4) {
return Err::SCE_DISC_MAP_ERROR_NO_BITMAP_INFO;
return Err::DiscMap::NO_BITMAP_INFO;
}
EXPORT SYSV_ABI int __NID_HEX(E7EBCE96E92F91F8)() {
return Ok;
}
}
}

View File

@ -2,7 +2,9 @@
#include <stdint.h>
namespace Err {
constexpr int VALIDATION_NOT_ENABLED = 0x80D13FFF;
constexpr int FAILURE = 0x800EEEFF;
constexpr int RAZOR_NOT_LOADED = 0x80D15001;
} // namespace Err
namespace Gnm {
constexpr int VALIDATION_NOT_ENABLED = -2133770241;
constexpr int FAILURE = -2146504961;
constexpr int RAZOR_NOT_LOADED = -2133766143;
} // namespace Gnm
} // namespace Err

View File

@ -128,8 +128,24 @@ int SYSV_ABI sceGnmUpdatePsShader(uint32_t* cmdOut, uint64_t size, const uint32_
int SYSV_ABI sceGnmUpdatePsShader350(uint32_t* cmdOut, uint64_t size, const uint32_t* ps_regs) {
LOG_USE_MODULE(libSceGraphicsDriver);
LOG_TRACE(L"%S 0x%08llx", __FUNCTION__, (uint64_t)cmdOut);
cmdOut[0] = Pm4::create(size, Pm4::Custom::R_PS_UPDATE);
memcpy(&cmdOut[1], ps_regs, 8 + size);
if (cmdOut == nullptr || size < 39) return -1;
if (ps_regs != nullptr) {
cmdOut[0] = Pm4::create(size, Pm4::Custom::R_PS_UPDATE);
memcpy(&cmdOut[1], ps_regs, 8 + size);
} else {
cmdOut[0] = Pm4::create(size, Pm4::Custom::R_PS_EMBEDDED);
cmdOut[1] = 0x00000000;
cmdOut[2] = 0x00000000;
cmdOut[3] = 0x00000000;
cmdOut[4] = 0xc0011000;
cmdOut[5] = 0xc01e0203;
cmdOut[6] = 0x00000000;
cmdOut[7] = 0xc0016900;
cmdOut[8] = 0x0000008f;
cmdOut[9] = 0x0000000f;
cmdOut[10] = 0xc01c1000;
cmdOut[11] = 0x00000000;
}
return Ok;
}
@ -212,7 +228,7 @@ int SYSV_ABI sceGnmDrawIndexAuto(uint32_t* cmdOut, uint64_t size, uint32_t index
int32_t SYSV_ABI sceGnmValidateDrawCommandBuffers(uint32_t count, void* dcbGpuAddrs[], uint32_t* dcbSizesInBytes, void* ccbGpuAddrs[],
uint32_t* ccbSizesInBytes) {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int SYSV_ABI sceGnmSubmitCommandBuffers(uint32_t count, void** dcb_gpu_addrs, const uint32_t* dcb_sizes_in_bytes, void** ccb_gpu_addrs,
@ -443,31 +459,31 @@ void* SYSV_ABI sceGnmGetTheTessellationFactorRingBufferBaseAddress() {
}
int SYSV_ABI sceGnmValidateCommandBuffers() {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateDispatchCommandBuffers(uint32_t count, void* dcbGpuAddrs, uint32_t* dcbSizesInBytes) {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateDisableDiagnostics(uint32_t count, void* data) {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateDisableDiagnostics2(uint32_t count, uint32_t* diagList) {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateGetDiagnosticInfo(int32_t query, void* diagnosticOutputs) {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateGetDiagnostics(int32_t query, void* diagnosticOutputs) {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateResetState() {
return Err::VALIDATION_NOT_ENABLED;
return Err::Gnm::VALIDATION_NOT_ENABLED;
}
int32_t SYSV_ABI sceGnmValidateGetVersion() {
@ -499,7 +515,7 @@ int SYSV_ABI sceGnmRegisterResource(uint32_t* resource_handle, uint32_t owner_ha
*resource_handle = rhandle;
}
return Err::FAILURE;
return Err::Gnm::FAILURE;
}
int SYSV_ABI sceGnmUnregisterAllResourcesForOwner(uint32_t owner_handle) {
@ -525,7 +541,7 @@ int SYSV_ABI sceGnmDriverTraceInProgress() {
int SYSV_ABI sceGnmDriverTriggerCapture(const char* filename) {
LOG_USE_MODULE(libSceGraphicsDriver);
LOG_ERR(L"CaptureStatus: Something went wrong");
return Err::RAZOR_NOT_LOADED;
return Err::Gnm::RAZOR_NOT_LOADED;
}
void SYSV_ABI sceGnmDebugHardwareStatus(int flag) {

View File

@ -250,4 +250,9 @@ EXPORT SYSV_ABI int sceHttpsSetSslCallback(int id, SceHttpsCallback cbfunc, void
EXPORT SYSV_ABI int sceHttpsSetSslVersion(int id, SceSslVersion version) {
return accessNetworking().httpsSetSslVersion(id, version);
}
EXPORT SYSV_ABI int sceHttpUriEscape(char* out, size_t* req, size_t outsz, const char* str) {
*req = 0;
return 0;
}
}

View File

@ -2,6 +2,7 @@
#include <stdint.h>
namespace Err {
namespace Json {
constexpr int32_t PARSE_INVALID_CHAR = -2138799871;
constexpr int32_t NOMEM = -2138799870;
constexpr int32_t NOFILE = -2138799869;
@ -9,12 +10,16 @@ constexpr int32_t NOROOT = -2138799868;
constexpr int32_t NOBUF = -2138799867;
constexpr int32_t NOINIT = -2138799856;
constexpr int32_t MULTIPLEINIT = -2138799855;
constexpr int32_t ALREADY_SET = -2138799854;
constexpr int32_t NOT_SUPPORTED = -2138799853;
constexpr int32_t SPECIAL_FLOAT = -2138799852;
constexpr int32_t NOT_EXIST_KEY = -2138799851;
constexpr int32_t NOT_EXIST_INDEX = -2138799850;
constexpr int32_t NOT_A_OBJECT = -2138799849;
constexpr int32_t NOT_A_CONTAINER = -2138799848;
constexpr int32_t INVALID_ARGUMENT = -2138799840;
} // namespace Json
namespace Json2 {
constexpr int32_t ALREADY_SET = -2138799854;
constexpr int32_t NOT_SUPPORTED = -2138799853;
constexpr int32_t SPECIAL_FLOAT = -2138799852;
constexpr int32_t NOT_EXIST_KEY = -2138799851;
constexpr int32_t NOT_EXIST_INDEX = -2138799850;
constexpr int32_t NOT_A_OBJECT = -2138799849;
constexpr int32_t NOT_A_CONTAINER = -2138799848;
constexpr int32_t INVALID_ARGUMENT = -2138799840;
} // namespace Json2
} // namespace Err

View File

@ -107,9 +107,10 @@ EXPORT SYSV_ABI void __NID(_ZN3sce4Json12MemAllocatorC2Ev)(sce::Json::MemAllocat
* @brief sce::Json::Value::Value()
*
*/
EXPORT SYSV_ABI void __NID(_ZN3sce4Json5ValueC1Ev)() {
EXPORT SYSV_ABI void __NID(_ZN3sce4Json5ValueC1Ev)(sce::Json::Value* _this) {
LOG_USE_MODULE(libSceJson2);
LOG_ERR(L"todo %S", __FUNCTION__);
::memset((void*)_this, 0, sizeof(sce::Json::Value));
}
/**
@ -156,10 +157,9 @@ EXPORT SYSV_ABI int32_t __NID(_ZN3sce4Json5Value3setEd)() {
* @brief sce::Json::Value::~Value()
*
*/
EXPORT SYSV_ABI int32_t __NID(_ZN3sce4Json5ValueD1Ev)() {
EXPORT SYSV_ABI void __NID(_ZN3sce4Json5ValueD1Ev)() {
LOG_USE_MODULE(libSceJson2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}
/**
@ -247,6 +247,14 @@ EXPORT SYSV_ABI void __NID(_ZN3sce4Json11InitializerD1Ev)(sce::Json::Initializer
_this->~Initializer();
}
/**
* @brief sce::Json::MemAllocator::notifyError(int, unsigned long, void*)
*
*/
EXPORT SYSV_ABI void __NID(_ZN3sce4Json12MemAllocator11notifyErrorEimPv)(sce::Json::MemAllocator* _this, int32_t error, size_t size, void* userData) {
return _this->notifyError(error, size, userData);
}
EXPORT SYSV_ABI int32_t __NID(_ZN3sce4Json11Initializer10initializeEPKNS0_13InitParameterE)(sce::Json::Initializer* _this,
sce::Json::InitParameter const* param) {
return _this->initialize(param);

View File

@ -12,7 +12,7 @@ class MemAllocator {
virtual void notifyError(int32_t error, size_t size, void* userData);
};
enum ValueType { Null = 0, Boolean, Integer, UnsignedInteger, Double, String, Array, Object };
enum ValueType { eNull = 0, eBoolean, eInteger, eUnsignedInteger, eDouble, eString, eArray, eObject };
enum SpecialFloatFormat { FloatString, FloatNull, FloatSym };
@ -68,5 +68,46 @@ class Initializer {
private:
bool m_bIsInited;
};
struct RootParam;
class String {};
class Array {};
class Object {};
class Value {
private:
Value* m_parent;
RootParam* m_rootParameter;
union {
bool m_boolean;
int64_t m_integer;
uint64_t m_uinteger;
double m_double;
String* m_string;
Array* m_array;
Object* m_object;
};
char _padding[4];
ValueType m_type;
public:
~Value();
Value();
Value(ValueType type);
Value(bool b);
Value(int64_t i);
Value(uint64_t ui);
Value(double d);
Value(const char* s);
Value(const String& s);
Value(const Array& a);
Value(const Object& o);
Value(const Value& v);
};
} // namespace Json
} // namespace sce

View File

@ -35,8 +35,7 @@ EXPORT SYSV_ABI int sceNetCtlGetResult(int eventType, int* errorCode) {
}
EXPORT SYSV_ABI int sceNetCtlGetState(int* state) {
*state = 3; // IP address obtained
return Ok;
return accessNetworking().netCtlGetState(state);
}
EXPORT SYSV_ABI int sceNetCtlGetInfo(int code, SceNetCtlInfo* info) {

View File

@ -2,6 +2,7 @@
#include <stdint.h>
namespace Err {
namespace Ngs2 {
constexpr int32_t INVALID_WAVEFORM_DATA = -2142632952;
constexpr int32_t INVALID_BUFFER_ADDRESS = -2142633465;
constexpr int32_t INVALID_BUFFER_SIZE = -2142633466;
@ -16,6 +17,7 @@ constexpr int32_t INVALID_OUT_ADDRESS = -2142633901;
constexpr int32_t INVALID_NUM_CHANNELS = -2142633902;
constexpr int32_t INVALID_MAX_GRAIN_SAMPLES = -2142633904;
constexpr int32_t FAIL = -2142633983;
} // namespace Ngs2
} // namespace Err
constexpr int32_t SCE_NGS2_MAX_VOICE_CHANNELS = 8;

View File

@ -109,7 +109,7 @@ static int32_t ParseData(const uint8_t* data, size_t size, SceNgs2WaveformFormat
int ret = avformat_open_input(&fmtctx, "nullptr", nullptr, nullptr);
if (ret != 0) {
LOG_ERR(L"ParseRIFF: ffmpeg failed to read passed data: %d", ret);
return Err::FAIL;
return Err::Ngs2::FAIL;
}
AVStream* astream = nullptr;
@ -122,7 +122,7 @@ static int32_t ParseData(const uint8_t* data, size_t size, SceNgs2WaveformFormat
if (astream == nullptr) {
LOG_ERR(L"ParseRIFF: no audio stream detected!");
return Err::FAIL;
return Err::Ngs2::FAIL;
}
wf->info.type = ParseWaveType(astream->codecpar->codec_id);
@ -165,7 +165,7 @@ static int32_t ProcessWaveData(WaveformInfo* wi, SceNgs2WaveformFormat* wf) {
}
/* todo: Deal with WAV/VAG files */
return Err::INVALID_WAVEFORM_DATA;
return Err::Ngs2::INVALID_WAVEFORM_DATA;
}
} // namespace
@ -202,7 +202,7 @@ EXPORT SYSV_ABI int32_t sceNgs2ParseWaveformData(const void* ptr, size_t size, S
LOG_TRACE(L"todo %S", __FUNCTION__);
if (ptr == nullptr) {
return Err::INVALID_BUFFER_ADDRESS;
return Err::Ngs2::INVALID_BUFFER_ADDRESS;
}
WaveformInfo wi {
@ -253,7 +253,7 @@ EXPORT SYSV_ABI int32_t sceNgs2ParseWaveformFile(const char* path, long offset,
};
if (wi.ud.fileHandle == 0) {
return Err::INVALID_WAVEFORM_DATA;
return Err::Ngs2::INVALID_WAVEFORM_DATA;
}
return ProcessWaveData(&wi, wf);
@ -264,7 +264,7 @@ EXPORT SYSV_ABI int32_t sceNgs2ParseWaveformUser(SceWaveformUserFunc* user, size
LOG_ERR(L"todo %S", __FUNCTION__);
if (user == nullptr) {
return Err::INVALID_BUFFER_ADDRESS;
return Err::Ngs2::INVALID_BUFFER_ADDRESS;
}
WaveformInfo wi {
@ -296,8 +296,8 @@ EXPORT SYSV_ABI int32_t sceNgs2RackGetUserData(SceNgs2Handle* rh, uintptr_t* use
}
EXPORT SYSV_ABI int32_t sceNgs2RackGetVoiceHandle(SceNgs2Handle* rh, uint32_t voiceId, SceNgs2Handle** outh) {
if (rh == nullptr) return Err::INVALID_RACK_HANDLE;
if (voiceId > 0) return Err::INVALID_VOICE_INDEX; // todo: how much indexes??
if (rh == nullptr) return Err::Ngs2::INVALID_RACK_HANDLE;
if (voiceId > rh->un.rack.info.maxVoices) return Err::Ngs2::INVALID_VOICE_INDEX;
LOG_USE_MODULE(libSceNgs2);
LOG_TRACE(L"todo %S", __FUNCTION__);
// todo: write to outh voice handle from rack
@ -361,11 +361,11 @@ EXPORT SYSV_ABI int32_t sceNgs2SystemUnlock(SceNgs2Handle* sysh) {
EXPORT SYSV_ABI int32_t sceNgs2SystemRender(SceNgs2Handle* sysh, SceNgs2RenderBufferInfo* rbi, int32_t count) {
LOG_USE_MODULE(libSceNgs2);
LOG_TRACE(L"todo %S", __FUNCTION__);
if (sysh == nullptr) return Err::INVALID_SYSTEM_HANDLE;
if (rbi->bufferPtr == nullptr) return Err::INVALID_BUFFER_ADDRESS;
if (rbi->bufferSize == 0) return Err::INVALID_BUFFER_SIZE;
if (rbi->waveType >= SceNgs2WaveFormType::MAX_TYPES) return Err::INVALID_WAVEFORM_TYPE;
if (rbi->channelsCount > SceNgs2ChannelsCount::CH_7_1) return Err::INVALID_NUM_CHANNELS;
if (sysh == nullptr) return Err::Ngs2::INVALID_SYSTEM_HANDLE;
if (rbi->bufferPtr == nullptr) return Err::Ngs2::INVALID_BUFFER_ADDRESS;
if (rbi->bufferSize == 0) return Err::Ngs2::INVALID_BUFFER_SIZE;
if (rbi->waveType >= SceNgs2WaveFormType::MAX_TYPES) return Err::Ngs2::INVALID_WAVEFORM_TYPE;
if (rbi->channelsCount > SceNgs2ChannelsCount::CH_7_1) return Err::Ngs2::INVALID_NUM_CHANNELS;
for (int32_t i = 0; i < count; i++) {
if (rbi[i].bufferPtr != nullptr) {
@ -465,16 +465,47 @@ EXPORT SYSV_ABI int32_t sceNgs2GeomResetSourceParam(SceNgs2GeomSourceParam* para
return Ok;
}
EXPORT SYSV_ABI int32_t sceNgs2RackCreate(SceNgs2Handle* sysh, uint32_t rackId, const SceNgs2RackOption* ro, const SceNgs2ContextBufferInfo* cbi,
EXPORT SYSV_ABI int32_t sceNgs2RackCreate(SceNgs2Handle* sysh, uint32_t rackId, const SceNgs2RackOption* ropt, const SceNgs2ContextBufferInfo* cbi,
SceNgs2Handle** outh) {
LOG_USE_MODULE(libSceNgs2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
LOG_ERR(L"todo %S(%p, %d, %p, %p, %p)", __FUNCTION__, sysh, rackId, ropt, cbi, outh);
if (outh == nullptr) return Err::Ngs2::INVALID_OUT_ADDRESS;
if (sysh == nullptr) return Err::Ngs2::INVALID_SYSTEM_HANDLE;
if (ropt != nullptr && ropt->size < sizeof(SceNgs2RackOption)) return Err::Ngs2::INVALID_OPTION_SIZE;
if (cbi == nullptr || cbi->hostBuffer == nullptr || cbi->hostBufferSize < sizeof(SceNgs2Handle)) return Err::Ngs2::INVALID_BUFFER_ADDRESS;
*outh = (SceNgs2Handle*)cbi->hostBuffer;
(*outh)->allocSet = false;
(*outh)->alloc.allocHandler = nullptr;
(*outh)->alloc.freeHandler = nullptr;
(*outh)->alloc.userData = nullptr;
(*outh)->owner = sysh;
if (ropt != nullptr) {
(*outh)->un.rack.info.maxPorts = ropt->maxPorts;
(*outh)->un.rack.info.maxMatrices = ropt->maxMatrices;
(*outh)->un.rack.info.maxGrainSamples = ropt->maxGrainSamples;
(*outh)->un.rack.info.maxVoices = ropt->maxVoices;
} else {
(*outh)->un.rack.info.maxPorts = 1;
(*outh)->un.rack.info.maxMatrices = 1;
(*outh)->un.rack.info.maxGrainSamples = 1;
(*outh)->un.rack.info.maxVoices = 1;
}
auto vo = (*outh)->un.rack.voices = new SceNgs2Handle;
vo->allocSet = false;
vo->alloc.allocHandler = nullptr;
vo->alloc.freeHandler = nullptr;
vo->alloc.userData = nullptr;
return (*outh) != nullptr ? Ok : Err::Ngs2::FAIL;
}
EXPORT SYSV_ABI int32_t sceNgs2RackCreateWithAllocator(SceNgs2Handle* sysh, uint32_t rackId, const SceNgs2RackOption* ro, const SceNgs2BufferAllocator* alloc,
SceNgs2Handle** outh) {
if (sysh == nullptr) return Err::INVALID_SYSTEM_HANDLE;
if (sysh == nullptr) return Err::Ngs2::INVALID_SYSTEM_HANDLE;
if (alloc == nullptr) return Err::Ngs2::INVALID_BUFFER_ALLOCATOR;
LOG_USE_MODULE(libSceNgs2);
LOG_TRACE(L"todo %S", __FUNCTION__);
@ -510,12 +541,18 @@ EXPORT SYSV_ABI int32_t sceNgs2RackCreateWithAllocator(SceNgs2Handle* sysh, uint
}
EXPORT SYSV_ABI int32_t sceNgs2RackDestroy(SceNgs2Handle* rh, SceNgs2ContextBufferInfo* cbi) {
if (rh == nullptr) return Err::INVALID_SYSTEM_HANDLE;
if (rh == nullptr) return Err::Ngs2::INVALID_SYSTEM_HANDLE;
if (rh->allocSet) {
cbi->hostBuffer = rh;
cbi->hostBufferSize = sizeof(SceNgs2Handle);
cbi->hostBuffer = rh->un.rack.voices;
if (auto ret = rh->alloc.freeHandler(cbi)) return ret;
cbi->hostBuffer = rh;
if (auto ret = rh->alloc.freeHandler(cbi)) return ret;
} else {
if (rh->un.rack.voices != nullptr) delete rh->un.rack.voices;
delete rh;
}
return Ok;
}
@ -527,9 +564,9 @@ EXPORT SYSV_ABI int32_t sceNgs2RackQueryBufferSize(uint32_t rackId, const SceNgs
EXPORT SYSV_ABI int32_t sceNgs2SystemCreateWithAllocator(const SceNgs2SystemOption* sysopt, SceNgs2BufferAllocator* alloc, SceNgs2Handle** outh) {
LOG_USE_MODULE(libSceNgs2);
LOG_ERR(L"todo %S(%p, %p, %p)", __FUNCTION__, sysopt, alloc, outh);
if (alloc == nullptr || alloc->allocHandler == nullptr) return Err::INVALID_BUFFER_ALLOCATOR;
if (outh == nullptr) return Err::INVALID_OUT_ADDRESS;
if (sysopt != nullptr || sysopt->size < sizeof(SceNgs2SystemOption)) return Err::INVALID_OPTION_SIZE;
if (alloc == nullptr || alloc->allocHandler == nullptr) return Err::Ngs2::INVALID_BUFFER_ALLOCATOR;
if (outh == nullptr) return Err::Ngs2::INVALID_OUT_ADDRESS;
if (sysopt != nullptr && sysopt->size < sizeof(SceNgs2SystemOption)) return Err::Ngs2::INVALID_OPTION_SIZE;
SceNgs2ContextBufferInfo cbi = {
.hostBuffer = nullptr,
@ -554,29 +591,32 @@ EXPORT SYSV_ABI int32_t sceNgs2SystemCreateWithAllocator(const SceNgs2SystemOpti
EXPORT SYSV_ABI int32_t sceNgs2SystemCreate(const SceNgs2SystemOption* sysopt, const SceNgs2ContextBufferInfo* cbi, SceNgs2Handle** outh) {
LOG_USE_MODULE(libSceNgs2);
LOG_ERR(L"todo %S(%p, %p, %p)", __FUNCTION__, sysopt, cbi, outh);
if (outh == nullptr) return Err::INVALID_OUT_ADDRESS;
if (sysopt != nullptr && sysopt->size != sizeof(SceNgs2SystemOption)) return Err::INVALID_OPTION_SIZE;
if (cbi == nullptr || cbi->hostBuffer == nullptr || cbi->hostBufferSize < sizeof(SceNgs2Handle)) return Err::INVALID_BUFFER_ADDRESS;
if (outh == nullptr) return Err::Ngs2::INVALID_OUT_ADDRESS;
if (sysopt != nullptr && sysopt->size < sizeof(SceNgs2SystemOption)) return Err::Ngs2::INVALID_OPTION_SIZE;
if (cbi == nullptr || cbi->hostBuffer == nullptr || cbi->hostBufferSize < sizeof(SceNgs2Handle)) return Err::Ngs2::INVALID_BUFFER_ADDRESS;
*outh = (SceNgs2Handle*)cbi->hostBuffer;
(*outh)->allocSet = false;
(*outh)->owner = nullptr;
return (*outh) != nullptr ? Ok : Err::FAIL;
return (*outh) != nullptr ? Ok : Err::Ngs2::FAIL;
}
EXPORT SYSV_ABI int32_t sceNgs2SystemDestroy(SceNgs2Handle* sysh, SceNgs2ContextBufferInfo* cbi) {
if (sysh == nullptr) return Err::INVALID_SYSTEM_HANDLE;
if (sysh == nullptr) return Err::Ngs2::INVALID_SYSTEM_HANDLE;
if (sysh->allocSet) {
cbi->hostBuffer = sysh;
cbi->hostBufferSize = sizeof(SceNgs2Handle);
if (auto ret = sysh->alloc.freeHandler(cbi)) return ret;
} else {
delete sysh;
}
return Ok;
}
EXPORT SYSV_ABI int32_t sceNgs2SystemQueryBufferSize(const SceNgs2SystemOption* sysopt, SceNgs2ContextBufferInfo* cbi) {
if (cbi == nullptr) return Err::INVALID_BUFFER_ADDRESS;
if (cbi == nullptr) return Err::Ngs2::INVALID_BUFFER_ADDRESS;
cbi->hostBufferSize = sizeof(SceNgs2Handle);
return Ok;
}

View File

@ -68,4 +68,10 @@ EXPORT SYSV_ABI int32_t sceNpAuthGetIdTokenA() {
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}
EXPORT SYSV_ABI int32_t sceNpAuthGetAuthorizationCodeV3() {
LOG_USE_MODULE(libSceNpAuth);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}
}

View File

@ -1,5 +1,5 @@
#include "codes.h"
#include "common.h"
#include "errorcodes.h"
#include "logging.h"
LOG_DEFINE_MODULE(libSceNpGameIntent);

View File

@ -1,5 +1,5 @@
#include "codes.h"
#include "common.h"
#include "errorcodes.h"
#include "logging.h"
LOG_DEFINE_MODULE(libSceNpToolkit2);

View File

@ -24,4 +24,8 @@ EXPORT SYSV_ABI int32_t sceNpWebApi2AddHttpRequestHeader() {
EXPORT SYSV_ABI int32_t sceNpWebApi2SendRequest() {
return Ok;
}
EXPORT SYSV_ABI int32_t sceNpWebApi2CreateUserContext() {
return Ok;
}
}

View File

@ -2,6 +2,7 @@
#include <stdint.h>
namespace Err {
namespace Pad {
constexpr int32_t INVALID_ARG = -2137915391; /* 0x80920001 */
constexpr int32_t INVALID_PORT = -2137915390; /* 0x80920002 */
constexpr int32_t INVALID_HANDLE = -2137915389; /* 0x80920003 */
@ -11,8 +12,8 @@ constexpr int32_t INVALID_LIGHTBAR_SETTING = -2137915386; /* 0x80920006 */
constexpr int32_t DEVICE_NOT_CONNECTED = -2137915385; /* 0x80920007 */
constexpr int32_t NO_HANDLE = -2137915384; /* 0x80920008 */
constexpr int32_t FATAL = -2137915137; /* 0x809200FF */
} // namespace Pad
} // namespace Err
constexpr uint32_t SCE_PAD_MAX_TOUCH_NUM = 2;
constexpr uint32_t SCE_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE = 12;
constexpr uint32_t SCE_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE = 12;

View File

@ -1,16 +1,12 @@
#include "cconfig.h"
#include "common.h"
#include "core/timer/timer.h"
#include "core/videoout/videoout.h"
#include "interfaces/ikbd.h"
#include "interfaces/isdl.h"
#include "interfaces/ixip.h"
#include "logging.h"
#include "types.h"
#include <algorithm>
#include <chrono>
LOG_DEFINE_MODULE(libScePad);
namespace {
@ -19,7 +15,7 @@ constexpr uint32_t MAX_CONTROLLERS_COUNT = 16;
struct Controller {
int32_t userId = -1;
std::unique_ptr<IController> padPtr;
std::unique_ptr<IController> backend;
ScePadData prePadData;
};
@ -28,14 +24,59 @@ struct Pimpl {
std::mutex m_mutexInt;
ControllerConfig cfg;
std::array<Controller, MAX_CONTROLLERS_COUNT /* Define? */> controller;
ControllerConfig cfg;
std::array<Controller, MAX_CONTROLLERS_COUNT> controller;
};
static auto* getData() {
static Pimpl obj;
return &obj;
}
static int _padOpen(int32_t userId, PadPortType type, int32_t index, const void* pParam) {
if ((userId < 1 || userId > 4) && userId != 0xFF) return Err::Pad::INVALID_ARG;
if (type == PadPortType::REMOTE_CONTROL && userId != 0xFF) return Err::Pad::INVALID_ARG;
if (type != PadPortType::STANDARD && type != PadPortType::SPECIAL) return Err::Pad::INVALID_ARG;
LOG_USE_MODULE(libScePad);
auto pData = getData();
std::unique_lock const lock(pData->m_mutexInt);
// Check already opened
for (uint32_t n = 0; n < MAX_CONTROLLERS_COUNT; ++n) {
if (pData->controller[n].userId == userId) return Err::Pad::ALREADY_OPENED;
}
// - already open
for (int n = 0; n < MAX_CONTROLLERS_COUNT; ++n) {
if (pData->controller[n].userId >= 0) continue;
auto& padBackend = pData->controller[n].backend;
pData->controller[n].prePadData = ScePadData();
pData->controller[n].userId = userId;
switch (pData->cfg.GetPadType(userId)) {
case ControllerType::SDL: padBackend = createController_sdl(&pData->cfg, userId); break;
case ControllerType::Xinput: padBackend = createController_xinput(&pData->cfg, userId); break;
case ControllerType::Keyboard: padBackend = createController_keyboard(&pData->cfg, userId); break;
default: LOG_CRIT(L"Unimplemented controller type!"); return Err::Pad::FATAL;
}
LOG_INFO(L"-> Pad[%d]: userId:%d name:%S guid:%S", n, userId, padBackend->getName(), padBackend->getGUID());
return n + 1;
}
return Err::Pad::NO_HANDLE;
}
static inline Controller* getController(int32_t handle) {
if (handle < 1 || handle >= MAX_CONTROLLERS_COUNT) return nullptr;
return &getData()->controller[handle - 1];
}
} // namespace
extern "C" {
@ -44,106 +85,69 @@ EXPORT const char* MODULE_NAME = "libScePad";
EXPORT SYSV_ABI int scePadInit(void) {
LOG_USE_MODULE(libScePad);
LOG_TRACE(L"scePadInit()");
(void)getData();
return Ok;
}
EXPORT SYSV_ABI int scePadOpen(int32_t userId, PadPortType type, int32_t index, const void* pParam) {
if (userId < 1 || userId > 4) return Err::INVALID_ARG;
LOG_USE_MODULE(libScePad);
auto pData = getData();
std::unique_lock const lock(pData->m_mutexInt);
// Check already opened
for (uint32_t n = 0; n < MAX_CONTROLLERS_COUNT; ++n) {
if (pData->controller[n].userId == userId) return Err::ALREADY_OPENED;
}
// - already open
for (int n = 0; n < MAX_CONTROLLERS_COUNT; ++n) {
if (pData->controller[n].userId >= 0) continue;
auto& pController = pData->controller[n].padPtr;
pData->controller[n].prePadData = ScePadData();
pData->controller[n].userId = userId;
switch (pData->cfg.GetPadType(userId)) {
case ControllerType::SDL: pController = createController_sdl(&pData->cfg, userId); break;
case ControllerType::Xinput: pController = createController_xinput(&pData->cfg, userId); break;
case ControllerType::Keyboard: pController = createController_keyboard(&pData->cfg, userId); break;
default: LOG_CRIT(L"Unimplemented controller type!"); return Err::FATAL;
}
LOG_INFO(L"-> Pad[%d]: userId:%d name:%S guid:%S", n, userId, pController->getName(), pController->getGUID());
return n;
}
return Err::NO_HANDLE;
EXPORT SYSV_ABI int scePadOpen(int32_t userId, PadPortType type, int32_t index, const void* param) {
return _padOpen(userId, type, index, param);
}
EXPORT SYSV_ABI int scePadOpenExt(int userId, int type, int index, int param) {
if (userId < 1 || userId > 4) return Err::INVALID_ARG;
LOG_USE_MODULE(libScePad);
LOG_DEBUG(L"todo %S", __FUNCTION__);
return Ok;
EXPORT SYSV_ABI int scePadOpenExt(int userId, PadPortType type, int index, const void* param) {
return _padOpen(userId, type, index, param);
}
EXPORT SYSV_ABI int scePadClose(int32_t handle) {
if (handle < 0) return Ok;
LOG_USE_MODULE(libScePad);
auto pData = getData();
std::unique_lock const lock(pData->m_mutexInt);
LOG_INFO(L"<- Pad[%d]", handle);
pData->controller[handle].userId = -1;
if (pData->controller[handle].padPtr) {
pData->controller[handle].padPtr->close();
if (auto ctl = getController(handle)) {
std::unique_lock const lock(getData()->m_mutexInt);
ctl->userId = -1;
if (ctl->backend) ctl->backend->close();
return Ok;
}
return Ok;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadGetHandle(int32_t userId, PadPortType type, int32_t index) {
if (userId < 1 || userId > 4) return Err::INVALID_ARG;
auto pData = getData();
LOG_USE_MODULE(libScePad);
LOG_DEBUG(L"");
auto pData = getData();
std::unique_lock const lock(pData->m_mutexInt);
for (uint32_t n = 0; n < MAX_CONTROLLERS_COUNT; ++n) {
if (pData->controller[n].userId == userId) {
return n;
return n + 1;
}
}
return Err::NO_HANDLE;
return Err::Pad::NO_HANDLE;
}
EXPORT SYSV_ABI int scePadRead(int32_t handle, ScePadData* pPadData, int32_t num) {
LOG_USE_MODULE(libScePad);
if (handle < 0) return Err::INVALID_HANDLE;
auto pData = getData();
auto& pController = pData->controller[handle].padPtr;
if (!pController) return Err::INVALID_HANDLE;
if (auto ctl = getController(handle)) {
if (ctl->backend == nullptr) return Err::Pad::INVALID_HANDLE;
std::unique_lock const lock(pData->m_mutexInt);
std::unique_lock const lock(getData()->m_mutexInt);
pController->readPadData(*pPadData);
ctl->backend->readPadData(*pPadData);
int retVal = std::memcmp((uint8_t*)&pData->controller[handle].prePadData, (uint8_t*)pPadData, offsetof(ScePadData, connected));
LOG_TRACE(L"buttons 0x%x leftStick:%u/%u rightStick:%u/%u L2/R2:%u,%u diff:%d", pPadData->buttons, pPadData->leftStick.x, pPadData->leftStick.y,
pPadData->rightStick.x, pPadData->rightStick.y, pPadData->analogButtons.l2, pPadData->analogButtons.r2, retVal);
int retVal = std::memcmp((uint8_t*)&ctl->prePadData, (uint8_t*)pPadData, offsetof(ScePadData, connected));
LOG_TRACE(L"buttons 0x%x leftStick:%u/%u rightStick:%u/%u L2/R2:%u,%u diff:%d", pPadData->buttons, pPadData->leftStick.x, pPadData->leftStick.y,
pPadData->rightStick.x, pPadData->rightStick.y, pPadData->analogButtons.l2, pPadData->analogButtons.r2, retVal);
pData->controller[handle].prePadData = *pPadData;
return abs(retVal);
ctl->prePadData = *pPadData;
return abs(retVal);
}
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadReadState(int32_t handle, ScePadData* pData) {
@ -152,127 +156,125 @@ EXPORT SYSV_ABI int scePadReadState(int32_t handle, ScePadData* pData) {
}
EXPORT SYSV_ABI int scePadSetMotionSensorState(int32_t handle, bool bEnable) {
LOG_USE_MODULE(libScePad);
if (handle < 0) return Err::INVALID_HANDLE;
if (auto ctl = getController(handle)) {
if (ctl->backend == nullptr) return Err::Pad::INVALID_HANDLE;
ctl->backend->setMotion(bEnable);
return Ok;
}
auto pData = getData();
auto& pController = pData->controller[handle].padPtr;
if (!pController) return Err::INVALID_HANDLE;
pController->setMotion(bEnable);
return Ok;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadSetTiltCorrectionState(int32_t handle, bool bEnable) {
if (handle < 0) return Err::INVALID_HANDLE;
if (getController(handle) == nullptr) return Err::Pad::INVALID_ARG;
return Ok;
}
EXPORT SYSV_ABI int scePadSetAngularVelocityDeadbandState(int32_t handle, bool bEnable) {
if (handle < 0) return Err::INVALID_HANDLE;
if (getController(handle) == nullptr) return Err::Pad::INVALID_ARG;
return Ok;
}
EXPORT SYSV_ABI int scePadResetOrientation(int32_t handle) {
if (handle < 0) return Err::INVALID_HANDLE;
auto pData = getData();
auto& pController = pData->controller[handle].padPtr;
if (!pController) return Err::INVALID_HANDLE;
if (auto ctl = getController(handle)) {
if (ctl->backend == nullptr) return Err::Pad::INVALID_HANDLE;
ctl->backend->resetOrientation();
return Ok;
}
return pController->resetOrientation() ? Ok : Err::FATAL;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadSetVibration(int32_t handle, const ScePadVibrationParam* pParam) {
if (handle < 0) return Err::INVALID_HANDLE;
if (pParam == nullptr) return Err::INVALID_ARG;
if (pParam == nullptr) return Err::Pad::INVALID_ARG;
auto pData = getData();
auto& pController = pData->controller[handle].padPtr;
if (!pController) return Err::INVALID_HANDLE;
if (auto ctl = getController(handle)) {
if (ctl->backend == nullptr) return Err::Pad::INVALID_HANDLE;
return ctl->backend->setRumble(pParam) ? Ok : Err::Pad::INVALID_ARG;
}
return pController->setRumble(pParam) ? Ok : Err::INVALID_ARG;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadSetLightBar(int32_t handle, const ScePadColor* pParam) {
if (handle < 0) return Err::INVALID_HANDLE;
if (pParam == nullptr) return Err::INVALID_ARG;
if (pParam == nullptr) return Err::Pad::INVALID_ARG;
auto pData = getData();
auto& pController = pData->controller[handle].padPtr;
if (!pController) return Err::INVALID_HANDLE;
if (auto ctl = getController(handle)) {
if (ctl->backend == nullptr) return Err::Pad::INVALID_HANDLE;
return ctl->backend->setLED(pParam) ? Ok : Err::Pad::INVALID_LIGHTBAR_SETTING;
}
return pController->setLED(pParam) ? Ok : Err::INVALID_LIGHTBAR_SETTING;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadResetLightBar(int32_t handle) {
if (handle < 0) return Err::INVALID_HANDLE;
if (auto ctl = getController(handle)) {
if (ctl->backend == nullptr) return Err::Pad::INVALID_HANDLE;
return ctl->backend->resetLED() ? Ok : Err::Pad::INVALID_LIGHTBAR_SETTING;
}
auto pData = getData();
auto& pController = pData->controller[handle].padPtr;
if (!pController) return Err::INVALID_HANDLE;
return pController->resetLED() ? Ok : Err::INVALID_LIGHTBAR_SETTING;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadGetControllerInformation(int32_t handle, ScePadControllerInformation* pInfo) {
LOG_USE_MODULE(libScePad);
if (handle < 0) return Err::INVALID_HANDLE;
auto pData = getData();
std::unique_lock const lock(pData->m_mutexInt);
if (auto ctl = getController(handle)) {
std::unique_lock const lock(getData()->m_mutexInt);
auto const& pad = pData->controller[handle];
// Not connected -> defaults
if (ctl->userId < 0) {
pInfo->touchPadInfo.pixelDensity = 1.f;
pInfo->touchPadInfo.resolution.x = 1920;
pInfo->touchPadInfo.resolution.y = 950;
// Not connected -> defaults
if (pad.userId < 0) {
pInfo->touchPadInfo.pixelDensity = 1.f;
pInfo->stickInfo.deadZoneLeft = 2; // todo make config
pInfo->stickInfo.deadZoneRight = 2; // todo make config
pInfo->connectionType = (uint8_t)PadPortType::STANDARD;
pInfo->connectedCount = ctl->backend ? ctl->backend->getConnectionsCount() : 0;
pInfo->connected = false;
pInfo->deviceClass = ScePadDeviceClass::STANDARD;
return Ok;
}
// -
pInfo->connectionType = ctl->backend->getPortType();
pInfo->connectedCount = ctl->backend->getConnectionsCount();
pInfo->connected = ctl->backend->isConnected();
pInfo->deviceClass = ctl->backend->getClass();
pInfo->touchPadInfo.pixelDensity = 44.86f;
pInfo->touchPadInfo.resolution.x = 1920;
pInfo->touchPadInfo.resolution.y = 950;
pInfo->touchPadInfo.resolution.y = 943;
pInfo->stickInfo.deadZoneLeft = 2; // todo make config
pInfo->stickInfo.deadZoneRight = 2; // todo make config
pInfo->connectionType = (uint8_t)PadPortType::STANDARD;
pInfo->connectedCount = pad.padPtr ? pad.padPtr->getConnectionsCount() : 0;
pInfo->connected = false;
pInfo->deviceClass = ScePadDeviceClass::STANDARD;
LOG_DEBUG(L"handle:%d connected:%d", handle, pInfo->connected);
return Ok;
}
// -
pInfo->touchPadInfo.pixelDensity = 44.86f;
pInfo->touchPadInfo.resolution.x = 1920;
pInfo->touchPadInfo.resolution.y = 943;
pInfo->stickInfo.deadZoneLeft = 2; // todo make config
pInfo->stickInfo.deadZoneRight = 2; // todo make config
pInfo->connectionType = pad.padPtr->getPortType();
pInfo->connectedCount = pad.padPtr->getConnectionsCount();
pInfo->connected = pad.padPtr->isConnected();
pInfo->deviceClass = pad.padPtr->getClass();
LOG_DEBUG(L"handle:%d connected:%d", handle, pInfo->connected);
return Ok;
return Err::Pad::INVALID_ARG;
}
EXPORT SYSV_ABI int scePadGetExtControllerInformation(int32_t handle, ScePadExtControllerInformation* pInfo) {
if (getController(handle) == nullptr) return Err::Pad::INVALID_ARG;
LOG_USE_MODULE(libScePad);
LOG_DEBUG(L"todo %S", __FUNCTION__);
if (handle < 0) return Err::INVALID_HANDLE;
return Ok;
}
EXPORT SYSV_ABI int scePadDeviceClassParseData(int32_t handle, const ScePadData* pData, ScePadDeviceClassData* pDeviceClassData) {
if (getController(handle) == nullptr) return Err::Pad::INVALID_ARG;
LOG_USE_MODULE(libScePad);
LOG_DEBUG(L"todo %S", __FUNCTION__);
if (handle < 0) return Err::INVALID_HANDLE;
return Ok;
}
EXPORT SYSV_ABI int scePadDeviceClassGetExtendedInformation(int32_t handle, ScePadDeviceClassExtendedInformation* pExtInfo) {
if (getController(handle) == nullptr) return Err::Pad::INVALID_ARG;
LOG_USE_MODULE(libScePad);
LOG_DEBUG(L"todo %S", __FUNCTION__);
if (handle < 0) return Err::INVALID_HANDLE;
return Ok;
}
@ -280,9 +282,7 @@ EXPORT SYSV_ABI void scePadTerminate() {
auto pData = getData();
for (int i = 0; i < MAX_CONTROLLERS_COUNT; i++) {
if (auto& ptr = pData->controller[i].padPtr; ptr.get() != nullptr) {
ptr->close();
}
if (auto backend = pData->controller[i].backend.get()) backend->close();
}
}
}

View File

@ -79,7 +79,6 @@ uint32_t KBDController::getButtons(const uint8_t* keys) {
#define MAP_TRIGGER(_keys, _down) (uint8_t)(resolveBindFor(_keys, _down) ? 0xFF : 0x00)
bool KBDController::readPadData(ScePadData& data) {
if (m_state == ControllerState::Closed) return false;
const uint8_t* keys = SDL_GetKeyboardState(nullptr);

View File

@ -16,6 +16,7 @@ class SDLPadManager {
public:
SDL_GameController* openNew() {
for (int n = 0; n < SDL_NumJoysticks(); n++) {
if (!SDL_IsGameController(n)) continue;
auto pad = SDL_GameControllerOpen(n);
if (std::find(m_openedPads.begin(), m_openedPads.end(), pad) != m_openedPads.end()) continue;
m_openedPads.push_back(pad);
@ -191,20 +192,23 @@ bool SDLController::readPadData(ScePadData& data) {
.touchData =
{
.touchNum = 0,
.touch = {{
.x = 0,
.y = 0,
.id = 1,
},
{
.x = 0,
.y = 0,
.id = 2,
}},
.touch =
{
{
.x = 0,
.y = 0,
.id = 1,
},
{
.x = 0,
.y = 0,
.id = 2,
},
},
},
.connected = m_state == ControllerState::Connected,
.connected = IController::isConnected(),
.timestamp = accessTimer().getTicks(),
.connectedCount = m_connectCount,
.deviceUniqueDataLen = 0,

View File

@ -182,20 +182,23 @@ bool XIPController::readPadData(ScePadData& data) {
.touchData =
{
.touchNum = 0,
.touch = {{
.x = 0,
.y = 0,
.id = 1,
},
{
.x = 0,
.y = 0,
.id = 2,
}},
.touch =
{
{
.x = 0,
.y = 0,
.id = 1,
},
{
.x = 0,
.y = 0,
.id = 2,
},
},
},
.connected = m_state == ControllerState::Connected,
.connected = IController::isConnected(),
.timestamp = accessTimer().getTicks(),
.connectedCount = m_connectCount,
.deviceUniqueDataLen = 0,

View File

@ -2,6 +2,7 @@
#include <stdint.h>
namespace Err {
namespace PngDec {
constexpr int32_t INVALID_ADDR = -2140602367;
constexpr int32_t INVALID_SIZE = -2140602366;
constexpr int32_t INVALID_PARAM = -2140602365;
@ -10,6 +11,7 @@ constexpr int32_t INVALID_DATA = -2140602352;
constexpr int32_t UNSUPPORT_DATA = -2140602351;
constexpr int32_t DECODE_ERROR = -2140602350;
constexpr int32_t FATAL = -2140602336;
} // namespace PngDec
} // namespace Err
constexpr uint8_t SCE_PNG_DEC_IMAGE_FLAG_ADAM7_INTERLACE = 1;

View File

@ -36,12 +36,12 @@ extern "C" {
EXPORT const char* MODULE_NAME = "libScePngDec";
EXPORT SYSV_ABI int32_t scePngDecCreate(const ScePngDecCreateParam* param, void* mem, uint32_t size, ScePngDecHandle* handle) {
if (mem == nullptr) return Err::INVALID_ADDR;
if (size < sizeof(_PngHandle)) return Err::INVALID_SIZE;
if (mem == nullptr) return Err::PngDec::INVALID_ADDR;
if (size < sizeof(_PngHandle)) return Err::PngDec::INVALID_SIZE;
auto pngh = (_PngHandle*)mem;
pngh->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (pngh->png == nullptr) return Err::FATAL;
if (pngh->png == nullptr) return Err::PngDec::FATAL;
pngh->info = png_create_info_struct(pngh->png);
if (pngh->info == nullptr) {
@ -55,10 +55,10 @@ EXPORT SYSV_ABI int32_t scePngDecCreate(const ScePngDecCreateParam* param, void*
EXPORT SYSV_ABI int32_t scePngDecDecode(ScePngDecHandle handle, const ScePngDecDecodeParam* param, ScePngDecImageInfo* ii) {
LOG_USE_MODULE(libScePngDec);
if (param->pngAddr == nullptr || param->imageAddr == nullptr) return Err::INVALID_ADDR;
if (param->pngSize < 8) return Err::INVALID_SIZE;
if (png_sig_cmp((png_const_bytep)param->pngAddr, 0, 8) != 0) return Err::INVALID_DATA;
if (handle == nullptr) return Err::INVALID_HANDLE;
if (param->pngAddr == nullptr || param->imageAddr == nullptr) return Err::PngDec::INVALID_ADDR;
if (param->pngSize < 8) return Err::PngDec::INVALID_SIZE;
if (png_sig_cmp((png_const_bytep)param->pngAddr, 0, 8) != 0) return Err::PngDec::INVALID_DATA;
if (handle == nullptr) return Err::PngDec::INVALID_HANDLE;
auto pngh = (_PngHandle*)handle;
struct pngreader {
@ -95,7 +95,7 @@ EXPORT SYSV_ABI int32_t scePngDecDecode(ScePngDecHandle handle, const ScePngDecD
if (png_get_valid(pngh->png, pngh->info, PNG_INFO_tRNS)) ii->imageFlag |= SCE_PNG_DEC_IMAGE_FLAG_TRNS_CHUNK_EXIST;
}
if ((w * h * 4) > param->imageSize) return Err::INVALID_SIZE;
if ((w * h * 4) > param->imageSize) return Err::PngDec::INVALID_SIZE;
if (bi == 16) png_set_strip_16(pngh->png);
if (ct == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(pngh->png);
if (ct == PNG_COLOR_TYPE_GRAY && bi < 8) png_set_expand_gray_1_2_4_to_8(pngh->png);
@ -124,16 +124,16 @@ EXPORT SYSV_ABI int32_t scePngDecDecode(ScePngDecHandle handle, const ScePngDecD
}
EXPORT SYSV_ABI int32_t scePngDecDelete(ScePngDecHandle handle) {
if (handle == nullptr) return Err::INVALID_HANDLE;
if (handle == nullptr) return Err::PngDec::INVALID_HANDLE;
auto pngh = *(_PngHandle**)handle;
png_destroy_read_struct(&pngh->png, &pngh->info, nullptr);
return Ok;
}
EXPORT SYSV_ABI int32_t scePngDecParseHeader(const ScePngDecParseParam* param, ScePngDecImageInfo* ii) {
if (param->pngAddr == nullptr) return Err::INVALID_ADDR;
if (param->pngSize < 8) return Err::INVALID_SIZE;
if (png_sig_cmp((png_const_bytep)param->pngAddr, 0, 8) != 0) return Err::INVALID_DATA;
if (param->pngAddr == nullptr) return Err::PngDec::INVALID_ADDR;
if (param->pngSize < 8) return Err::PngDec::INVALID_SIZE;
if (png_sig_cmp((png_const_bytep)param->pngAddr, 0, 8) != 0) return Err::PngDec::INVALID_DATA;
auto png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (png_ptr == nullptr) return false;
@ -177,9 +177,9 @@ EXPORT SYSV_ABI int32_t scePngDecParseHeader(const ScePngDecParseParam* param, S
}
EXPORT SYSV_ABI int32_t scePngDecQueryMemorySize(const ScePngDecCreateParam* param) {
if (param == nullptr) return Err::INVALID_ADDR;
if (param->cbSize != sizeof(ScePngDecCreateParam)) return Err::INVALID_SIZE;
if (param->maxImageWidth > 1000000) return Err::INVALID_PARAM;
if (param == nullptr) return Err::PngDec::INVALID_ADDR;
if (param->cbSize != sizeof(ScePngDecCreateParam)) return Err::PngDec::INVALID_SIZE;
if (param->maxImageWidth > 1000000) return Err::PngDec::INVALID_PARAM;
return sizeof(_PngHandle);
}
}

View File

@ -1,19 +1,22 @@
#pragma once
#include <stdint.h>
#include <cstdint>
namespace Err {
constexpr int32_t SCE_RTC_ERROR_NOT_INITIALIZED = -2135621631;
constexpr int32_t SCE_RTC_ERROR_INVALID_POINTER = -2135621630;
constexpr int32_t SCE_RTC_ERROR_INVALID_VALUE = -2135621629;
constexpr int32_t SCE_RTC_ERROR_INVALID_ARG = -2135621628;
constexpr int32_t SCE_RTC_ERROR_NOT_SUPPORTED = -2135621627;
constexpr int32_t SCE_RTC_ERROR_NO_CLOCK = -2135621626;
constexpr int32_t SCE_RTC_ERROR_BAD_PARSE = -2135621625;
constexpr int32_t SCE_RTC_ERROR_INVALID_YEAR = -2135621624;
constexpr int32_t SCE_RTC_ERROR_INVALID_MONTH = -2135621623;
constexpr int32_t SCE_RTC_ERROR_INVALID_DAY = -2135621622;
constexpr int32_t SCE_RTC_ERROR_INVALID_HOUR = -2135621621;
constexpr int32_t SCE_RTC_ERROR_INVALID_MINUTE = -2135621620;
constexpr int32_t SCE_RTC_ERROR_INVALID_SECOND = -2135621619;
constexpr int32_t SCE_RTC_ERROR_INVALID_MICROSECOND = -2135621618;
} // namespace Err
namespace Rtc {
constexpr int32_t NOT_INITIALIZED = -2135621631;
constexpr int32_t INVALID_POINTER = -2135621630;
constexpr int32_t INVALID_VALUE = -2135621629;
constexpr int32_t INVALID_ARG = -2135621628;
constexpr int32_t NOT_SUPPORTED = -2135621627;
constexpr int32_t NO_CLOCK = -2135621626;
constexpr int32_t BAD_PARSE = -2135621625;
constexpr int32_t INVALID_YEAR = -2135621624;
constexpr int32_t INVALID_MONTH = -2135621623;
constexpr int32_t INVALID_DAY = -2135621622;
constexpr int32_t INVALID_HOUR = -2135621621;
constexpr int32_t INVALID_MINUTE = -2135621620;
constexpr int32_t INVALID_SECOND = -2135621619;
constexpr int32_t INVALID_MICROSECOND = -2135621618;
} // namespace Rtc
} // namespace Err

View File

@ -3,31 +3,31 @@
#include <string_view>
namespace Err {
constexpr int SAVE_DATA_ERROR_PARAMETER = -2137063424;
constexpr int SAVE_DATA_ERROR_NOT_INITIALIZED = -2137063423;
constexpr int SAVE_DATA_ERROR_OUT_OF_MEMORY = -2137063422;
constexpr int SAVE_DATA_ERROR_BUSY = -2137063421;
constexpr int SAVE_DATA_ERROR_NOT_MOUNTED = -2137063420;
constexpr int SAVE_DATA_ERROR_NO_PERMISSION = -2137063419;
constexpr int SAVE_DATA_ERROR_FINGERPRINT_MISMATCH = -2137063418;
constexpr int SAVE_DATA_ERROR_EXISTS = -2137063417;
constexpr int SAVE_DATA_ERROR_NOT_FOUND = -2137063416;
constexpr int SAVE_DATA_ERROR_NO_SPACE_FS = -2137063414;
constexpr int SAVE_DATA_ERROR_INTERNAL = -2137063413;
constexpr int SAVE_DATA_ERROR_MOUNT_FULL = -2137063412;
constexpr int SAVE_DATA_ERROR_BAD_MOUNTED = -2137063411;
constexpr int SAVE_DATA_ERROR_FILE_NOT_FOUND = -2137063410;
constexpr int SAVE_DATA_ERROR_BROKEN = -2137063409;
constexpr int SAVE_DATA_ERROR_INVALID_LOGIN_USER = -2137063407;
constexpr int SAVE_DATA_ERROR_MEMORY_NOT_READY = -2137063406;
constexpr int SAVE_DATA_ERROR_BACKUP_BUSY = -2137063405;
constexpr int SAVE_DATA_ERROR_NOT_REGIST_CALLBACK = -2137063403;
constexpr int SAVE_DATA_ERROR_BUSY_FOR_SAVING = -2137063402;
constexpr int SAVE_DATA_ERROR_LIMITATION_OVER = -2137063401;
constexpr int SAVE_DATA_ERROR_EVENT_BUSY = -2137063400;
constexpr int SAVE_DATA_ERROR_PARAMSFO_TRANSFER_TITLE_ID_NOT_FOUND = -2137063399;
namespace SaveData {
constexpr int PARAMETER = -2137063424;
constexpr int NOT_INITIALIZED = -2137063423;
constexpr int OUT_OF_MEMORY = -2137063422;
constexpr int BUSY = -2137063421;
constexpr int NOT_MOUNTED = -2137063420;
constexpr int NO_PERMISSION = -2137063419;
constexpr int FINGERPRINT_MISMATCH = -2137063418;
constexpr int EXISTS = -2137063417;
constexpr int NOT_FOUND = -2137063416;
constexpr int NO_SPACE_FS = -2137063414;
constexpr int INTERNAL = -2137063413;
constexpr int MOUNT_FULL = -2137063412;
constexpr int BAD_MOUNTED = -2137063411;
constexpr int FILE_NOT_FOUND = -2137063410;
constexpr int BROKEN = -2137063409;
constexpr int INVALID_LOGIN_USER = -2137063407;
constexpr int MEMORY_NOT_READY = -2137063406;
constexpr int BACKUP_BUSY = -2137063405;
constexpr int NOT_REGIST_CALLBACK = -2137063403;
constexpr int BUSY_FOR_SAVING = -2137063402;
constexpr int LIMITATION_OVER = -2137063401;
constexpr int EVENT_BUSY = -2137063400;
constexpr int PARAMSFO_TRANSFER_TITLE_ID_NOT_FOUND = -2137063399;
} // namespace SaveData
} // namespace Err
constexpr uint32_t SCE_SAVE_DATA_TITLE_ID_DATA_SIZE = 10;
@ -60,4 +60,4 @@ constexpr std::string_view SCE_SAVE_DATA_DIRNAME_SAVE_DATA_MEMORY_SLOT_1 = "sce_
constexpr std::string_view SCE_SAVE_DATA_DIRNAME_SAVE_DATA_MEMORY_SLOT_2 = "sce_sdmemory2";
constexpr std::string_view SCE_SAVE_DATA_DIRNAME_SAVE_DATA_MEMORY_SLOT_3 = "sce_sdmemory3";
constexpr std::string_view SCE_SAVE_DATA_FILENAME_SAVE_DATA_MEMORY = "memory.dat";
constexpr std::string_view SCE_SAVE_DATA_FILENAME_SAVE_DATA_MEMORY = "memory.dat";

View File

@ -39,7 +39,7 @@ int saveDataMount(int32_t userId, const char* dirName, SceSaveDataMountMode moun
if (doOpen || doCreate) {
if (!accessFileManager().getMountPoint(MountType::Save, dirSaveFiles.filename().string()).empty()) {
LOG_DEBUG(L"Savedir already created dir:%S", dirName);
return Err::SAVE_DATA_ERROR_BUSY;
return Err::SaveData::BUSY;
}
}
@ -66,7 +66,7 @@ int saveDataMount(int32_t userId, const char* dirName, SceSaveDataMountMode moun
break;
}
}
if (mountPoint.empty()) return Err::SAVE_DATA_ERROR_MOUNT_FULL;
if (mountPoint.empty()) return Err::SaveData::MOUNT_FULL;
}
// - mountpoint
@ -74,7 +74,7 @@ int saveDataMount(int32_t userId, const char* dirName, SceSaveDataMountMode moun
if (!std::filesystem::exists(dirSaveFiles)) {
LOG_DEBUG(L"Savedir doesn't exist");
return Err::SAVE_DATA_ERROR_NOT_FOUND;
return Err::SaveData::NOT_FOUND;
}
auto const count = mountPoint.copy(mountResult->mountPoint.data, SCE_SAVE_DATA_MOUNT_POINT_DATA_MAXSIZE - 1);
@ -176,7 +176,7 @@ EXPORT SYSV_ABI int32_t sceSaveDataUmountWithBackup(const SceSaveDataMountPoint*
zip_close(za);
} else {
LOG_ERR(L"Backup failed: %d", zerr);
return Err::SAVE_DATA_ERROR_INTERNAL;
return Err::SaveData::INTERNAL;
}
return sceSaveDataUmount(mountPoint);
@ -452,7 +452,7 @@ EXPORT SYSV_ABI int32_t sceSaveDataRestoreBackupData(const SceSaveDataRestoreBac
}
EXPORT SYSV_ABI int32_t sceSaveDataCheckBackupData(const SceSaveDataCheckBackupData* check) {
if (check->titleId != nullptr) return Err::SAVE_DATA_ERROR_INTERNAL;
if (check->titleId != nullptr) return Err::SaveData::INTERNAL;
// todo: check if savedata directory is already mounted
@ -470,7 +470,7 @@ EXPORT SYSV_ABI int32_t sceSaveDataCheckBackupData(const SceSaveDataCheckBackupD
zip_close(za);
}
return Err::SAVE_DATA_ERROR_NOT_FOUND;
return Err::SaveData::NOT_FOUND;
}
EXPORT SYSV_ABI int32_t sceSaveDataBackup(const SceSaveDataBackup* backup) {

View File

@ -1,5 +1,5 @@
#include "codes.h"
#include "common.h"
#include "errorcodes.h"
#include "logging.h"
LOG_DEFINE_MODULE(libSceSystemGesture);

View File

@ -1,15 +1,19 @@
#pragma once
#include <cstdint>
namespace Err {
constexpr int USER_SERVICE_ERROR_INTERNAL = -2137653247; /* 0x80960001 */
constexpr int USER_SERVICE_ERROR_NOT_INITIALIZED = -2137653246; /* 0x80960002 */
constexpr int USER_SERVICE_ERROR_ALREADY_INITIALIZED = -2137653245; /* 0x80960003 */
constexpr int USER_SERVICE_ERROR_NO_MEMORY = -2137653244; /* 0x80960004 */
constexpr int USER_SERVICE_ERROR_INVALID_ARGUMENT = -2137653243; /* 0x80960005 */
constexpr int USER_SERVICE_ERROR_OPERATION_NOT_SUPPORTED = -2137653242; /* 0x80960006 */
constexpr int USER_SERVICE_ERROR_NO_EVENT = -2137653241; /* 0x80960007 */
constexpr int USER_SERVICE_ERROR_NOT_LOGGED_IN = -2137653239; /* 0x80960009 */
constexpr int USER_SERVICE_ERROR_BUFFER_TOO_SHORT = -2137653238; /* 0x8096000A */
namespace UserService {
constexpr int32_t INTERNAL = -2137653247; /* 0x80960001 */
constexpr int32_t NOT_INITIALIZED = -2137653246; /* 0x80960002 */
constexpr int32_t ALREADY_INITIALIZED = -2137653245; /* 0x80960003 */
constexpr int32_t NO_MEMORY = -2137653244; /* 0x80960004 */
constexpr int32_t INVALID_ARGUMENT = -2137653243; /* 0x80960005 */
constexpr int32_t OPERATION_NOT_SUPPORTED = -2137653242; /* 0x80960006 */
constexpr int32_t NO_EVENT = -2137653241; /* 0x80960007 */
constexpr int32_t NOT_LOGGED_IN = -2137653239; /* 0x80960009 */
constexpr int32_t BUFFER_TOO_SHORT = -2137653238; /* 0x8096000A */
} // namespace UserService
} // namespace Err
constexpr size_t USER_SERVICE_MAX_USER_NAME_LENGTH = 16;

View File

@ -71,7 +71,7 @@ EXPORT SYSV_ABI int sceUserServiceGetEvent(UserServiceEvent* event) {
}
}
return Err::USER_SERVICE_ERROR_NO_EVENT;
return Err::UserService::NO_EVENT;
}
EXPORT SYSV_ABI int sceUserServiceGetLoginUserIdList(UserServiceLoginUserIdList* userId_list) {
@ -89,7 +89,7 @@ EXPORT SYSV_ABI int sceUserServiceGetLoginUserIdList(UserServiceLoginUserIdList*
}
EXPORT SYSV_ABI int sceUserServiceGetUserName(int userId, char* name, size_t size) {
if (userId < 1 || userId > 3 || name == nullptr || size == 0) return Err::USER_SERVICE_ERROR_INVALID_ARGUMENT;
if (userId < 1 || userId > 3 || name == nullptr || size == 0) return Err::UserService::INVALID_ARGUMENT;
std::string username = "Anon";
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::GENERAL);
@ -101,14 +101,14 @@ EXPORT SYSV_ABI int sceUserServiceGetUserName(int userId, char* name, size_t siz
} catch (json::exception& ex) {
}
if (size < (username.size() + 1)) return Err::USER_SERVICE_ERROR_BUFFER_TOO_SHORT;
if (size < (username.size() + 1)) return Err::UserService::BUFFER_TOO_SHORT;
auto const count = username.copy(name, size - 1);
name[count] = '\0';
return Ok;
}
EXPORT SYSV_ABI int32_t sceUserServiceGetUserColor(int userId, UserServiceUserColor* color) {
if (userId < 1 || userId > 3) return Err::USER_SERVICE_ERROR_INVALID_ARGUMENT;
if (userId < 1 || userId > 3) return Err::UserService::INVALID_ARGUMENT;
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::GENERAL);
std::string _scolor;

View File

@ -1,34 +1,37 @@
#pragma once
#include <stdint.h>
#include <cstdint>
namespace Err {
constexpr int VIDEO_OUT_ERROR_INVALID_VALUE = -2144796671; /* 0x80290001 */
constexpr int VIDEO_OUT_ERROR_INVALID_ADDRESS = -2144796670; /* 0x80290002 */
constexpr int VIDEO_OUT_ERROR_INVALID_PIXEL_FORMAT = -2144796669; /* 0x80290003 */
constexpr int VIDEO_OUT_ERROR_INVALID_PITCH = -2144796668; /* 0x80290004 */
constexpr int VIDEO_OUT_ERROR_INVALID_RESOLUTION = -2144796667; /* 0x80290005 */
constexpr int VIDEO_OUT_ERROR_INVALID_FLIP_MODE = -2144796666; /* 0x80290006 */
constexpr int VIDEO_OUT_ERROR_INVALID_TILING_MODE = -2144796665; /* 0x80290007 */
constexpr int VIDEO_OUT_ERROR_INVALID_ASPECT_RATIO = -2144796664; /* 0x80290008 */
constexpr int VIDEO_OUT_ERROR_RESOURCE_BUSY = -2144796663; /* 0x80290009 */
constexpr int VIDEO_OUT_ERROR_INVALID_INDEX = -2144796662; /* 0x8029000A */
constexpr int VIDEO_OUT_ERROR_INVALID_HANDLE = -2144796661; /* 0x8029000B */
constexpr int VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE = -2144796660; /* 0x8029000C */
constexpr int VIDEO_OUT_ERROR_INVALID_EVENT = -2144796659; /* 0x8029000D */
constexpr int VIDEO_OUT_ERROR_NO_EMPTY_SLOT = -2144796657; /* 0x8029000F */
constexpr int VIDEO_OUT_ERROR_SLOT_OCCUPIED = -2144796656; /* 0x80290010 */
constexpr int VIDEO_OUT_ERROR_FLIP_QUEUE_FULL = -2144796654; /* 0x80290012 */
constexpr int VIDEO_OUT_ERROR_INVALID_MEMORY = -2144796653; /* 0x80290013 */
constexpr int VIDEO_OUT_ERROR_MEMORY_NOT_PHYSICALLY_CONTIGUOUS = -2144796652; /* 0x80290014 */
constexpr int VIDEO_OUT_ERROR_MEMORY_INVALID_ALIGNMENT = -2144796651; /* 0x80290015 */
constexpr int VIDEO_OUT_ERROR_UNSUPPORTED_OUTPUT_MODE = -2144796650; /* 0x80290016 */
constexpr int VIDEO_OUT_ERROR_OVERFLOW = -2144796649; /* 0x80290017 */
constexpr int VIDEO_OUT_ERROR_NO_DEVICE = -2144796648; /* 0x80290018 */
constexpr int VIDEO_OUT_ERROR_UNAVAILABLE_OUTPUT_MODE = -2144796647; /* 0x80290019 */
constexpr int VIDEO_OUT_ERROR_INVALID_OPTION = -2144796646; /* 0x8029001A */
constexpr int VIDEO_OUT_ERROR_PORT_UNSUPPORTED_FUNCTION = -2144796645; /* 0x8029001B */
constexpr int VIDEO_OUT_ERROR_UNSUPPORTED_OPERATION = -2144796644; /* 0x8029001C */
constexpr int VIDEO_OUT_ERROR_FATAL = -2144796417; /* 0x802900FF */
constexpr int VIDEO_OUT_ERROR_UNKNOWN = -2144796418; /* 0x802900FE */
constexpr int VIDEO_OUT_ERROR_ENOMEM = -2144792564; /* 0x8029100C */
} // namespace Err
namespace VideoOut {
constexpr int32_t INVALID_VALUE = -2144796671; /* 0x80290001 */
constexpr int32_t INVALID_ADDRESS = -2144796670; /* 0x80290002 */
constexpr int32_t INVALID_PIXEL_FORMAT = -2144796669; /* 0x80290003 */
constexpr int32_t INVALID_PITCH = -2144796668; /* 0x80290004 */
constexpr int32_t INVALID_RESOLUTION = -2144796667; /* 0x80290005 */
constexpr int32_t INVALID_FLIP_MODE = -2144796666; /* 0x80290006 */
constexpr int32_t INVALID_TILING_MODE = -2144796665; /* 0x80290007 */
constexpr int32_t INVALID_ASPECT_RATIO = -2144796664; /* 0x80290008 */
constexpr int32_t RESOURCE_BUSY = -2144796663; /* 0x80290009 */
constexpr int32_t INVALID_INDEX = -2144796662; /* 0x8029000A */
constexpr int32_t INVALID_HANDLE = -2144796661; /* 0x8029000B */
constexpr int32_t INVALID_EVENT_QUEUE = -2144796660; /* 0x8029000C */
constexpr int32_t INVALID_EVENT = -2144796659; /* 0x8029000D */
constexpr int32_t NO_EMPTY_SLOT = -2144796657; /* 0x8029000F */
constexpr int32_t SLOT_OCCUPIED = -2144796656; /* 0x80290010 */
constexpr int32_t FLIP_QUEUE_FULL = -2144796654; /* 0x80290012 */
constexpr int32_t INVALID_MEMORY = -2144796653; /* 0x80290013 */
constexpr int32_t MEMORY_NOT_PHYSICALLY_CONTIGUOUS = -2144796652; /* 0x80290014 */
constexpr int32_t MEMORY_INVALID_ALIGNMENT = -2144796651; /* 0x80290015 */
constexpr int32_t UNSUPPORTED_OUTPUT_MODE = -2144796650; /* 0x80290016 */
constexpr int32_t VOVERFLOW = -2144796649; /* 0x80290017 */
constexpr int32_t NO_DEVICE = -2144796648; /* 0x80290018 */
constexpr int32_t UNAVAILABLE_OUTPUT_MODE = -2144796647; /* 0x80290019 */
constexpr int32_t INVALID_OPTION = -2144796646; /* 0x8029001A */
constexpr int32_t PORT_UNSUPPORTED_FUNCTION = -2144796645; /* 0x8029001B */
constexpr int32_t UNSUPPORTED_OPERATION = -2144796644; /* 0x8029001C */
constexpr int32_t FATAL = -2144796417; /* 0x802900FF */
constexpr int32_t UNKNOWN = -2144796418; /* 0x802900FE */
constexpr int32_t NOMEM = -2144792564; /* 0x8029100C */
} // namespace VideoOut
} // namespace Err

View File

@ -39,13 +39,11 @@ EXPORT SYSV_ABI int32_t sceVideoOutClose(int32_t handle) {
EXPORT SYSV_ABI int32_t sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex, void* const* addresses, int32_t bufferNum,
const SceVideoOutBufferAttribute* attribute) {
[[unlikely]] if (addresses == nullptr) { return Err::VIDEO_OUT_ERROR_INVALID_ADDRESS; }
[[unlikely]] if (addresses == nullptr) { return Err::VideoOut::INVALID_ADDRESS; }
[[unlikely]] if (attribute == nullptr) { return Err::VIDEO_OUT_ERROR_INVALID_OPTION; }
[[unlikely]] if (attribute == nullptr) { return Err::VideoOut::INVALID_OPTION; }
[[unlikely]] if (startIndex < 0 || startIndex > 15 || bufferNum < 1 || bufferNum > 16 || startIndex + bufferNum > 15) {
return Err::VIDEO_OUT_ERROR_INVALID_VALUE;
}
[[unlikely]] if (startIndex < 0 || startIndex > 15 || bufferNum < 1 || bufferNum > 16 || startIndex + bufferNum > 15) { return Err::VideoOut::INVALID_VALUE; }
return accessVideoOut().registerBuffers(handle, startIndex, addresses, bufferNum, attribute);
}
@ -82,7 +80,7 @@ EXPORT SYSV_ABI int32_t sceVideoOutSetWindowModeMargins(int32_t handle, int top,
EXPORT SYSV_ABI int32_t sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex, uint32_t flipMode, int64_t flipArg) {
if (bufferIndex < 0 || bufferIndex > 15) {
return Err::VIDEO_OUT_ERROR_INVALID_INDEX;
return Err::VideoOut::INVALID_INDEX;
}
accessVideoOut().submitFlip(handle, bufferIndex, flipArg);
return Ok;
@ -108,7 +106,7 @@ EXPORT SYSV_ABI int32_t sceVideoOutGetResolutionStatus(int32_t handle, SceVideoO
}
EXPORT SYSV_ABI int32_t sceVideoOutAddFlipEvent(Kernel::EventQueue::IKernelEqueue_t eq, int32_t handle, void* udata) {
[[unlikely]] if (eq == nullptr) { return Err::VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE; }
[[unlikely]] if (eq == nullptr) { return Err::VideoOut::INVALID_EVENT_QUEUE; }
Kernel::EventQueue::KernelEqueueEvent const event = {.triggered = false,
.event =
@ -132,7 +130,7 @@ EXPORT SYSV_ABI int32_t sceVideoOutAddFlipEvent(Kernel::EventQueue::IKernelEqueu
}
EXPORT SYSV_ABI int32_t sceVideoOutAddVblankEvent(Kernel::EventQueue::IKernelEqueue_t eq, int32_t handle, void* udata) {
[[unlikely]] if (eq == nullptr) { return Err::VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE; }
[[unlikely]] if (eq == nullptr) { return Err::VideoOut::INVALID_EVENT_QUEUE; }
Kernel::EventQueue::KernelEqueueEvent const event = {.triggered = false,
.event =
@ -256,4 +254,4 @@ EXPORT SYSV_ABI int32_t sceVideoOutConfigureOutputMode_(int32_t handle, uint32_t
SceVideoOutConfigureOptions const* pOptions, uint32_t sizeOfMode, uint32_t sizeOfOptions) {
return Ok;
}
}
}

View File

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.24)
include(../setupModule.cmake)
set(libName libkernel_cpumode_platform)
project(${libName})
add_library(${libName} SHARED entry.cpp)
setupModule(${libName})

View File

@ -0,0 +1,4 @@
#pragma once
#include <stdint.h>
namespace Err {} // namespace Err

View File

@ -0,0 +1,16 @@
#include "common.h"
#include "logging.h"
#include "types.h"
LOG_DEFINE_MODULE(libkernel_cpumode_platform);
namespace {} // namespace
extern "C" {
EXPORT const char* MODULE_NAME = "libkernel";
EXPORT SYSV_ABI int32_t sceKernelIsProspero() {
return 0; // PS5
}
}

View File

@ -0,0 +1,2 @@
#pragma once
#include "codes.h"

View File

@ -142,6 +142,13 @@ Config::Config() {
for (auto& [dkey, dval]: def.items()) {
json& cval = getVal(obj, dkey);
if (dkey.starts_with("_")) { // Temporary (probably) workaround to stop fixing underscore objects
if (cval.is_null()) {
missing = true;
cval = dval;
}
continue;
}
if ((cval.is_null() && !dval.is_null()) || !isJsonTypesSimilar(cval, dval)) {
cval = dval;
@ -171,6 +178,9 @@ Config::Config() {
bool unused = false;
for (auto& [ckey, cval]: obj.items()) {
if (ckey.starts_with("_")) { // Temporary (probably) workaround to stop removing underscore objects
continue;
}
json& dval = getVal(def, ckey);
if (dval.is_null()) {
@ -221,8 +231,10 @@ Config::Config() {
};
}
m_logging._future = std::async(std::launch::async | std::launch::deferred, load, &m_logging,
json({{"$schema", "./.schemas/logging.json"}, {"sink", "FileBin"}, {"verbosity", 1}}), ConfigModFlag::LOGGING);
m_logging._future =
std::async(std::launch::async | std::launch::deferred, load, &m_logging,
json({{"$schema", "./.schemas/logging.json"}, {"sink", "FileBin"}, {"verbosity", 1}, {"_customVerb", json(json::value_t::object)}}),
ConfigModFlag::LOGGING);
m_graphics._future = std::async(
std::launch::async | std::launch::deferred, load, &m_graphics,

View File

@ -83,8 +83,25 @@ void* __registerLoggingModule(std::wstring_view name) {
*trace = P7_Create_Trace(*getClient(), __APPNAME);
}
}
auto getCustomVerb = [](std::wstring_view name) -> int32_t {
int32_t vlevel;
std::string sname(name.begin(), name.end());
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::LOGGING);
auto& modver = (*jData)["_customVerb"][sname];
if (modver.is_number_integer()) {
printf("Custom verbosity set for: %ls\n", name.data());
return modver.get_to(vlevel);
}
return -1;
};
IP7_Trace::hModule pModule;
(*trace)->Register_Module(name.data(), &pModule);
auto lvl = getCustomVerb(name);
if (lvl != -1) (*trace)->Set_Verbosity(pModule, (eP7Trace_Level)lvl);
return pModule;
}