Gainput  v1.0.0
GainputInputState.h
1 
2 #ifndef GAINPUTINPUTSTATE_H_
3 #define GAINPUTINPUTSTATE_H_
4 
5 namespace gainput
6 {
7 
9 class GAINPUT_LIBEXPORT InputState
10 {
11 public:
13 
17  InputState(Allocator& allocator, unsigned int buttonCount);
19  ~InputState();
20 
22 
27  unsigned GetButtonCount() const { return buttonCount_; }
28 
30  bool GetBool(DeviceButtonId buttonId) const { return buttons_[buttonId].b; }
32  void Set(DeviceButtonId buttonId, bool value) { buttons_[buttonId].b = value; }
34  float GetFloat(DeviceButtonId buttonId) const { return buttons_[buttonId].f; }
36  void Set(DeviceButtonId buttonId, float value) { buttons_[buttonId].f = value; }
37 
39  InputState& operator=(const InputState& other);
40 
41 private:
42  Allocator& allocator_;
43  unsigned int buttonCount_;
44 
45  struct Button
46  {
47  union
48  {
49  bool b;
50  float f;
51  };
52  };
53 
54  Button* buttons_;
55 };
56 
57 }
58 
59 #endif
60 
float GetFloat(DeviceButtonId buttonId) const
Returns the float state of the given device button.
Definition: GainputInputState.h:34
void Set(DeviceButtonId buttonId, bool value)
Sets the bool state of the given device button.
Definition: GainputInputState.h:32
void Set(DeviceButtonId buttonId, float value)
Sets the float state of the given device button.
Definition: GainputInputState.h:36
unsigned GetButtonCount() const
Returns the number of buttons in this state.
Definition: GainputInputState.h:27
bool GetBool(DeviceButtonId buttonId) const
Returns the bool state of the given device button.
Definition: GainputInputState.h:30
unsigned int DeviceButtonId
ID of a specific button unique to an input device.
Definition: gainput.h:109
State of an input device.
Definition: GainputInputState.h:9
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