diff --git a/include/wups/button_combo.h b/include/wups/button_combo.h index 8c19e8d..9e4fd80 100644 --- a/include/wups/button_combo.h +++ b/include/wups/button_combo.h @@ -138,7 +138,7 @@ typedef struct WUPSButtonCombo_ButtonComboOptions { typedef struct WUPSButtonCombo_ButtonComboInfoEx { WUPSButtonCombo_ComboType type; WUPSButtonCombo_ButtonComboOptions basicCombo; - uint32_t optionalHoldForXFrames; + uint32_t optionalHoldForXMs; } WUPSButtonCombo_ButtonComboInfoEx; typedef struct WUPSButtonCombo_ComboOptions { @@ -205,11 +205,11 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboPressDownObserver(const c WUPSButtonCombo_ComboHandle *outHandle, WUPSButtonCombo_ComboStatus *outStatus); /** - * @brief Adds a button combo which triggers a callback if a certain button combination was hold for X frames on any controller. + * @brief Adds a button combo which triggers a callback if a certain button combination was hold for X ms on any controller. * - * Registers a unique button combination which will trigger a callback if the combo is held for a certain amount of frames **on any connected controller** and the button combo is valid. + * Registers a unique button combination which will trigger a callback if the combo is held for a certain amount of ms **on any connected controller** and the button combo is valid. * - * The callback is triggered if the given button combination has been held down for the given number of frames (frame rate might vary from game to game). + * The callback is triggered if the given button combination has been held down for at least X ms * * Conflict management: * The button combination is only active if this function returns WUPS_BUTTON_COMBO_ERROR_SUCCESS and outStatus is WUPS_BUTTON_COMBO_COMBO_STATUS_VALID. @@ -225,15 +225,16 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboPressDownObserver(const c * * @param label Label of this button combo * @param combo Combination which should be checked - * @param holdDurationInFrames - * @param callbackOptions Information about the callbacks that will be called if the combo is triggered + * @param holdDurationInMs + * @param callback + * @param context * @param outHandle The handle of the combo will be stored here. Must not be nullptr. * @param outStatus The status of the combo will be stored here. Only if the status is WUPS_BUTTON_COMBO_COMBO_STATUS_VALID the combo is valid. Must not be nullptr. * @return **/ WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHold(const char *label, WUPSButtonCombo_Buttons combo, - uint32_t holdDurationInFrames, + uint32_t holdDurationInMs, WUPSButtonCombo_ComboCallback callback, void *context, WUPSButtonCombo_ComboHandle *outHandle, @@ -241,7 +242,7 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHold(const char *label, WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHoldObserver(const char *label, WUPSButtonCombo_Buttons combo, - uint32_t holdDurationInFrames, + uint32_t holdDurationInMs, WUPSButtonCombo_ComboCallback callback, void *context, WUPSButtonCombo_ComboHandle *outHandle, @@ -277,7 +278,7 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_UpdateButtonCombo(WUPSButtonCombo_Combo WUPSButtonCombo_ComboStatus *outStatus); WUPSButtonCombo_Error WUPSButtonComboAPI_UpdateHoldDuration(WUPSButtonCombo_ComboHandle handle, - uint32_t holdDurationInFrames); + uint32_t holdDurationInMs); WUPSButtonCombo_Error WUPSButtonComboAPI_GetButtonComboMeta(WUPSButtonCombo_ComboHandle handle, WUPSButtonCombo_MetaOptionsOut *outOptions); diff --git a/include/wups/button_combo_internal.h b/include/wups/button_combo_internal.h index 47ed44b..e02a0e2 100644 --- a/include/wups/button_combo_internal.h +++ b/include/wups/button_combo_internal.h @@ -64,7 +64,7 @@ typedef WUPSButtonCombo_Error (*WUPSButtonCombo_UpdateButtonComboFunction)(void */ typedef WUPSButtonCombo_Error (*WUPSButtonCombo_UpdateHoldDurationFunction)(void *identifier, WUPSButtonCombo_ComboHandle handle, - uint32_t holdDurationInFrames); + uint32_t holdDurationInMs); /** * @typedef WUPSButtonCombo_GetButtonComboMetaFunction diff --git a/libraries/libwups/button_combo.cpp b/libraries/libwups/button_combo.cpp index b318e0a..4413f06 100644 --- a/libraries/libwups/button_combo.cpp +++ b/libraries/libwups/button_combo.cpp @@ -103,7 +103,7 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboPressDownObserver(const c static WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHoldEx(const char *label, const WUPSButtonCombo_Buttons combo, - const uint32_t holdDurationInFrames, + const uint32_t holdDurationInMs, const WUPSButtonCombo_ComboCallback callback, void *context, const bool observer, @@ -115,29 +115,29 @@ static WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHoldEx(const char options.buttonComboOptions.type = observer ? WUPS_BUTTON_COMBO_COMBO_TYPE_HOLD_OBSERVER : WUPS_BUTTON_COMBO_COMBO_TYPE_HOLD; options.buttonComboOptions.basicCombo.combo = combo; options.buttonComboOptions.basicCombo.controllerMask = WUPS_BUTTON_COMBO_CONTROLLER_ALL; - options.buttonComboOptions.optionalHoldForXFrames = holdDurationInFrames; + options.buttonComboOptions.optionalHoldForXMs = holdDurationInMs; return WUPSButtonComboAPI_AddButtonCombo(&options, outHandle, outStatus); } WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHold(const char *label, const WUPSButtonCombo_Buttons combo, - const uint32_t holdDurationInFrames, + const uint32_t holdDurationInMs, const WUPSButtonCombo_ComboCallback callback, void *context, WUPSButtonCombo_ComboHandle *outHandle, WUPSButtonCombo_ComboStatus *outStatus) { - return WUPSButtonComboAPI_AddButtonComboHoldEx(label, combo, holdDurationInFrames, callback, context, false, outHandle, outStatus); + return WUPSButtonComboAPI_AddButtonComboHoldEx(label, combo, holdDurationInMs, callback, context, false, outHandle, outStatus); } WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonComboHoldObserver(const char *label, const WUPSButtonCombo_Buttons combo, - const uint32_t holdDurationInFrames, + const uint32_t holdDurationInMs, const WUPSButtonCombo_ComboCallback callback, void *context, WUPSButtonCombo_ComboHandle *outHandle, WUPSButtonCombo_ComboStatus *outStatus) { - return WUPSButtonComboAPI_AddButtonComboHoldEx(label, combo, holdDurationInFrames, callback, context, true, outHandle, outStatus); + return WUPSButtonComboAPI_AddButtonComboHoldEx(label, combo, holdDurationInMs, callback, context, true, outHandle, outStatus); } WUPSButtonCombo_Error WUPSButtonComboAPI_AddButtonCombo(const WUPSButtonCombo_ComboOptions *options, @@ -233,14 +233,14 @@ WUPSButtonCombo_Error WUPSButtonComboAPI_UpdateButtonCombo(const WUPSButtonCombo } WUPSButtonCombo_Error WUPSButtonComboAPI_UpdateHoldDuration(const WUPSButtonCombo_ComboHandle handle, - const uint32_t holdDurationInFrames) { + const uint32_t holdDurationInMs) { if (__internal_functions.update_hold_duration_function_ptr == nullptr) { return WUPS_BUTTON_COMBO_ERROR_INTERNAL_NOT_INITIALIZED; } if (__internal_functions.identifier == nullptr) { return WUPS_BUTTON_COMBO_ERROR_INTERNAL_NOT_INITIALIZED; } - return __internal_functions.update_hold_duration_function_ptr(__internal_functions.identifier, handle, holdDurationInFrames); + return __internal_functions.update_hold_duration_function_ptr(__internal_functions.identifier, handle, holdDurationInMs); } WUPSButtonCombo_Error WUPSButtonComboAPI_GetButtonComboMeta(const WUPSButtonCombo_ComboHandle handle,