feat: better cmake support (#21)

* feat: CMakeSettings.json

* chore: remove visual studio stuff
chore: move .clang-format to main directory

* feat: new file structure, easier to implement as a submodule within existing projects

* chore: we actually include some code now...

* chore: remove prebuilt libraries (oops)

* feat: new shader building script using cmake

* chore: add debug postfix specifier

* fix: forgot that windows builds use 4J_Render_PC for the render library

* fix: didn't add the output directory (where shaders are saved to) to the include directories of 4J_Render
This commit is contained in:
gsds
2026-04-21 02:07:59 -04:00
committed by GitHub
parent 576f038dd0
commit e0ae7b1ec1
111 changed files with 1802 additions and 1458 deletions
@@ -0,0 +1,84 @@
#pragma once
/*
MIT License
Copyright (c) 2026 Patoke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "LinkedList.h"
#define MAX_EFFECTS 10
class CForceFeedback
{
public:
enum FF_PARAMS
{
FF_PARAMS_RAMP,
FF_PARAMS_PERIODIC
};
struct RUMBLE_EFFECT
{
DWORD m_Pad;
uint64_t m_TimeLeft;
XINPUT_VIBRATION m_RumbleData;
WORD unk;
};
struct FF_EFFECT
{
unsigned int m_uiEffectType;
unsigned int m_uiDurationMs;
BYTE gap8[4];
unsigned int m_uiMagnitude;
BYTE gap10[8];
DWORD dword18;
DWORD dword1C;
};
struct FF_EFFECT_INSTANCE
{
bool m_bIsActive;
unsigned int m_uiInst;
CForceFeedback::FF_EFFECT *m_Effect;
};
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
void RumbleEnable(int iQuadrant, bool bRumbleEnabled);
void CreateEffect(void);
void AddEffectInstance(unsigned int uiEffect);
void SetEffectInstanceState(unsigned int uiEffectInstance, unsigned int uiState);
void ProcessEventInstance(FF_EFFECT_INSTANCE *pEffectInst);
void PauseEventInstance(FF_EFFECT_INSTANCE *pEffectInst);
void AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rightMotorSpeed, float fSeconds);
void Tick(void);
LinkedList m_EffectList;
FF_EFFECT *m_Effects;
int m_EffectC;
LinkedList m_RumbleList;
float m_TicksPerSecond;
bool m_unkBool;
};
@@ -0,0 +1,50 @@
#pragma once
/*
MIT License
Copyright (c) 2026 Patoke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "4J_Input.h"
void ClearGlobalText();
uint16_t *GetGlobalText();
void SeedEditBox();
class CKeyboard
{
public:
enum EKeyboardProcessState
{
};
struct SKeyboardInfo
{
};
void Tick(void);
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
C_4JInput::EKeyboardMode eMode);
void GetText(uint16_t *UTF16String);
BYTE gap0[0x68];
};
+183
View File
@@ -0,0 +1,183 @@
#pragma once
/*
MIT License
Copyright (c) 2026 Patoke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "INP_ForceFeedback.h"
#include "INP_Keyboard.h"
#define MAX_JOYPADS 4
class CInput
{
public:
struct JOYPAD
{
bool m_bIsDisabled;
bool m_bIsConnected;
bool m_bWasConnected;
bool m_bHasConnected;
unsigned int m_uiButtons;
unsigned int m_uiOldButtons;
int m_uiButtonsPressed;
int m_uiButtonsReleased;
int m_iRightThumbX;
int m_iRightThumbY;
int m_iLeftThumbX;
int m_iLeftThumbY;
DWORD m_iNormalizedRightThumbX;
DWORD m_iNormalizedRightThumbY;
DWORD m_iNormalizedLeftThumbX;
DWORD m_iNormalizedLeftThumbY;
float m_fNormalizedRightThumbX;
float m_fNormalizedRightThumbY;
float m_fNormalizedLeftThumbX;
float m_fNormalizedLeftThumbY;
unsigned char m_ucLeftTriggerState;
unsigned char m_ucRightTriggerState;
float *m_pfLeftThumbXAxisMap;
float *m_pfLeftThumbYAxisMap;
float *m_pfRightThumbXAxisMap;
float *m_pfRightThumbYAxisMap;
float m_fSensitivity;
BYTE *m_pucLeftTriggerAxisMap;
BYTE *m_pucRightTriggerAxisMap;
unsigned char m_ucMappingValue;
unsigned char m_ucInputStateIndex;
XINPUT_STATE *m_pInputStates;
};
struct JOYPADS
{
};
struct TimeInfo
{
LARGE_INTEGER m_qwStartTime;
LARGE_INTEGER m_qwTotalHoldTicks;
float m_fTotalHoldTime;
float m_fLastRepeatTime;
bool m_bInitialPressHandled;
};
CInput();
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
void Tick(void);
void SetJoypadValues(JOYPAD *pThisPad);
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax);
void SetJoypadSensitivity(int iPad, float fSensitivity);
void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal);
unsigned int GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction);
void SetJoypadMapVal(int iPad, unsigned char ucMap);
unsigned char GetJoypadMapVal(int iPad);
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
bool IsPadConnected(int iPad);
void SetSigninJoypadMask(unsigned int mask);
unsigned int GetValue(int iPad, unsigned char ucAction, bool bRepeat = false);
bool IsSet(int iPad, unsigned char ucAction);
bool ButtonPressed(int iPad, unsigned char ucAction = 255); // toggled
bool ButtonReleased(int iPad, unsigned char ucAction); // toggled
bool ButtonDown(int iPad, unsigned char ucAction = 255); // button held down
float GetJoypadStick_Menu_LX(unsigned char ucPad);
float GetJoypadStick_Menu_LY(unsigned char ucPad);
float GetJoypadStick_Menu_RX(unsigned char ucPad);
float GetJoypadStick_Menu_RY(unsigned char ucPad);
unsigned char GetJoypadLTrigger_Menu(unsigned char ucPad);
unsigned char GetJoypadRTrigger_Menu(unsigned char ucPad);
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay = true);
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay = true);
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay = true);
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay = true);
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay = true);
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay = true);
void SetMenuDisplayed(int iPad, bool bVal);
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
void SetDebugSequence(const char *chSequenceA, int (*Func)(LPVOID), LPVOID lpParam);
FLOAT GetIdleSeconds(int iPad);
bool UpdateJoypads(void);
void ClearJoypadValues(JOYPAD *pThisPad);
void InitTime(void);
void GetStartTime(int iPad, int iKey);
void UpdateTime(int iPad, int iKey);
BYTE gap0[16];
JOYPAD m_Joypads[MAX_JOYPADS];
int m_iDeadzone;
int m_iMovementRangeMax;
int m_iEffectiveRange;
int m_iHalfRange;
float m_fEffectiveRange;
unsigned char m_ucInputStateC;
unsigned char m_ucJoypadMapC;
unsigned char m_ucJoypadMapActionC;
unsigned char m_ucMenuActionC;
unsigned int **m_JoypadMap;
bool m_bJoypadMapArrayIsSetup;
unsigned int m_uiSigninJoypadMask;
bool m_bIsMenuDisplayed[MAX_JOYPADS];
CForceFeedback m_ForceFeedback;
CKeyboard m_Keyboard;
float m_fTickToSeconds;
float m_fRepeatDelaySecs;
float m_fRepeatRateSecs;
TimeInfo m_Timers[MAX_JOYPADS][24];
LARGE_INTEGER m_LastActivityTime[MAX_JOYPADS];
char *m_sDebugSequenceName;
unsigned int m_uiDebugSequenceIndex;
int (*m_pDebugSequenceFn)(void *);
LPVOID m_pDebugSequenceParam;
};
// Singleton
extern CInput InternalInputManager;
@@ -0,0 +1,24 @@
#pragma once
/*
MIT License
Copyright (c) 2026 Patoke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+52
View File
@@ -0,0 +1,52 @@
#pragma once
/*
MIT License
Copyright (c) 2026 Patoke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
class LinkedList
{
public:
struct _LL_NODE
{
template <typename T>
T *GetDataAs()
{
return (T *)m_pvData;
}
void *m_pvData;
_LL_NODE *m_Next;
_LL_NODE *m_Prev;
};
int m_NodeC;
_LL_NODE *m_Head;
_LL_NODE *m_Tail;
LinkedList();
void AddToHead(void *pvData);
void AddToTail(void *pvData);
void RemoveNode(_LL_NODE *pNodeToRemove);
_LL_NODE *RemoveHeadNode();
void ClearList();
};
+34
View File
@@ -0,0 +1,34 @@
#ifndef STDAFX_H
#define STDAFX_H
/*
MIT License
Copyright (c) 2026 Patoke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <cstdint>
#include <assert.h>
#include <Xinput.h>
#endif //STDAFX_H