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