Panda3D
mouseInterfaceNode.h
1 // Filename: mouseInterfaceNode.h
2 // Created by: drose (11Jun04)
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 MOUSEINTERFACENODE_H
16 #define MOUSEINTERFACENODE_H
17 
18 #include "pandabase.h"
19 
20 #include "dataNode.h"
21 #include "modifierButtons.h"
22 
23 class ButtonEventList;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : MouseInterfaceNode
27 // Description : This is the base class for some classes that monitor
28 // the mouse and keyboard input and perform some action
29 // due to their state.
30 //
31 // It collects together some common interface; in
32 // particular, the require_button() and related methods.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_TFORM MouseInterfaceNode : public DataNode {
35 public:
36  MouseInterfaceNode(const string &name);
37  virtual ~MouseInterfaceNode();
38 
39 PUBLISHED:
40  void require_button(const ButtonHandle &button, bool is_down);
41  void clear_button(const ButtonHandle &button);
42  void clear_all_buttons();
43 
44 protected:
45  void watch_button(const ButtonHandle &button);
46  const ButtonEventList *check_button_events(const DataNodeTransmit &input,
47  bool &required_buttons_match);
48 
49  INLINE bool is_down(ButtonHandle button) const;
50 
51 private:
52  ModifierButtons _current_button_state;
53  ModifierButtons _watched_buttons;
54  ModifierButtons _required_buttons_mask;
55  ModifierButtons _required_buttons_state;
56 
57 private:
58  int _button_events_input;
59 
60 public:
61  static TypeHandle get_class_type() {
62  return _type_handle;
63  }
64  static void init_type() {
65  DataNode::init_type();
66  register_type(_type_handle, "MouseInterfaceNode",
67  DataNode::get_class_type());
68  }
69  virtual TypeHandle get_type() const {
70  return get_class_type();
71  }
72  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
73 
74 private:
75  static TypeHandle _type_handle;
76 };
77 
78 #include "mouseInterfaceNode.I"
79 
80 #endif
The fundamental type of node for the data graph.
Definition: dataNode.h:64
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
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
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
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.