Gainput  v1.0.0
GainputInputRecording.h
1 
2 #ifndef GAINPUTINPUTRECORDING_H_
3 #define GAINPUTINPUTRECORDING_H_
4 
5 #ifdef GAINPUT_ENABLE_RECORDER
6 
7 namespace gainput
8 {
9 
11 struct GAINPUT_LIBEXPORT RecordedDeviceButtonChange
12 {
14  uint64_t time;
19 
20  union
21  {
23  bool b;
25  float f;
26  };
27 };
28 
30 
39 class GAINPUT_LIBEXPORT InputRecording
40 {
41 public:
43 
48 
57  InputRecording(InputManager& manager, void* data, size_t size, Allocator& allocator = GetDefaultAllocator());
58 
60 
69  void AddChange(uint64_t time, DeviceId deviceId, DeviceButtonId buttonId, bool value);
71 
80  void AddChange(uint64_t time, DeviceId deviceId, DeviceButtonId buttonId, float value);
81 
83  void Clear();
84 
86 
91  bool GetNextChange(uint64_t time, RecordedDeviceButtonChange& outChange);
93 
97  void Reset() { position_ = 0; }
98 
100  uint64_t GetDuration() const;
101 
103  size_t GetSerializedSize() const;
105 
111  void GetSerialized(InputManager& manager, void* data) const;
112 
113 private:
115 
117  unsigned position_;
118 };
119 
120 }
121 
122 #endif
123 
124 #endif
125 
A recorded sequence of input changes.
Definition: GainputInputRecording.h:39
A std::vector-like data container for POD-types.
Definition: GainputContainers.h:96
Manages all input devices and some other helpful stuff.
Definition: GainputInputManager.h:24
DeviceButtonId buttonId
The ID of the button that changed.
Definition: GainputInputRecording.h:18
GAINPUT_LIBEXPORT DefaultAllocator & GetDefaultAllocator()
Returns the default instance of the default allocator.
uint64_t time
The time at which the change occurred.
Definition: GainputInputRecording.h:14
A single recorded change for a device button.
Definition: GainputInputRecording.h:11
float f
If the button's type is BT_FLOAT, this contains the new value.
Definition: GainputInputRecording.h:25
unsigned int DeviceId
ID of an input device.
Definition: gainput.h:107
DeviceId deviceId
The ID of the device owning the button that changed.
Definition: GainputInputRecording.h:16
void Reset()
Resets the playback position.
Definition: GainputInputRecording.h:97
bool b
If the button's type is BT_BOOL, this contains the new value.
Definition: GainputInputRecording.h:23
unsigned int DeviceButtonId
ID of a specific button unique to an input device.
Definition: gainput.h:109
Interface used to pass custom allocators to the library.
Definition: GainputAllocator.h:16
Contains all Gainput related classes, types, and functions.
Definition: gainput.h:103