Panda3D
clientDialDevice.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file clientDialDevice.I
10  * @author drose
11  * @date 2001-01-26
12  */
13 
14 /**
15  *
16  */
17 INLINE ClientDialDevice::DialState::
18 DialState() :
19  _offset(0.0),
20  _known(false)
21 {
22 }
23 
24 /**
25  *
26  */
27 INLINE ClientDialDevice::
28 ClientDialDevice(ClientBase *client, const std::string &device_name):
29  ClientDevice(client, get_class_type(), device_name)
30 {
31 }
32 
33 /**
34  * Returns the number of dial dials known to the ClientDialDevice. This
35  * number may change as more dials are discovered.
36  */
37 INLINE int ClientDialDevice::
38 get_num_dials() const {
39  return _dials.size();
40 }
41 
42 /**
43  * Marks that the dial has been offset by the indicated amount. It is the
44  * user's responsibility to ensure that this call is protected within
45  * acquire().
46  */
47 INLINE void ClientDialDevice::
48 push_dial(int index, double offset) {
49  ensure_dial_index(index);
50  nassertv(index >= 0 && index < (int)_dials.size());
51  _dials[index]._offset += offset;
52  _dials[index]._known = true;
53 }
54 
55 /**
56  * Returns the number of complete revolutions of the dial since the last time
57  * read_dial() was called. This is a destructive operation; it is not
58  * possible to read the dial without resetting the counter.
59  *
60  * It is the user's responsibility to ensure that this call is protected
61  * within acquire().
62  */
63 INLINE double ClientDialDevice::
64 read_dial(int index) {
65  if (index >= 0 && index < (int)_dials.size()) {
66  double result = _dials[index]._offset;
67  _dials[index]._offset = 0.0;
68  return result;
69  } else {
70  return 0.0;
71  }
72 }
73 
74 /**
75  * Returns true if the state of the indicated dial dial is known, or false if
76  * we have never heard anything about this particular dial.
77  */
78 INLINE bool ClientDialDevice::
79 is_dial_known(int index) const {
80  if (index >= 0 && index < (int)_dials.size()) {
81  return _dials[index]._known;
82  } else {
83  return false;
84  }
85 }
double read_dial(int index)
Returns the number of complete revolutions of the dial since the last time read_dial() was called.
void push_dial(int index, double offset)
Marks that the dial has been offset by the indicated amount.
bool is_dial_known(int index) const
Returns true if the state of the indicated dial dial is known, or false if we have never heard anythi...
int get_num_dials() const
Returns the number of dial dials known to the ClientDialDevice.
An abstract base class for a family of client device interfaces–including trackers,...
Definition: clientBase.h:43
Any of a number of different devices that might be attached to a ClientBase, including trackers,...
Definition: clientDevice.h:27