Skip to content

Commit

Permalink
ButtonComboAPI: Move button combo API into it's own namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Jan 1, 2025
1 parent 67b8431 commit 7b31373
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 274 deletions.
55 changes: 28 additions & 27 deletions include/wups/button_combo/WUPSButtonCombo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,55 @@

#include "defines.h"

#include <coreinit/debug.h>
#include <optional>

class WUPSButtonCombo {
public:
static std::optional<WUPSButtonCombo> Create(const WUPSButtonCombo_ComboOptions &options,
namespace WUPSButtonComboAPI {
class ButtonCombo {
public:
static std::optional<ButtonCombo> Create(const WUPSButtonCombo_ComboOptions &options,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

static WUPSButtonCombo Create(const WUPSButtonCombo_ComboOptions &options,
static ButtonCombo Create(const WUPSButtonCombo_ComboOptions &options,
WUPSButtonCombo_ComboStatus &outStatus);

~WUPSButtonCombo();
WUPSButtonCombo(const WUPSButtonCombo &) = delete;
~ButtonCombo();
ButtonCombo(const ButtonCombo &) = delete;

WUPSButtonCombo(WUPSButtonCombo &&other) noexcept;
ButtonCombo(ButtonCombo &&other) noexcept;

WUPSButtonCombo &operator=(const WUPSButtonCombo &) = delete;
ButtonCombo &operator=(const ButtonCombo &) = delete;

WUPSButtonCombo &operator=(WUPSButtonCombo &&other) noexcept;
ButtonCombo &operator=(ButtonCombo &&other) noexcept;

[[nodiscard]] WUPSButtonCombo_ComboHandle getHandle() const;
[[nodiscard]] WUPSButtonCombo_ComboHandle getHandle() const;

WUPSButtonCombo_Error GetButtonComboStatus(WUPSButtonCombo_ComboStatus &outStatus) const;
WUPSButtonCombo_Error GetButtonComboStatus(WUPSButtonCombo_ComboStatus &outStatus) const;

[[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboMeta(const WUPSButtonCombo_MetaOptions &metaOptions) const;
[[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboMeta(const WUPSButtonCombo_MetaOptions &metaOptions) const;

[[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboCallback(const WUPSButtonCombo_CallbackOptions &callbackOptions) const;
[[nodiscard]] WUPSButtonCombo_Error UpdateButtonComboCallback(const WUPSButtonCombo_CallbackOptions &callbackOptions) const;

[[nodiscard]] WUPSButtonCombo_Error UpdateControllerMask(WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_ComboStatus &outStatus) const;
[[nodiscard]] WUPSButtonCombo_Error UpdateControllerMask(WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_ComboStatus &outStatus) const;

[[nodiscard]] WUPSButtonCombo_Error UpdateButtonCombo(WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboStatus &outStatus) const;
[[nodiscard]] WUPSButtonCombo_Error UpdateButtonCombo(WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboStatus &outStatus) const;

[[nodiscard]] WUPSButtonCombo_Error UpdateHoldDuration(uint32_t holdDurationInFrames) const;
[[nodiscard]] WUPSButtonCombo_Error UpdateHoldDuration(uint32_t holdDurationInFrames) const;

[[nodiscard]] WUPSButtonCombo_Error GetButtonComboMeta(WUPSButtonCombo_MetaOptionsOut &outOptions) const;
[[nodiscard]] WUPSButtonCombo_Error GetButtonComboMeta(WUPSButtonCombo_MetaOptionsOut &outOptions) const;

WUPSButtonCombo_Error GetButtonComboCallback(WUPSButtonCombo_CallbackOptions &outOptions) const;
WUPSButtonCombo_Error GetButtonComboCallback(WUPSButtonCombo_CallbackOptions &outOptions) const;

WUPSButtonCombo_Error GetButtonComboInfoEx(WUPSButtonCombo_ButtonComboInfoEx &outOptions) const;
WUPSButtonCombo_Error GetButtonComboInfoEx(WUPSButtonCombo_ButtonComboInfoEx &outOptions) const;

private:
void ReleaseButtonComboHandle();
private:
void ReleaseButtonComboHandle();

explicit WUPSButtonCombo(WUPSButtonCombo_ComboHandle handle);
explicit ButtonCombo(WUPSButtonCombo_ComboHandle handle);

WUPSButtonCombo_ComboHandle mHandle = WUPSButtonCombo_ComboHandle(nullptr);
};
WUPSButtonCombo_ComboHandle mHandle = WUPSButtonCombo_ComboHandle(nullptr);
};
} // namespace WUPSButtonComboAPI
#endif
188 changes: 95 additions & 93 deletions include/wups/button_combo/api.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#pragma once
#include "WUPSButtonCombo.h"

#include <optional>
#include "defines.h"

#include <stdint.h>
#include <string_view>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -156,103 +155,106 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_DetectButtonCombo_Blocking(const WUPSBu
#endif

#ifdef __cplusplus
namespace WUPSButtonComboAPI {

#include "WUPSButtonCombo.h"
#include <optional>
#include <string_view>

namespace WUPSButtonComboAPI {
std::string_view GetStatusStr(WUPSButtonCombo_Error status);

std::optional<WUPSButtonCombo> CreateComboPressDownEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<WUPSButtonCombo> CreateComboPressDown(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<WUPSButtonCombo> CreateComboPressDownObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<WUPSButtonCombo> CreateComboHoldEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<WUPSButtonCombo> CreateComboHold(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<WUPSButtonCombo> CreateComboHoldObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;


WUPSButtonCombo CreateComboPressDownEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus);

WUPSButtonCombo CreateComboPressDown(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);

WUPSButtonCombo CreateComboPressDownObserver(std::string_view label,
std::optional<ButtonCombo> CreateComboPressDownEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<ButtonCombo> CreateComboPressDown(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<ButtonCombo> CreateComboPressDownObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<ButtonCombo> CreateComboHoldEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);

WUPSButtonCombo CreateComboHoldEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus);

WUPSButtonCombo CreateComboHold(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);

WUPSButtonCombo CreateComboHoldObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);
bool observer,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<ButtonCombo> CreateComboHold(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;

std::optional<ButtonCombo> CreateComboHoldObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus,
WUPSButtonCombo_Error &outError) noexcept;


ButtonCombo CreateComboPressDownEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus);

ButtonCombo CreateComboPressDown(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);

ButtonCombo CreateComboPressDownObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);

ButtonCombo CreateComboHoldEx(std::string_view label,
WUPSButtonCombo_ControllerTypes controllerMask,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
bool observer,
WUPSButtonCombo_ComboStatus &outStatus);

ButtonCombo CreateComboHold(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);

ButtonCombo CreateComboHoldObserver(std::string_view label,
WUPSButtonCombo_Buttons combo,
uint32_t holdDurationInMs,
WUPSButtonCombo_ComboCallback callback,
void *context,
WUPSButtonCombo_ComboStatus &outStatus);
WUPSButtonCombo_Error CheckComboAvailable(const WUPSButtonCombo_ButtonComboOptions &options,
WUPSButtonCombo_ComboStatus &outStatus);

Expand Down
Loading

0 comments on commit 7b31373

Please sign in to comment.