core: Library cleanup (#1631)

* core: Split error codes into separate files

* Reduces build times and is cleaner

* core: Bring structs and enums to codebase style

* core: More style changes
This commit is contained in:
TheTurtle 2024-11-30 22:37:36 +02:00 committed by GitHub
parent 3d0aacd43d
commit 5b6e0ab238
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
114 changed files with 2158 additions and 2509 deletions

View file

@ -1,12 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/assert.h"
#include "common/config.h"
#include "common/logging/log.h"
#include "common/singleton.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "core/libraries/pad/pad_errors.h"
#include "input/controller.h"
#include "pad.h"
@ -99,8 +98,8 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
pInfo->connectedCount = 1;
pInfo->connected = false;
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
return SCE_OK;
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
return ORBIS_OK;
}
pInfo->touchPadInfo.pixelDensity = 1;
pInfo->touchPadInfo.resolution.x = 1920;
@ -110,12 +109,12 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
pInfo->connectedCount = 1;
pInfo->connected = true;
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
if (Config::getUseSpecialPad()) {
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
pInfo->deviceClass = (OrbisPadDeviceClass)Config::getSpecialPadClass();
}
return SCE_OK;
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetDataInternal() {
@ -382,7 +381,7 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
pData->connectedCount = 1; // connectedCount;
pData->deviceUniqueDataLen = 0;
return SCE_OK;
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadReadStateExt() {

View file

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

View file

@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/libraries/error_codes.h"
// Pad library
constexpr int ORBIS_PAD_ERROR_INVALID_ARG = 0x80920001;
constexpr int ORBIS_PAD_ERROR_INVALID_PORT = 0x80920002;
constexpr int ORBIS_PAD_ERROR_INVALID_HANDLE = 0x80920003;
constexpr int ORBIS_PAD_ERROR_ALREADY_OPENED = 0x80920004;
constexpr int ORBIS_PAD_ERROR_NOT_INITIALIZED = 0x80920005;
constexpr int ORBIS_PAD_ERROR_INVALID_LIGHTBAR_SETTING = 0x80920006;
constexpr int ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED = 0x80920007;
constexpr int ORBIS_PAD_ERROR_DEVICE_NO_HANDLE = 0x80920008;
constexpr int ORBIS_PAD_ERROR_FATAL = 0x809200FF;
constexpr int ORBIS_PAD_ERROR_NOT_PERMITTED = 0x80920101;
constexpr int ORBIS_PAD_ERROR_INVALID_BUFFER_LENGTH = 0x80920102;
constexpr int ORBIS_PAD_ERROR_INVALID_REPORT_LENGTH = 0x80920103;
constexpr int ORBIS_PAD_ERROR_INVALID_REPORT_ID = 0x80920104;
constexpr int ORBIS_PAD_ERROR_SEND_AGAIN = 0x80920105;