Files
Plugin/Source/SenseGloveCoreImpl/Private/SGCoreImpl/SGSenseGloveVarsImpl.cpp
T
2023-02-03 13:43:40 +01:00

139 lines
6.1 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 "SGCoreImpl/SGSenseGloveVarsImpl.h"
#include <string>
#include "Containers/StringConv.h"
#include "SGBuildHacks/SGInclude_Core_Quat.h"
#include "SGBuildHacks/SGInclude_Core_SenseGloveVars.h"
#include "SGBuildHacks/SGInclude_Core_Vect3D.h"
#include "SGCoreImpl/SGQuatImpl.h"
#include "SGCoreImpl/SGSenseGloveInfoImpl.h"
#include "SGCoreImpl/SGVect3DImpl.h"
#include "SGUtils/SGArrayUtils.h"
FString FSGSenseGloveVarsImpl::GetStandardConstantsString(const FString& HardwareVersion, const float FirmwareVersion,
const bool bRightHanded)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
const FString String(UTF8_TO_TCHAR(FSenseGloveVarsType::GetStandardConstantsString(MoveTemp(HardwareVersionString),
FirmwareVersion, bRightHanded).c_str()));
return String;
}
FString FSGSenseGloveVarsImpl::GetSensorString(const FString& HardwareVersion, const float FirmwareVersion)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
const FString String(UTF8_TO_TCHAR(FSenseGloveVarsType::GetSensorString(MoveTemp(HardwareVersionString),
FirmwareVersion).c_str()));
return String;
}
TArray<FVector> FSGSenseGloveVarsImpl::GetStartPositions(const FString& HardwareVersion, const bool bRightHanded)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
const TArray<FVector> StartPositions{
FSGArrayUtils::FromMillimeters<FSGVect3DImpl::FVect3DType, FSGVect3DImpl>(
FSenseGloveVarsType::GetStartPositions(MoveTemp(HardwareVersionString), bRightHanded))
};
return StartPositions;
}
TArray<FQuat> FSGSenseGloveVarsImpl::GetStartRotations(const FString& HardwareVersion, const bool bRightHanded)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
const TArray<FQuat> StartRotations{
FSGArrayUtils::FromStdVector<FSGQuatImpl::FQuatType, FQuat, FSGQuatImpl, &FSGQuatImpl::ToFQuat>(
FSenseGloveVarsType::GetStartRotations(MoveTemp(HardwareVersionString), bRightHanded))
};
return StartRotations;
}
TArray<TArray<FVector>> FSGSenseGloveVarsImpl::GetGloveLengths(const FString& HardwareVersion)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
const TArray<TArray<FVector>> GloveLengths{
FSGArrayUtils::FromMillimeters<FSGVect3DImpl::FVect3DType, FSGVect3DImpl>(
FSenseGloveVarsType::GetGloveLengths(MoveTemp(HardwareVersionString)))
};
return GloveLengths;
}
int32 FSGSenseGloveVarsImpl::GetSensors(const FString& HardwareVersion)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
return FSenseGloveVarsType::GetSensors(MoveTemp(HardwareVersionString));
}
FQuat FSGSenseGloveVarsImpl::GetImuCorrection(const FString& HardwareVersion, const int32 FirmwareVersion,
const int32 SubFirmwareVersion)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
return FSGQuatImpl(FSenseGloveVarsType::GetImuCorrection(
MoveTemp(HardwareVersionString), FirmwareVersion, SubFirmwareVersion)).ToFQuat();
}
TArray<bool> FSGSenseGloveVarsImpl::GetFunctions(const FString& HardwareVersion, const int32 FirmwareVersion,
const int32 SubFirmwareVersion)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
const TArray<bool> Functions{FSGArrayUtils::FromStdVector(FSenseGloveVarsType::GetFunctions(
MoveTemp(HardwareVersionString), FirmwareVersion, SubFirmwareVersion))
};
return Functions;
}
FSGSenseGloveInfoImpl FSGSenseGloveVarsImpl::GenerateGloveModel(const FString& HardwareVersion,
const int32 FirmwareVersion,
const int32 SubFirmwareVersion, const bool bRightHanded)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
return FSGSenseGloveInfoImpl(FSenseGloveVarsType::GenerateGloveModel(
MoveTemp(HardwareVersionString), FirmwareVersion, SubFirmwareVersion, bRightHanded));
}
FSGSenseGloveInfoImpl FSGSenseGloveVarsImpl::GenerateGloveModel(const FString& HardwareVersion,
const int32 FirmwareVersion,
const int32 SubFirmwareVersion, const bool bRightHanded,
const FString& CustomId)
{
std::string HardwareVersionString(TCHAR_TO_UTF8(*HardwareVersion));
std::string CustomIdString(TCHAR_TO_UTF8(*CustomId));
return FSGSenseGloveInfoImpl(FSenseGloveVarsType::GenerateGloveModel(
MoveTemp(HardwareVersionString), FirmwareVersion, SubFirmwareVersion, bRightHanded, MoveTemp(CustomIdString)));
}