diff --git a/include/wups/button_combo/WUPSButtonCombo.h b/include/wups/button_combo/WUPSButtonCombo.h index a50b805..76c4595 100644 --- a/include/wups/button_combo/WUPSButtonCombo.h +++ b/include/wups/button_combo/WUPSButtonCombo.h @@ -5,10 +5,14 @@ #include "defines.h" #include +#include namespace WUPSButtonComboAPI { class ButtonCombo { public: + struct MetaOptions { + std::string label; + }; static std::optional Create(const WUPSButtonCombo_ComboOptions &options, WUPSButtonCombo_ComboStatus &outStatus, WUPSButtonCombo_Error &outError) noexcept; @@ -29,7 +33,7 @@ namespace WUPSButtonComboAPI { WUPSButtonCombo_Error GetButtonComboStatus(WUPSButtonCombo_ComboStatus &outStatus) const; - [[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboMeta(const WUPSButtonCombo_MetaOptions &metaOptions) const; + [[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboMeta(const MetaOptions &metaOptions) const; [[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboCallback(const WUPSButtonCombo_CallbackOptions &callbackOptions) const; @@ -41,7 +45,7 @@ namespace WUPSButtonComboAPI { [[nodiscard]] WUPSButtonCombo_Error UpdateHoldDuration(uint32_t holdDurationInFrames) const; - [[nodiscard]] WUPSButtonCombo_Error GetButtonComboMeta(WUPSButtonCombo_MetaOptionsOut &outOptions) const; + [[nodiscard]] WUPSButtonCombo_Error GetButtonComboMeta(MetaOptions &outOptions) const; WUPSButtonCombo_Error GetButtonComboCallback(WUPSButtonCombo_CallbackOptions &outOptions) const; diff --git a/libraries/libwups/WUPSButtonCombo.cpp b/libraries/libwups/WUPSButtonCombo.cpp index bf40ac1..3b8c83b 100644 --- a/libraries/libwups/WUPSButtonCombo.cpp +++ b/libraries/libwups/WUPSButtonCombo.cpp @@ -1,9 +1,12 @@ #include "wups/button_combo/WUPSButtonCombo.h" -#include -#include #include +#include + +#include +#include + namespace WUPSButtonComboAPI { std::optional ButtonCombo::Create(const WUPSButtonCombo_ComboOptions &options, WUPSButtonCombo_ComboStatus &outStatus, @@ -65,8 +68,9 @@ namespace WUPSButtonComboAPI { return WUPSButtonComboAPI_GetButtonComboStatus(mHandle, &outStatus); } - [[nodiscard]] WUPSButtonCombo_Error ButtonCombo::UpdateButtonComboMeta(const WUPSButtonCombo_MetaOptions &metaOptions) const { - return WUPSButtonComboAPI_UpdateButtonComboMeta(mHandle, &metaOptions); + [[nodiscard]] WUPSButtonCombo_Error ButtonCombo::UpdateButtonComboMeta(const MetaOptions &metaOptions) const { + const WUPSButtonCombo_MetaOptions options = {.label = metaOptions.label.c_str()}; + return WUPSButtonComboAPI_UpdateButtonComboMeta(mHandle, &options); } [[nodiscard]] WUPSButtonCombo_Error ButtonCombo::UpdateButtonComboCallback(const WUPSButtonCombo_CallbackOptions &callbackOptions) const { @@ -87,8 +91,15 @@ namespace WUPSButtonComboAPI { return WUPSButtonComboAPI_UpdateHoldDuration(mHandle, holdDurationInFrames); } - [[nodiscard]] WUPSButtonCombo_Error ButtonCombo::GetButtonComboMeta(WUPSButtonCombo_MetaOptionsOut &outOptions) const { - return WUPSButtonComboAPI_GetButtonComboMeta(mHandle, &outOptions); + [[nodiscard]] WUPSButtonCombo_Error ButtonCombo::GetButtonComboMeta(MetaOptions &outOptions) const { + outOptions.label.resize(512); + memset(outOptions.label.data(), 0, outOptions.label.size()); + WUPSButtonCombo_MetaOptionsOut options; + options.labelBuffer = outOptions.label.data(); + options.labelBufferLength = outOptions.label.size(); + const auto res = WUPSButtonComboAPI_GetButtonComboMeta(mHandle, &options); + outOptions.label.resize(outOptions.label.find_first_of('\0')); + return res; } WUPSButtonCombo_Error ButtonCombo::GetButtonComboCallback(WUPSButtonCombo_CallbackOptions &outOptions) const {