00001 // Filename: analogNode.I 00002 // Created by: drose (12Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: AnalogNode::OutputData::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE AnalogNode::OutputData:: 00026 OutputData() { 00027 _index = -1; 00028 _flip = false; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: AnalogNode::is_valid 00033 // Access: Public 00034 // Description: Returns true if the AnalogNode is valid and 00035 // connected to a server, false otherwise. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE bool AnalogNode:: 00038 is_valid() const { 00039 return (_analog != (ClientAnalogDevice *)NULL) && _analog->is_connected(); 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: AnalogNode::get_num_controls 00044 // Access: Public 00045 // Description: Returns the number of analog controls known to the 00046 // AnalogNode. This number may change as more controls 00047 // are discovered. 00048 //////////////////////////////////////////////////////////////////// 00049 INLINE int AnalogNode:: 00050 get_num_controls() const { 00051 _analog->lock(); 00052 int result = _analog->get_num_controls(); 00053 _analog->unlock(); 00054 return result; 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: AnalogNode::get_control_state 00059 // Access: Public 00060 // Description: Returns the current position of indicated analog 00061 // control identified by its index number, or 0.0 if 00062 // the control is unknown. The normal range of a single 00063 // control is -1.0 to 1.0. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE double AnalogNode:: 00066 get_control_state(int index) const { 00067 _analog->lock(); 00068 double result = _analog->get_control_state(index); 00069 _analog->unlock(); 00070 return result; 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: AnalogNode::is_control_known 00075 // Access: Public 00076 // Description: Returns true if the state of the indicated analog 00077 // control is known, or false if we have never heard 00078 // anything about this particular control. 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE bool AnalogNode:: 00081 is_control_known(int index) const { 00082 _analog->lock(); 00083 bool result = _analog->is_control_known(index); 00084 _analog->unlock(); 00085 return result; 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: AnalogNode::set_output 00090 // Access: Public 00091 // Description: Causes a particular analog control to be placed in 00092 // the data graph for the indicated channel. Normally, 00093 // a mouse uses channels 0 and 1 for the X and Y 00094 // information, respectively; channels 0, 1, and 2 are 00095 // available. If flip is true, the analog control value 00096 // will be reversed before outputting it. 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE void AnalogNode:: 00099 set_output(int channel, int index, bool flip) { 00100 nassertv(channel >= 0 && channel < max_outputs); 00101 _outputs[channel]._index = index; 00102 _outputs[channel]._flip = flip; 00103 } 00104 00105 //////////////////////////////////////////////////////////////////// 00106 // Function: AnalogNode::clear_output 00107 // Access: Public 00108 // Description: Removes the output to the data graph associated with 00109 // the indicated channel. See set_output(). 00110 //////////////////////////////////////////////////////////////////// 00111 INLINE void AnalogNode:: 00112 clear_output(int channel) { 00113 nassertv(channel >= 0 && channel < max_outputs); 00114 _outputs[channel]._index = -1; 00115 } 00116 00117 //////////////////////////////////////////////////////////////////// 00118 // Function: AnalogNode::get_output 00119 // Access: Public 00120 // Description: Returns the analog control index that is output to 00121 // the data graph on the indicated channel, or -1 if no 00122 // control is output on that channel. See set_output(). 00123 //////////////////////////////////////////////////////////////////// 00124 INLINE int AnalogNode:: 00125 get_output(int channel) const { 00126 nassertr(channel >= 0 && channel < max_outputs, -1); 00127 return _outputs[channel]._index; 00128 } 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function: AnalogNode::is_output_flipped 00132 // Access: Public 00133 // Description: Returns true if the analog control index that is 00134 // output to the data graph on the indicated channel is 00135 // flipped. See set_output(). 00136 //////////////////////////////////////////////////////////////////// 00137 INLINE bool AnalogNode:: 00138 is_output_flipped(int channel) const { 00139 nassertr(channel >= 0 && channel < max_outputs, false); 00140 return _outputs[channel]._flip; 00141 }