InputNode.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <set>
6 #include <utility>
7 
8 namespace iv
9 {
10 
11 class InputNode;
12 class InputSystem;
13 
14 class InputRoot
15 {
16 public:
17  virtual void treeRefresh() = 0;
18  virtual void deactivateSubtree( InputNode * node ) = 0;
19  virtual void reserve_key( Input::DeviceKey key, bool reserve ) = 0;
20 };
21 
25 class InputNode
26 {
27 public:
28 friend class InputSystem; // Only used for debugging prints.
30  InputNode( Instance * inst );
31  ~InputNode();
32 
33  Instance * instance() const;
34  void status( iv::TableDebugView * view );
35 
39  void inputEnabled( bool );
40  bool inputEnabled();
41 
45  void quiet( bool );
46  bool quiet() const;
47 
51  void input_deactivate();
52 
53  /*
54  Call this when:
55  1. Method input_eachChild would give different set of nodes or would give them in different order (if that is relevant for input priority).
56  2. Method input_trigger_process or input_process trigger would accept different inputs than before.
57  This is the same as calling InputRoot::treeChanged.
58  This should be called on InputNode that is already part of the tree, because it uses pointer to last InputRoot to inform the root about this change.
59  */
60  void input_treeRefresh();
61 
62  //--------------------- input tree ----------------------------------
67  void input_setParent( InputNode * );
68 
72 
75  virtual InputRoot * input_getRoot();
76 
81  virtual void input_eachChild( std::function< void( InputNode * ) > const & ){}
82 
85  virtual void input_childDisconnect( InputNode * ){}
86 
87  //--------------------- end point input processing --------------------------------------------------------
92 
97  bool input_visit( InputRoot * root, Input::DeviceKey key, bool & press, bool & real, bool & offspace );
98 
99 protected:
100  //--------------------- end-point input processing ------------------------
104  virtual bool input_trigger_process( InputRoot * root, Input::DeviceKey key ){ return true; }
105 
111  virtual void input_process( InputRoot * root, Input::DeviceKey key, bool & press, bool & real, bool & offspace ){}
112 
113 private:
114  Instance * inst;
115  bool _enabled;
116  InputNode * _parent;
117  bool _quiet;
118 };
119 
120 }