matf-rg-engine  1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Input.hpp
Go to the documentation of this file.
1 
6 #ifndef INPUT_HPP
7 #define INPUT_HPP
8 #include <string_view>
9 
10 namespace engine::platform {
14  enum KeyId {
148  };
149 
154  class Key final {
155  friend class PlatformController;
156 
157  public:
161  enum class State {
165  Released,
170  JustPressed,
176  Pressed,
182  };
183 
188  return m_state;
189  }
190 
194  KeyId id() const {
195  return m_key;
196  }
197 
201  std::string_view name();
202 
203  State state() const {
204  return m_state;
205  }
206 
210  std::string_view state_str() const;
211 
216  bool is_down() const {
218  }
219 
224  bool is_up() const {
226  }
227 
228  private:
231  };
232 
237  struct MousePosition {
241  float x;
245  float y;
249  float dx;
253  float dy;
254 
258  float scroll;
259  };
260 }
261 #endif //INPUT_HPP
Represents the state of the key in a given frame.
Definition: Input.hpp:154
KeyId id() const
Definition: Input.hpp:194
bool is_up() const
Shorthand method for checking whether the key is up.
Definition: Input.hpp:224
KeyId m_key
Definition: Input.hpp:229
State state() const
Definition: Input.hpp:203
std::string_view name()
Definition: PlatformController.cpp:159
State
The state of the key with regard to whether it is pressed or not.
Definition: Input.hpp:161
@ JustReleased
Lasts only for the frame in which the key was released. In the next frame, if the key is not pressed ...
@ JustPressed
The key has just been pressed in the current frame. This state only lasts for the frame in which the ...
@ Pressed
The key is being held down. If the key was JustPressed in the previous frame, and it is still down in...
std::string_view state_str() const
Definition: PlatformController.cpp:163
bool is_down() const
Shorthand method for checking whether the key is down.
Definition: Input.hpp:216
State m_state
Definition: Input.hpp:230
State & state()
Definition: Input.hpp:187
Registers Platform events such as mouse movement, key press, window events...
Definition: PlatformController.hpp:45
Definition: Input.hpp:10
KeyId
All the Keys that the engine can register.
Definition: Input.hpp:14
@ MOUSE_BUTTON_LEFT
Definition: Input.hpp:24
@ KEY_KP_7
Definition: Input.hpp:128
@ KEY_F7
Definition: Input.hpp:102
@ KEY_DOWN
Definition: Input.hpp:85
@ KEY_LEFT_BRACKET
Definition: Input.hpp:71
@ KEY_F23
Definition: Input.hpp:118
@ KEY_Q
Definition: Input.hpp:61
@ KEY_F25
Definition: Input.hpp:120
@ KEY_D
Definition: Input.hpp:48
@ KEY_KP_MULTIPLY
Definition: Input.hpp:133
@ KEY_F1
Definition: Input.hpp:96
@ KEY_R
Definition: Input.hpp:62
@ KEY_F11
Definition: Input.hpp:106
@ KEY_ENTER
Definition: Input.hpp:78
@ KEY_X
Definition: Input.hpp:68
@ KEY_KP_ADD
Definition: Input.hpp:135
@ KEY_KP_3
Definition: Input.hpp:124
@ KEY_PRINT_SCREEN
Definition: Input.hpp:94
@ KEY_KP_DECIMAL
Definition: Input.hpp:131
@ KEY_KP_1
Definition: Input.hpp:122
@ MOUSE_BUTTON_MIDDLE
Definition: Input.hpp:26
@ KEY_PERIOD
Definition: Input.hpp:31
@ KEY_F15
Definition: Input.hpp:110
@ KEY_W
Definition: Input.hpp:67
@ KEY_F19
Definition: Input.hpp:114
@ KEY_F2
Definition: Input.hpp:97
@ KEY_RIGHT_ALT
Definition: Input.hpp:144
@ KEY_7
Definition: Input.hpp:40
@ KEY_4
Definition: Input.hpp:37
@ KEY_F14
Definition: Input.hpp:109
@ KEY_LEFT
Definition: Input.hpp:84
@ KEY_WORLD_1
Definition: Input.hpp:75
@ KEY_PAUSE
Definition: Input.hpp:95
@ KEY_RIGHT
Definition: Input.hpp:83
@ KEY_KP_DIVIDE
Definition: Input.hpp:132
@ KEY_RIGHT_SHIFT
Definition: Input.hpp:142
@ MOUSE_BUTTON_1
Definition: Input.hpp:15
@ KEY_HOME
Definition: Input.hpp:89
@ MOUSE_BUTTON_RIGHT
Definition: Input.hpp:25
@ KEY_DELETE
Definition: Input.hpp:82
@ KEY_LEFT_CONTROL
Definition: Input.hpp:139
@ KEY_WORLD_2
Definition: Input.hpp:76
@ KEY_SPACE
Definition: Input.hpp:27
@ KEY_APOSTROPHE
Definition: Input.hpp:28
@ KEY_F20
Definition: Input.hpp:115
@ KEY_KP_2
Definition: Input.hpp:123
@ KEY_KP_4
Definition: Input.hpp:125
@ KEY_8
Definition: Input.hpp:41
@ KEY_S
Definition: Input.hpp:63
@ KEY_B
Definition: Input.hpp:46
@ KEY_F17
Definition: Input.hpp:112
@ KEY_F3
Definition: Input.hpp:98
@ KEY_K
Definition: Input.hpp:55
@ KEY_KP_5
Definition: Input.hpp:126
@ KEY_F6
Definition: Input.hpp:101
@ KEY_KP_EQUAL
Definition: Input.hpp:137
@ KEY_LEFT_SUPER
Definition: Input.hpp:141
@ KEY_RIGHT_SUPER
Definition: Input.hpp:145
@ KEY_J
Definition: Input.hpp:54
@ KEY_F12
Definition: Input.hpp:107
@ KEY_F9
Definition: Input.hpp:104
@ KEY_Z
Definition: Input.hpp:70
@ KEY_SCROLL_LOCK
Definition: Input.hpp:92
@ MOUSE_BUTTON_7
Definition: Input.hpp:21
@ KEY_MINUS
Definition: Input.hpp:30
@ KEY_CAPS_LOCK
Definition: Input.hpp:91
@ KEY_T
Definition: Input.hpp:64
@ KEY_PAGE_DOWN
Definition: Input.hpp:88
@ KEY_EQUAL
Definition: Input.hpp:44
@ MOUSE_BUTTON_3
Definition: Input.hpp:17
@ KEY_COUNT
Definition: Input.hpp:147
@ KEY_F24
Definition: Input.hpp:119
@ KEY_KP_6
Definition: Input.hpp:127
@ KEY_A
Definition: Input.hpp:45
@ KEY_LEFT_SHIFT
Definition: Input.hpp:138
@ KEY_E
Definition: Input.hpp:49
@ KEY_F
Definition: Input.hpp:50
@ KEY_V
Definition: Input.hpp:66
@ KEY_F16
Definition: Input.hpp:111
@ KEY_P
Definition: Input.hpp:60
@ KEY_L
Definition: Input.hpp:56
@ KEY_INSERT
Definition: Input.hpp:81
@ KEY_COMMA
Definition: Input.hpp:29
@ KEY_ESCAPE
Definition: Input.hpp:77
@ KEY_N
Definition: Input.hpp:58
@ KEY_M
Definition: Input.hpp:57
@ KEY_NUM_LOCK
Definition: Input.hpp:93
@ KEY_UP
Definition: Input.hpp:86
@ KEY_9
Definition: Input.hpp:42
@ MOUSE_BUTTON_4
Definition: Input.hpp:18
@ KEY_KP_8
Definition: Input.hpp:129
@ KEY_KP_SUBTRACT
Definition: Input.hpp:134
@ KEY_SLASH
Definition: Input.hpp:32
@ KEY_C
Definition: Input.hpp:47
@ KEY_GRAVE_ACCENT
Definition: Input.hpp:74
@ KEY_F18
Definition: Input.hpp:113
@ KEY_KP_9
Definition: Input.hpp:130
@ KEY_BACKSPACE
Definition: Input.hpp:80
@ KEY_3
Definition: Input.hpp:36
@ KEY_1
Definition: Input.hpp:34
@ MOUSE_BUTTON_6
Definition: Input.hpp:20
@ KEY_2
Definition: Input.hpp:35
@ KEY_5
Definition: Input.hpp:38
@ KEY_BACKSLASH
Definition: Input.hpp:72
@ MOUSE_BUTTON_8
Definition: Input.hpp:22
@ KEY_RIGHT_CONTROL
Definition: Input.hpp:143
@ KEY_G
Definition: Input.hpp:51
@ KEY_O
Definition: Input.hpp:59
@ KEY_MENU
Definition: Input.hpp:146
@ KEY_TAB
Definition: Input.hpp:79
@ KEY_6
Definition: Input.hpp:39
@ KEY_PAGE_UP
Definition: Input.hpp:87
@ KEY_SEMICOLON
Definition: Input.hpp:43
@ KEY_0
Definition: Input.hpp:33
@ KEY_U
Definition: Input.hpp:65
@ KEY_KP_0
Definition: Input.hpp:121
@ KEY_I
Definition: Input.hpp:53
@ KEY_F10
Definition: Input.hpp:105
@ KEY_Y
Definition: Input.hpp:69
@ KEY_F21
Definition: Input.hpp:116
@ KEY_END
Definition: Input.hpp:90
@ KEY_F4
Definition: Input.hpp:99
@ MOUSE_BUTTON_2
Definition: Input.hpp:16
@ KEY_KP_ENTER
Definition: Input.hpp:136
@ MOUSE_BUTTON_5
Definition: Input.hpp:19
@ KEY_F8
Definition: Input.hpp:103
@ KEY_LEFT_ALT
Definition: Input.hpp:140
@ KEY_F13
Definition: Input.hpp:108
@ KEY_F22
Definition: Input.hpp:117
@ KEY_F5
Definition: Input.hpp:100
@ KEY_RIGHT_BRACKET
Definition: Input.hpp:73
@ MOUSE_BUTTON_LAST
Definition: Input.hpp:23
@ KEY_H
Definition: Input.hpp:52
Represents mouse position in a given frame relative to the top left corner of the screen.
Definition: Input.hpp:237
float dx
The change in the X coordinate from the previous frame.
Definition: Input.hpp:249
float y
Y coordinate of the mouse position relative to the top left corner of the screen.
Definition: Input.hpp:245
float dy
The change in the Y coordinate from the previous frame.
Definition: Input.hpp:253
float x
X coordinate of the mouse position relative to the top left corner of the screen.
Definition: Input.hpp:241
float scroll
The rotation of the scroll button.
Definition: Input.hpp:258