Panda3D
vrpnButton.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 vrpnButton.h
10  * @author drose
11  * @date 2001-01-26
12  */
13 
14 #ifndef VRPNBUTTON_H
15 #define VRPNBUTTON_H
16 
17 #include "pandabase.h"
18 
19 #include "vrpn_interface.h"
20 
21 #include "pvector.h"
22 
23 class VrpnButtonDevice;
24 
25 /**
26  * This is the actual interface to a particular VRPN button device, and all of
27  * its numbered buttons. A pointer to this object is stored in the VrpnClient
28  * class for each differently-named VRPN button device we connect to.
29  *
30  * The VRPN callbacks go here, which in turn get vectored out to any
31  * VrpnButtonDevice objects that register with this. When the last
32  * VrpnButtonDevice object unregisters, the VrpnButton will be deleted by the
33  * VrpnClient.
34  *
35  * This class does not need to be exported from the DLL.
36  */
37 class VrpnButton {
38 public:
39  VrpnButton(const std::string &button_name, vrpn_Connection *connection);
40  ~VrpnButton();
41 
42  INLINE const std::string &get_button_name() const;
43  INLINE bool is_empty() const;
44 
45  void mark(VrpnButtonDevice *device);
46  void unmark(VrpnButtonDevice *device);
47 
48  INLINE void poll();
49 
50  void output(std::ostream &out) const;
51  void write(std::ostream &out, int indent_level = 0) const;
52 
53 private:
54  static void VRPN_CALLBACK
55  vrpn_button_callback(void *userdata, const vrpn_BUTTONCB info);
56 
57 private:
58  std::string _button_name;
59  vrpn_Button_Remote *_button;
60 
62  Devices _devices;
63 };
64 
65 INLINE std::ostream &operator << (std::ostream &out, const VrpnButton &button) {
66  button.output(out);
67  return out;
68 }
69 
70 #include "vrpnButton.I"
71 
72 #endif
void unmark(VrpnButtonDevice *device)
Removes the indicated VrpnButtonDevice from the list of devices that are sharing this VrpnButton.
Definition: vrpnButton.cxx:60
void poll()
Polls the connected device.
Definition: vrpnButton.I:37
const std::string & get_button_name() const
Returns the name of the button device that was used to create this VrpnButton.
Definition: vrpnButton.I:19
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void mark(VrpnButtonDevice *device)
Adds the indicated VrpnButtonDevice to the list of devices that are sharing this VrpnButton.
Definition: vrpnButton.cxx:48
The Panda interface to a VRPN button.
This is the actual interface to a particular VRPN button device, and all of its numbered buttons.
Definition: vrpnButton.h:37
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_empty() const
Returns true if no VrpnButtonDevices reference this VrpnButton, or false otherwise.
Definition: vrpnButton.I:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.