Panda3D
|
00001 // Filename: vrpnButton.h 00002 // Created by: drose (26Jan01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef VRPNBUTTON_H 00016 #define VRPNBUTTON_H 00017 00018 #include "pandabase.h" 00019 00020 #include "vrpn_interface.h" 00021 00022 #include "pvector.h" 00023 00024 class VrpnButtonDevice; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : VrpnButton 00028 // Description : This is the actual interface to a particular VRPN 00029 // button device, and all of its numbered buttons. A 00030 // pointer to this object is stored in the VrpnClient 00031 // class for each differently-named VRPN button device 00032 // we connect to. 00033 // 00034 // The VRPN callbacks go here, which in turn get 00035 // vectored out to any VrpnButtonDevice objects that 00036 // register with this. When the last VrpnButtonDevice 00037 // object unregisters, the VrpnButton will be deleted 00038 // by the VrpnClient. 00039 // 00040 // This class does not need to be exported from the DLL. 00041 //////////////////////////////////////////////////////////////////// 00042 class VrpnButton { 00043 public: 00044 VrpnButton(const string &button_name, vrpn_Connection *connection); 00045 ~VrpnButton(); 00046 00047 INLINE const string &get_button_name() const; 00048 INLINE bool is_empty() const; 00049 00050 void mark(VrpnButtonDevice *device); 00051 void unmark(VrpnButtonDevice *device); 00052 00053 INLINE void poll(); 00054 00055 void output(ostream &out) const; 00056 void write(ostream &out, int indent_level = 0) const; 00057 00058 private: 00059 static void VRPN_CALLBACK 00060 vrpn_button_callback(void *userdata, const vrpn_BUTTONCB info); 00061 00062 private: 00063 string _button_name; 00064 vrpn_Button_Remote *_button; 00065 00066 typedef pvector<VrpnButtonDevice *> Devices; 00067 Devices _devices; 00068 }; 00069 00070 INLINE ostream &operator << (ostream &out, const VrpnButton &button) { 00071 button.output(out); 00072 return out; 00073 } 00074 00075 #include "vrpnButton.I" 00076 00077 #endif