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