Panda3D
 All Classes Functions Variables Enumerations
buttonNode.h
00001 // Filename: ButtonNode.h
00002 // Created by:  drose (12Mar02)
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 BUTTONNODE_H
00016 #define BUTTONNODE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "clientBase.h"
00021 #include "clientButtonDevice.h"
00022 #include "dataNode.h"
00023 #include "buttonEventList.h"
00024 
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : ButtonNode
00028 // Description : This is the primary interface to on/off button
00029 //               devices associated with a ClientBase.  This creates a
00030 //               node that connects to the named button device, if it
00031 //               exists, and provides hooks to the user to read the
00032 //               state of any of the sequentially numbered buttons
00033 //               associated with that device.
00034 //
00035 //               It also can associate an arbitrary ButtonHandle with
00036 //               each button; when buttons are associated with
00037 //               ButtonHandles, this node will put appropriate up and
00038 //               down events on the data graph for each button state
00039 //               change.
00040 ////////////////////////////////////////////////////////////////////
00041 class EXPCL_PANDA_DEVICE ButtonNode : public DataNode {
00042 PUBLISHED:
00043   ButtonNode(ClientBase *client, const string &device_name);
00044   virtual ~ButtonNode();
00045 
00046   INLINE bool is_valid() const;
00047 
00048   INLINE int get_num_buttons() const;
00049 
00050   INLINE void set_button_map(int index, ButtonHandle button);
00051   INLINE ButtonHandle get_button_map(int index) const;
00052 
00053   INLINE bool get_button_state(int index) const;
00054   INLINE bool is_button_known(int index) const;
00055 
00056 public:
00057   virtual void output(ostream &out) const;
00058   virtual void write(ostream &out, int indent_level = 0) const;
00059 
00060 private:
00061   PT(ClientButtonDevice) _button;
00062 
00063 protected:
00064   // Inherited from DataNode
00065   virtual void do_transmit_data(DataGraphTraverser *trav,
00066                                 const DataNodeTransmit &input,
00067                                 DataNodeTransmit &output);
00068 
00069 private:
00070   // outputs
00071   int _button_events_output;
00072   PT(ButtonEventList) _button_events;
00073 
00074 public:
00075   static TypeHandle get_class_type() {
00076     return _type_handle;
00077   }
00078   static void init_type() {
00079     DataNode::init_type();
00080     register_type(_type_handle, "ButtonNode",
00081                   DataNode::get_class_type());
00082   }
00083   virtual TypeHandle get_type() const {
00084     return get_class_type();
00085   }
00086   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00087 
00088 private:
00089   static TypeHandle _type_handle;
00090 };
00091 
00092 #include "buttonNode.I"
00093 
00094 #endif
 All Classes Functions Variables Enumerations