GamepadCodec Arduino Lib 1.0.1
Loading...
Searching...
No Matches
gamepad_codec_encoder.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "gamepad_codec_data_type.h"
#include "gamepad_input_tracker.h"
#include "robust_frame.h"

Go to the source code of this file.

Functions

ByteBuffer gamepad::codec::Encode (const gamepad::input::State &state) noexcept
 Encode a gamepad::input::State into a RobustFrame.
 
void gamepad::codec::Encode (const gamepad::input::State &state, Stream &stream) noexcept
 Encode a gamepad::input::State into a robust frame and send directly to a Stream.
 

Macro Definition Documentation

◆ _GAMEPAD_CODEC_ENCODER_H_

#define _GAMEPAD_CODEC_ENCODER_H_

Definition at line 4 of file gamepad_codec_encoder.h.

Function Documentation

◆ Encode() [1/2]

ByteBuffer gamepad::codec::Encode ( const gamepad::input::State & state)
noexcept

Encode a gamepad::input::State into a RobustFrame.

Parameters
[in]stateThe input state to encode.
Returns
ByteBuffer containing the encoded frame. The buffer is automatically sized to accommodate the maximum possible frame length.
Note
Use this function when you need to send the frame later or via custom transport. For direct sending via Stream, use the Stream overload.

Definition at line 10 of file gamepad_codec_encoder.cpp.

◆ Encode() [2/2]

void gamepad::codec::Encode ( const gamepad::input::State & state,
Stream & stream )
noexcept

Encode a gamepad::input::State into a robust frame and send directly to a Stream.

Parameters
[in]stateThe input state to encode.
[in]streamThe output stream, to write the frame to.
Note
This function is suitable for scenarios where frames are sent directly via Stream without requiring an intermediate buffer

Definition at line 18 of file gamepad_codec_encoder.cpp.