Panda3D
inputDeviceNode.h
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file InputDeviceNode.h
10  * @author fireclaw
11  * @date 2016-07-14
12  */
13 
14 #ifndef INPUTDEVICENODE_H
15 #define INPUTDEVICENODE_H
16 
17 #include "pandabase.h"
18 
19 #include "dataNode.h"
20 #include "inputDeviceManager.h"
21 #include "linmath_events.h"
22 
23 /**
24  * Reads the controller data sent from the InputDeviceManager, and transmits
25  * it down the data graph.
26  *
27  * This is intended to only be accessed from the app thread.
28  */
29 class EXPCL_PANDA_DEVICE InputDeviceNode : public DataNode {
30 PUBLISHED:
31  InputDeviceNode(InputDevice *device, const std::string &name);
32 
33 public:
34  void set_device(InputDevice *device);
35  PT(InputDevice) get_device() const;
36 
37 PUBLISHED:
38  MAKE_PROPERTY(device, get_device, set_device);
39 
40 protected:
41  // Inherited from DataNode
42  virtual void do_transmit_data(DataGraphTraverser *trav,
43  const DataNodeTransmit &input,
44  DataNodeTransmit &output);
45 
46 private:
47  pmap<ButtonHandle, bool> _button_states;
48  pmap<InputDevice::Axis, double> _control_states;
49 
50  // outputs
51  int _button_events_output;
52 
53  PT(InputDevice) _device;
54 
55 public:
56  static TypeHandle get_class_type() {
57  return _type_handle;
58  }
59  static void init_type() {
60  DataNode::init_type();
61  register_type(_type_handle, "InputDeviceNode",
62  DataNode::get_class_type());
63  }
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68 
69 private:
70  static TypeHandle _type_handle;
71 };
72 
73 #endif // INPUTDEVICENODE_H
The fundamental type of node for the data graph.
Definition: dataNode.h:52
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Reads the controller data sent from the InputDeviceManager, and transmits it down the data graph.
This is a structure representing a single input device.
Definition: inputDevice.h:53
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encapsulates the data generated from (or sent into) any particular DataNode.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...