Panda3D
mouseInterfaceNode.h
Go to the documentation of this file.
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 mouseInterfaceNode.h
10  * @author drose
11  * @date 2004-06-11
12  */
13 
14 #ifndef MOUSEINTERFACENODE_H
15 #define MOUSEINTERFACENODE_H
16 
17 #include "pandabase.h"
18 
19 #include "dataNode.h"
20 #include "modifierButtons.h"
21 
22 class ButtonEventList;
23 
24 /**
25  * This is the base class for some classes that monitor the mouse and keyboard
26  * input and perform some action due to their state.
27  *
28  * It collects together some common interface; in particular, the
29  * require_button() and related methods.
30  */
31 class EXPCL_PANDA_TFORM MouseInterfaceNode : public DataNode {
32 public:
33  explicit MouseInterfaceNode(const std::string &name);
34  virtual ~MouseInterfaceNode();
35 
36 PUBLISHED:
37  void require_button(const ButtonHandle &button, bool is_down);
38  void clear_button(const ButtonHandle &button);
39  void clear_all_buttons();
40 
41 protected:
42  void watch_button(const ButtonHandle &button);
43  const ButtonEventList *check_button_events(const DataNodeTransmit &input,
44  bool &required_buttons_match);
45 
46  INLINE bool is_down(ButtonHandle button) const;
47 
48 private:
49  ModifierButtons _current_button_state;
50  ModifierButtons _watched_buttons;
51  ModifierButtons _required_buttons_mask;
52  ModifierButtons _required_buttons_state;
53 
54 private:
55  int _button_events_input;
56 
57 public:
58  static TypeHandle get_class_type() {
59  return _type_handle;
60  }
61  static void init_type() {
62  DataNode::init_type();
63  register_type(_type_handle, "MouseInterfaceNode",
64  DataNode::get_class_type());
65  }
66  virtual TypeHandle get_type() const {
67  return get_class_type();
68  }
69  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
70 
71 private:
72  static TypeHandle _type_handle;
73 };
74 
75 #include "mouseInterfaceNode.I"
76 
77 #endif
The fundamental type of node for the data graph.
Definition: dataNode.h:52
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
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.
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:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Encapsulates the data generated from (or sent into) any particular DataNode.