211 lines
6.4 KiB
C++
211 lines
6.4 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
|
|
*
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "Containers/Array.h"
|
|
#include "Math/Quat.h"
|
|
#include "Math/Vector.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
#include "Templates/SharedPointer.h"
|
|
#include "Templates/UniquePtr.h"
|
|
|
|
#include "SGCoreImpl/SGDeviceImpl.h"
|
|
#include "SGCoreImpl/SGPlatform.h"
|
|
#include "SGTypes/SGCoreTypes.h"
|
|
|
|
namespace SGCore
|
|
{
|
|
class HapticGlove;
|
|
}
|
|
|
|
class FSGBasicHandModelImpl;
|
|
class FSGBuzzCommandImpl;
|
|
class FSGForceFeedbackCommandImpl;
|
|
class FSGHandPoseImpl;
|
|
class FSGHandProfileImpl;
|
|
class FSGThumperCommandImpl;
|
|
|
|
class SENSEGLOVECOREIMPL_API FSGHapticGloveImpl : public FSGDeviceImpl
|
|
{
|
|
#if ENGINE_MAJOR_VERSION >= 5
|
|
friend class SharedPointerInternals::TIntrusiveReferenceController<FSGHapticGloveImpl, ESPMode::ThreadSafe>;
|
|
#else
|
|
friend class SharedPointerInternals::TIntrusiveReferenceController<FSGHapticGloveImpl>;
|
|
#endif /* ENGINE_MAJOR_VERSION >= 5 */
|
|
|
|
public:
|
|
typedef SGCore::HapticGlove FHapticGloveType;
|
|
|
|
public:
|
|
typedef std::shared_ptr<FHapticGloveType> FHapticGlovePtrType;
|
|
typedef std::vector<FHapticGlovePtrType> FHapticGlovePtrVectorType;
|
|
|
|
public:
|
|
static TArray<TSharedRef<FSGHapticGloveImpl>> GetHapticGloves();
|
|
|
|
static bool GetGlove(TSharedPtr<FSGHapticGloveImpl>& OutGlove);
|
|
|
|
static bool GetGlove(bool bRightHanded, TSharedPtr<FSGHapticGloveImpl>& OutGlove);
|
|
|
|
private:
|
|
struct FImpl;
|
|
|
|
struct FImplDeleter
|
|
{
|
|
void operator()(const FImpl* P) const;
|
|
};
|
|
|
|
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
public:
|
|
FSGHapticGloveImpl();
|
|
|
|
public:
|
|
/**
|
|
* The cast from underlying pointer type constructor.
|
|
*/
|
|
explicit FSGHapticGloveImpl(const FHapticGlovePtrType HapticGlove);
|
|
|
|
public:
|
|
/**
|
|
* The copy constructor.
|
|
*/
|
|
FSGHapticGloveImpl(const FSGHapticGloveImpl& Rhs);
|
|
|
|
/**
|
|
* The move constructor.
|
|
*/
|
|
FSGHapticGloveImpl(FSGHapticGloveImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The destructor.
|
|
*/
|
|
virtual ~FSGHapticGloveImpl() override;
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
FSGHapticGloveImpl& operator=(const FSGHapticGloveImpl& Rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
FSGHapticGloveImpl& operator=(FSGHapticGloveImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The cast to underlying pointer type method.
|
|
*/
|
|
FHapticGlovePtrType ToHapticGlovePtr() const;
|
|
|
|
/**
|
|
* The checked cast to underlying pointer type method.
|
|
*/
|
|
FHapticGlovePtrType ToHapticGlovePtrChecked() const;
|
|
|
|
public:
|
|
virtual ESGDeviceType GetDeviceType() const override;
|
|
virtual FString GetDeviceId() const override;
|
|
|
|
virtual FString GetHardwareVersion() const override;
|
|
virtual int32 GetFirmwareVersion() const override;
|
|
virtual int32 GetSubFirmwareVersion() const override;
|
|
|
|
virtual bool IsRight() const;
|
|
|
|
virtual bool GetImuRotation(FQuat& OutImu);
|
|
|
|
virtual bool GetHandPose(const FSGBasicHandModelImpl& HandGeometry, const FSGHandProfileImpl& HandProfile,
|
|
FSGHandPoseImpl& OutHandPose);
|
|
|
|
virtual bool GetHandPose(const FSGHandProfileImpl& HandProfile, FSGHandPoseImpl& OutHandPose);
|
|
|
|
virtual bool GetHandPose(const FSGBasicHandModelImpl& HandGeometry, FSGHandPoseImpl& OutHandPose);
|
|
|
|
virtual bool GetHandPose(FSGHandPoseImpl& OutHandPose);
|
|
|
|
#if PLATFORM_ANDROID
|
|
virtual bool GetHandPose(float DeltaTime, FSGHandPoseImpl& OutHandPose);
|
|
#endif /* PLATFORM_ANDROID */
|
|
|
|
public:
|
|
virtual void StopHaptics();
|
|
|
|
virtual void StopVibrations();
|
|
|
|
virtual void SendHaptics(const FSGForceFeedbackCommandImpl& ForceFeedbackCommand);
|
|
|
|
virtual void SendHaptics(const FSGBuzzCommandImpl& BuzzCommand);
|
|
|
|
virtual void SendHaptics(const FSGThumperCommandImpl& ThumperCommand);
|
|
|
|
virtual void SendHaptics(const FSGForceFeedbackCommandImpl& ForceFeedbackCommand,
|
|
const FSGBuzzCommandImpl& BuzzCommand);
|
|
|
|
virtual void SendHaptics(const FSGForceFeedbackCommandImpl& ForceFeedbackCommand,
|
|
const FSGBuzzCommandImpl& BuzzCommand,
|
|
const FSGThumperCommandImpl& ThumperCommand);
|
|
|
|
public:
|
|
virtual bool GetCalibrationValues(TArray<FVector>& OutValues);
|
|
|
|
virtual void ResetCalibrationRange();
|
|
|
|
virtual void UpdateCalibrationRange();
|
|
|
|
virtual void UpdateCalibrationRange(const TArray<FVector>& CalibrationValues);
|
|
|
|
virtual void GetCalibrationRange(TArray<FVector>& OutMinValues,
|
|
TArray<FVector>& OutMaxValues);
|
|
|
|
virtual void UpdateCalibration(FSGHandProfileImpl& OutProfile);
|
|
|
|
virtual void ApplyCalibration(FSGHandProfileImpl& OutProfile) const;
|
|
|
|
public:
|
|
virtual void GetWristLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
|
ESGPositionalTrackingHardware TrackingHardware,
|
|
FVector& OutWristPosition, FQuat& OutWristRotation) const;
|
|
|
|
virtual void GetGloveLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
|
ESGPositionalTrackingHardware TrackingHardware,
|
|
FVector& OutGlovePosition, FQuat& OutGloveRotation) const;
|
|
}; |