/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @section LICENSE * * Copyright (c) 2020 - 2026 SenseGlove * * @section DESCRIPTION * * Contains information on Haptic channels available to this device for IPC. * Some devices have different "Haptic Channels". This info is exposed via IPC to * SGCore. */ #pragma once #include #include #include #include #include namespace SGConnect { /// Different types of Haptic Channels - with different behaviours enum class EHapticChannelType : uint8_t { /// This type of haptic channel can be constantly overridden. SGConnect will only send a command if /// a change occurs. Ideal for Force-Feedback. StreamingChannel, /// These commands must be sent once, after thire queue is cleared. FireAndForgetChannel }; /// Contains information on Haptic channels available to this device for IPC. class SGCONNECT_API HapticResponse; }// namespace SGCore /// Contains information on Haptic channels available to this device for IPC. class SGCONNECT_API SGConnect::HapticResponse { public: /// Byte used to identify streaming channels static uint8_t GetStreamingType(); /// byte used to indicate fire-and-forget channels. static uint8_t GetFireNForgetType(); public: /// Parse a raw HapticResponse, as received from a possible SGDevice, into useful data. static HapticResponse Parse(std::string& out_rawCommand); /// Parse a series of characters into a collections of 'enumerators' (uint8_t). /// /// static std::vector ParseChannels(const std::string& section); //--------------------------------------------------------------------------------- // C++ Constructor Voodoo private: struct Impl; std::unique_ptr Pimpl; public: //--------------------------------------------------------------------------------- // Actual C++ Constructors /// Create a new instance of an invalid IdResponse HapticResponse(); /// Create a new instance of a processed IdResponse HapticResponse(const std::vector& sChannels, const std::vector& hChannels); public: /** * The copy constructor. */ HapticResponse(const HapticResponse& rhs); /** * The move constructor. */ HapticResponse(HapticResponse&& rhs) noexcept; public: virtual ~HapticResponse(); public: /** * The copy assignment operator. */ HapticResponse& operator=(const HapticResponse& rhs); /** * The move assignment operator. */ HapticResponse& operator=(HapticResponse&& rhs) noexcept; public: //--------------------------------------------------------------------------------- // Accessors //--------------------------------------------------------------------------------- // Class Methods /// Generates new Device Addresses for this haptic data /// void RegenerateAddresses(int32_t deviceIndex); int32_t GetHapticChannelCount() const; /// Returns true if we need to clear the channel /// /// bool ClearsChannel(int32_t index) const; /// Returns the device address wihtin the block(s). /// /// bool GetBlockAddress(int32_t index, std::string& out_address) const; /// Returns the device address wihtin the block(s) - without checking if this Index is valid. /// /// std::string& GetBlockAddress_Unguarded(int32_t index) const; /// Returns the channel byte type - without checking if this Index is valid /// /// uint8_t GetChannelType_Unguarded(int32_t index) const; /// Store the last sent haptics in the appropriate channel. /// /// void SetLastHaptics_Unguarded(int32_t channel, const std::string& lastHaptics); /// Retrieve the last haptic command send through a channel. Returns true if length > 0. /// /// /// /// void GetLastHaptics_Unguarded(int32_t channel, std::string& out_lastHaptics, int32_t& out_sentAmount) const; /// Set the amount of times a message was sent to the channel /// /// void SetSentAmount_Unguarded(int32_t channel, int32_t sentAmount); /// Increment the SentAmount of a specific channel, after sending the command to the device. /// void IncrementSentAmount_Unguarded(int32_t channel); /// Returns a string representing a series of characters for SGCore to detect the haptic channel /// implementation. /// const std::string& ReportChannels() const; };