Skip to content

Commit

Permalink
Merge pull request #105 from Qudix/upstream-po3-dev-pr
Browse files Browse the repository at this point in the history
Refactor OS API's
  • Loading branch information
powerof3 authored Feb 23, 2024
2 parents 51f4a71 + 8a3d961 commit e85a295
Show file tree
Hide file tree
Showing 91 changed files with 8,438 additions and 3,664 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ target_link_libraries(
PUBLIC
binary_io::binary_io
spdlog::spdlog
Version.lib
Advapi32.lib
D3D11.lib
Dbghelp.lib
DXGI.lib
Ole32.lib
Version.lib
)

target_precompile_headers(
Expand Down
43 changes: 38 additions & 5 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1620,16 +1620,40 @@ set(SOURCES
include/REL/REL.h
include/REL/Relocation.h
include/REL/Version.h
include/REX/PS4.h
include/REX/PS4/SCEPAD.h
include/REX/W32.h
include/REX/W32/ADVAPI32.h
include/REX/W32/BASE.h
include/REX/W32/COM.h
include/REX/W32/COMPTR.h
include/REX/W32/D3D.h
include/REX/W32/D3D11.h
include/REX/W32/D3D11_1.h
include/REX/W32/D3D11_2.h
include/REX/W32/D3D11_3.h
include/REX/W32/D3D11_4.h
include/REX/W32/D3DCOMPILER.h
include/REX/W32/DBGHELP.h
include/REX/W32/DINPUT.h
include/REX/W32/DXGI.h
include/REX/W32/DXGI_2.h
include/REX/W32/DXGI_3.h
include/REX/W32/DXGI_4.h
include/REX/W32/DXGI_5.h
include/REX/W32/DXGI_6.h
include/REX/W32/KERNEL32.h
include/REX/W32/OLE32.h
include/REX/W32/SHELL32.h
include/REX/W32/USER32.h
include/REX/W32/VERSION.h
include/REX/W32/XINPUT.h
include/SKSE/API.h
include/SKSE/Events.h
include/SKSE/IAT.h
include/SKSE/Impl/DInputAPI.h
include/SKSE/Impl/PCH.h
include/SKSE/Impl/RegistrationTraits.h
include/SKSE/Impl/ScePadAPI.h
include/SKSE/Impl/Stubs.h
include/SKSE/Impl/WinAPI.h
include/SKSE/Impl/XInputAPI.h
include/SKSE/InputMap.h
include/SKSE/Interfaces.h
include/SKSE/Logger.h
Expand Down Expand Up @@ -1965,10 +1989,19 @@ set(SOURCES
src/RE/Z/ZeroFunctionArguments.cpp
src/REL/ID.cpp
src/REL/Module.cpp
src/REX/W32/ADVAPI32.cpp
src/REX/W32/D3D11.cpp
src/REX/W32/D3DCOMPILER.cpp
src/REX/W32/DBGHELP.cpp
src/REX/W32/DXGI.cpp
src/REX/W32/KERNEL32.cpp
src/REX/W32/OLE32.cpp
src/REX/W32/SHELL32.cpp
src/REX/W32/USER32.cpp
src/REX/W32/VERSION.cpp
src/SKSE/API.cpp
src/SKSE/IAT.cpp
src/SKSE/Impl/PCH.cpp
src/SKSE/Impl/WinAPI.cpp
src/SKSE/InputMap.cpp
src/SKSE/Interfaces.cpp
src/SKSE/Logger.cpp
Expand Down
4 changes: 3 additions & 1 deletion include/RE/A/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "RE/T/TESNPC.h"
#include "RE/T/TESObjectREFR.h"

#include "REX/W32/BASE.h"

namespace RE
{
class ActorMagicCaster;
Expand Down Expand Up @@ -688,7 +690,7 @@ namespace RE
std::uint32_t unk274; // 274
std::uint64_t unk278; // 278
std::uint64_t unk280; // 280
WinAPI::CRITICAL_SECTION unk288; // 288 - havok related
REX::W32::CRITICAL_SECTION unk288; // 288 - havok related

private:
void CalculateCurrentVendorFaction() const;
Expand Down
4 changes: 3 additions & 1 deletion include/RE/B/BSAtomic.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once

#include "REX/W32/BASE.h"

namespace RE
{
class BSCriticalSection
{
public:
// members
WinAPI::CRITICAL_SECTION criticalSection; // 00
REX::W32::CRITICAL_SECTION criticalSection; // 00
};
static_assert(sizeof(BSCriticalSection) == 0x28);

Expand Down
21 changes: 15 additions & 6 deletions include/RE/B/BSDirectInputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@

#include "RE/B/BSTSingleton.h"

#include "REX/W32/BASE.h"

namespace REX::W32
{
struct DIDEVICEOBJECTDATA;
struct IDirectInput8A;
struct IDirectInputDevice8A;
}

namespace RE
{
class BSDirectInputManager : public BSTSingletonSDM<BSDirectInputManager>
{
public:
static BSDirectInputManager* GetSingleton();

DirectInput8::IDirectInputDevice8A* CreateDeviceWithGUID(WinAPI::GUID* a_guid);
void GetDeviceState(DirectInput8::IDirectInputDevice8A* a_device, std::uint32_t a_size, void* a_outData);
void GetDeviceData(DirectInput8::IDirectInputDevice8A* a_device, std::uint32_t* a_dataSize, DirectInput8::DIDEVICEOBJECTDATA** a_outData);
void ReleaseDevice(DirectInput8::IDirectInputDevice8A* a_device);
REX::W32::IDirectInputDevice8A* CreateDeviceWithGUID(REX::W32::GUID* a_guid);
void GetDeviceState(REX::W32::IDirectInputDevice8A* a_device, std::uint32_t a_size, void* a_outData);
void GetDeviceData(REX::W32::IDirectInputDevice8A* a_device, std::uint32_t* a_dataSize, REX::W32::DIDEVICEOBJECTDATA** a_outData);
void ReleaseDevice(REX::W32::IDirectInputDevice8A* a_device);

// members
std::uint32_t pad00; // 00
DirectInput8::IDirectInput8A* diInterface; // 08
std::uint32_t pad00; // 00
REX::W32::IDirectInput8A* diInterface; // 08
};
static_assert(sizeof(BSDirectInputManager) == 0x10);
}
34 changes: 18 additions & 16 deletions include/RE/B/BSFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "RE/N/NiFile.h"

#include "REX/W32/BASE.h"

namespace RE
{
class BSFile : public NiFile
Expand Down Expand Up @@ -31,22 +33,22 @@ namespace RE
virtual void Unk_12(void); // 12

// members
bool useAuxBuffer; // 048
std::uint8_t pad049; // 049
std::uint16_t pad04A; // 04A
std::uint32_t pad04C; // 04C
char* auxBuffer; // 050
std::int32_t auxTrueFilePos; // 058
std::uint32_t auxBufferMinIndex; // 05C
std::uint32_t auxBufferMaxIndex; // 060
char fileName[WinAPI::MAX_PATH]; // 064
std::uint32_t result; // 168
std::uint32_t ioSize; // 16C
std::uint32_t trueFilePos; // 170
std::uint32_t fileSize; // 174
bool virtualAlloc; // 178
std::uint8_t unk179; // 179
std::uint16_t unk17A; // 17A
bool useAuxBuffer; // 048
std::uint8_t pad049; // 049
std::uint16_t pad04A; // 04A
std::uint32_t pad04C; // 04C
char* auxBuffer; // 050
std::int32_t auxTrueFilePos; // 058
std::uint32_t auxBufferMinIndex; // 05C
std::uint32_t auxBufferMaxIndex; // 060
char fileName[REX::W32::MAX_PATH]; // 064
std::uint32_t result; // 168
std::uint32_t ioSize; // 16C
std::uint32_t trueFilePos; // 170
std::uint32_t fileSize; // 174
bool virtualAlloc; // 178
std::uint8_t unk179; // 179
std::uint16_t unk17A; // 17A
};
static_assert(sizeof(BSFile) == 0x180);
}
4 changes: 3 additions & 1 deletion include/RE/B/BSMultiIndexTriShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "RE/N/NiColor.h"
#include "RE/N/NiSmartPointer.h"

#include "REX/W32/D3D.h"

namespace RE
{
namespace BSGraphics
Expand All @@ -29,7 +31,7 @@ namespace RE
// members
BSGraphics::IndexBuffer* altIndexBuffer; // 160
std::uint32_t altPrimCount; // 168
DirectX::XMFLOAT4X4 materialProjection; // 16C
REX::W32::XMFLOAT4X4 materialProjection; // 16C
std::uint32_t pad1AC; // 1AC
NiPointer<BSShaderProperty> additionalShaderProperty; // 1B0
std::uint8_t useAdditionalTriList; // 1B8
Expand Down
38 changes: 20 additions & 18 deletions include/RE/B/BSPCOrbisGamepadDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "RE/B/BSPCGamepadDeviceDelegate.h"

#include "REX/PS4/SCEPAD.h"

namespace RE
{
// PS4 controller used via HID polling
Expand All @@ -17,26 +19,26 @@ namespace RE
{
// Masks for buttonState
// Key hardware value
kUp = ScePad::ScePadButton::SCE_PAD_BUTTON_UP,
kDown = ScePad::ScePadButton::SCE_PAD_BUTTON_DOWN,
kLeft = ScePad::ScePadButton::SCE_PAD_BUTTON_LEFT,
kRight = ScePad::ScePadButton::SCE_PAD_BUTTON_RIGHT,
kPS3_Start = ScePad::ScePadButton::SCE_PAD_BUTTON_OPTIONS,
kPS3_Back = ScePad::ScePadButton::SCE_PAD_BUTTON_TOUCH_PAD, // This is mapped to the touchpad on the PS4 controller
kPS3_L3 = ScePad::ScePadButton::SCE_PAD_BUTTON_L3,
kPS3_R3 = ScePad::ScePadButton::SCE_PAD_BUTTON_R3,
kPS3_LB = ScePad::ScePadButton::SCE_PAD_BUTTON_L1,
kPS3_RB = ScePad::ScePadButton::SCE_PAD_BUTTON_R1,
kPS3_A = ScePad::ScePadButton::SCE_PAD_BUTTON_CROSS,
kPS3_B = ScePad::ScePadButton::SCE_PAD_BUTTON_CIRCLE,
kPS3_X = ScePad::ScePadButton::SCE_PAD_BUTTON_SQUARE,
kPS3_Y = ScePad::ScePadButton::SCE_PAD_BUTTON_TRIANGLE,
kUp = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_UP,
kDown = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_DOWN,
kLeft = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_LEFT,
kRight = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_RIGHT,
kPS3_Start = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_OPTIONS,
kPS3_Back = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_TOUCH_PAD, // This is mapped to the touchpad on the PS4 controller
kPS3_L3 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L3,
kPS3_R3 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R3,
kPS3_LB = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L1,
kPS3_RB = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R1,
kPS3_A = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_CROSS,
kPS3_B = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_CIRCLE,
kPS3_X = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_SQUARE,
kPS3_Y = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_TRIANGLE,

// Unused by Skyrim
kPS4_Share = ScePad::ScePadButton::SCE_PAD_BUTTON_SHARE, // Skyrim uses the touchpad for Back and leaves the Share button unused
kPS4_L2 = ScePad::ScePadButton::SCE_PAD_BUTTON_L2, // Skyrim uses trigger axis read instead of button press
kPS4_R2 = ScePad::ScePadButton::SCE_PAD_BUTTON_R2, // Skyrim uses trigger axis read instead of button press
kPS4_PSBtn = ScePad::ScePadButton::SCE_PAD_BUTTON_PLAYSTATION, // Playstation button
kPS4_Share = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_SHARE, // Skyrim uses the touchpad for Back and leaves the Share button unused
kPS4_L2 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L2, // Skyrim uses trigger axis read instead of button press
kPS4_R2 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R2, // Skyrim uses trigger axis read instead of button press
kPS4_PSBtn = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_PLAYSTATION, // Playstation button

// arbitrary values
// IDs meant to be used with ButtonEvent
Expand Down
26 changes: 14 additions & 12 deletions include/RE/B/BSParticleShaderCubeEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "RE/B/BSParticleShaderEmitter.h"
#include "RE/N/NiPoint3.h"

#include "REX/W32/D3D.h"

namespace RE
{
class BSParticleShaderCubeEmitter : public BSParticleShaderEmitter
Expand All @@ -16,18 +18,18 @@ namespace RE
bool Generate(bool a_arg1, NiPoint3& a_arg2, NiPoint3& a_arg3) override; // 03 - { return false; }

// members
alignas(0x10) DirectX::XMFLOAT4X4 occlusionProjection; // ED0
NiPoint3 cameraOffsetVector; // F10
NiPoint3 offsetVector; // F1C
NiPoint3 compositeOffsetVector; // F28
NiPoint3 frameVelocityVector; // F34
NiPoint3 windVelocity; // F40
NiPoint3 gravityVelocity; // F4C
float rotation; // F58
float rotationVelocity; // F5C
float cubeSize; // F60
float density; // F64
NiPoint3 instanceOffsets[10]; // F68
alignas(0x10) REX::W32::XMFLOAT4X4 occlusionProjection; // ED0
NiPoint3 cameraOffsetVector; // F10
NiPoint3 offsetVector; // F1C
NiPoint3 compositeOffsetVector; // F28
NiPoint3 frameVelocityVector; // F34
NiPoint3 windVelocity; // F40
NiPoint3 gravityVelocity; // F4C
float rotation; // F58
float rotationVelocity; // F5C
float cubeSize; // F60
float density; // F64
NiPoint3 instanceOffsets[10]; // F68
};
static_assert(sizeof(BSParticleShaderCubeEmitter) == 0xFE0);
}
17 changes: 9 additions & 8 deletions include/RE/B/BSSystemFile.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "REX/W32/BASE.h"

namespace RE
{
namespace BSResource
Expand All @@ -9,21 +11,20 @@ namespace RE
public:
struct Info
{
public:
// members
WinAPI::FILETIME accessTime; // 00
WinAPI::FILETIME modifyTime; // 08
WinAPI::FILETIME createTime; // 10
std::uint64_t fileSize; // 18
REX::W32::FILETIME accessTime; // 00
REX::W32::FILETIME modifyTime; // 08
REX::W32::FILETIME createTime; // 10
std::uint64_t fileSize; // 18
};
static_assert(sizeof(Info) == 0x20);

BSSystemFile();

// members
std::uint32_t flags{ 1 }; // 00
std::uint32_t pad04{ 0 }; // 04
void* file{ WinAPI::INVALID_HANDLE_VALUE }; // 08
std::uint32_t flags{ 1 }; // 00
std::uint32_t pad04{ 0 }; // 04
void* file{ REX::W32::INVALID_HANDLE_VALUE }; // 08
};
static_assert(sizeof(BSSystemFile) == 0x10);
}
Expand Down
20 changes: 11 additions & 9 deletions include/RE/B/BSThread.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "REX/W32/BASE.h"

namespace RE
{
class BSThread
Expand All @@ -14,15 +16,15 @@ namespace RE
virtual void Unk_02(void); // 02 - { return; }

// members
WinAPI::CRITICAL_SECTION lock; // 08
void* thread; // 30
void* ownerThread; // 38
std::uint32_t threadID; // 40
std::uint32_t ownerThreadID; // 44
bool initialized; // 48
std::uint8_t pad49; // 49
std::uint16_t pad4A; // 4A
std::uint32_t pad4C; // 4C
REX::W32::CRITICAL_SECTION lock; // 08
void* thread; // 30
void* ownerThread; // 38
std::uint32_t threadID; // 40
std::uint32_t ownerThreadID; // 44
bool initialized; // 48
std::uint8_t pad49; // 49
std::uint16_t pad4A; // 4A
std::uint32_t pad4C; // 4C
};
static_assert(sizeof(BSThread) == 0x50);
}
Loading

0 comments on commit e85a295

Please sign in to comment.