210 lines
7.6 KiB
C++
210 lines
7.6 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
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#include "SGCoreImpl/SGBuzzCommandImpl.h"
|
|
|
|
#include "SGCoreImpl/SGCoreEnumCast.h"
|
|
#include "SGBuildHacks/SGInclude_Core_BuzzCommand.h"
|
|
#include "SGUtils/SGArrayUtils.h"
|
|
|
|
struct FSGBuzzCommandImpl::FImpl
|
|
{
|
|
/************************
|
|
* Member variables
|
|
************************/
|
|
|
|
|
|
/************************
|
|
* Owner object
|
|
************************/
|
|
|
|
FSGBuzzCommandImpl* Owner;
|
|
|
|
/************************
|
|
* Constructor / Destructor
|
|
************************/
|
|
|
|
explicit FImpl(FSGBuzzCommandImpl* InOwner);
|
|
~FImpl();
|
|
|
|
/************************
|
|
* Default copy constructor & copy assignment operator
|
|
************************/
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
};
|
|
|
|
const FSGBuzzCommandImpl& FSGBuzzCommandImpl::Off()
|
|
{
|
|
static const FSGBuzzCommandImpl Command(FBuzzCommandType::Off());
|
|
return Command;
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl()
|
|
: FSGFingerCommandImpl(MakeShared<FBuzzCommandType>()),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(const TArray<int32>& BuzzLevels)
|
|
: FSGFingerCommandImpl(MakeShared<FBuzzCommandType>(FSGArrayUtils::ToStdVector<int32>(BuzzLevels))),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(const int32 Thumb, const int32 Index, const int32 Middle, const int32 Ring,
|
|
const int32 Pinky)
|
|
: FSGFingerCommandImpl(MakeShared<FBuzzCommandType>(Thumb, Index, Middle, Ring, Pinky)),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(const ESGFinger Finger, const int32 BuzzLevel)
|
|
: FSGFingerCommandImpl(MakeShared<FBuzzCommandType>(FSGCoreEnumCast::ToEFinger(Finger), BuzzLevel)),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(const FBuzzCommandType& BuzzCommand)
|
|
: FSGFingerCommandImpl(MakeShared<FBuzzCommandType>(BuzzCommand)),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(const TSharedRef<FBuzzCommandType> BuzzCommand)
|
|
: FSGFingerCommandImpl(BuzzCommand),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(const FSGBuzzCommandImpl& Rhs)
|
|
: FSGFingerCommandImpl(Rhs),
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{*Rhs.Pimpl}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{*Rhs.Pimpl}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
Pimpl->Owner = this;
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FSGBuzzCommandImpl(FSGBuzzCommandImpl&& Rhs)
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
noexcept
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
= default;
|
|
|
|
FSGBuzzCommandImpl::~FSGBuzzCommandImpl() = default;
|
|
|
|
FSGBuzzCommandImpl& FSGBuzzCommandImpl::operator=(const FSGBuzzCommandImpl& Rhs)
|
|
{
|
|
FSGFingerCommandImpl::operator=(Rhs);
|
|
*Pimpl = *Rhs.Pimpl;
|
|
Pimpl->Owner = this;
|
|
return *this;
|
|
}
|
|
|
|
FSGBuzzCommandImpl& FSGBuzzCommandImpl::operator=(FSGBuzzCommandImpl&& Rhs)
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
noexcept
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
= default;
|
|
|
|
const FSGBuzzCommandImpl::FBuzzCommandType& FSGBuzzCommandImpl::ToBuzzCommand() const
|
|
{
|
|
return *StaticCastSharedRef<FBuzzCommandType>(ToFingerCommandRef());
|
|
}
|
|
|
|
TSharedRef<FSGBuzzCommandImpl::FBuzzCommandType> FSGBuzzCommandImpl::ToBuzzCommandRef() const
|
|
{
|
|
return StaticCastSharedRef<FBuzzCommandType>(ToFingerCommandRef());
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FBuzzCommandType& FSGBuzzCommandImpl::ToBuzzCommand()
|
|
{
|
|
return *StaticCastSharedRef<FBuzzCommandType>(ToFingerCommandRef());
|
|
}
|
|
|
|
TSharedRef<FSGBuzzCommandImpl::FBuzzCommandType> FSGBuzzCommandImpl::ToBuzzCommandRef()
|
|
{
|
|
return StaticCastSharedRef<FBuzzCommandType>(ToFingerCommandRef());
|
|
}
|
|
|
|
FSGBuzzCommandImpl FSGBuzzCommandImpl::Copy() const
|
|
{
|
|
return FSGBuzzCommandImpl(ToBuzzCommandRef()->Copy());
|
|
}
|
|
|
|
FSGBuzzCommandImpl FSGBuzzCommandImpl::Merge(const FSGBuzzCommandImpl& Command) const
|
|
{
|
|
return FSGBuzzCommandImpl(ToBuzzCommandRef()->Merge(Command.ToBuzzCommand()));
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FImpl::FImpl(FSGBuzzCommandImpl* InOwner)
|
|
: Owner(InOwner)
|
|
{
|
|
}
|
|
|
|
FSGBuzzCommandImpl::FImpl::~FImpl() = default;
|
|
|
|
void FSGBuzzCommandImpl::FImplDeleter::operator()(const FSGBuzzCommandImpl::FImpl* P) const
|
|
{
|
|
delete P;
|
|
} |