sculpto
Main Page
Namespaces
Classes
Files
File List
File Members
core
events
keyboard_event.h
Go to the documentation of this file.
1
/*!****************************************************************/
/*!*
2
* \file keyboard_event.h
3
* \brief Keyboard action (key pressed, key hold, key up) event implementation module.
4
*
5
* \author Sabitov Kirill
6
* \date 25 June 2022
7
*********************************************************************/
8
9
#pragma once
10
11
#include "../application/input_keycodes.h"
12
#include "
utilities/event/event.h
"
13
14
namespace
scl
15
{
17
class
keyboard_event
:
public
event
18
{
19
SCL_MAKE_EVENT(Keyboard);
20
21
private
:
22
bool
Pressed;
23
bool
PrevPressed;
24
bool
Clicked;
25
keycode
KeyCode;
26
27
public
:
28
/*!*
29
* Keyboard event default constructor.
30
*
31
* \param Pressed - is key pressed or released flag.
32
* \param RepeatCount - is key pressed continiaously flag.
33
* \param KeyCode - kode of acting key
34
*/
35
keyboard_event
(
bool
Pressed,
bool
PrevPressed,
keycode
KeyCode) :
36
Pressed(Pressed), PrevPressed(PrevPressed), KeyCode(KeyCode),
37
Clicked(!PrevPressed && Pressed) {}
38
40
bool
GetPressed
() {
return
Pressed; }
42
int
GetPrevPressed
() {
return
PrevPressed; }
44
int
GetClicked
() {
return
Clicked; }
46
keycode
GetKeyCode
() {
return
KeyCode; }
47
48
/*!*
49
* Convert event to string (for debug).
50
*
51
* \param None.
52
* \return string representation of event.
53
*/
54
inline
std::string
ToString
()
const override
55
{
56
std::stringstream ss;
57
ss <<
GetName
() <<
": Pressed? - "
<< Pressed <<
", Prev. Pressed? - "
<< PrevPressed
58
<<
", Clicked? - "
<< Clicked <<
", KeyCode - "
<< (int)KeyCode;
59
return
ss.str();
60
}
61
};
62
}
scl::event
Definition:
event.h:24
scl::event::GetName
virtual const char * GetName() const =0
scl::keyboard_event
Definition:
keyboard_event.h:18
scl::keyboard_event::GetPressed
bool GetPressed()
Definition:
keyboard_event.h:40
scl::keyboard_event::keyboard_event
keyboard_event(bool Pressed, bool PrevPressed, keycode KeyCode)
Definition:
keyboard_event.h:35
scl::keyboard_event::GetClicked
int GetClicked()
Definition:
keyboard_event.h:44
scl::keyboard_event::GetPrevPressed
int GetPrevPressed()
Definition:
keyboard_event.h:42
scl::keyboard_event::GetKeyCode
keycode GetKeyCode()
Definition:
keyboard_event.h:46
scl::keyboard_event::ToString
std::string ToString() const override
Definition:
keyboard_event.h:54
event.h
scl
Definition:
base.h:33
scl::keycode
keycode
Definition:
input_keycodes.h:15
Generated by
1.9.4