Gainput  v1.0.0
Public Member Functions | List of all members
gainput::InputRecording Class Reference

A recorded sequence of input changes. More...

#include <GainputInputRecording.h>

Public Member Functions

 InputRecording (Allocator &allocator=GetDefaultAllocator())
 Initializes the recording in an empty state. More...
 
 InputRecording (InputManager &manager, void *data, size_t size, Allocator &allocator=GetDefaultAllocator())
 Initializes the recording from the given serialized data. More...
 
void AddChange (uint64_t time, DeviceId deviceId, DeviceButtonId buttonId, bool value)
 Appends a device button change to the recording. More...
 
void AddChange (uint64_t time, DeviceId deviceId, DeviceButtonId buttonId, float value)
 Appends a device button change to the recording. More...
 
void Clear ()
 Removes all state changes.
 
bool GetNextChange (uint64_t time, RecordedDeviceButtonChange &outChange)
 Gets the next button change before and including the given time and returns it. More...
 
void Reset ()
 Resets the playback position. More...
 
uint64_t GetDuration () const
 Returns what time frame this recording spans.
 
size_t GetSerializedSize () const
 Returns the size required to serialize this recording.
 
void GetSerialized (InputManager &manager, void *data) const
 Serializes this recording to the given buffer. More...
 

Detailed Description

A recorded sequence of input changes.

The recording can be recorded to, played, or serialized/deserialized.

In order for input recording to be available, Gainput must have been built with GAINPUT_ENABLE_RECORDER defined.

See also
InputPlayer
InputRecorder
Examples:
/samples/recording/recordingsample.cpp.

Constructor & Destructor Documentation

◆ InputRecording() [1/2]

gainput::InputRecording::InputRecording ( Allocator allocator = GetDefaultAllocator())

Initializes the recording in an empty state.

Parameters
allocatorThe allocator to be used for all memory allocations.

◆ InputRecording() [2/2]

gainput::InputRecording::InputRecording ( InputManager manager,
void *  data,
size_t  size,
Allocator allocator = GetDefaultAllocator() 
)

Initializes the recording from the given serialized data.

The recording is reconstructed from a previously serialized recording obtained through GetSerialized().

Parameters
managerUsed to resolve device and button references in the recording.
dataThe serialized recording as obtained from GetSerialized().
sizeThe length of the serialized recording as obtained from GetSerializedSize().
allocatorThe allocator to be used for all memory allocations.

Member Function Documentation

◆ AddChange() [1/2]

void gainput::InputRecording::AddChange ( uint64_t  time,
DeviceId  deviceId,
DeviceButtonId  buttonId,
bool  value 
)

Appends a device button change to the recording.

The changes must be added in chronological order, i.e. time must always greater or equal to the time AddChange() was last called with.

Parameters
timeThe time elapsed before the change occurred.
deviceIdThe ID of the device owning the button that changed.
buttonIdThe ID of the button that changed.
valueThe new value of the button.

◆ AddChange() [2/2]

void gainput::InputRecording::AddChange ( uint64_t  time,
DeviceId  deviceId,
DeviceButtonId  buttonId,
float  value 
)

Appends a device button change to the recording.

The changes must be added in chronological order, i.e. time must always greater or equal to the time AddChange() was last called with.

Parameters
timeThe time elapsed before the change occurred.
deviceIdThe ID of the device owning the button that changed.
buttonIdThe ID of the button that changed.
valueThe new value of the button.

◆ GetNextChange()

bool gainput::InputRecording::GetNextChange ( uint64_t  time,
RecordedDeviceButtonChange outChange 
)

Gets the next button change before and including the given time and returns it.

Parameters
timeThe time up to which to return changes.
[out]outChangeThe change properties will be written to this if this function returns true.
Returns
true if a change matching the given time was found, false otherwise.

◆ GetSerialized()

void gainput::InputRecording::GetSerialized ( InputManager manager,
void *  data 
) const

Serializes this recording to the given buffer.

This function serializes this recording so that it can be saved and read back in and deserialized later.

Parameters
managerUsed to resolve device and button references in the recording.
dataA buffer of (at least) a size as returned by GetSerializedSize().
Examples:
/samples/recording/recordingsample.cpp.

◆ Reset()

void gainput::InputRecording::Reset ( )
inline

Resets the playback position.

After calling this function, GetNextChange() will return changes from the beginning of the recorded sequence of changes again.


The documentation for this class was generated from the following file: