Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_systems
InputSystem
Char_InputNode.cpp
Go to the documentation of this file.
1
#include "
Char_InputNode.hpp
"
2
3
#include "
InputSystem/InputQuery.hpp
"
4
#include "../Defs.hpp"
5
6
namespace
iv
7
{
8
9
//------------------------- CharListener -----------------------------
10
CharListener::CharListener
(
Instance
* inst ) :
11
cm( inst, this,
"CharListener"
),
12
inst( inst )
13
{
14
}
15
16
CharListener::~CharListener
()
17
{
18
}
19
20
Instance
*
CharListener::instance
()
const
21
{
22
return
this->inst;
23
}
24
25
//--------------------------- Char_InputNode --------------------------------------------
26
Char_InputNode::Char_InputNode
(
Instance
* inst,
TimeId
time_type ) :
27
cm( inst, this,
"Char_InputEvent"
),
28
InputNode
( inst )
29
{
30
this->
cm
.
inherits
( this->
InputNode::cm
);
31
}
32
33
void
Char_InputNode::Insert_CharListener
(
CharListener
* listener )
34
{
35
this->char_listeners.insert( listener );
36
}
37
38
void
Char_InputNode::Remove_CharListener
(
CharListener
* listener )
39
{
40
this->char_listeners.erase( listener );
41
}
42
43
bool
Char_InputNode::input_trigger_process
(
InputRoot
* root,
Input::DeviceKey
key )
44
{
45
if
( key.first !=
Input::Key::Character
)
46
{
47
this->
cm
.
log
(
SRC_INFO
,
Defs::Log::Input
,
"Refuse input, not a Character input."
);
48
return
true
;
49
}
50
51
this->
cm
.
log
(
SRC_INFO
,
Defs::Log::Input
,
"Accept Character input."
);
52
53
InputQuery
iq( this->
instance
() );
54
unsigned
character = iq.
input_character
();
55
56
this->char_listeners.foreach(
57
[&](
CharListener
* listener )
58
{
59
listener->
on_char
(
this
, character );
60
}
61
);
62
63
return
false
;
64
}
65
66
}