diff --git a/include/pd/net/net.hpp b/include/pd/net/net.hpp index d157054..3b13c0f 100644 --- a/include/pd/net/net.hpp +++ b/include/pd/net/net.hpp @@ -27,9 +27,14 @@ SOFTWARE. #include namespace PD { +/** + * Download manager class + */ class DownloadManager : public SmartCtor { public: + /** Alias to contain Error Cdoe and for some Errors a Status Code */ using Error = u64; + /** Error Codes of DL Manager */ enum Error_ { Error_None, ///< Function Executed Successfully Error_Memory, ///< Memory Allocation Error @@ -42,12 +47,22 @@ class DownloadManager : public SmartCtor { Error_Invalid, ///< Invalid Json struct Error_NoWifi, ///< Console not connected to wifi }; - DownloadManager() {} - ~DownloadManager() {} + DownloadManager() = default; + ~DownloadManager() = default; + /** + * Extract the DL Manager Error code of a Error + * @param err Error + * @return Downloadmanager Error code + */ static Error_ GetErrorCode(Error err) { return (Error_)u32(err & 0xffffffff); } + /** + * Extract the DL Manager Status code of a Error + * @param err Error + * @return Status code + */ static int GetStatusCode(Error err) { Error_ c = GetErrorCode(err); if (c != Error_StatusCode && c != Error_CtrStatus && c != Error_Curl) { @@ -56,17 +71,45 @@ class DownloadManager : public SmartCtor { return u32(err >> 32); } + /** + * Download from URL inro a String Buffer + * @param url URL to download from + * @param res result buffer + * @return Error Code + */ Error Get(const std::string& url, std::string& res); + /** + * Download from URL into a File + * @param url URL to download from + * @param res_path Path to write file to + * @return Error Code + */ Error GetFile(const std::string& url, const std::string& res_path); + /** + * Download a File from a Git Release + * @param url URL of the repo + * @param asset Asset to download + * @param path Path to write file into + * @param pre download from Prerelease + * @return Error Code + */ Error GetGitRelease(const std::string& url, const std::string& asset, const std::string& path, bool pre); + /** + * Get a json API request as nlohmann json object + * @param url URL to request + * @param res result json object + * @return Error Code + */ Error GetAsJson(const std::string& url, nlohmann::json& res); + /** Get Current Progress in Bytes */ u64 ProgressCurrent() const { return current; } + /** Get Total number in bytes */ u64 ProgressTotal() const { return total; } private: - u64 current; - u64 total; + u64 current; ///< Current Progress + u64 total; ///< Total Bytes tp Download }; } // namespace PD \ No newline at end of file diff --git a/include/pd/overlays/keyboard.hpp b/include/pd/overlays/keyboard.hpp index d0569d6..c48bb2a 100644 --- a/include/pd/overlays/keyboard.hpp +++ b/include/pd/overlays/keyboard.hpp @@ -23,50 +23,71 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include #include +#include #include namespace PD { +/** + * Development Function to dump Keyboard Layout into a Json File + * @param path Path to write into + */ void DumpLayout(const std::string& path); -/// Keyboard class -/// @brief needs to be pushed with text and State reference as Overlay -/// to communicate with it -/// @note Hardcoded Rendering to get maximum Rendering Performance +/** + * Keyboard class + * + * - needs to be pushed with text and State reference as Overlay + * to communicate with it + * @note Hardcoded Rendering to get maximum Rendering Performance + */ class Keyboard : public Overlay { public: + /** Key Operations */ enum KeyOperation { - AppendSelf = 0, - Shift = 1, - Backspace = 2, - Enter = 3, - OpCancel = 4, - OpConfirm = 5, - Tab = 6, - Caps = 7, - Space = 8, - Op1 = 9, - Op2 = 10, + AppendSelf = 0, ///< Append Keyname to res string + Shift = 1, ///< Shift + Backspace = 2, ///< Backspace + Enter = 3, ///< Enter + OpCancel = 4, ///< Cancel + OpConfirm = 5, ///< Confirm + Tab = 6, ///< Tab + Caps = 7, ///< Caps + Space = 8, ///< Space + Op1 = 9, ///< Unnset Op 1 + Op2 = 10, ///< Unset Op 2 }; + /** Keyboard Type */ enum Type { - Default, - Numpad, - Password, + Default, ///< Default Keyboard + Numpad, ///< Numpad + Password, ///< Password Input }; + /** State */ enum State { - None, - Cancel, - Confirm, + None, ///< Doing nothing + Cancel, ///< Cancelled + Confirm, ///< Confirmed }; + /** Alias for Keyboard Flags */ using Flags = u32; + /** Flags */ enum Flags_ { - Flags_None = 0, - Flags_BlendTop = 1 << 0, - Flags_BlendBottom = 1 << 1, - Flags_LockControls = 1 << 2, - Flags_Transparency = 1 << 3, + Flags_None = 0, ///< Nothing + Flags_BlendTop = 1 << 0, ///< Blend Top Screen + Flags_BlendBottom = 1 << 1, ///< Blend Bottom + Flags_LockControls = 1 << 2, ///< Lock Contols (Input Driver) + Flags_Transparency = 1 << 3, ///< Transparant Keyboard Colors + // Default Flags Flags_Default = Flags_BlendBottom | Flags_BlendTop | Flags_LockControls, }; + /** + * Keyboard Constructor + * @param text Result Text + * @param state Result State + * @param hint Hint to display if result is empty + * @param type Keyboard type + * @param flags Keyboard flags to use + */ Keyboard(std::string& text, State& state, const std::string& hint = "", Type type = Default, Flags flags = Flags_Default) { too++; @@ -84,46 +105,74 @@ class Keyboard : public Overlay { flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad); chflymgr.From(vec2(-320, 0)).To(vec2(-320, 0)).In(0.1f).As(chflymgr.Linear); } + /** Deconstructor */ ~Keyboard() { too--; } + /** + * Rendering and Input Handler + * @param delta Deltatime for Animations + * @param ren Renderer Reference + * @param inp Input Driver reference + */ void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override; + /** Remove Keyboard */ void Rem() { rem = true; flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad); } private: + /** Prerender Keys */ void LoadTheKeys(LI::Renderer::Ref ren); + /** Controller Movement */ void Movement(Hid::Ref inp); + /** Trigger Move from to Animation */ void MoveSelector(); + /** Execute a Key operation */ void DoOperation(KeyOperation op, const std::string& kname); + /** Recolor all Keys with the same operation */ void RecolorBy(KeyOperation op, u32 color, int cm); + /** Bind an operation */ void InputOpBind(Hid::Key k, KeyOperation op, Hid::Ref inp, int cm); + // Result Text reference std::string* text; + // Copy of the Text std::string copy; + // Hint std::string hint; + // Result State reference State* state; + // Keyboard Type Type type; + // Keyboard flags Flags flags; - int mode = 0; // def, caps, shift + // def, caps, shift + int mode = 0; // Stands for The Only One static int too; + // Tween for selector Movement Tween selector; + // Tween for Selector Size Tween sel_szs; + // Current Cell size vec2 cselszs; + // selector index int raw_sel; - // Performance Optimisation + // Prerendered Keytables LI::StaticObject::Ref keys[3]; + // Value to check if table is loadet bool keys_loadet = false; - // Some Animation + // Remove Animation bool rem = false; /// Probably a float would've done the job as well ;) Tween flymgr; + // Secode Flymanager Tween chflymgr; + // Show Help bool show_help = true; }; } // namespace PD \ No newline at end of file diff --git a/include/pd/overlays/message_mgr.hpp b/include/pd/overlays/message_mgr.hpp index dd4e4b2..59fd3d6 100644 --- a/include/pd/overlays/message_mgr.hpp +++ b/include/pd/overlays/message_mgr.hpp @@ -23,24 +23,45 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include #include #include +#include namespace PD { +/** + * Message Manager + */ class MessageMgr : public PD::SmartCtor { public: + /** + * Message Container + */ class Container : public PD::SmartCtor { public: + /** + * Message Constructor + * @param title Title + * @param msg Message + */ Container(const std::string& title, const std::string& msg); - ~Container() {} + ~Container() = default; + /** Render the Container */ void Render(PD::LI::Renderer::Ref ren); + /** + * Update Animations by slot and delta + * @param slot Slot + * @param delta Deltatime + */ void Update(int slot, float delta); + /** Trigger Fly in Animation */ void FlyIn(); + /** Trigger Change Position Animation */ void ToBeMoved(int slot); + /** Trigger Removed Animation */ void ToBeRemoved(); + /** Check if Message can be removed from list */ bool ShouldBeRemoved() const { return (tbr && pos.IsFinished()) || kill; } private: @@ -55,14 +76,24 @@ class MessageMgr : public PD::SmartCtor { bool kill = false; // Instant Kill int s = 0; // Slot }; + /** Constructor to Link a Renderer reference */ MessageMgr(PD::LI::Renderer::Ref r) { ren = r; } - ~MessageMgr() {} + ~MessageMgr() = default; + /** + * Add a New Message + * @param title Message Title + * @param text Message Text + */ void Push(const std::string& title, const std::string& text); + /** + * Update Messages + * @param delta Deltatime + */ void Update(float delta); private: - std::vector msgs; - PD::LI::Renderer::Ref ren; + std::vector msgs; // List of Messages + PD::LI::Renderer::Ref ren; // Renderer Reference }; } // namespace PD \ No newline at end of file diff --git a/include/pd/overlays/overlay.hpp b/include/pd/overlays/overlay.hpp index d54755c..488a01a 100644 --- a/include/pd/overlays/overlay.hpp +++ b/include/pd/overlays/overlay.hpp @@ -28,19 +28,30 @@ SOFTWARE. #include namespace PD { +/** + * Overlay Template class + */ class Overlay : public SmartCtor { public: - Overlay() {} - virtual ~Overlay() {} + Overlay() = default; + virtual ~Overlay() = default; + /** + * Update Function for Overlay input and rendering + * @param delta Deltatime + * @param ren Renderer reference + * @param inp Input Driver + */ virtual void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) = 0; + /** Check if killed to remove from Overlay Manager */ bool IsKilled() const { return kill; } protected: + /** Internall Kill function to call from your Overlay */ void Kill() { kill = true; } private: - bool kill = false; + bool kill = false; ///< Should be killed or not }; } // namespace PD \ No newline at end of file diff --git a/include/pd/overlays/overlay_mgr.hpp b/include/pd/overlays/overlay_mgr.hpp index 5e9c9f8..f98e07f 100644 --- a/include/pd/overlays/overlay_mgr.hpp +++ b/include/pd/overlays/overlay_mgr.hpp @@ -28,20 +28,37 @@ SOFTWARE. #include namespace PD { +/** + * Overlay Manager Class + */ class OverlayMgr : public SmartCtor { public: + /** + * Constructor + * @param ren Renderer + * @param inp Input Driver reference + */ OverlayMgr(LI::Renderer::Ref ren, Hid::Ref inp) { this->ren = ren; this->inp = inp; } + /** Deconstructor */ ~OverlayMgr() { overlays.clear(); } + /** + * Append a New Overlay + * @param overlay Overlay reference to push + */ void Push(Overlay::Ref overlay); + /** + * Update Overlays + * @paran delta Deltatime + */ void Update(float delta); private: - std::vector overlays; - LI::Renderer::Ref ren; - Hid::Ref inp; + std::vector overlays; ///< Overlay List + LI::Renderer::Ref ren; ///< Renderer reference + Hid::Ref inp; ///< Input Driver reference }; } // namespace PD \ No newline at end of file diff --git a/include/pd/overlays/performance.hpp b/include/pd/overlays/performance.hpp index 638448e..69508f7 100644 --- a/include/pd/overlays/performance.hpp +++ b/include/pd/overlays/performance.hpp @@ -27,8 +27,25 @@ SOFTWARE. #include namespace PD { +/** + * Performance Overlay + * + * - Framerate / Frametime + * - Renderer Avarage Time + * - Overlays Avarage Time + * - UserApp Average Time + * - **V**ertices and **I**ndices + * - **D**Draw Commands and Draw **C**alls + * - Text Map System Texts + * - Auto static Text Texts + */ class Performance : public Overlay { public: + /** + * Constructor + * @param skill (if set to true the Overlay self kills) + * @param screen Bottom or Top Screen + */ Performance(bool& skill, bool& screen) { too++; if (too > 1) { @@ -39,11 +56,24 @@ class Performance : public Overlay { *this->skill = false; // Make sure its false this->screen = &screen; } + /** Deconstructor */ ~Performance() { too--; } + /** + * Rendering Function + * @param delta Deltatime + * @param ren Renderer Reference + * @param inp Input Driver Reference + */ void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override; private: + /** + * Render an Info line + * @param pos Position reference (gets updated for next line) + * @param text Text to Show + * @param ren Renderer Reference + */ void Line(vec2& pos, const std::string& text, LI::Renderer::Ref ren); // Trace String Average std::string TSA(const std::string& id); diff --git a/include/pd/overlays/settings.hpp b/include/pd/overlays/settings.hpp index ad54ada..1789182 100644 --- a/include/pd/overlays/settings.hpp +++ b/include/pd/overlays/settings.hpp @@ -23,14 +23,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include #include +#include #include #include namespace PD { +/** + * Settings Menu Overlay + */ class SettingsMenu : public Overlay { public: + /** + * Constructor to setup Overlay + */ SettingsMenu() { too++; if (too > 1) { @@ -39,10 +45,15 @@ class SettingsMenu : public Overlay { } flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad); } + /** Deconstructor */ ~SettingsMenu() { too--; } + /** Rendering and Input Handler */ void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override; + /** + * Function to Trigger remove animation + */ void Rem() { rem = true; flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad); diff --git a/include/pd/sound/decoder.hpp b/include/pd/sound/decoder.hpp index fffa6e4..0f98b62 100644 --- a/include/pd/sound/decoder.hpp +++ b/include/pd/sound/decoder.hpp @@ -27,17 +27,27 @@ SOFTWARE. namespace PD { namespace Music { +/** + * Decoder Template class + */ class Decoder : public SmartCtor { public: - Decoder() {} - virtual ~Decoder() {} + Decoder() = default; + virtual ~Decoder() = default; + /** Template Init function */ virtual int Init(const std::string& path) = 0; + /** Template deinit function */ virtual void Deinit() = 0; + /** Template function to get sample rate */ virtual u32 GetSampleRate() = 0; + /** template function to get number of channels */ virtual u8 GetChannels() = 0; + /** template function to get buffer size */ virtual size_t GetBufSize() = 0; + /** template decode function */ virtual u64 Decode(u16* buf_address) = 0; + /** template function to get file sanples if exist */ virtual size_t GetFileSamples() = 0; }; } // namespace Music diff --git a/include/pd/sound/metadata.hpp b/include/pd/sound/metadata.hpp index 1d2c89b..4bf044f 100644 --- a/include/pd/sound/metadata.hpp +++ b/include/pd/sound/metadata.hpp @@ -27,25 +27,42 @@ SOFTWARE. namespace PD { namespace Music { +/** + * Music Metadata Data Holder + */ class MetaData { public: - MetaData() {} - ~MetaData() {} + MetaData() = default; + ~MetaData() = default; + /** Getter for name */ std::string Name() const { return name; } + /** Getter for album */ std::string Album() const { return album; } + /** Getter for year */ std::string Year() const { return year; } + /** Getter for Title */ std::string Title() const { return title; } + /** Getter for Artist */ std::string Artist() const { return artist; } + /** Getter for [what is this] */ std::string Mdt() const { return mdt; } + /** Gettr for file path */ std::string Path() const { return path; } + /** Setter for Name */ void Name(const std::string &v) { name = v; } + /** Setter for Album */ void Album(const std::string &v) { album = v; } + /** Settr for Year */ void Year(const std::string &v) { year = v; } + /** Settr for Title */ void Title(const std::string &v) { title = v; } + /** Settr for Artist */ void Artist(const std::string &v) { artist = v; } + /** Settr for [what is this] */ void Mdt(const std::string &v) { mdt = v; } + /** Settr for Path */ void Path(const std::string &v) { path = v; } private: diff --git a/include/pd/sound/mp3.hpp b/include/pd/sound/mp3.hpp index a3365cb..df42d68 100644 --- a/include/pd/sound/mp3.hpp +++ b/include/pd/sound/mp3.hpp @@ -29,17 +29,27 @@ SOFTWARE. namespace PD { namespace Music { + /** + * MP3 Decoder + */ class Mp3Decoder : public Decoder { public: - Mp3Decoder() {} - ~Mp3Decoder() {} + Mp3Decoder() = default; + ~Mp3Decoder() = default; + /** Init Funciton to load file and Init decoder */ int Init(const std::string& path) override; + /** Unload Decoder */ void Deinit() override; + /** Get Sample Rate */ u32 GetSampleRate() override; + /** Get Channels */ u8 GetChannels() override; + /** Get Buffer Size */ size_t GetBufSize() override; + /** Decode next data */ u64 Decode(u16* buf_address) override; + /** Get File Samples if exist */ size_t GetFileSamples() override; private: diff --git a/include/pd/sound/player.hpp b/include/pd/sound/player.hpp index 9857b5c..e7627ac 100644 --- a/include/pd/sound/player.hpp +++ b/include/pd/sound/player.hpp @@ -29,6 +29,9 @@ SOFTWARE. namespace PD { namespace Music { +/** + * Music Player + */ class Player : public SmartCtor { public: Player() {} diff --git a/include/pd/sound/sound.hpp b/include/pd/sound/sound.hpp deleted file mode 100644 index 95fe5cf..0000000 --- a/include/pd/sound/sound.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -/* -MIT License -Copyright (c) 2024 - 2025 René Amthor (tobid7) - -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 <3ds.h> - -#include -#include - -namespace PD { -class Sound : public SmartCtor { - public: - Sound(); - ~Sound(); - - void Play(); - void Stop(); - - private: - u32 dataSize; - ndspWaveBuf wavBuf; - std::vector> dat; - int channel; -}; -} // namespace PD \ No newline at end of file