#pragma once #ifdef __cplusplus #include #include "UltraController.h" #define DEFINE_HOOK(name, type) struct name { typedef std::function fn; } namespace ModInternal { template struct RegisteredHooks { inline static std::vector functions; }; template void RegisterHook(typename H::fn h) { RegisteredHooks::functions.push_back(h); } template void ExecuteHooks(Args&&... args) { for (auto& fn : RegisteredHooks::functions) { fn(std::forward(args)...); } } DEFINE_HOOK(ControllerRead, void(OSContPad* cont_pad)); DEFINE_HOOK(AudioInit, void()); DEFINE_HOOK(LoadTexture, void(const char* path, uint8_t** texture)); DEFINE_HOOK(GfxInit, void()); } #endif #ifdef __cplusplus extern "C" { #endif void ModInternal_ExecuteAudioInitHooks(); #ifdef __cplusplus } #endif