diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt index 3515c0458..924139334 100644 --- a/DataSpec/DNACommon/CMakeLists.txt +++ b/DataSpec/DNACommon/CMakeLists.txt @@ -8,4 +8,5 @@ add_library(DNACommon STRG.hpp STRG.cpp TXTR.hpp TXTR.cpp ANCS.hpp - ANIM.hpp ANIM.cpp) + ANIM.hpp ANIM.cpp + Tweaks/ITweakPlayerControl.hpp) diff --git a/DataSpec/DNACommon/GX.hpp b/DataSpec/DNACommon/GX.hpp index 20bdc48ee..7402b9c1e 100644 --- a/DataSpec/DNACommon/GX.hpp +++ b/DataSpec/DNACommon/GX.hpp @@ -1,13 +1,13 @@ #ifndef _DNACOMMON_GX_HPP_ #define _DNACOMMON_GX_HPP_ -#include +#include "DNACommon.hpp" namespace GX { /* RGBA8 structure (GXColor) */ -struct Color : Athena::io::DNA +struct Color : Retro::BigDNA { Value r; Value g; @@ -30,7 +30,8 @@ enum AttrType INDEX16 }; -enum TevColorArg { +enum TevColorArg +{ CC_CPREV = 0, /*!< Use the color value from previous TEV stage */ CC_APREV = 1, /*!< Use the alpha value from previous TEV stage */ CC_C0 = 2, /*!< Use the color value from the color/output register 0 */ @@ -49,7 +50,8 @@ enum TevColorArg { CC_ZERO = 15 /*!< Use to pass zero value */ }; -enum TevAlphaArg { +enum TevAlphaArg +{ CA_APREV = 0, /*!< Use the alpha value from previous TEV stage */ CA_A0 = 1, /*!< Use the alpha value from the color/output register 0 */ CA_A1 = 2, /*!< Use the alpha value from the color/output register 1 */ @@ -132,7 +134,8 @@ enum TevKAlphaSel TEV_KASEL_K3_A = 0x1F }; -enum TevOp { +enum TevOp +{ TEV_ADD = 0, TEV_SUB = 1, TEV_COMP_R8_GT = 8, @@ -147,20 +150,23 @@ enum TevOp { TEV_COMP_A8_EQ = TEV_COMP_RGB8_EQ // for alpha channel }; -enum TevBias { +enum TevBias +{ TB_ZERO = 0, TB_ADDHALF = 1, TB_SUBHALF = 2, }; -enum TevScale { +enum TevScale +{ CS_SCALE_1 = 0, CS_SCALE_2 = 1, CS_SCALE_4 = 2, CS_DIVIDE_2 = 3 }; -enum TevRegID { +enum TevRegID +{ TEVPREV = 0, TEVREG0 = 1, TEVREG1 = 2, diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp new file mode 100644 index 000000000..f09655a10 --- /dev/null +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp @@ -0,0 +1,16 @@ +#ifndef __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ +#define __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ + +#include "../DNACommon.hpp" + +namespace Retro +{ + +struct ITweakPlayerControl : BigYAML +{ + virtual atUint32 GetMapping(atUint32) const=0; +}; + +} + +#endif // __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ diff --git a/DataSpec/DNAMP1/CMakeLists.txt b/DataSpec/DNAMP1/CMakeLists.txt index 52851b8be..0aaa62983 100644 --- a/DataSpec/DNAMP1/CMakeLists.txt +++ b/DataSpec/DNAMP1/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(Tweaks) make_dnalist(liblist PAK MLVL @@ -10,7 +9,8 @@ make_dnalist(liblist MAPA CMDLMaterials MREA - Tweaks/CTweakParticle) + Tweaks/CTweakParticle + Tweaks/CTweakPlayerControl) add_library(DNAMP1 DNAMP1.hpp DNAMP1.cpp ${liblist} diff --git a/DataSpec/DNAMP1/Tweaks/CMakeLists.txt b/DataSpec/DNAMP1/Tweaks/CMakeLists.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp new file mode 100644 index 000000000..3a8624a36 --- /dev/null +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp @@ -0,0 +1,22 @@ +#ifndef _DNAMP1_CTWEAKPLAYERCONTROL_HPP_ +#define _DNAMP1_CTWEAKPLAYERCONTROL_HPP_ + +#include "../../DNACommon/Tweaks/ITweakPlayerControl.hpp" + +namespace Retro +{ +namespace DNAMP1 +{ + +struct CTweakPlayerControl : ITweakPlayerControl +{ + DECL_YAML + Vector m_mappings; + atUint32 GetMapping(atUint32 command) const {return m_mappings[command];} + CTweakPlayerControl(Athena::io::IStreamReader& reader) {this->read(reader);} +}; + +} +} + +#endif // _DNAMP1_CTWEAKPLAYERCONTROL_HPP_ diff --git a/Runtime/CGameAllocator.cpp b/Runtime/CGameAllocator.cpp index 6a162d943..fa90ef664 100644 --- a/Runtime/CGameAllocator.cpp +++ b/Runtime/CGameAllocator.cpp @@ -38,7 +38,7 @@ CGameAllocator::SGameMemInfo* CGameAllocator::GetMemInfoFromBlockPtr(void* ptr) return reinterpret_cast(reinterpret_cast(ptr) - 32); } -bool CGameAllocator::Initialize(COsContext&) +bool CGameAllocator::Initialize() { } void CGameAllocator::Shutdown() diff --git a/Runtime/CGameAllocator.hpp b/Runtime/CGameAllocator.hpp index e9ee00679..1410f0fcd 100644 --- a/Runtime/CGameAllocator.hpp +++ b/Runtime/CGameAllocator.hpp @@ -31,7 +31,7 @@ public: u32 GetLargestFreeChunk() const; SGameMemInfo* GetMemInfoFromBlockPtr(void* ptr); - bool Initialize(COsContext&); + bool Initialize(); void Shutdown(); void* Alloc(size_t, EHint, EScope, EType, const CCallStack&); void Free(void*); diff --git a/Runtime/CMainFlowBase.hpp b/Runtime/CMainFlowBase.hpp index 62353090d..4ec2688f9 100644 --- a/Runtime/CMainFlowBase.hpp +++ b/Runtime/CMainFlowBase.hpp @@ -8,10 +8,10 @@ namespace Retro enum EClientFlowStates { - ClientStateUnspecified = -1, - ClientStateFrontEnd = 7, - ClientStateGameLoad = 13, - ClientStateMoviePlay = 14 + ClientFlowUnspecified = -1, + ClientFlowFrontEnd = 7, + ClientFlowGameLoad = 13, + ClientFlowMoviePlay = 14 }; class CMainFlowBase : public CIOWin diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 6dd9e6b0d..d69afa9d5 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -16,7 +16,6 @@ else() endif() add_library(RuntimeCommon - COsContext.hpp COsContextBoo.cpp CMemory.hpp CMemory.cpp CMemoryCardSys.hpp IAllocator.hpp IAllocator.cpp diff --git a/Runtime/CMemory.cpp b/Runtime/CMemory.cpp index 817e052bc..11bdd8d49 100644 --- a/Runtime/CMemory.cpp +++ b/Runtime/CMemory.cpp @@ -12,9 +12,9 @@ static CGameAllocator g_gameAllocator; static IAllocator* g_memoryAllocator = &g_gameAllocator; static bool g_memoryAllocatorReady = false; -void CMemory::Startup(COsContext& cos) +void CMemory::Startup() { - g_memoryAllocatorReady = g_memoryAllocator->Initialize(cos); + g_memoryAllocatorReady = g_memoryAllocator->Initialize(); } void CMemory::Shutdown() @@ -23,12 +23,12 @@ void CMemory::Shutdown() g_memoryAllocatorReady = false; } -void CMemory::SetAllocator(COsContext& cos, IAllocator& alloc) +void CMemory::SetAllocator(IAllocator& alloc) { if (&alloc != g_memoryAllocator) { g_memoryAllocator = &alloc; - g_memoryAllocator->Initialize(cos); + g_memoryAllocator->Initialize(); } } @@ -56,10 +56,10 @@ void* CMemory::Alloc(size_t sz, IAllocator::EHint hint, IAllocator::EScope scope return newPtr; } -CMemorySys::CMemorySys(COsContext& cos, IAllocator& alloc) +CMemorySys::CMemorySys(IAllocator& alloc) { - CMemory::Startup(cos); - CMemory::SetAllocator(cos, alloc); + CMemory::Startup(); + CMemory::SetAllocator(alloc); } CMemorySys::~CMemorySys() diff --git a/Runtime/CMemory.hpp b/Runtime/CMemory.hpp index abbfe0e4f..9ec951c0d 100644 --- a/Runtime/CMemory.hpp +++ b/Runtime/CMemory.hpp @@ -10,9 +10,9 @@ class COsContext; class CMemory { public: - static void Startup(COsContext&); + static void Startup(); static void Shutdown(); - static void SetAllocator(COsContext&, IAllocator&); + static void SetAllocator(IAllocator&); static void OffsetFakeStatics(int); static void SetOutOfMemoryCallback(const IAllocator::TOutOfMemoryCallback, void*); static void Free(void*); @@ -22,7 +22,7 @@ public: class CMemorySys { public: - CMemorySys(COsContext&, IAllocator&); + CMemorySys(IAllocator&); ~CMemorySys(); static IAllocator& GetGameAllocator(); }; diff --git a/Runtime/COsContext.hpp b/Runtime/COsContext.hpp deleted file mode 100644 index 8ae0baa6a..000000000 --- a/Runtime/COsContext.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __RETRO_COSCONTEXT_HPP__ -#define __RETRO_COSCONTEXT_HPP__ - -namespace Retro -{ - -class COsContext -{ -public: - COsContext(); - int OpenWindow(const char* name, int x, int y, int w, int h); -}; - -} - -#endif // __RETRO_COSCONTEXT_HPP__ diff --git a/Runtime/COsContextBoo.cpp b/Runtime/COsContextBoo.cpp deleted file mode 100644 index 531460bd3..000000000 --- a/Runtime/COsContextBoo.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "COsContext.hpp" -#include - -namespace Retro -{ - -COsContext::COsContext() -{ -} - -int COsContext::OpenWindow(const char* name, int x, int y, int w, int h) -{ - return 0; -} - -} diff --git a/Runtime/CPakFile.hpp b/Runtime/CPakFile.hpp index 5d4d12e7b..2caf6bebd 100644 --- a/Runtime/CPakFile.hpp +++ b/Runtime/CPakFile.hpp @@ -37,12 +37,12 @@ private: public: CPakFile(const std::string& filename, bool flag) : CDvdFile(filename.c_str()) {} const std::vector& GetDepList() const {return x5c_depList;} - u32 GetResIdByName(const char* name) const + const SObjectTag* GetResIdByName(const char* name) const { for (const std::pair& p : x4c_nameList) if (!CStringExtras::CompareCaseInsensitive(p.first.c_str(), name)) - return p.second.id; - return 0; + return &p.second; + return nullptr; } const SResInfo* GetResInfoForLoad(u32 id) {} const SResInfo* GetResInfo(u32 id) const {} diff --git a/Runtime/CResFactory.hpp b/Runtime/CResFactory.hpp index ba288de05..397a16970 100644 --- a/Runtime/CResFactory.hpp +++ b/Runtime/CResFactory.hpp @@ -30,7 +30,7 @@ public: void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**); void CancelBuild(const SObjectTag&); bool CanBuild(const SObjectTag& tag) {return x4_loader.ResourceExists(tag);} - u32 GetResourceIdByName(const char* name) const {return x4_loader.GetResourceIdByName(name);} + const SObjectTag* GetResourceIdByName(const char* name) const {return x4_loader.GetResourceIdByName(name);} std::vector> GetResourceIdToNameList() const { diff --git a/Runtime/CResLoader.cpp b/Runtime/CResLoader.cpp index ea9fb476b..2063d3858 100644 --- a/Runtime/CResLoader.cpp +++ b/Runtime/CResLoader.cpp @@ -138,15 +138,15 @@ FourCC CResLoader::GetResourceTypeById(u32 id) return false; } -u32 CResLoader::GetResourceIdByName(const char* name) const +const SObjectTag* CResLoader::GetResourceIdByName(const char* name) const { for (const std::unique_ptr& file : x1c_pakLoadedList) { - u32 id = file->GetResIdByName(name); + const SObjectTag* id = file->GetResIdByName(name); if (id) return id; } - return 0; + return nullptr; } bool CResLoader::AreAllPaksLoaded() const diff --git a/Runtime/CResLoader.hpp b/Runtime/CResLoader.hpp index 1724ca9c8..b3b111d9d 100644 --- a/Runtime/CResLoader.hpp +++ b/Runtime/CResLoader.hpp @@ -34,7 +34,7 @@ public: u32 ResourceSize(const SObjectTag& tag); bool ResourceExists(const SObjectTag& tag); FourCC GetResourceTypeById(u32 id); - u32 GetResourceIdByName(const char* name) const; + const SObjectTag* GetResourceIdByName(const char* name) const; bool AreAllPaksLoaded() const; void AsyncIdlePakLoading(); bool FindResource(u32 id); diff --git a/Runtime/Character/CAssetFactory.hpp b/Runtime/Character/CAssetFactory.hpp index 5413163b0..35159714d 100644 --- a/Runtime/Character/CAssetFactory.hpp +++ b/Runtime/Character/CAssetFactory.hpp @@ -12,7 +12,7 @@ public: void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) {} void CancelBuild(const SObjectTag&) {} bool CanBuild(const SObjectTag&) {} - u32 GetResourceIdByName(const char*) const {} + const SObjectTag* GetResourceIdByName(const char*) const {} }; } diff --git a/Runtime/GameGlobalObjects.hpp b/Runtime/GameGlobalObjects.hpp index 387119ef9..bfedb4a6a 100644 --- a/Runtime/GameGlobalObjects.hpp +++ b/Runtime/GameGlobalObjects.hpp @@ -13,6 +13,8 @@ extern class CGameState* g_GameState; extern class CInGameTweakManagerBase* g_TweakManager; extern class CBooRenderer* g_Renderer; +extern class ITweakPlayerControl* g_tweakPlayerControl; + } #endif // __RETRO_GAMEGLOBALOBJECTS_HPP__ diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 50f3f06db..f71c2ba48 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -4,14 +4,13 @@ namespace Retro { class IObjectStore; -class COsContext; class CMemorySys; class CResFactory; class CBooRenderer { public: - CBooRenderer(IObjectStore&, COsContext&, CMemorySys&, CResFactory&) + CBooRenderer(IObjectStore&, CMemorySys&, CResFactory&) { } }; diff --git a/Runtime/IAllocator.hpp b/Runtime/IAllocator.hpp index e8cea55ff..df5cfd61c 100644 --- a/Runtime/IAllocator.hpp +++ b/Runtime/IAllocator.hpp @@ -59,7 +59,7 @@ public: typedef bool(*TOutOfMemoryCallback)(void*, u32); typedef bool(*TAllocationVisitCallback)(const SAllocInfo&, void*); - virtual bool Initialize(COsContext&)=0; + virtual bool Initialize()=0; virtual void Shutdown()=0; virtual void* Alloc(size_t, EHint, EScope, EType, const CCallStack&)=0; virtual void Free(void*)=0; diff --git a/Runtime/IFactory.hpp b/Runtime/IFactory.hpp index 1ae2b249d..f544e52d2 100644 --- a/Runtime/IFactory.hpp +++ b/Runtime/IFactory.hpp @@ -17,7 +17,7 @@ public: virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**)=0; virtual void CancelBuild(const SObjectTag&)=0; virtual bool CanBuild(const SObjectTag&)=0; - virtual u32 GetResourceIdByName(const char*) const=0; + virtual const SObjectTag* GetResourceIdByName(const char*) const=0; }; } diff --git a/Runtime/Input/CDolphinController.hpp b/Runtime/Input/CDolphinController.hpp new file mode 100644 index 000000000..8b19a3174 --- /dev/null +++ b/Runtime/Input/CDolphinController.hpp @@ -0,0 +1,15 @@ +#ifndef __RETRO_CDOLPHINCONTROLLER_HPP__ +#define __RETRO_CDOLPHINCONTROLLER_HPP__ + +#include "IController.hpp" + +namespace Retro +{ + +class CDolphinController : public IController +{ +}; + +} + +#endif // __RETRO_CDOLPHINCONTROLLER_HPP__ diff --git a/Runtime/Input/CFinalInput.cpp b/Runtime/Input/CFinalInput.cpp index e69de29bb..fd451d810 100644 --- a/Runtime/Input/CFinalInput.cpp +++ b/Runtime/Input/CFinalInput.cpp @@ -0,0 +1,8 @@ +#include "CFinalInput.hpp" + +namespace Retro +{ + + + +} diff --git a/Runtime/Input/CFinalInput.hpp b/Runtime/Input/CFinalInput.hpp index 0aa39377a..137b60cc6 100644 --- a/Runtime/Input/CFinalInput.hpp +++ b/Runtime/Input/CFinalInput.hpp @@ -1,11 +1,121 @@ #ifndef __RETRO_CFINALINPUT_HPP__ #define __RETRO_CFINALINPUT_HPP__ +#include "../RetroTypes.hpp" + namespace Retro { class CFinalInput { + float x0_dt; + u32 x4_controllerIdx; + float x8_anaLeftX; + float xc_anaLeftY; + float x10_anaRightX; + float x14_anaRightY; + float x18_anaLeftTrigger; + float x1c_anaRightTrigger; + bool x20_enableAnaLeftXP; + bool x21_enableAnaLeftYP; + bool x22_enableAnaRightXP; + bool x23_enableAnaRightYP; + float x24_anaLeftTriggerP; + float x28_anaRightTriggerP; + + bool x2c_b24_A:1; + bool x2c_b25_B:1; + bool x2c_b26_X:1; + bool x2c_b27_Y:1; + bool x2c_b28_Z:1; + bool x2c_b29_L:1; + bool x2c_b30_R:1; + bool x2c_b31_DPUp:1; + bool x2d_b24_DPRight:1; + bool x2d_b25_DPDown:1; + bool x2d_b26_DPLeft:1; + bool x2d_b27_Start:1; + + bool x2d_b28_PA:1; + bool x2d_b29_PB:1; + bool x2d_b30_PX:1; + bool x2d_b31_PY:1; + bool x2e_b24_PZ:1; + bool x2e_b25_PL:1; + bool x2e_b26_PR:1; + bool x2e_b27_PDPUp:1; + bool x2e_b28_PDPRight:1; + bool x2e_b29_PDPDown:1; + bool x2e_b30_PDPLeft:1; + bool x2e_b31_PStart:1; + +public: + bool PStart() const {return x2e_b31_PStart;} + bool PR() const {return x2e_b26_PR;} + bool PL() const {return x2e_b25_PL;} + bool PZ() const {return x2e_b24_PZ;} + bool PY() const {return x2d_b31_PY;} + bool PX() const {return x2d_b30_PX;} + bool PB() const {return x2d_b29_PB;} + bool PA() const {return x2d_b28_PA;} + bool PDPRight() const {return x2e_b28_PDPRight;} + bool PDPLeft() const {return x2e_b30_PDPLeft;} + bool PDPDown() const {return x2e_b29_PDPDown;} + bool PDPUp() const {return x2e_b27_PDPUp;} + bool PRTrigger() const {return x28_anaRightTriggerP > 0.050000001;} + bool PLTrigger() const {return x24_anaLeftTriggerP > 0.050000001;} + bool PRARight() const {return x22_enableAnaRightXP && x10_anaRightX > 0.69999999;} + bool PRALeft() const {return x22_enableAnaRightXP && x10_anaRightX < -0.69999999;} + bool PRADown() const {return x23_enableAnaRightYP && x14_anaRightY < -0.69999999;} + bool PRAUp() const {return x23_enableAnaRightYP && x14_anaRightY > 0.69999999;} + bool PLARight() const {return x20_enableAnaLeftXP && x8_anaLeftX > 0.69999999;} + bool PLALeft() const {return x20_enableAnaLeftXP && x8_anaLeftX < -0.69999999;} + bool PLADown() const {return x21_enableAnaLeftYP && xc_anaLeftY < -0.69999999;} + bool PLAUp() const {return x21_enableAnaLeftYP && xc_anaLeftY > 0.69999999;} + bool DStart() const {return x2d_b27_Start;} + bool DR() const {return x2c_b30_R;} + bool DL() const {return x2c_b29_L;} + bool DZ() const {return x2c_b28_Z;} + bool DY() const {return x2c_b27_Y;} + bool DX() const {return x2c_b26_X;} + bool DB() const {return x2c_b25_B;} + bool DA() const {return x2c_b24_A;} + bool DDPRight() const {return x2d_b24_DPRight;} + bool DDPLeft() const {return x2d_b26_DPLeft;} + bool DDPDown() const {return x2d_b25_DPDown;} + bool DDPUp() const {return x2c_b31_DPUp;} + bool DRTrigger() const {return x1c_anaRightTrigger > 050000001;} + bool DLTrigger() const {return x18_anaLeftTrigger > 050000001;} + bool DRARight() const {return x10_anaRightX > 0.69999999;} + bool DRALeft() const {return x10_anaRightX < -0.69999999;} + bool DRADown() const {return x14_anaRightY < -0.69999999;} + bool DRAUp() const {return x14_anaRightY > 0.69999999;} + bool DLARight() const {return x8_anaLeftX > 0.69999999;} + bool DLALeft() const {return x8_anaLeftX < -0.69999999;} + bool DLADown() const {return xc_anaLeftY < -0.69999999;} + bool DLAUp() const {return xc_anaLeftY > 0.69999999;} + float AStart() const {return x2d_b27_Start ? 1.0 : 0.0;} + float AR() const {return x2c_b30_R ? 1.0 : 0.0;} + float AL() const {return x2c_b29_L ? 1.0 : 0.0;} + float AZ() const {return x2c_b28_Z ? 1.0 : 0.0;} + float AY() const {return x2c_b27_Y ? 1.0 : 0.0;} + float AX() const {return x2c_b26_X ? 1.0 : 0.0;} + float AB() const {return x2c_b25_B ? 1.0 : 0.0;} + float AA() const {return x2c_b24_A ? 1.0 : 0.0;} + float ADPRight() const {return x2d_b24_DPRight ? 1.0 : 0.0;} + float ADPLeft() const {return x2d_b26_DPLeft ? 1.0 : 0.0;} + float ADPDown() const {return x2d_b25_DPDown ? 1.0 : 0.0;} + float ADPUp() const {return x2c_b31_DPUp ? 1.0 : 0.0;} + float ARTrigger() const {return x1c_anaRightTrigger;} + float ALTrigger() const {return x18_anaLeftTrigger;} + float ARARight() const {return x10_anaRightX > 0.0 ? x10_anaRightX : 0.0;} + float ARALeft() const {return x10_anaRightX < 0.0 ? -x10_anaRightX : 0.0;} + float ARADown() const {return x14_anaRightY < 0.0 ? -x14_anaRightY : 0.0;} + float ARAUp() const {return x14_anaRightY > 0.0 ? x14_anaRightY : 0.0;} + float ALARight() const {return x8_anaLeftX > 0.0 ? x8_anaLeftX : 0.0;} + float ALALeft() const {return x8_anaLeftX < 0.0 ? -x8_anaLeftX : 0.0;} + float ALADown() const {return xc_anaLeftY < 0.0 ? -xc_anaLeftY : 0.0;} + float ALAUp() const {return xc_anaLeftY > 0.0 ? xc_anaLeftY : 0.0;} }; } diff --git a/Runtime/Input/CInputGenerator.cpp b/Runtime/Input/CInputGenerator.cpp index e69de29bb..cefa0ff3c 100644 --- a/Runtime/Input/CInputGenerator.cpp +++ b/Runtime/Input/CInputGenerator.cpp @@ -0,0 +1,8 @@ +#include "CInputGenerator.hpp" + +namespace Retro +{ + + + +} diff --git a/Runtime/Input/CInputGenerator.hpp b/Runtime/Input/CInputGenerator.hpp index 6acc4c404..6aee98da8 100644 --- a/Runtime/Input/CInputGenerator.hpp +++ b/Runtime/Input/CInputGenerator.hpp @@ -1,11 +1,115 @@ #ifndef __RETRO_CINPUTGENERATOR_HPP__ #define __RETRO_CINPUTGENERATOR_HPP__ +#include + namespace Retro { + + class CInputGenerator { + struct WindowCallback : boo::IWindowCallback + { + void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) + { + fprintf(stderr, "Mouse Down %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]); + } + void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) + { + fprintf(stderr, "Mouse Up %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]); + } + void mouseMove(const SWindowCoord& coord) + { + //fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]); + } + void scroll(const SWindowCoord& coord, const SScrollDelta& scroll) + { + fprintf(stderr, "Mouse Scroll (%f,%f) (%f,%f)\n", coord.norm[0], coord.norm[1], scroll.delta[0], scroll.delta[1]); + } + + void touchDown(const STouchCoord& coord, uintptr_t tid) + { + //fprintf(stderr, "Touch Down %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]); + } + void touchUp(const STouchCoord& coord, uintptr_t tid) + { + //fprintf(stderr, "Touch Up %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]); + } + void touchMove(const STouchCoord& coord, uintptr_t tid) + { + //fprintf(stderr, "Touch Move %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]); + } + + void charKeyDown(unsigned long charCode, EModifierKey mods, bool isRepeat) + { + + } + void charKeyUp(unsigned long charCode, EModifierKey mods) + { + + } + void specialKeyDown(ESpecialKey key, EModifierKey mods, bool isRepeat) + { + + } + void specialKeyUp(ESpecialKey key, EModifierKey mods) + { + + } + void modKeyDown(EModifierKey mod, bool isRepeat) + { + + } + void modKeyUp(EModifierKey mod) + { + + } + + } m_windowCb; + + struct DolphinSmashAdapterCallback : boo::IDolphinSmashAdapterCallback + { + void controllerConnected(unsigned idx, boo::EDolphinControllerType) + { + printf("CONTROLLER %u CONNECTED\n", idx); + } + void controllerDisconnected(unsigned idx, boo::EDolphinControllerType) + { + printf("CONTROLLER %u DISCONNECTED\n", idx); + } + void controllerUpdate(unsigned idx, boo::EDolphinControllerType, + const boo::DolphinControllerState& state) + { + printf("CONTROLLER %u UPDATE %d %d\n", idx, state.m_leftStick[0], state.m_leftStick[1]); + } + }; + + class ApplicationDeviceFinder : public boo::DeviceFinder + { + std::unique_ptr smashAdapter = NULL; + DolphinSmashAdapterCallback m_cb; + public: + ApplicationDeviceFinder() + : boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)}) + {} + void deviceConnected(boo::DeviceToken& tok) + { + if (!smashAdapter) + { + smashAdapter.reset(dynamic_cast(tok.openAndGetDevice())); + smashAdapter->setCallback(&m_cb); + smashAdapter->startRumble(0); + } + } + void deviceDisconnected(boo::DeviceToken&, boo::DeviceBase* device) + { + if (smashAdapter.get() == device) + smashAdapter.reset(nullptr); + } + }; + }; } diff --git a/Runtime/Input/CKeyboardController.hpp b/Runtime/Input/CKeyboardController.hpp new file mode 100644 index 000000000..afe6a3c23 --- /dev/null +++ b/Runtime/Input/CKeyboardController.hpp @@ -0,0 +1,15 @@ +#ifndef __RETRO_CKEYBOARDCONTROLLER_HPP__ +#define __RETRO_CKEYBOARDCONTROLLER_HPP__ + +#include "IController.hpp" + +namespace Retro +{ + +class CKeyboardController : public IController +{ +}; + +} + +#endif // __RETRO_CKEYBOARDCONTROLLER_HPP__ diff --git a/Runtime/Input/CMakeLists.txt b/Runtime/Input/CMakeLists.txt index c02ccf972..1f2785db8 100644 --- a/Runtime/Input/CMakeLists.txt +++ b/Runtime/Input/CMakeLists.txt @@ -1,3 +1,8 @@ add_library(RuntimeCommonInput + IController.hpp + CDolphinController.hpp + CKeyboardController.hpp + CMouseController.hpp + ControlMapper.hpp ControlMapper.cpp CInputGenerator.hpp CInputGenerator.cpp CFinalInput.hpp CFinalInput.cpp) diff --git a/Runtime/Input/CMouseController.hpp b/Runtime/Input/CMouseController.hpp new file mode 100644 index 000000000..7a4784ddb --- /dev/null +++ b/Runtime/Input/CMouseController.hpp @@ -0,0 +1,15 @@ +#ifndef __RETRO_CMOUSECONTROLLER_HPP__ +#define __RETRO_CMOUSECONTROLLER_HPP__ + +#include "IController.hpp" + +namespace Retro +{ + +class CMouseController : public IController +{ +}; + +} + +#endif // __RETRO_CMOUSECONTROLLER_HPP__ diff --git a/Runtime/Input/ControlMapper.cpp b/Runtime/Input/ControlMapper.cpp new file mode 100644 index 000000000..ca1dc1029 --- /dev/null +++ b/Runtime/Input/ControlMapper.cpp @@ -0,0 +1,256 @@ +#include "../RetroTypes.hpp" +#include "ControlMapper.hpp" +#include "CFinalInput.hpp" +#include "DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp" +#include "../GameGlobalObjects.hpp" + +namespace Retro +{ + +static const char* skCommandDescs[] = +{ + "Forward", + "Backward", + "Turn Left", + "Turn Right", + "Strafe Left", + "Strafe Right", + "Look Left", + "Look Right", + "Look Up", + "Look Down", + "Jump/Boost", + "Fire/Bomb", + "Missile/PowerBomb", + "Morph", + "Aim Up", + "Aim Down", + "Cycle Beam Up", + "Cycle Beam Down", + "Cycle Item", + "Power Beam", + "Ice Beam", + "Wave Beam", + "Plasma Beam", + "Toggle Holster", + "Orbit Close", + "Orbit Far", + "Orbit Object", + "Orbit Select", + "Orbit Confirm", + "Orbit Left", + "Orbit Right", + "Orbit Up", + "Orbit Down", + "Look Hold1", + "Look Hold2", + "Look Zoom In", + "Look Zoom Out", + "Aim Hold", + "Map Circle Up", + "Map Circle Down", + "Map Circle Left", + "Map Circle Right", + "Map Move Forward", + "Map Move Back", + "Map Move Left", + "Map Move Right", + "Map Zoom In", + "Map Zoom Out", + "SpiderBall", + "Chase Camera", + "XRay Visor", + "Thermo Visor", + "Enviro Visor", + "No Visor", + "Visor Menu", + "Visor Up", + "Visor Down", + "Use Shield", + "Scan Item", + "UNKNOWN" + +}; + +static const char* skFunctionDescs[] = +{ + "None", + "Left Stick Up", + "Left Stick Down", + "Left Stick Left", + "Left Stick Right", + "Right Stick Up", + "Right Stick Down", + "Right Stick Left", + "Right Stick Right", + "Left Trigger", + "Right Trigger", + "D-Pad Up ", + "D-Pad Down ", + "D-Pad Left ", + "D-Pad Right", + "A Button", + "B Button", + "X Button", + "Y Button", + "Z Button", + "Left Trigger Press", + "Right Trigger Press", + "Start" +}; + +typedef bool (CFinalInput::*BoolReturnFn)() const; +typedef float (CFinalInput::*FloatReturnFn)() const; + +static BoolReturnFn skPressFuncs[] = +{ + nullptr, + &CFinalInput::PLAUp, + &CFinalInput::PLADown, + &CFinalInput::PLALeft, + &CFinalInput::PLARight, + &CFinalInput::PRAUp, + &CFinalInput::PRADown, + &CFinalInput::PRALeft, + &CFinalInput::PRARight, + &CFinalInput::PLTrigger, + &CFinalInput::PRTrigger, + &CFinalInput::PDPUp, + &CFinalInput::PDPDown, + &CFinalInput::PDPLeft, + &CFinalInput::PDPRight, + &CFinalInput::PA, + &CFinalInput::PB, + &CFinalInput::PX, + &CFinalInput::PY, + &CFinalInput::PZ, + &CFinalInput::PL, + &CFinalInput::PR, + &CFinalInput::PStart, + nullptr +}; + +static BoolReturnFn skDigitalFuncs[] = +{ + nullptr, + &CFinalInput::DLAUp, + &CFinalInput::DLADown, + &CFinalInput::DLALeft, + &CFinalInput::DLARight, + &CFinalInput::DRAUp, + &CFinalInput::DRADown, + &CFinalInput::DRALeft, + &CFinalInput::DRARight, + &CFinalInput::DLTrigger, + &CFinalInput::DRTrigger, + &CFinalInput::DDPUp, + &CFinalInput::DDPDown, + &CFinalInput::DDPLeft, + &CFinalInput::DDPRight, + &CFinalInput::DA, + &CFinalInput::DB, + &CFinalInput::DX, + &CFinalInput::DY, + &CFinalInput::DZ, + &CFinalInput::DL, + &CFinalInput::DR, + &CFinalInput::DStart, + nullptr +}; + +static FloatReturnFn skAnalogFuncs[] = +{ + nullptr, + &CFinalInput::ALAUp, + &CFinalInput::ALADown, + &CFinalInput::ALALeft, + &CFinalInput::ALARight, + &CFinalInput::ARAUp, + &CFinalInput::ARADown, + &CFinalInput::ARALeft, + &CFinalInput::ARARight, + &CFinalInput::ALTrigger, + &CFinalInput::ARTrigger, + &CFinalInput::ADPUp, + &CFinalInput::ADPDown, + &CFinalInput::ADPLeft, + &CFinalInput::ADPRight, + &CFinalInput::AA, + &CFinalInput::AB, + &CFinalInput::AX, + &CFinalInput::AY, + &CFinalInput::AZ, + &CFinalInput::AL, + &CFinalInput::AR, + &CFinalInput::AStart, + nullptr +}; + +#define kCommandFilterCount 65 +static bool skCommandFilterFlag[kCommandFilterCount]; + +void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered) +{ + skCommandFilterFlag[cmd] = filtered; +} + +void ControlMapper::ResetCommandFilters() +{ + for (int i=0 ; iGetMapping(cmd)); + if (func > FuncMAX) + return false; + BoolReturnFn fn = skPressFuncs[func]; + if (!fn) + return false; + return (input.*fn)(); +} + +bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input) +{ + if (!skCommandFilterFlag[cmd]) + return false; + EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(cmd)); + if (func > FuncMAX) + return false; + BoolReturnFn fn = skDigitalFuncs[func]; + if (!fn) + return false; + return (input.*fn)(); +} + +float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input) +{ + if (!skCommandFilterFlag[cmd]) + return 0.0; + EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(cmd)); + if (func > FuncMAX) + return 0.0; + FloatReturnFn fn = skAnalogFuncs[func]; + if (!fn) + return 0.0; + return (input.*fn)(); +} + +const char* ControlMapper::GetDescriptionForCommand(ECommands cmd) +{ + if (cmd > CmdMAX) + return nullptr; + return skCommandDescs[cmd]; +} + +const char* ControlMapper::GetDescriptionForFunction(EFunctionList func) +{ + if (func > FuncMAX) + return nullptr; + return skFunctionDescs[func]; +} + +} diff --git a/Runtime/Input/ControlMapper.hpp b/Runtime/Input/ControlMapper.hpp new file mode 100644 index 000000000..7303abfd2 --- /dev/null +++ b/Runtime/Input/ControlMapper.hpp @@ -0,0 +1,115 @@ +#ifndef __RETRO_CCONTROLMAPPER_HPP__ +#define __RETRO_CCONTROLMAPPER_HPP__ + +namespace Retro +{ +class CFinalInput; + +class ControlMapper +{ +public: + enum ECommands + { + CmdForward, + CmdBackward, + CmdTurnLeft, + CmdTurnRight, + CmdStrafeLeft, + CmdStrafeRight, + CmdLookLeft, + CmdLookRight, + CmdLookUp, + CmdLookDown, + CmdJumpOrBoost, + CmdFireOrBomb, + CmdMissileOrPowerBomb, + CmdMorph, + CmdAimUp, + CmdAimDown, + CmdCycleBeamUp, + CmdCycleBeamDown, + CmdCycleItem, + CmdPowerBeam, + CmdIceBeam, + CmdWaveBeam, + CmdPlasmaBeam, + CmdToggleHolster, + CmdOrbitClose, + CmdOrbitFar, + CmdOrbitObject, + CmdOrbitSelect, + CmdOrbitConfirm, + CmdOrbitLeft, + CmdOrbitRight, + CmdOrbitUp, + CmdOrbitDown, + CmdLookHold1, + CmdLookHold2, + CmdLookZoomIn, + CmdLookZoomOut, + CmdAimHold, + CmdMapCircleUp, + CmdMapCircleDown, + CmdMapCircleLeft, + CmdMapCircleRight, + CmdMapMoveForward, + CmdMapMoveBack, + CmdMapMoveLeft, + CmdMapMoveRight, + CmdMapZoomIn, + CmdMapZoomOut, + CmdChaseCamera, + CmdXrayVisor, + CmdThermoVisor, + CmdInviroVisor, + CmdNoVisor, + CmdVisorMenu, + CmdVisorUp, + CmdVisorDown, + CmdUseSheild, + CmdScanItem, + CmdUNKNOWN, + CmdNone, + CmdMAX + }; + + enum EFunctionList + { + FuncNone, + FuncLeftStickUp, + FuncLeftStickDown, + FuncLeftStickLeft, + FuncLeftStickRight, + FuncRightStickUp, + FuncRightStickDown, + FuncRightStickLeft, + FuncRightStickRight, + FuncLeftTrigger, + FuncRightTrigger, + FuncDPadUp, + FuncDPadDown, + FuncDPadLeft, + FuncDPadRight, + FuncAButton, + FuncBButton, + FuncXButton, + FuncYButton, + FuncZButton, + FuncLeftTriggerPress, + FuncRightTriggerPress, + FuncStart, + FuncMAX // default case + }; + + static void SetCommandFiltered(ECommands cmd, bool filtered); + static void ResetCommandFilters(); + static bool GetPressInput(ECommands cmd, const CFinalInput& input); + static bool GetDigitalInput(ECommands cmd, const CFinalInput& input); + static float GetAnalogInput(ECommands cmd, const CFinalInput& input); + static const char* GetDescriptionForCommand(ECommands cmd); + static const char* GetDescriptionForFunction(EFunctionList func); +}; + +} + +#endif // __RETRO_CCONTROLMAPPER_HPP__ diff --git a/Runtime/Input/IController.hpp b/Runtime/Input/IController.hpp new file mode 100644 index 000000000..3f5cafdd9 --- /dev/null +++ b/Runtime/Input/IController.hpp @@ -0,0 +1,27 @@ +#ifndef __RETRO_ICONTROLLER_HPP__ +#define __RETRO_ICONTROLLER_HPP__ + +namespace Retro +{ + +class IController +{ +public: + class CControllerAxis + { + }; + class CControllerButton + { + }; + class IControllerGamepadData + { + }; + + void Poll(); + u32 GetDeviceCount(); + +}; + +} + +#endif // __RETRO_ICONTROLLER_HPP__ diff --git a/Runtime/MP1/CMain.hpp b/Runtime/MP1/CMain.hpp index d57dfe8c6..a8e958c53 100644 --- a/Runtime/MP1/CMain.hpp +++ b/Runtime/MP1/CMain.hpp @@ -1,7 +1,7 @@ #ifndef __RETRO_CMAIN_HPP__ #define __RETRO_CMAIN_HPP__ -#include "COsContext.hpp" +#include #include "CMemory.hpp" #include "CTweaks.hpp" #include "CPlayMovie.hpp" @@ -21,12 +21,35 @@ enum EGameplayResult GameplayResultPlaying }; -class CMain : public COsContext -{ +class CMain : public boo::IApplicationCallback +{ + boo::IWindow* mainWindow = NULL; +#if 0 + ApplicationDeviceFinder devFinder; + WindowCallback windowCallback; + void appLaunched(boo::IApplication* app) + { + mainWindow = app->newWindow("YAY!"); + mainWindow->setCallback(&windowCallback); + mainWindow->showWindow(); + devFinder.startScanning(); + } + void appQuitting(boo::IApplication*) + {} + void appFilesOpen(boo::IApplication*, const std::vector& paths) + { + fprintf(stderr, "OPENING: "); + for (const std::string& path : paths) + fprintf(stderr, "%s ", path.c_str()); + fprintf(stderr, "\n"); + } +#endif + CMemorySys x6c_memSys; CTweaks x70_tweaks; EGameplayResult xe4_gameplayResult; bool xe8_finished = false; + public: CMain(); void RegisterResourceTweaks(); diff --git a/Runtime/MP1/CMainFlow.cpp b/Runtime/MP1/CMainFlow.cpp index f9354726f..5cc6286a7 100644 --- a/Runtime/MP1/CMainFlow.cpp +++ b/Runtime/MP1/CMainFlow.cpp @@ -16,15 +16,15 @@ void CMainFlow::AdvanceGameState(CArchitectureQueue& queue) { switch (x14_gameState) { - case ClientStateFrontEnd: - SetGameState(ClientStateGameLoad, queue); + case ClientFlowFrontEnd: + CMainFlow::SetGameState(ClientFlowGameLoad, queue); break; - case ClientStateUnspecified: - case ClientStateGameLoad: - SetGameState(ClientStateMoviePlay, queue); + case ClientFlowUnspecified: + case ClientFlowGameLoad: + CMainFlow::SetGameState(ClientFlowMoviePlay, queue); break; - case ClientStateMoviePlay: - SetGameState(ClientStateFrontEnd, queue); + case ClientFlowMoviePlay: + CMainFlow::SetGameState(ClientFlowFrontEnd, queue); break; } } @@ -33,7 +33,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) { switch (state) { - case ClientStateFrontEnd: + case ClientFlowFrontEnd: { if (g_main->GetGameplayResult() == GameplayResultNone) { @@ -48,12 +48,12 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) queue.Push(std::move(MakeMsg::CreateCreateIOWin(TargetIOWinManager, 12, 11, new CFrontEndUI(queue)))); break; } - case ClientStateGameLoad: + case ClientFlowGameLoad: { queue.Push(std::move(MakeMsg::CreateCreateIOWin(TargetIOWinManager, 10, 1000, new CMFGameLoader()))); break; } - case ClientStateMoviePlay: + case ClientFlowMoviePlay: { switch (g_main->GetGameplayResult()) { diff --git a/Runtime/MP1/CTweaks.cpp b/Runtime/MP1/CTweaks.cpp index 15c75d914..ed674b6b3 100644 --- a/Runtime/MP1/CTweaks.cpp +++ b/Runtime/MP1/CTweaks.cpp @@ -1,12 +1,36 @@ +#include #include "CTweaks.hpp" +#include "CResFactory.hpp" +#include "CResLoader.hpp" +#include "GameGlobalObjects.hpp" +#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp" namespace Retro { +ITweakPlayerControl* g_tweakPlayerControl = nullptr; + namespace MP1 { +LogVisor::LogModule Log("MP1::CTweaks"); + +static const SObjectTag& IDFromFactory(CResFactory& factory, const char* name) +{ + const SObjectTag* tag = factory.GetResourceIdByName(name); + if (!tag) + Log.report(LogVisor::FatalError, "Tweak Asset not found when loading... '%s'", name); + return *tag; +} + void CTweaks::RegisterTweaks() { + CResFactory& factory = *g_ResFactory; + CResLoader& loader = factory.GetLoader(); + std::unique_ptr strm; + + strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "PlayerControls"), nullptr)); + TOneStatic playerControl(*strm); + g_tweakPlayerControl = playerControl.GetAllocSpace(); } void CTweaks::RegisterResourceTweaks() diff --git a/Runtime/MP1/main.cpp b/Runtime/MP1/main.cpp index c76d7362b..72ee20378 100644 --- a/Runtime/MP1/main.cpp +++ b/Runtime/MP1/main.cpp @@ -57,10 +57,10 @@ class CGameGlobalObjects { } static CBooRenderer* - AllocateRenderer(IObjectStore& store, COsContext& osctx, + AllocateRenderer(IObjectStore& store, CMemorySys& memSys, CResFactory& resFactory) { - g_Renderer = new CBooRenderer(store, osctx, memSys, resFactory); + g_Renderer = new CBooRenderer(store, memSys, resFactory); return g_Renderer; } @@ -77,11 +77,11 @@ public: g_TweakManager = &m_tweakManager; } - void PostInitialize(COsContext& osctx, CMemorySys& memSys) + void PostInitialize(CMemorySys& memSys) { AddPaksAndFactories(); LoadStringTable(); - m_renderer.reset(AllocateRenderer(m_simplePool, osctx, memSys, m_resFactory)); + m_renderer.reset(AllocateRenderer(m_simplePool, memSys, m_resFactory)); } }; @@ -97,7 +97,7 @@ class CGameArchitectureSupport CConsoleOutputWindow m_consoleWindow; CAudioStateWin m_audioStateWin; public: - CGameArchitectureSupport(COsContext& osctx) + CGameArchitectureSupport() : m_audioSys(0,0,0,0,0) { } @@ -109,9 +109,8 @@ public: }; CMain::CMain() -: x6c_memSys(*this, CMemorySys::GetGameAllocator()) +: x6c_memSys(CMemorySys::GetGameAllocator()) { - OpenWindow("", 0, 0, 640, 480); g_main = this; xe4_gameplayResult = GameplayResultPlaying; } @@ -140,12 +139,12 @@ int CMain::RsMain(int argc, const char* argv[]) { TOneStatic globalObjs; InitializeSubsystems(); - globalObjs->PostInitialize(*this, x6c_memSys); + globalObjs->PostInitialize(x6c_memSys); x70_tweaks.RegisterTweaks(); AddWorldPaks(); g_TweakManager->ReadFromMemoryCard("AudioTweaks"); FillInAssetIDs(); - TOneStatic archSupport(*this); + TOneStatic archSupport; while (!xe8_finished) { xe8_finished = archSupport->Update(); @@ -156,138 +155,11 @@ int CMain::RsMain(int argc, const char* argv[]) } } -struct WindowCallback : boo::IWindowCallback -{ - - void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) - { - fprintf(stderr, "Mouse Down %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]); - } - void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) - { - fprintf(stderr, "Mouse Up %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]); - } - void mouseMove(const SWindowCoord& coord) - { - //fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]); - } - void scroll(const SWindowCoord& coord, const SScrollDelta& scroll) - { - fprintf(stderr, "Mouse Scroll (%f,%f) (%f,%f)\n", coord.norm[0], coord.norm[1], scroll.delta[0], scroll.delta[1]); - } - - void touchDown(const STouchCoord& coord, uintptr_t tid) - { - //fprintf(stderr, "Touch Down %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]); - } - void touchUp(const STouchCoord& coord, uintptr_t tid) - { - //fprintf(stderr, "Touch Up %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]); - } - void touchMove(const STouchCoord& coord, uintptr_t tid) - { - //fprintf(stderr, "Touch Move %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]); - } - - void charKeyDown(unsigned long charCode, EModifierKey mods, bool isRepeat) - { - - } - void charKeyUp(unsigned long charCode, EModifierKey mods) - { - - } - void specialKeyDown(ESpecialKey key, EModifierKey mods, bool isRepeat) - { - - } - void specialKeyUp(ESpecialKey key, EModifierKey mods) - { - - } - void modKeyDown(EModifierKey mod, bool isRepeat) - { - - } - void modKeyUp(EModifierKey mod) - { - - } - -}; - -struct DolphinSmashAdapterCallback : boo::IDolphinSmashAdapterCallback -{ - void controllerConnected(unsigned idx, boo::EDolphinControllerType) - { - printf("CONTROLLER %u CONNECTED\n", idx); - } - void controllerDisconnected(unsigned idx, boo::EDolphinControllerType) - { - printf("CONTROLLER %u DISCONNECTED\n", idx); - } - void controllerUpdate(unsigned idx, boo::EDolphinControllerType, - const boo::DolphinControllerState& state) - { - printf("CONTROLLER %u UPDATE %d %d\n", idx, state.m_leftStick[0], state.m_leftStick[1]); - } -}; - -class ApplicationDeviceFinder : public boo::DeviceFinder -{ - std::unique_ptr smashAdapter = NULL; - DolphinSmashAdapterCallback m_cb; -public: - ApplicationDeviceFinder() - : boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)}) - {} - void deviceConnected(boo::DeviceToken& tok) - { - if (!smashAdapter) - { - smashAdapter.reset(dynamic_cast(tok.openAndGetDevice())); - smashAdapter->setCallback(&m_cb); - smashAdapter->startRumble(0); - } - } - void deviceDisconnected(boo::DeviceToken&, boo::DeviceBase* device) - { - if (smashAdapter.get() == device) - smashAdapter.reset(nullptr); - } -}; - -struct ApplicationCallback : boo::IApplicationCallback -{ - boo::IWindow* mainWindow = NULL; - ApplicationDeviceFinder devFinder; - WindowCallback windowCallback; - void appLaunched(boo::IApplication* app) - { - mainWindow = app->newWindow("YAY!"); - mainWindow->setCallback(&windowCallback); - mainWindow->showWindow(); - devFinder.startScanning(); - } - void appQuitting(boo::IApplication*) - { - delete mainWindow; - } - void appFilesOpen(boo::IApplication*, const std::vector& paths) - { - fprintf(stderr, "OPENING: "); - for (const std::string& path : paths) - fprintf(stderr, "%s ", path.c_str()); - fprintf(stderr, "\n"); - } -}; - int main(int argc, const char* argv[]) { - Retro::TOneStatic appCB; - std::unique_ptr app = - boo::ApplicationBootstrap(boo::IApplication::PLAT_AUTO, *appCB, - "mp1", "MP1", argc, argv); Retro::TOneStatic main; + std::unique_ptr app = + boo::ApplicationBootstrap(boo::IApplication::PLAT_AUTO, *main, + "mp1", "MP1", argc, argv); return main->RsMain(argc, argv); } diff --git a/libBoo b/libBoo index d69e76d91..12e5948d3 160000 --- a/libBoo +++ b/libBoo @@ -1 +1 @@ -Subproject commit d69e76d911198e060b825000cc4e8ce9273df537 +Subproject commit 12e5948d3178df7f689d9676e103760dbb89d07d