Panda3D
 All Classes Functions Variables Enumerations
modifierButtons.h
1 // Filename: modifierButtons.h
2 // Created by: drose (01Mar00)
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 MODIFIERBUTTONS_H
16 #define MODIFIERBUTTONS_H
17 
18 #include "pandabase.h"
19 
20 #include "buttonHandle.h"
21 #include "pointerToArray.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : ModifierButtons
25 // Description : This class monitors the state of a number of
26 // individual buttons and tracks whether each button is
27 // known to be down or up.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDA_PUTIL ModifierButtons {
30 PUBLISHED:
32  ModifierButtons(const ModifierButtons &copy);
33  ~ModifierButtons();
34  INLINE void operator = (const ModifierButtons &copy);
35 
36  INLINE bool operator == (const ModifierButtons &other) const;
37  INLINE bool operator != (const ModifierButtons &other) const;
38  INLINE bool operator < (const ModifierButtons &other) const;
39 
40  INLINE ModifierButtons operator & (const ModifierButtons &other) const;
41  INLINE ModifierButtons operator | (const ModifierButtons &other) const;
42 
43  void operator &= (const ModifierButtons &other);
44  void operator |= (const ModifierButtons &other);
45 
46  void set_button_list(const ModifierButtons &other);
47 
48  bool matches(const ModifierButtons &other) const;
49 
50  bool add_button(ButtonHandle button);
51  bool has_button(ButtonHandle button) const;
52  bool remove_button(ButtonHandle button);
53 
54  INLINE int get_num_buttons() const;
55  INLINE ButtonHandle get_button(int index) const;
56  MAKE_SEQ(get_buttons, get_num_buttons, get_button);
57 
58  bool button_down(ButtonHandle button);
59  bool button_up(ButtonHandle button);
60  INLINE void all_buttons_up();
61 
62  bool is_down(ButtonHandle button) const;
63  INLINE bool is_down(int index) const;
64  INLINE bool is_any_down() const;
65 
66  string get_prefix() const;
67 
68  void output(ostream &out) const;
69  void write(ostream &out) const;
70 
71 private:
72  void modify_button_list();
73 
74  PTA(ButtonHandle) _button_list;
75  typedef unsigned long BitmaskType;
76  BitmaskType _state;
77 };
78 
79 INLINE ostream &operator << (ostream &out, const ModifierButtons &mb) {
80  mb.output(out);
81  return out;
82 }
83 
84 #include "modifierButtons.I"
85 
86 #endif
87 
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
void output(ostream &out) const
Writes a one-line summary of the buttons known to be down.