Panda3D
analogNode.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 analogNode.I
10  * @author drose
11  * @date 2002-03-12
12  */
13 
14 /**
15  *
16  */
17 INLINE AnalogNode::OutputData::
18 OutputData() {
19  _index = -1;
20  _flip = false;
21 }
22 
23 /**
24  * Returns true if the AnalogNode is valid and connected to a server, false
25  * otherwise.
26  */
27 INLINE bool AnalogNode::
28 is_valid() const {
29  return (_analog != nullptr) && _analog->is_connected();
30 }
31 
32 /**
33  * Returns the number of analog controls known to the AnalogNode. This number
34  * may change as more controls are discovered.
35  */
36 INLINE int AnalogNode::
38  return _analog->get_num_axes();
39 }
40 
41 /**
42  * Returns the current position of indicated analog control identified by its
43  * index number, or 0.0 if the control is unknown. The normal range of a
44  * single control is -1.0 to 1.0.
45  */
46 INLINE double AnalogNode::
47 get_control_state(int index) const {
48  return _analog->get_axis_value(index);
49 }
50 
51 /**
52  * Returns true if the state of the indicated analog control is known, or
53  * false if we have never heard anything about this particular control.
54  */
55 INLINE bool AnalogNode::
56 is_control_known(int index) const {
57  return _analog->is_axis_known(index);
58 }
59 
60 /**
61  * Causes a particular analog control to be placed in the data graph for the
62  * indicated channel. Normally, a mouse uses channels 0 and 1 for the X and Y
63  * information, respectively; channels 0, 1, and 2 are available. If flip is
64  * true, the analog control value will be reversed before outputting it.
65  */
66 INLINE void AnalogNode::
67 set_output(int channel, int index, bool flip) {
68  nassertv(channel >= 0 && channel < max_outputs);
69  _outputs[channel]._index = index;
70  _outputs[channel]._flip = flip;
71 }
72 
73 /**
74  * Removes the output to the data graph associated with the indicated channel.
75  * See set_output().
76  */
77 INLINE void AnalogNode::
78 clear_output(int channel) {
79  nassertv(channel >= 0 && channel < max_outputs);
80  _outputs[channel]._index = -1;
81 }
82 
83 /**
84  * Returns the analog control index that is output to the data graph on the
85  * indicated channel, or -1 if no control is output on that channel. See
86  * set_output().
87  */
88 INLINE int AnalogNode::
89 get_output(int channel) const {
90  nassertr(channel >= 0 && channel < max_outputs, -1);
91  return _outputs[channel]._index;
92 }
93 
94 /**
95  * Returns true if the analog control index that is output to the data graph
96  * on the indicated channel is flipped. See set_output().
97  */
98 INLINE bool AnalogNode::
99 is_output_flipped(int channel) const {
100  nassertr(channel >= 0 && channel < max_outputs, false);
101  return _outputs[channel]._flip;
102 }
bool is_output_flipped(int channel) const
Returns true if the analog control index that is output to the data graph on the indicated channel is...
Definition: analogNode.I:99
void clear_output(int channel)
Removes the output to the data graph associated with the indicated channel.
Definition: analogNode.I:78
int get_output(int channel) const
Returns the analog control index that is output to the data graph on the indicated channel,...
Definition: analogNode.I:89
bool is_valid() const
Returns true if the AnalogNode is valid and connected to a server, false otherwise.
Definition: analogNode.I:28
int get_num_controls() const
Returns the number of analog controls known to the AnalogNode.
Definition: analogNode.I:37
void set_output(int channel, int index, bool flip)
Causes a particular analog control to be placed in the data graph for the indicated channel.
Definition: analogNode.I:67
bool is_control_known(int index) const
Returns true if the state of the indicated analog control is known, or false if we have never heard a...
Definition: analogNode.I:56
double get_control_state(int index) const
Returns the current position of indicated analog control identified by its index number,...
Definition: analogNode.I:47