Panda3D
Loading...
Searching...
No Matches
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
22class 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 */
31class EXPCL_PANDA_TFORM MouseInterfaceNode : public DataNode {
32public:
33 explicit MouseInterfaceNode(const std::string &name);
34 virtual ~MouseInterfaceNode();
35
36PUBLISHED:
37 void require_button(const ButtonHandle &button, bool is_down);
38 void clear_button(const ButtonHandle &button);
39 void clear_all_buttons();
40
41protected:
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
48private:
49 ModifierButtons _current_button_state;
50 ModifierButtons _watched_buttons;
51 ModifierButtons _required_buttons_mask;
52 ModifierButtons _required_buttons_state;
53
54private:
55 int _button_events_input;
56
57public:
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
71private:
72 static TypeHandle _type_handle;
73};
74
75#include "mouseInterfaceNode.I"
76
77#endif
Records a set of button events that happened recently.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Encapsulates the data generated from (or sent into) any particular DataNode.
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
void clear_button(const ButtonHandle &button)
Removes any requirement on the indicated button set by an earlier call to require_button().
void clear_all_buttons()
Removes all requirements on buttons set by an earlier call to require_button().
void require_button(const ButtonHandle &button, bool is_down)
Indicates that the indicated button must be in the required state (either up or down) in order for th...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...