218 lines
8.8 KiB
C++
218 lines
8.8 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2023 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
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#include "SGCore/SGTimedBuzzCommand.h"
|
|
|
|
#include "SGFingerCommandImplCast.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
|
|
#include "SGCore/SGBuzzCommand.h"
|
|
#include "SGCoreImpl/SGExportedFunctions.h"
|
|
#include "SGInterop/SGIC_ESGFinger.h"
|
|
#include "SGInterop/SGIC_FSGBuzzCommandImpl.h"
|
|
#include "SGInterop/SGIC_FSGFingerCommandImpl.h"
|
|
#include "SGInterop/SGIC_FSGTimedBuzzCommandImpl.h"
|
|
#include "SGInterop/SGIC_FString.h"
|
|
#include "SGInterop/SGIC_TSharedPtr_FSGTimedBuzzCommandImpl.h"
|
|
|
|
USGTimedBuzzCommand* USGTimedBuzzCommand::NewTimedBuzzCommand(
|
|
UObject* Outer, const FSGTimedBuzzCommandImpl& TimedBuzzCommandImpl)
|
|
{
|
|
USGTimedBuzzCommand* Instance = NewObject<USGTimedBuzzCommand>(Outer);
|
|
Instance->SetFingerCommandImpl(TimedBuzzCommandImpl);
|
|
return Instance;
|
|
}
|
|
|
|
USGTimedBuzzCommand* USGTimedBuzzCommand::NewTimedBuzzCommand(
|
|
UObject* Outer, TSharedRef<FSGTimedBuzzCommandImpl> TimedBuzzCommandImpl)
|
|
{
|
|
USGTimedBuzzCommand* Instance = NewObject<USGTimedBuzzCommand>(Outer);
|
|
Instance->SetFingerCommandImpl(MoveTemp(TimedBuzzCommandImpl));
|
|
return Instance;
|
|
}
|
|
|
|
USGTimedBuzzCommand* USGTimedBuzzCommand::NewTimedBuzzCommand(UObject* Outer)
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer;
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ctor(&OutSharedPtrContainer);
|
|
|
|
return NewTimedBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
|
|
}
|
|
|
|
USGTimedBuzzCommand* USGTimedBuzzCommand::NewTimedBuzzCommand(
|
|
UObject* Outer,
|
|
const ESGFinger Finger, const int32 Magnitude, const float DurationSeconds, const float StartTimeSeconds)
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer;
|
|
FSGIC_ESGFinger FingerContainer{Finger};
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_Finger_Magnitude_DurationSeconds_StartTimeSeconds_MakeShared(
|
|
&OutSharedPtrContainer, &FingerContainer, Magnitude, DurationSeconds, StartTimeSeconds);
|
|
|
|
return NewTimedBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
|
|
}
|
|
|
|
USGTimedBuzzCommand* USGTimedBuzzCommand::NewTimedBuzzCommand(
|
|
UObject* Outer,
|
|
const USGBuzzCommand* BaseCommand, const float DurationSeconds, const float StartTimeSeconds)
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer;
|
|
FSGIC_FSGBuzzCommandImpl BaseCommandContainer{BaseCommand->ToBuzzCommandImpl().Get()};
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_BaseCommand_DurationSeconds_StartTimeSeconds_MakeShared(
|
|
&OutSharedPtrContainer, &BaseCommandContainer, DurationSeconds, StartTimeSeconds);
|
|
|
|
return NewTimedBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
|
|
}
|
|
|
|
USGTimedBuzzCommand::USGTimedBuzzCommand()
|
|
: USGBuzzCommand()
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutTimedBuzzCommandImplContainer;
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_MakeShared(&OutTimedBuzzCommandImplContainer);
|
|
|
|
SetFingerCommandImpl(OutTimedBuzzCommandImplContainer.Ptr.ToSharedRef());
|
|
}
|
|
|
|
USGTimedBuzzCommand::USGTimedBuzzCommand(const ESGFinger Finger, const int32 Magnitude,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
: USGBuzzCommand()
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer;
|
|
FSGIC_ESGFinger FingerContainer{Finger};
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_Finger_Magnitude_DurationSeconds_StartTimeSeconds_MakeShared(
|
|
&OutSharedPtrContainer, &FingerContainer, Magnitude, DurationSeconds, StartTimeSeconds);
|
|
|
|
SetFingerCommandImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
|
|
}
|
|
|
|
USGTimedBuzzCommand::USGTimedBuzzCommand(const USGBuzzCommand* BaseCommand,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
: USGBuzzCommand()
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer;
|
|
FSGIC_FSGBuzzCommandImpl BaseCommandContainer{BaseCommand->ToBuzzCommandImpl().Get()};
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_BaseCommand_DurationSeconds_StartTimeSeconds_MakeShared(
|
|
&OutSharedPtrContainer, &BaseCommandContainer, DurationSeconds, StartTimeSeconds);
|
|
|
|
SetFingerCommandImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
|
|
}
|
|
|
|
USGTimedBuzzCommand::USGTimedBuzzCommand(const FSGTimedBuzzCommandImpl& TimedBuzzCommandImpl)
|
|
: USGBuzzCommand(TimedBuzzCommandImpl)
|
|
{
|
|
}
|
|
|
|
USGTimedBuzzCommand::USGTimedBuzzCommand(TSharedRef<FSGTimedBuzzCommandImpl> TimedBuzzCommandImpl)
|
|
: USGBuzzCommand(MoveTemp(TimedBuzzCommandImpl))
|
|
{
|
|
}
|
|
|
|
USGTimedBuzzCommand::~USGTimedBuzzCommand() = default;
|
|
|
|
TSharedRef<FSGTimedBuzzCommandImpl> USGTimedBuzzCommand::ToTimedBuzzCommandImpl() const
|
|
{
|
|
return FSGFingerCommandImplCast::ToTimedBuzzCommandImpl(ToFingerCommandImpl());
|
|
}
|
|
|
|
USGBuzzCommand* USGTimedBuzzCommand::Copy(UObject* Outer) const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
FSGIC_FSGBuzzCommandImpl OutBuzzCommandImplContainer;
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_Copy(&InstanceContainer, &OutBuzzCommandImplContainer);
|
|
|
|
return NewBuzzCommand(Outer, MoveTemp(OutBuzzCommandImplContainer.BuzzCommandImpl));
|
|
}
|
|
|
|
USGBuzzCommand* USGTimedBuzzCommand::Merge(UObject* Outer, const USGBuzzCommand* BuzzCommand) const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
FSGIC_FSGBuzzCommandImpl BuzzCommandImplContainer{BuzzCommand->ToBuzzCommandImpl().Get()};
|
|
FSGIC_FSGBuzzCommandImpl OutBuzzCommandImplContainer;
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_Merge(&InstanceContainer, &OutBuzzCommandImplContainer,
|
|
&BuzzCommandImplContainer);
|
|
|
|
return NewBuzzCommand(Outer, MoveTemp(OutBuzzCommandImplContainer.BuzzCommandImpl));
|
|
}
|
|
|
|
USGBuzzCommand* USGTimedBuzzCommand::GetBaseCommand(UObject* Outer) const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
FSGIC_FSGBuzzCommandImpl OutCommandContainer;
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_GetBaseCommand(&InstanceContainer, &OutCommandContainer);
|
|
return NewBuzzCommand(Outer, MoveTemp(OutCommandContainer.BuzzCommandImpl));
|
|
}
|
|
|
|
float USGTimedBuzzCommand::GetDuration() const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
return SGCoreImpl_FSGTimedBuzzCommandImpl_GetDuration(&InstanceContainer);
|
|
}
|
|
|
|
float USGTimedBuzzCommand::GetElapsedTime() const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
return SGCoreImpl_FSGTimedBuzzCommandImpl_GetElapsedTime(&InstanceContainer);
|
|
}
|
|
|
|
bool USGTimedBuzzCommand::HasTimeElapsed() const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
return SGCoreImpl_FSGTimedBuzzCommandImpl_HasTimeElapsed(&InstanceContainer);
|
|
}
|
|
|
|
float USGTimedBuzzCommand::NormalizedTime(const bool bClamp01) const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
return SGCoreImpl_FSGTimedBuzzCommandImpl_NormalizedTime(&InstanceContainer, bClamp01);
|
|
}
|
|
|
|
void USGTimedBuzzCommand::ResetTiming()
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ResetTiming(&InstanceContainer);
|
|
}
|
|
|
|
void USGTimedBuzzCommand::UpdateTiming(const float DeltaSeconds)
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_UpdateTiming(&InstanceContainer, DeltaSeconds);
|
|
}
|
|
|
|
FString USGTimedBuzzCommand::ToString() const
|
|
{
|
|
FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl InstanceContainer{ToTimedBuzzCommandImpl()};
|
|
FSGIC_FString OutStringContainer;
|
|
SGCoreImpl_FSGTimedBuzzCommandImpl_ToString(&InstanceContainer, &OutStringContainer);
|
|
return MoveTemp(OutStringContainer.String);
|
|
} |