Files
Plugin/Source/SenseGloveCoreImpl/Private/SGCoreImpl/SGHapticGloveHandProfilesImpl.cpp
T

130 lines
4.9 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/SGHapticGloveHandProfilesImpl.h"
#include "Containers/StringConv.h"
#include "SGBuildHacks/SGInclude_Core_HandProfile.h"
#include "SGBuildHacks/SGInclude_Core_HapticGloveHandProfiles.h"
#include "SGBuildHacks/SGInclude_Core_SensorRange.h"
#include "SGCoreImpl/SGHandProfileImpl.h"
#include "SGCoreImpl/SGHapticGloveImpl.h"
#include "SGCoreImpl/SGSenseGloveImpl.h"
#include "SGCoreImpl/SGSensorRangeImpl.h"
const FString& FSGHapticGloveHandProfilesImpl::GetProfileDirectory()
{
static const FString Directory(UTF8_TO_TCHAR(FHapticGloveHandProfilesType::GetProfileDirectory().c_str()));
return Directory;
}
void FSGHapticGloveHandProfilesImpl::SetProfileDirectory(const FString& Directory)
{
std::string DirectoryString(TCHAR_TO_UTF8(*Directory));
FHapticGloveHandProfilesType::SetProfileDirectory(MoveTemp(DirectoryString));
}
void FSGHapticGloveHandProfilesImpl::GetLeftHandProfile(FSGHandProfileImpl& OutHandProfileImpl)
{
FSGHandProfileImpl::FHandProfileType HandProfile;
FHapticGloveHandProfilesType::GetRightHandProfile(HandProfile);
OutHandProfileImpl = FSGHandProfileImpl(MoveTemp(HandProfile));
}
void FSGHapticGloveHandProfilesImpl::SetLeftHandProfile(const FSGHandProfileImpl& HandProfileImpl)
{
FHapticGloveHandProfilesType::SetLeftHandProfile(HandProfileImpl.ToHandProfile());
}
void FSGHapticGloveHandProfilesImpl::GetRightHandProfile(FSGHandProfileImpl& OutHandProfileImpl)
{
FSGHandProfileImpl::FHandProfileType HandProfile;
FHapticGloveHandProfilesType::GetRightHandProfile(HandProfile);
OutHandProfileImpl = FSGHandProfileImpl(MoveTemp(HandProfile));
}
void FSGHapticGloveHandProfilesImpl::SetRightHandProfile(const FSGHandProfileImpl& HandProfileImpl)
{
FHapticGloveHandProfilesType::SetRightHandProfile(HandProfileImpl.ToHandProfile());
}
void FSGHapticGloveHandProfilesImpl::GetProfile(const bool bRightHanded, FSGHandProfileImpl& OutHandProfileImpl)
{
FSGHandProfileImpl::FHandProfileType HandProfile;
FHapticGloveHandProfilesType::GetProfile(bRightHanded, HandProfile);
OutHandProfileImpl = FSGHandProfileImpl(MoveTemp(HandProfile));
}
void FSGHapticGloveHandProfilesImpl::SetProfile(const FSGHandProfileImpl& HandProfileImpl)
{
FHapticGloveHandProfilesType::SetProfile(HandProfileImpl.ToHandProfile());
}
void FSGHapticGloveHandProfilesImpl::SetProfile(const FSGHandProfileImpl& HandProfileImpl, const bool bRightHanded)
{
FHapticGloveHandProfilesType::SetProfile(HandProfileImpl.ToHandProfile(), bRightHanded);
}
void FSGHapticGloveHandProfilesImpl::RestoreDefaults()
{
FHapticGloveHandProfilesType::RestoreDefaults();
}
void FSGHapticGloveHandProfilesImpl::RestoreDefaults(const bool bRightHanded)
{
FHapticGloveHandProfilesType::RestoreDefaults(bRightHanded);
}
void FSGHapticGloveHandProfilesImpl::TryLoadingFromDisk()
{
FHapticGloveHandProfilesType::TryLoadingFromDisk();
}
bool FSGHapticGloveHandProfilesImpl::SaveLastRange(const FSGSensorRangeImpl& CurrentRange,
const TSharedRef<FSGHapticGloveImpl> ForGlove)
{
return FHapticGloveHandProfilesType::SaveLastRange(CurrentRange.ToSensorRange(),
ForGlove->ToHapticGlovePtrChecked());
}
bool FSGHapticGloveHandProfilesImpl::LoadLastRange(const TSharedRef<FSGHapticGloveImpl> ForGlove,
FSGSensorRangeImpl& OutLastRange)
{
FSGSensorRangeImpl::FSensorRangeType LastRange;
const bool bResult = FHapticGloveHandProfilesType::LoadLastRange(ForGlove->ToHapticGlovePtrChecked(), LastRange);
OutLastRange = FSGSensorRangeImpl{LastRange};
return bResult;
}