InputNode.cpp
Go to the documentation of this file.
1 #include "InputNode.hpp"
2 #include "../Defs.hpp"
3 
4 namespace iv
5 {
6 
8  cm( inst, this, "InputNode", ClientMarker::Status() ),
9  inst( inst ),
10  _enabled( true ),
11  _parent( nullptr ),
12  _quiet( false )
13 {
14 }
15 
17 {
18  if( this->_parent )
19  this->_parent->input_childDisconnect( this );
20 }
21 
23 {
24  return this->inst;
25 }
26 
28 {
29  static iv::TableId DebugTable = TableId::create( "InputNode" );
30  auto row = view->Table( DebugTable ).Row( this );
31 
32  row.Column( "inputEnabled", this->inputEnabled() );
33 }
34 
36 {
37  return this->_parent;
38 }
39 
41 {
42  this->_parent = parent;
43 }
44 
46 {
47  if( this->_parent )
48  return this->_parent->input_getRoot();
49  else
50  return nullptr;
51 }
52 
53 void InputNode::inputEnabled( bool value )
54 {
55  if( this->_enabled == value )
56  return;
57 
58  this->_enabled = value;
59  this->input_treeRefresh();
60 }
61 
63 {
64  return this->_enabled;
65 }
66 
68 {
69  if( auto root = this->input_getRoot() )
70  root->treeRefresh();
71 }
72 
74 {
75  if( auto root = this->input_getRoot() )
76  root->deactivateSubtree( this );
77 }
78 
79 void InputNode::quiet( bool val )
80 {
81  this->_quiet = val;
82 }
83 
84 bool InputNode::quiet() const
85 {
86  return this->_quiet;
87 }
88 
89 //---------------
90 bool InputNode::input_visit( InputRoot * root, Input::DeviceKey key, bool & press, bool & real, bool & offspace )
91 {
92  if( !this->_enabled )
93  return true;
94 
95  // try to process it
96  this->cm.log( SRC_INFO, Defs::Log::InputTree, press ? "press" : "release", " ", real ? " " : "(fake) ", offspace ? "(offspace) " : " ", key.first, "/", key.second, "" );
97 
98  this->input_process( root, key, press, real, offspace );
99 
100  this->input_eachChild(
101  [&]( InputNode * node )
102  {
103  node->input_visit( root, key, press, real, offspace );
104  }
105  );
106 
107  return true;
108 }
109 
111 {
112  if( !this->_enabled )
113  return true;
114 
115  bool cont = this->input_trigger_process( root, key );
116 
117  this->cm.log( SRC_INFO, Defs::Log::InputTree, "trigger ", key.first, "/", key.second, " -> ", cont ? "continue" : "stop" );
118 
119  if( !cont )
120  return false;
121 
122  bool keep_going = true;
123  this->input_eachChild(
124  [&]( InputNode * node )
125  {
126  keep_going = keep_going && node->input_trigger_visit( root, key );
127  }
128  );
129  if( !keep_going )
130  return false;
131 
132  return true;
133 }
134 
135 }