Panda3D

clientDialDevice.I

00001 // Filename: clientDialDevice.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 //     Function: ClientDialDevice::DialState::Constructor
00017 //       Access: Public
00018 //  Description:
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE ClientDialDevice::DialState::
00021 DialState() :
00022   _offset(0.0),
00023   _known(false)
00024 {
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: ClientDialDevice::Constructor
00029 //       Access: Protected
00030 //  Description:
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE ClientDialDevice::
00033 ClientDialDevice(ClientBase *client, const string &device_name):
00034   ClientDevice(client, get_class_type(), device_name)
00035 {
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: ClientDialDevice::get_num_dials
00040 //       Access: Public
00041 //  Description: Returns the number of dial dials known to the
00042 //               ClientDialDevice.  This number may change as
00043 //               more dials are discovered.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE int ClientDialDevice::
00046 get_num_dials() const {
00047   return _dials.size();
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: ClientDialDevice::push_dial
00052 //       Access: Public
00053 //  Description: Marks that the dial has been offset by the indicated
00054 //               amount.  It is the user's responsibility to ensure
00055 //               that this call is protected within acquire().
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE void ClientDialDevice::
00058 push_dial(int index, double offset) {
00059   ensure_dial_index(index);
00060   nassertv(index >= 0 && index < (int)_dials.size());
00061   _dials[index]._offset += offset;
00062   _dials[index]._known = true;
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: ClientDialDevice::read_dial
00067 //       Access: Public
00068 //  Description: Returns the number of complete revolutions of the
00069 //               dial since the last time read_dial() was called.
00070 //               This is a destructive operation; it is not possible
00071 //               to read the dial without resetting the counter.
00072 //
00073 //               It is the user's responsibility to ensure that this
00074 //               call is protected within acquire().
00075 ////////////////////////////////////////////////////////////////////
00076 INLINE double ClientDialDevice::
00077 read_dial(int index) {
00078   if (index >= 0 && index < (int)_dials.size()) {
00079     double result = _dials[index]._offset;
00080     _dials[index]._offset = 0.0;
00081     return result;
00082   } else {
00083     return 0.0;
00084   }
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: ClientDialDevice::is_dial_known
00089 //       Access: Public
00090 //  Description: Returns true if the state of the indicated dial
00091 //               dial is known, or false if we have never heard
00092 //               anything about this particular dial.
00093 ////////////////////////////////////////////////////////////////////
00094 INLINE bool ClientDialDevice::
00095 is_dial_known(int index) const {
00096   if (index >= 0 && index < (int)_dials.size()) {
00097     return _dials[index]._known;
00098   } else {
00099     return false;
00100   }
00101 }
 All Classes Functions Variables Enumerations