221 lines
6.0 KiB
C++
221 lines
6.0 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
|
|
*
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "Containers/UnrealString.h"
|
|
#include "Templates/SharedPointer.h"
|
|
#include "Templates/UniquePtr.h"
|
|
|
|
#include "SGBuildHacks/SGPlatform.h"
|
|
#include "SGTypes/SGCoreTypes.h"
|
|
|
|
namespace SGCore
|
|
{
|
|
class SGDevice;
|
|
}
|
|
|
|
class FSGBetaDeviceImpl;
|
|
class FSGHapticChannelInfoImpl;
|
|
class FSGHapticGloveImpl;
|
|
class FSGNova2GloveImpl;
|
|
class FSGNovaGloveImpl;
|
|
class FSGSenseGloveImpl;
|
|
|
|
class SENSEGLOVECOREIMPL_API FSGDeviceImpl : public TSharedFromThis<FSGDeviceImpl>
|
|
{
|
|
public:
|
|
typedef SGCore::SGDevice FSGDeviceType;
|
|
|
|
typedef std::shared_ptr<FSGDeviceType> FSGDevicePtrType;
|
|
typedef std::vector<FSGDevicePtrType> FSGDevicePtrVectorType;
|
|
|
|
public:
|
|
static void ParseFirmware(const FString& RawFirmware, int32& OutMainVersion, int32& OutSubVersion);
|
|
|
|
static bool FirmwareNewerThan(int32 MyFirmwareMain, int32 MyFirmwareSub,
|
|
int32 ReferenceMain, int32 ReferenceSub,
|
|
bool bInclusive);
|
|
static bool FirmwareOlderThan(int32 MyFirmwareMain, int32 MyFirmwareSub,
|
|
int32 ReferenceMain, int32 ReferenceSub,
|
|
bool bInclusive);
|
|
|
|
static FString ToString(ESGDeviceType DeviceType);
|
|
|
|
private:
|
|
struct FImpl;
|
|
|
|
struct FImplDeleter
|
|
{
|
|
void operator()(const FImpl* P) const;
|
|
};
|
|
|
|
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
public:
|
|
FSGDeviceImpl();
|
|
|
|
public:
|
|
/**
|
|
* The cast from underlying pointer type constructor.
|
|
*/
|
|
explicit FSGDeviceImpl(const FSGDevicePtrType SGDevice);
|
|
|
|
public:
|
|
/**
|
|
* The copy constructor.
|
|
*/
|
|
FSGDeviceImpl(const FSGDeviceImpl& Rhs);
|
|
|
|
/**
|
|
* The move constructor.
|
|
*/
|
|
FSGDeviceImpl(FSGDeviceImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The destructor.
|
|
*/
|
|
virtual ~FSGDeviceImpl();
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
FSGDeviceImpl& operator=(const FSGDeviceImpl& Rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
FSGDeviceImpl& operator=(FSGDeviceImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The cast to underlying pointer type method.
|
|
*/
|
|
FSGDevicePtrType ToSGDevicePtr() const;
|
|
|
|
/**
|
|
* The checked cast to underlying pointer type method.
|
|
*/
|
|
FSGDevicePtrType ToSGDevicePtrChecked() const;
|
|
|
|
public:
|
|
/**
|
|
* The cast to base TSharedRef<FSGDeviceImpl> type method.
|
|
*/
|
|
TSharedRef<FSGDeviceImpl> ToSGDeviceImplRef();
|
|
|
|
/**
|
|
* The cast to derived TSharedRef<FSGBetaDeviceImpl> type method.
|
|
*/
|
|
TSharedRef<FSGBetaDeviceImpl> ToBetaDeviceImplRef();
|
|
|
|
/**
|
|
* The cast to derived TSharedRef<FSGHapticGloveImpl> type method.
|
|
*/
|
|
TSharedRef<FSGHapticGloveImpl> ToHapticGloveImplRef();
|
|
|
|
/**
|
|
* The cast to derived TSharedRef<FSGNova2GloveImpl> type method.
|
|
*/
|
|
TSharedRef<FSGNova2GloveImpl> ToNova2GloveImplRef();
|
|
|
|
/**
|
|
* The cast to derived TSharedRef<FSGNovaGloveImpl> type method.
|
|
*/
|
|
TSharedRef<FSGNovaGloveImpl> ToNovaGloveImplRef();
|
|
|
|
/**
|
|
* The cast to derived TSharedRef<FSGSenseGloveImpl> type method.
|
|
*/
|
|
TSharedRef<FSGSenseGloveImpl> ToSenseGloveImplRef();
|
|
|
|
public:
|
|
bool IsABetaDevice() const;
|
|
bool IsAHapticGlove() const;
|
|
bool IsANova2Glove() const;
|
|
bool IsANovaGlove() const;
|
|
bool IsASenseGlove() const;
|
|
|
|
public:
|
|
TSharedPtr<FSGBetaDeviceImpl> AsBetaDevice() const;
|
|
TSharedPtr<FSGHapticGloveImpl> AsHapticGlove() const;
|
|
TSharedPtr<FSGNova2GloveImpl> AsNova2Glove() const;
|
|
TSharedPtr<FSGNovaGloveImpl> AsNovaGlove() const;
|
|
TSharedPtr<FSGSenseGloveImpl> AsSenseGlove() const;
|
|
|
|
public:
|
|
virtual ESGDeviceType GetDeviceType() const;
|
|
|
|
virtual FString GetDeviceId() const;
|
|
|
|
virtual FString GetHardwareVersion() const;
|
|
virtual int32 GetFirmwareVersion() const;
|
|
virtual int32 GetSubFirmwareVersion() const;
|
|
virtual FString GetFirmwareString() const;
|
|
|
|
bool FirmwareNewerThan(int32 FirmwareMain, int32 FirmwareSub, bool bInclusive) const;
|
|
bool FirmwareOlderThan(int32 FirmwareMain, int32 FirmwareSub, bool bInclusive) const;
|
|
|
|
FString GetAddress() const;
|
|
|
|
bool IsConnected() const;
|
|
ESGConnectionType GetConnectionType() const;
|
|
|
|
int32 PacketsPerSecondReceived() const;
|
|
int32 PacketsPerSecondSent() const;
|
|
|
|
int32 GetDeviceIndex() const;
|
|
virtual void SetDeviceIndex(int32 NewIndex);
|
|
|
|
virtual bool IsWireless() const;
|
|
|
|
virtual bool HasBattery() const;
|
|
virtual bool IsCharging();
|
|
virtual bool GetBatteryLevel(float& OutLevel);
|
|
|
|
public:
|
|
virtual void SetHapticChannels(const FSGHapticChannelInfoImpl& Channels);
|
|
|
|
int32 GetHapticChannelCount() const;
|
|
int32 GetHapticChannelCount(ESGHapticChannelType ChannelType) const;
|
|
|
|
public:
|
|
virtual FString ToString() const;
|
|
}; |