diff --git a/Runtime/Input/CFinalInput.hpp b/Runtime/Input/CFinalInput.hpp index ca882fa7c..b8ee75992 100644 --- a/Runtime/Input/CFinalInput.hpp +++ b/Runtime/Input/CFinalInput.hpp @@ -72,6 +72,8 @@ public: const CKeyboardMouseControllerData& data, const CFinalInput& prevInput); CFinalInput& operator|=(const CFinalInput& other); + bool operator==(const CFinalInput& other) + { return memcmp(this, &other, sizeof(CFinalInput)) == 0; } bool PStart() const {return x2e_b31_PStart;} bool PR() const {return x2e_b26_PR;} diff --git a/Runtime/Input/CInputGenerator.cpp b/Runtime/Input/CInputGenerator.cpp index 3c620cb76..6f4abf82a 100644 --- a/Runtime/Input/CInputGenerator.cpp +++ b/Runtime/Input/CInputGenerator.cpp @@ -7,6 +7,12 @@ namespace pshag void CInputGenerator::Update(float dt, CArchitectureQueue& queue) { + if (m_firstFrame) + { + m_firstFrame = false; + return; + } + /* Keyboard/Mouse first */ CFinalInput kbInput = getFinalInput(0, dt); bool kbUsed = false; diff --git a/Runtime/Input/CInputGenerator.hpp b/Runtime/Input/CInputGenerator.hpp index 8fe435c04..160366378 100644 --- a/Runtime/Input/CInputGenerator.hpp +++ b/Runtime/Input/CInputGenerator.hpp @@ -32,6 +32,8 @@ class CInputGenerator : public boo::DeviceFinder m_lastUpdate = CFinalInput(idx, dt, m_data, m_lastUpdate); return m_lastUpdate; } + + bool m_firstFrame = true; public: CInputGenerator(float leftDiv, float rightDiv) : boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)}), diff --git a/Runtime/Input/CMakeLists.txt b/Runtime/Input/CMakeLists.txt index a09f2b6e2..4e3926808 100644 --- a/Runtime/Input/CMakeLists.txt +++ b/Runtime/Input/CMakeLists.txt @@ -3,4 +3,7 @@ add_library(RuntimeCommonInput CKeyboardMouseController.hpp ControlMapper.hpp ControlMapper.cpp CInputGenerator.hpp CInputGenerator.cpp - CFinalInput.hpp CFinalInput.cpp) + CFinalInput.hpp CFinalInput.cpp + CRumbleManager.hpp CRumbleManager.cpp + CRumbleGenerator.hpp CRumbleGenerator.cpp + CRumbleVoice.hpp CRumbleVoice.cpp) diff --git a/Runtime/Input/CRumbleGenerator.cpp b/Runtime/Input/CRumbleGenerator.cpp new file mode 100644 index 000000000..24c7861df --- /dev/null +++ b/Runtime/Input/CRumbleGenerator.cpp @@ -0,0 +1,8 @@ +#include "CRumbleGenerator.hpp" + +namespace pshag +{ +CRumbleGenerator::CRumbleGenerator() +{ +} +} diff --git a/Runtime/Input/CRumbleGenerator.hpp b/Runtime/Input/CRumbleGenerator.hpp new file mode 100644 index 000000000..e9c2ca247 --- /dev/null +++ b/Runtime/Input/CRumbleGenerator.hpp @@ -0,0 +1,17 @@ +#ifndef CRUMBLEGENERATOR_HPP +#define CRUMBLEGENERATOR_HPP + +#include "CRumbleVoice.hpp" + +namespace pshag +{ +class CRumbleGenerator +{ +public: + CRumbleGenerator(); + void Update(float); + void HardStopAll(); +}; +} + +#endif // CRUMBLEGENERATOR_HPP diff --git a/Runtime/Input/CRumbleManager.cpp b/Runtime/Input/CRumbleManager.cpp new file mode 100644 index 000000000..f5a0c7618 --- /dev/null +++ b/Runtime/Input/CRumbleManager.cpp @@ -0,0 +1,8 @@ +#include "CRumbleManager.hpp" + +namespace pshag +{ + +void CRumbleManager::Update(float dt) { x0_rumbleGenerator.Update(dt); } + +} diff --git a/Runtime/Input/CRumbleManager.hpp b/Runtime/Input/CRumbleManager.hpp new file mode 100644 index 000000000..cb19adf68 --- /dev/null +++ b/Runtime/Input/CRumbleManager.hpp @@ -0,0 +1,21 @@ +#ifndef __PSHAG_CRUMBLEMANAGER_HPP__ +#define __PSHAG_CRUMBLEMANAGER_HPP__ + +#include "CRumbleGenerator.hpp" + +namespace pshag +{ +class CStateManager; +class CRumbleManager +{ + CRumbleGenerator x0_rumbleGenerator; +public: + CRumbleManager() = default; + void Update(float); + void StopRumble(u16) {} + void Rumble(ERumbleFxId, CStateManager&, ERumblePriority priority); + void Rumble(ERumbleFxId, float, CStateManager&, ERumblePriority priority); +}; +} + +#endif // __PSHAG_CRUMBLEMANAGER_HPP__ diff --git a/Runtime/Input/CRumbleVoice.cpp b/Runtime/Input/CRumbleVoice.cpp new file mode 100644 index 000000000..77ed2dfb1 --- /dev/null +++ b/Runtime/Input/CRumbleVoice.cpp @@ -0,0 +1,5 @@ +#include "CRumbleVoice.hpp" + +namespace pshag +{ +} diff --git a/Runtime/Input/CRumbleVoice.hpp b/Runtime/Input/CRumbleVoice.hpp new file mode 100644 index 000000000..1f61917c3 --- /dev/null +++ b/Runtime/Input/CRumbleVoice.hpp @@ -0,0 +1,76 @@ +#ifndef CRUMBLEVOICE_HPP +#define CRUMBLEVOICE_HPP + +#include "RetroTypes.hpp" + +namespace pshag +{ +enum class ERumbleFxId +{ + +}; +enum class ERumblePriority +{ + None +}; + +struct SAdsrData; +class CRumbleVoice +{ +public: + CRumbleVoice() {} + CRumbleVoice(const SAdsrData& data); +}; + +struct SAdsrData +{ + float x0 = 0.f; + float x4 = 0.f; + float x8 = 0.f; + float xc = 0.f; + float x10 = 0.f; + float x14 = 0.f; + union + { + struct { bool x18_24 : 1; bool x18_25 : 1; }; + u8 dummy = 0; + }; + + SAdsrData() = default; + SAdsrData(float a, float b, float c, float d, float e, float f, bool g, bool h) + : x0(a), x4(b), x8(c), xc(d), x10(e), x14(f) + { + x18_24 = g; + x18_25 = h; + } +}; + +struct SAdsrDelta +{ + enum class EPhase + { + Stop, + Start, + }; + + float x0 = 0.f; + float x4 = 0.f; + float x8 = 0.f; + float xc = 0.f; + float x10 = 0.f; + ERumblePriority x1c_priority; + EPhase x20_phase; + + SAdsrDelta(EPhase phase, ERumblePriority priority) + : x1c_priority(priority), x20_phase(phase) + {} + SAdsrDelta(EPhase phase) + : x1c_priority(ERumblePriority::None), x20_phase(phase) + {} + + static SAdsrDelta Stopped() { return SAdsrDelta(EPhase::Stop); } + static SAdsrDelta Start(ERumblePriority priority) { return SAdsrDelta(EPhase::Start, priority); } +}; +} + +#endif // CRUMBLEVOICE_HPP