Panda3D

analogNode.I

00001 // Filename: analogNode.I
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: AnalogNode::OutputData::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE AnalogNode::OutputData::
00022 OutputData() {
00023   _index = -1;
00024   _flip = false;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: AnalogNode::is_valid
00029 //       Access: Public
00030 //  Description: Returns true if the AnalogNode is valid and
00031 //               connected to a server, false otherwise.
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE bool AnalogNode::
00034 is_valid() const {
00035   return (_analog != (ClientAnalogDevice *)NULL) && _analog->is_connected();
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: AnalogNode::get_num_controls
00040 //       Access: Public
00041 //  Description: Returns the number of analog controls known to the
00042 //               AnalogNode.  This number may change as more controls
00043 //               are discovered.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE int AnalogNode::
00046 get_num_controls() const {
00047   _analog->acquire();
00048   int result = _analog->get_num_controls();
00049   _analog->unlock();
00050   return result;
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: AnalogNode::get_control_state
00055 //       Access: Public
00056 //  Description: Returns the current position of indicated analog
00057 //               control identified by its index number, or 0.0 if
00058 //               the control is unknown.  The normal range of a single
00059 //               control is -1.0 to 1.0.
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE double AnalogNode::
00062 get_control_state(int index) const {
00063   _analog->acquire();
00064   double result = _analog->get_control_state(index);
00065   _analog->unlock();
00066   return result;
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: AnalogNode::is_control_known
00071 //       Access: Public
00072 //  Description: Returns true if the state of the indicated analog
00073 //               control is known, or false if we have never heard
00074 //               anything about this particular control.
00075 ////////////////////////////////////////////////////////////////////
00076 INLINE bool AnalogNode::
00077 is_control_known(int index) const {
00078   _analog->acquire();
00079   bool result = _analog->is_control_known(index);
00080   _analog->unlock();
00081   return result;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: AnalogNode::set_output
00086 //       Access: Public
00087 //  Description: Causes a particular analog control to be placed in
00088 //               the data graph for the indicated channel.  Normally,
00089 //               a mouse uses channels 0 and 1 for the X and Y
00090 //               information, respectively; channels 0, 1, and 2 are
00091 //               available.  If flip is true, the analog control value
00092 //               will be reversed before outputting it.
00093 ////////////////////////////////////////////////////////////////////
00094 INLINE void AnalogNode::
00095 set_output(int channel, int index, bool flip) {
00096   nassertv(channel >= 0 && channel < max_outputs);
00097   _outputs[channel]._index = index;
00098   _outputs[channel]._flip = flip;
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: AnalogNode::clear_output
00103 //       Access: Public
00104 //  Description: Removes the output to the data graph associated with
00105 //               the indicated channel.  See set_output().
00106 ////////////////////////////////////////////////////////////////////
00107 INLINE void AnalogNode::
00108 clear_output(int channel) {
00109   nassertv(channel >= 0 && channel < max_outputs);
00110   _outputs[channel]._index = -1;
00111 }
00112 
00113 ////////////////////////////////////////////////////////////////////
00114 //     Function: AnalogNode::get_output
00115 //       Access: Public
00116 //  Description: Returns the analog control index that is output to
00117 //               the data graph on the indicated channel, or -1 if no
00118 //               control is output on that channel.  See set_output().
00119 ////////////////////////////////////////////////////////////////////
00120 INLINE int AnalogNode::
00121 get_output(int channel) const {
00122   nassertr(channel >= 0 && channel < max_outputs, -1);
00123   return _outputs[channel]._index;
00124 }
00125 
00126 ////////////////////////////////////////////////////////////////////
00127 //     Function: AnalogNode::is_output_flipped
00128 //       Access: Public
00129 //  Description: Returns true if the analog control index that is
00130 //               output to the data graph on the indicated channel is
00131 //               flipped.  See set_output().
00132 ////////////////////////////////////////////////////////////////////
00133 INLINE bool AnalogNode::
00134 is_output_flipped(int channel) const {
00135   nassertr(channel >= 0 && channel < max_outputs, false);
00136   return _outputs[channel]._flip;
00137 }
 All Classes Functions Variables Enumerations