EHS
HID.h
Go to the documentation of this file.
1#pragma once
2
3#include "ehs/Array.h"
4#include "ButtonState.h"
5
6#define EHS_HID_UNKNOWN 0
7
8namespace ehs
9{
10 class EHS_LIB_IO HID
11 {
12 protected:
14 UInt_64 hashName;
16 UInt_64 id;
19 float heldTime;
21 bool active;
22
23 public:
24 HID();
25
26 HID(UInt_8 type, Str_8 name, UInt_64 id);
27
28 HID(HID&& hid) noexcept;
29
30 HID(const HID& hid);
31
32 HID& operator=(HID&& hid) noexcept;
33
34 HID& operator=(const HID& hid);
35
36 bool operator==(const HID& other) const;
37
38 bool operator!=(const HID& other) const;
39
40 bool operator==(UInt_64 otherId) const;
41
42 bool operator!=(UInt_64 otherId) const;
43
44 virtual void Poll(float delta);
45
46 UInt_8 GetType() const;
47
48 Str_8 GetName() const;
49
50 UInt_64 GetId() const;
51
52 void ReleaseAll();
53
54 Vector<const ButtonState*> GetAllTouched() const;
55
56 const ButtonState* IsTouched(const Button& button) const;
57
58 const ButtonState* IsTouched() const;
59
60 Vector<const ButtonState*> GetAllDown() const;
61
62 const ButtonState* IsDown(const Button& button) const;
63
64 const ButtonState* IsDown() const;
65
66 Vector<const ButtonState*> GetAllJustReleased() const;
67
68 const ButtonState* IsJustReleased(const Button& button) const;
69
70 const ButtonState* IsJustReleased() const;
71
72 Vector<const ButtonState*> GetAllUp() const;
73
74 const ButtonState* IsUp(const Button& button) const;
75
76 const ButtonState* IsUp() const;
77
78 const ButtonState *IsPressed(const Button &button);
79
80 const ButtonState *GetPressed();
81
82 void ButtonDown(const Button& button);
83
84 void ButtonUp(const Button& button);
85
86 const ButtonState* GetState(const Button& button) const;
87
88 bool IsValid() const;
89
90 virtual HID* Clone() const;
91
92 private:
93 bool HasState(const Button& button) const;
94
95 bool AddState(const ButtonState& state);
96
97 ButtonState* GetState(const Button& button);
98
99 bool TickHoldTime(float delta);
100
101 void ResetTime();
102
103 void TickActivateTime(float delta);
104 };
105}
bool operator!=(const T *const first, const ehs::Str< T, N > &second)
Definition: Str.h:1916
bool operator==(const T *const first, const ehs::Str< T, N > &second)
Definition: Str.h:1906
Definition: Array.h:16
Definition: ButtonState.h:17
Definition: Button.h:9
Definition: HID.h:11
Array< ButtonState > states
Definition: HID.h:17
float heldTime
Definition: HID.h:19
bool active
Definition: HID.h:21
Str_8 name
Definition: HID.h:15
Button lastState
Definition: HID.h:18
float activateTime
Definition: HID.h:20
UInt_64 id
Definition: HID.h:16
UInt_8 type
Definition: HID.h:13
UInt_64 hashName
Definition: HID.h:14
Definition: Vector.h:18
Definition: Anchor.h:6
unsigned char UInt_8
Definition: Types.h:43