00001 // Filename: buttonNode.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: ButtonNode::is_valid 00022 // Access: Public 00023 // Description: Returns true if the ButtonNode is valid and 00024 // connected to a server, false otherwise. 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE bool ButtonNode:: 00027 is_valid() const { 00028 return (_button != (ClientButtonDevice *)NULL) && _button->is_connected(); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: ButtonNode::get_num_buttons 00033 // Access: Public 00034 // Description: Returns the number of buttons known to the 00035 // ButtonNode. This includes those buttons whose state 00036 // has been seen, as well as buttons that have been 00037 // associated with a ButtonHandle even if their state is 00038 // unknown. This number may change as more buttons are 00039 // discovered. 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE int ButtonNode:: 00042 get_num_buttons() const { 00043 _button->lock(); 00044 int result = _button->get_num_buttons(); 00045 _button->unlock(); 00046 return result; 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: ButtonNode::set_button_map 00051 // Access: Public 00052 // Description: Associates the indicated ButtonHandle with the button 00053 // of the indicated index number. When the given button 00054 // index changes state, a corresponding ButtonEvent will 00055 // be generated with the given ButtonHandle. Pass 00056 // ButtonHandle::none() to turn off any association. 00057 // 00058 // It is not necessary to call this if you simply want 00059 // to query the state of the various buttons by index 00060 // number; this is only necessary in order to generate 00061 // ButtonEvents when the buttons change state. 00062 //////////////////////////////////////////////////////////////////// 00063 INLINE void ButtonNode:: 00064 set_button_map(int index, ButtonHandle button) { 00065 _button->lock(); 00066 _button->set_button_map(index, button); 00067 _button->unlock(); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: ButtonNode::get_button_map 00072 // Access: Public 00073 // Description: Returns the ButtonHandle that was previously 00074 // associated with the given index number by 00075 // a call to set_button_map(), or ButtonHandle::none() 00076 // if no button was associated. 00077 //////////////////////////////////////////////////////////////////// 00078 INLINE ButtonHandle ButtonNode:: 00079 get_button_map(int index) const { 00080 _button->lock(); 00081 ButtonHandle result = _button->get_button_map(index); 00082 _button->unlock(); 00083 return result; 00084 } 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function: ButtonNode::get_button_state 00088 // Access: Public 00089 // Description: Returns true if the indicated button (identified by 00090 // its index number) is currently known to be down, or 00091 // false if it is up or unknown. 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE bool ButtonNode:: 00094 get_button_state(int index) const { 00095 _button->lock(); 00096 bool result = _button->get_button_state(index); 00097 _button->unlock(); 00098 return result; 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: ButtonNode::is_button_known 00103 // Access: Public 00104 // Description: Returns true if the state of the indicated button is 00105 // known, or false if we have never heard anything about 00106 // this particular button. 00107 //////////////////////////////////////////////////////////////////// 00108 INLINE bool ButtonNode:: 00109 is_button_known(int index) const { 00110 _button->lock(); 00111 bool result = _button->is_button_known(index); 00112 _button->unlock(); 00113 return result; 00114 }