38 lines
1.8 KiB
C++
38 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <basalt/pipe_operator.hpp>
|
|
#include <cstdint>
|
|
|
|
namespace Basalt::Presenter {
|
|
|
|
class CommandClient {
|
|
public:
|
|
// Protocol codes
|
|
static constexpr std::uint8_t HANDSHAKE_CODE_REQUEST = 0x61; // Trainer -> Presenter
|
|
static constexpr std::uint8_t HANDSHAKE_CODE_RESPONSE = 0x62; // Presenter -> Trainer
|
|
static constexpr std::uint8_t DATA_READY_CODE = 0x01; // Presenter -> Trainer
|
|
static constexpr std::uint8_t DATA_RECEIVED_CODE = 0x02; // Trainer -> Presenter
|
|
static constexpr std::uint8_t ACTIVELY_STOP_CODE = 0x71; // Both directions
|
|
static constexpr std::uint8_t STOP_CODE = 0x71; // Both directions (same code)
|
|
|
|
// Pixel kind values
|
|
static constexpr std::uint8_t PIXEL_GRAY_FLOAT32 = 0x01; // Grayscale represented by one float32
|
|
static constexpr std::uint8_t PIXEL_GRAY_U8 = 0x02; // Grayscale represented by one u8
|
|
static constexpr std::uint8_t PIXEL_RGB_FLOAT32 = 0x03; // RGB represented by three float32
|
|
static constexpr std::uint8_t PIXEL_RGB_U8 = 0x04; // RGB represented by three u8
|
|
|
|
CommandClient(const std::basic_string_view<BSCHAR> pipe_name = BSTEXT("ed0e3f1f-d214-4880-9562-640bce15e72e"));
|
|
~CommandClient();
|
|
|
|
// Wait for handshake from Trainer, send response with data properties
|
|
void WaitHandshake(std::uint8_t pixel_kind, std::uint32_t width, std::uint32_t height);
|
|
|
|
// Tick function called every frame to send data ready and wait for response
|
|
bool Tick(bool actively_stop = false);
|
|
|
|
private:
|
|
Basalt::Shared::PipeOperator m_PipeOperator;
|
|
bool m_Handshaked = false; // Track handshake state
|
|
};
|
|
|
|
} // namespace Basalt::Presenter
|