Files
Plugin/Source/SenseGloveCoreKismet/Public/SGCoreKismet/SGTimedBuzzCommandKismetLibrary.h
T

154 lines
6.1 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* 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.
*
* @section DESCRIPTION
*
* Buzz Motor with timing parameters.
*/
#pragma once
#include "SGKismet/SGBlueprintFunctionLibrary.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGTimedBuzzCommandKismetLibrary.generated.h"
class USGBuzzCommand;
class USGTimedBuzzCommand;
/**
* Buzz motor commands that is meant to stop after a few milliseconds.
*
* @remarks Intended use; this.levels indicates the actual command.
*/
UCLASS(meta=(ScriptName = "SesneGloveTimedBuzzCommandKismetLibrary"))
class SENSEGLOVECOREKISMET_API USGTimedBuzzCommandKismetLibrary final : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/**
* Empty constructor for inheritance.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command",
meta=(WorldContext="WorldContextObject"))
static USGTimedBuzzCommand* MakeTimedBuzzCommand(UObject* WorldContextObject);
/**
* Create a new TimeBuzzCommand for a single finger.
*/
UFUNCTION(BlueprintPure, DisplayName="Make Timed Buzz Command",
Category="SenseGlove | Core | Haptics | Timed Buzz Command", meta=(WorldContext="WorldContextObject"))
static USGTimedBuzzCommand* MakeTimedBuzzCommand_F_M_DS_STS(
UObject* WorldContextObject,
ESGFinger Finger, int32 Magnitude, float DurationSeconds, float StartTimeSeconds = 0.0f);
/**
* Create a new buzz motor command that expires after timing_ms.
*/
UFUNCTION(BlueprintPure, DisplayName="Make Timed Buzz Command",
Category="SenseGlove | Core | Haptics | Timed Buzz Command", meta=(WorldContext="WorldContextObject"))
static USGTimedBuzzCommand* MakeTimedBuzzCommand_BC_DS_STS(
UObject* WorldContextObject,
const USGBuzzCommand* BaseCommand, float DurationSeconds, float StartTimeSeconds = 0.0f);
/**
* Copy this Buzz Command's values into a new object.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command",
meta=(WorldContext="WorldContextObject"))
static USGBuzzCommand* Copy(UObject* WorldContextObject, const USGTimedBuzzCommand* TimedBuzzCommand);
/**
* Merges this base command with another command.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command",
meta=(WorldContext="WorldContextObject"))
static USGBuzzCommand* Merge(UObject* WorldContextObject, const USGTimedBuzzCommand* A, const USGBuzzCommand* B);
/**
* Access the base command, which indicates the buzz levels to keep untill time elapses.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command",
meta=(WorldContext="WorldContextObject"))
static USGBuzzCommand* GetBaseCommand(UObject* WorldContextObject,
const USGTimedBuzzCommand* TimedBuzzCommand);
/**
*
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static int32 GetMagnitude(const USGTimedBuzzCommand* TimedBuzzCommand);
/**
* The total time [milliseconds] each buzz motor should be vibrating for.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static float GetDuration(const USGTimedBuzzCommand* TimedBuzzCommand);
/**
* The time elapsed since the command was sent [milliseconds].
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static float GetElapsedTime(const USGTimedBuzzCommand* TimedBuzzCommand);
/**
* Check if this timed command's timing has elapsed.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static bool HasTimeElapsed(const USGTimedBuzzCommand* TimedBuzzCommand);
/**
* Represents how far this effect is in its playtime; [0...1], where 0 means at the start, and 1 means at the end.
*
* @param bClamp01 Optional parameter; ensures this value is always between 0 and 1.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static float NormalizedTime(const USGTimedBuzzCommand* TimedBuzzCommand, bool bClamp01 = true);
/**
* Reset the timings of this BuzzCommand, allowing us to re-use it.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static void ResetTiming(UPARAM(ref) USGTimedBuzzCommand* TimedBuzzCommand);
/**
* Update the elapsed time to check if the buzz motors should stop.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static void UpdateTiming(UPARAM(ref) USGTimedBuzzCommand* TimedBuzzCommand, float DeltaSeconds);
/**
*
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptics | Timed Buzz Command")
static FString ToString(const USGTimedBuzzCommand* TimedBuzzCommand);
};