InputSystem.cpp
Go to the documentation of this file.
1 #include "InputSystem.hpp"
2 
4 
5 #include "../InputNode.hpp"
6 #include "../SourceInputNode.hpp"
7 #include "../../Defs.hpp"
8 
9 namespace iv
10 {
11 
13  System( sc ),
14  source( source ),
15  _window_size( 1, 1 ),
16  last_check_frame_id( 0 )
17 {
18 }
19 
21 {
22 }
23 
25 {
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 
90 {
91  return this->_window_size;
92 }
93 
95 {
96  this->_window_size = val;
97 }
98 
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 
110 {
111  return this->source->input_character();
112 }
113 
115 {
116  this->nodes.insert( node );
117 }
118 
120 {
121  this->nodes.erase( node );
122 }
123 
124 }