222 lines
8.5 KiB
C++
222 lines
8.5 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2024 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/SGHandLayer.h"
|
|
|
|
#include "SGCore/SGCustomWaveform.h"
|
|
#include "SGCore/SGHandPose.h"
|
|
#include "SGCore/SGHapticGlove.h"
|
|
#include "SGCoreImpl/SGExportedFunctions.h"
|
|
#include "SGInterop/SGIC_ESGDeviceType.h"
|
|
#include "SGInterop/SGIC_ESGHapticGloveCalibrationState.h"
|
|
#include "SGInterop/SGIC_ESGHapticLocation.h"
|
|
#include "SGInterop/SGIC_ESGPositionalTrackingHardware.h"
|
|
#include "SGInterop/SGIC_FQuat.h"
|
|
#include "SGInterop/SGIC_FSGCustomWaveformImpl.h"
|
|
#include "SGInterop/SGIC_FSGHandPoseImpl.h"
|
|
#include "SGInterop/SGIC_FString.h"
|
|
#include "SGInterop/SGIC_FVector.h"
|
|
#include "SGInterop/SGIC_TArray_float.h"
|
|
#include "SGInterop/SGIC_TSharedPtr_FSGHapticGloveImpl.h"
|
|
|
|
bool FSGHandLayer::DeviceConnected(const bool bRightHanded)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_DeviceConnected(bRightHanded);
|
|
}
|
|
|
|
ESGDeviceType FSGHandLayer::GetDeviceType(const bool bRightHanded)
|
|
{
|
|
FSGIC_ESGDeviceType DeviceTypeContainer;
|
|
SGCoreImpl_FSGHandLayerImpl_GetDeviceType(&DeviceTypeContainer, bRightHanded);
|
|
return DeviceTypeContainer.Type;
|
|
}
|
|
|
|
bool FSGHandLayer::GetFirstGloveHandedness()
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_GetFirstGloveHandedness();
|
|
}
|
|
|
|
int32 FSGHandLayer::GlovesConnected()
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_GlovesConnected();
|
|
}
|
|
|
|
bool FSGHandLayer::GetGloveInstance(UObject* Outer, const bool bRightHanded, USGHapticGlove*& OutGlove)
|
|
{
|
|
FSGIC_TSharedPtr_FSGHapticGloveImpl OutGloveContainer;
|
|
const bool bResult = SGCoreImpl_FSGHandLayerImpl_GetGloveInstance(bRightHanded, &OutGloveContainer);
|
|
OutGlove = USGHapticGlove::NewHapticGlove(Outer, OutGloveContainer.Ptr.ToSharedRef());
|
|
return bResult;
|
|
}
|
|
|
|
ESGHapticGloveCalibrationState FSGHandLayer::GetCalibrationState(const bool bRightHanded)
|
|
{
|
|
FSGIC_ESGHapticGloveCalibrationState HapticGloveCalibrationStateContainer;
|
|
SGCoreImpl_FSGHandLayerImpl_GetDeviceType(&HapticGloveCalibrationStateContainer, bRightHanded);
|
|
return HapticGloveCalibrationStateContainer.State;
|
|
}
|
|
|
|
FString FSGHandLayer::GetCalibrationInstructions(const bool bRightHanded)
|
|
{
|
|
FSGIC_FString CalibrationInstructionsContainer;
|
|
SGCoreImpl_FSGHandLayerImpl_GetCalibrationInstructions(&CalibrationInstructionsContainer, bRightHanded);
|
|
return MoveTemp(CalibrationInstructionsContainer.String);
|
|
}
|
|
|
|
void FSGHandLayer::ResetCalibration(const bool bRightHanded)
|
|
{
|
|
SGCoreImpl_FSGHandLayerImpl_ResetCalibration(bRightHanded);
|
|
}
|
|
|
|
void FSGHandLayer::EndCalibration(const bool bRightHanded)
|
|
{
|
|
SGCoreImpl_FSGHandLayerImpl_EndCalibration(bRightHanded);
|
|
}
|
|
|
|
bool FSGHandLayer::GetHandPose(UObject* Outer, const bool bRightHanded, USGHandPose*& OutHandPose)
|
|
{
|
|
FSGIC_FSGHandPoseImpl OutHandPoseContainer;
|
|
const bool bResult = SGCoreImpl_FSGHandLayerImpl_GetHandPose(bRightHanded, &OutHandPoseContainer);
|
|
OutHandPose = USGHandPose::NewHandPose(Outer, OutHandPose->ToHandPoseImpl());
|
|
return bResult;
|
|
}
|
|
|
|
void FSGHandLayer::GetWristLocation(
|
|
const bool bRightHanded, const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
|
const ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FQuat& OutWristRotation)
|
|
{
|
|
FSGIC_FVector ReferencePositionContainer{ReferencePosition};
|
|
FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation};
|
|
FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware};
|
|
FSGIC_FVector OutWristPositionContainer;
|
|
FSGIC_FQuat OutWristRotationContainer;
|
|
|
|
SGCoreImpl_FSGHandLayerImpl_GetWristLocation(
|
|
bRightHanded, &ReferencePositionContainer, &ReferenceRotationContainer,
|
|
&TrackingHardwareContainer,
|
|
&OutWristPositionContainer, &OutWristRotationContainer);
|
|
|
|
OutWristPosition = MoveTemp(OutWristPositionContainer.Vector);
|
|
OutWristRotation = MoveTemp(OutWristRotationContainer.Quat);
|
|
}
|
|
|
|
void FSGHandLayer::StopAllHaptics(const bool bRightHanded)
|
|
{
|
|
SGCoreImpl_FSGHandLayerImpl_StopAllHaptics(bRightHanded);
|
|
}
|
|
|
|
bool FSGHandLayer::SendHaptics(const bool bRightHanded)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_SendHaptics(bRightHanded);
|
|
}
|
|
|
|
bool FSGHandLayer::SupportsCustomWaveform(
|
|
const bool bRightHanded, const ESGHapticLocation AtLocation)
|
|
{
|
|
FSGIC_ESGHapticLocation AtLocationContainer{AtLocation};
|
|
return SGCoreImpl_FSGHandLayerImpl_SupportsCustomWaveform(bRightHanded, &AtLocationContainer);
|
|
}
|
|
|
|
bool FSGHandLayer::SendCustomWaveform(
|
|
const bool bRightHanded, USGCustomWaveform* OutWaveform, const ESGHapticLocation Location)
|
|
{
|
|
FSGIC_FSGCustomWaveformImpl OutWaveformContainer{OutWaveform->ToCustomWaveformImpl()};
|
|
FSGIC_ESGHapticLocation LocationContainer{Location};
|
|
return SGCoreImpl_FSGHandLayerImpl_SendCustomWaveform(bRightHanded, &OutWaveformContainer, &LocationContainer);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_ForceFeedbackLevel(
|
|
const bool bRightHanded, const int32 Finger, const float Level01, const bool bSendImmediate)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_ForceFeedbackLevel(bRightHanded, Finger, Level01, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_ForceFeedbackLevels(
|
|
const bool bRightHanded, const TArray<float>& Levels01, const bool bSendImmediate)
|
|
{
|
|
FSGIC_TArray_float Levels01Container{Levels01};
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_ForceFeedbackLevels(
|
|
bRightHanded, &Levels01Container, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_VibroLevels(
|
|
const bool bRightHanded, const TArray<float>& Levels01, const bool bSendImmediate)
|
|
{
|
|
FSGIC_TArray_float Levels01Container{Levels01};
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_VibroLevels(bRightHanded, &Levels01Container, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_VibroLevel(
|
|
const bool bRightHanded, const int32 Finger, const float Level01, const bool bSendImmediate)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_VibroLevel_bRightHanded_Finger_Level0_bSendImmediate(
|
|
bRightHanded, Finger, Level01, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_VibroLevel(
|
|
const bool bRightHanded, const ESGHapticLocation AtLocation, const float Level01, const bool bSendImmediate)
|
|
{
|
|
FSGIC_ESGHapticLocation AtLocationContainer{AtLocation};
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_VibroLevel_bRightHanded_AtLocation_Level01_bSendImmediate(
|
|
bRightHanded, &AtLocationContainer, Level01, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::SupportsWristSqueeze(const bool bRightHanded)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_SupportsWristSqueeze(bRightHanded);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_WristSqueeze(
|
|
const bool bRightHanded, const float SqueezeLevel01, const bool bSendImmediate)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_WristSqueeze(bRightHanded, SqueezeLevel01, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::SupportsFlexionLocks(const bool bRightHanded)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_SupportsFlexionLocks(bRightHanded);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_FlexionLock(
|
|
const bool bRightHanded, const int32 Finger, const float Flexion01, const bool bSendImmediate)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_FlexionLock(bRightHanded, Finger, Flexion01, bSendImmediate);
|
|
}
|
|
|
|
bool FSGHandLayer::QueueCommand_ClearFlexionLock(
|
|
const bool bRightHanded, const int32 Finger, const bool bSendImmediate)
|
|
{
|
|
return SGCoreImpl_FSGHandLayerImpl_QueueCommand_ClearFlexionLock(bRightHanded, Finger, bSendImmediate);
|
|
} |