Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_systems
InputSystem
InputSystem
InputSystem.cpp
Go to the documentation of this file.
1
#include "
InputSystem.hpp
"
2
3
#include <
ivorium_core/ivorium_core.hpp
>
4
5
#include "../InputNode.hpp"
6
#include "../SourceInputNode.hpp"
7
#include "../../Defs.hpp"
8
9
namespace
iv
10
{
11
12
InputSystem::InputSystem
(
SystemContainer
* sc,
InputSource
* source ) :
13
System
( sc ),
14
source( source ),
15
_window_size( 1, 1 ),
16
last_check_frame_id( 0 )
17
{
18
}
19
20
void
InputSystem::status
(
TextDebugView
* view )
21
{
22
}
23
24
bool
InputSystem::flushSystem
()
25
{
26
if
( this->
log_enabled
(
iv::Defs::Log::ConsistencyChecks_Frame
) )
27
{
28
unsigned
frame_id = this->
system_container
()->
frame_id
();
29
if
( this->last_check_frame_id != frame_id )
30
{
31
this->last_check_frame_id = frame_id;
32
33
std::unordered_set< InputNode * > roots;
34
for
(
InputNode
* node : this->nodes )
35
if
( !node->input_getParent() )
36
roots.insert( node );
37
38
for
(
InputNode
* root : roots )
39
{
40
if
( !root->quiet() && !
dynamic_cast<
SourceInputNode
*
>
( root ) )
41
{
42
this->
log
(
SRC_INFO
,
iv::Defs::Log::ConsistencyChecks_Frame
,
"InputNode "
, root->cm,
" is disconnected."
);
43
}
44
}
45
}
46
}
47
48
return
false
;
49
}
50
51
/*
52
void InputSystem::print_node( TreeDebugView * tree, InputNode * node )
53
{
54
for( InputNode * child : node->_children )
55
{
56
tree->Push( child->instance()->instance_name().c_str() );
57
child->cm.inheritance_root()->print_status_with_inherited( (TextDebugView*)tree, &child->cm );
58
this->print_node( tree, child );
59
tree->Pop();
60
}
61
}
62
63
void InputSystem::status( TextDebugView * view )
64
{
65
TreeDebugView tree( view->context() );
66
67
for( InputClient * root : this->input_listeners )
68
{
69
auto source = dynamic_cast< SourceInputNode * >( root );
70
if( !source )
71
{
72
tree.Push( root->instance()->instance_name().c_str() );
73
tree.out() << "<unknown>" << std::endl;
74
tree.Pop();
75
}
76
else
77
{
78
tree.Push( source->instance()->instance_name().c_str() );
79
source->cm.print_status_with_inherited( (TextDebugView*)&tree, &source->cm );
80
this->print_node( &tree, source );
81
tree.Pop();
82
}
83
}
84
85
tree.Write( TreeDebugView::Style::BoldFramesWeakLinks, view );
86
}
87
*/
88
89
int2
InputSystem::window_size
( )
90
{
91
return
this->_window_size;
92
}
93
94
void
InputSystem::window_size
(
int2
val )
95
{
96
this->_window_size = val;
97
}
98
99
int2
InputSystem::input_position
(
Input::Key
key,
int
device_id )
100
{
101
return
this->source->
input_position
( key, device_id );
102
}
103
104
float
InputSystem::input_value
(
Input::Key
key,
int
device_id )
105
{
106
return
this->source->
input_value
( key, device_id );
107
}
108
109
unsigned
InputSystem::input_character
()
110
{
111
return
this->source->
input_character
();
112
}
113
114
void
InputSystem::node_register
(
InputNode
* node )
115
{
116
this->nodes.insert( node );
117
}
118
119
void
InputSystem::node_unregister
(
InputNode
* node )
120
{
121
this->nodes.erase( node );
122
}
123
124
}