Files
Plugin/Source/SenseGloveCore/Public/SGCore/SGHandLayer.h
T

255 lines
7.7 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
*
* A way to access all sorts of Hand Tracking and -Haptics without needing to
* cache any device instances.
* Use this layer if you don't care where a HandPose is coming from, and are
* fine with calling generic haptic functions.
*/
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "HAL/Platform.h"
#include "Math/Quat.h"
#include "Math/Vector.h"
#include "UObject/ObjectMacros.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGHandLayer.generated.h"
class USGCustomWaveform;
class USGHandPose;
class USGHapticGlove;
/**
* A way to access all sorts of Hand Tracking and -Haptics without needing to cache any device instances.
*/
USTRUCT()
struct SENSEGLOVECORE_API FSGHandLayer
{
GENERATED_BODY()
public:
/**
* Returns true if there is a HapticGlove Device connected that corresponds to the chosen hand.
*
* @param bRightHanded
*/
static bool DeviceConnected(bool bRightHanded);
/**
* Returns the Device Type of the right / left hand.
*
* @param bRightHanded
*/
static ESGDeviceType GetDeviceType(bool bRightHanded);
/**
* Returns the handedness of the first device you can find; true for right, false for left. Use this for testing a
* single glove.
*/
static bool GetFirstGloveHandedness();
/**
* Returns the number of Haptic Gloves connected to the system.
*/
static int32 GlovesConnected();
/**
* Retrieve a Glove Instance for the right- or left hand to do more complicated, device-specific stuff.
*
* @param bRightHanded
* @param OutGlove
*/
static bool GetGloveInstance(UObject* Outer, bool bRightHanded, USGHapticGlove*& OutGlove);
/**
* Returns the calibration state of the chosen hand.
*
* @param bRightHanded
*/
static ESGHapticGloveCalibrationState GetCalibrationState(bool bRightHanded);
/**
* Returns the Calibration Instructions for the chosen hand.
*
* @param bRightHanded
*/
static FString GetCalibrationInstructions(bool bRightHanded);
/**
* Reset the calibration of the left/right hand.
*
* @param bRightHanded
*/
static void ResetCalibration(bool bRightHanded);
/**
* Reset the calibration of the left/right hand.
*
* @param bRightHanded
*/
static void EndCalibration(bool bRightHanded);
/**
* Attempt to get the HandPose through any of our gloves. You don't care which one is on the other side, as long as
* you get one.
*
* @param bRightHanded
* @param OutHandPose
*/
static bool GetHandPose(UObject* Outer, bool bRightHanded, USGHandPose*& OutHandPose);
/**
* Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware.
*
* @param bRightHanded
* @param ReferencePosition
* @param ReferenceRotation
* @param TrackingHardware
* @param OutWristPosition
* @param OutWristRotation
*/
static void GetWristLocation(
bool bRightHanded,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation);
/**
* Sends all haptics in the queue for the Left / Right hand.
* @param bRightHanded
*/
static bool SendHaptics(bool bRightHanded);
/**
* Stop all haptics on the chosen hand.
*
* @param bRightHanded
*/
static void StopAllHaptics(bool bRightHanded);
/**
* Tell a specific hand to hold the force-feedback at a certain level.
*
* @param bRightHanded
* @param Finger
* @param Level01
* @param bSendImmediate
*/
static bool QueueCommand_ForceFeedbackLevel(bool bRightHanded, int32 Finger, float Level01, bool bSendImmediate);
/**
* Queue Force Feedback for multiple fingers. Up to 5. Make sure the value is not NULL.
*
* @param bRightHanded
* @param Levels01
* @param bSendImmediate
*/
static bool QueueCommand_ForceFeedbackLevels(
bool bRightHanded, const TArray<float>& Levels01, bool bSendImmediate);
/**
* Queue a command to set the vibration level(s) of a Haptic Glove's finger. Note: This is only for Nova 1.0 and
* DK1.0.
*
* @param bRightHanded
* @param Finger
* @param Level01
* @param bSendImmediate
*/
static bool QueueCommand_SetVibroLevel(bool bRightHanded, int32 Finger, float Level01, bool bSendImmediate);
/**
* Queue a command to set the vibration level(s) of a Haptic Glove's finger. Note: This is only for Nova 1.0 and
* DK1.0.
*
* @param bRightHanded
* @param Levels01
* @param bSendImmediate
*/
static bool QueueCommand_SetVibroLevels(bool bRightHanded, const TArray<float>& Levels01, bool bSendImmediate);
/**
* Returns true if the glove for this hand supports a custom waveform vibration on said location.
*
* @param bRightHanded
* @param AtLocation
*/
static bool SupportsCustomWaveform(bool bRightHanded, ESGHapticLocation AtLocation);
/**
* Send a Custom Waveform to a glove at a specific location.
*
* @param bRightHanded
* @param OutWaveform
* @param Location
*/
static bool SendCustomWaveform(bool bRightHanded, USGCustomWaveform*& OutWaveform, ESGHapticLocation Location);
/**
* Returns true if the chosen glove supports active contact feedback on the Wrist.
*
* @param bRightHanded
*/
static bool SupportsWristSqueeze(bool bRightHanded);
/**
* Queue a command to set a squeeze level on the wrist, and optionally send it right away.
*
* @param bRightHanded
* @param SqueezeLevel01
* @param bSendImmediate
*/
static bool QueueCommand_WristSqueeze(bool bRightHanded, float SqueezeLevel01, bool bSendImmediate);
/**
* Returns true is the chosen hand supports flexion locking; automatic locking of FFB when flexed beyond a specific
* point.
*
* @param bRightHanded
*/
static bool SupportsFlexionLocks(bool bRightHanded);
/**
* If the flexion exceeds a particular value, turn on the Force-Feedback.
*/
static bool QueueCommand_FlexionLock(bool bRightHanded, int32 Finger, float Flexion01, bool bSendImmediate);
/**
* Stop any Flexion Threshold active on the chosen finger.
*/
static bool QueueCommand_ClearFlexionLock(bool bRightHanded, int32 Finger, bool bSendImmediate);
};