00001 // Filename: clientAnalogDevice.I 00002 // Created by: drose (26Jan01) 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: ClientAnalogDevice::AnalogState::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE ClientAnalogDevice::AnalogState:: 00026 AnalogState() : 00027 _state(0.0), 00028 _known(false) 00029 { 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: ClientAnalogDevice::Constructor 00034 // Access: Protected 00035 // Description: 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE ClientAnalogDevice:: 00038 ClientAnalogDevice(ClientBase *client, const string &device_name): 00039 ClientDevice(client, get_class_type(), device_name) 00040 { 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: ClientAnalogDevice::get_num_controls 00045 // Access: Public 00046 // Description: Returns the number of analog controls known to the 00047 // ClientAnalogDevice. This number may change as 00048 // more controls are discovered. 00049 //////////////////////////////////////////////////////////////////// 00050 INLINE int ClientAnalogDevice:: 00051 get_num_controls() const { 00052 return _controls.size(); 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: ClientAnalogDevice::set_control_state 00057 // Access: Public 00058 // Description: Sets the state of the indicated analog index. The 00059 // caller should ensure that lock() is in effect while 00060 // this call is made. This should be a number in the 00061 // range -1.0 to 1.0, representing the current position 00062 // of the control within its total range of movement. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE void ClientAnalogDevice:: 00065 set_control_state(int index, double state) { 00066 ensure_control_index(index); 00067 nassertv(index >= 0 && index < (int)_controls.size()); 00068 _controls[index]._state = state; 00069 _controls[index]._known = true; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: ClientAnalogDevice::get_control_state 00074 // Access: Public 00075 // Description: Returns the current position of indicated analog 00076 // control (identified by its index number), or 0.0 if 00077 // the control is unknown. The normal range of a single 00078 // control is -1.0 to 1.0. 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE double ClientAnalogDevice:: 00081 get_control_state(int index) const { 00082 if (index >= 0 && index < (int)_controls.size()) { 00083 return _controls[index]._state; 00084 } else { 00085 return 0.0; 00086 } 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: ClientAnalogDevice::is_control_known 00091 // Access: Public 00092 // Description: Returns true if the state of the indicated analog 00093 // control is known, or false if we have never heard 00094 // anything about this particular control. 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE bool ClientAnalogDevice:: 00097 is_control_known(int index) const { 00098 if (index >= 0 && index < (int)_controls.size()) { 00099 return _controls[index]._known; 00100 } else { 00101 return false; 00102 } 00103 }