Panda3D
 All Classes Functions Variables Enumerations
buttonNode.h
1 // Filename: ButtonNode.h
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BUTTONNODE_H
16 #define BUTTONNODE_H
17 
18 #include "pandabase.h"
19 
20 #include "clientBase.h"
21 #include "clientButtonDevice.h"
22 #include "dataNode.h"
23 #include "buttonEventList.h"
24 
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : ButtonNode
28 // Description : This is the primary interface to on/off button
29 // devices associated with a ClientBase. This creates a
30 // node that connects to the named button device, if it
31 // exists, and provides hooks to the user to read the
32 // state of any of the sequentially numbered buttons
33 // associated with that device.
34 //
35 // It also can associate an arbitrary ButtonHandle with
36 // each button; when buttons are associated with
37 // ButtonHandles, this node will put appropriate up and
38 // down events on the data graph for each button state
39 // change.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDA_DEVICE ButtonNode : public DataNode {
42 PUBLISHED:
43  ButtonNode(ClientBase *client, const string &device_name);
44  virtual ~ButtonNode();
45 
46  INLINE bool is_valid() const;
47 
48  INLINE int get_num_buttons() const;
49 
50  INLINE void set_button_map(int index, ButtonHandle button);
51  INLINE ButtonHandle get_button_map(int index) const;
52 
53  INLINE bool get_button_state(int index) const;
54  INLINE bool is_button_known(int index) const;
55 
56 public:
57  virtual void output(ostream &out) const;
58  virtual void write(ostream &out, int indent_level = 0) const;
59 
60 private:
61  PT(ClientButtonDevice) _button;
62 
63 protected:
64  // Inherited from DataNode
65  virtual void do_transmit_data(DataGraphTraverser *trav,
66  const DataNodeTransmit &input,
67  DataNodeTransmit &output);
68 
69 private:
70  // outputs
71  int _button_events_output;
72  PT(ButtonEventList) _button_events;
73 
74 public:
75  static TypeHandle get_class_type() {
76  return _type_handle;
77  }
78  static void init_type() {
79  DataNode::init_type();
80  register_type(_type_handle, "ButtonNode",
81  DataNode::get_class_type());
82  }
83  virtual TypeHandle get_type() const {
84  return get_class_type();
85  }
86  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
87 
88 private:
89  static TypeHandle _type_handle;
90 };
91 
92 #include "buttonNode.I"
93 
94 #endif
This is the primary interface to on/off button devices associated with a ClientBase.
Definition: buttonNode.h:41
The fundamental type of node for the data graph.
Definition: dataNode.h:64
A device, attached to the ClientBase by a ButtonNode, that records the data from a single named butto...
Records a set of button events that happened recently.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
Definition: clientBase.h:47
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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...