forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalogNode.I
More file actions
102 lines (93 loc) · 2.75 KB
/
analogNode.I
File metadata and controls
102 lines (93 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file analogNode.I
* @author drose
* @date 2002-03-12
*/
/**
*
*/
INLINE AnalogNode::OutputData::
OutputData() {
_index = -1;
_flip = false;
}
/**
* Returns true if the AnalogNode is valid and connected to a server, false
* otherwise.
*/
INLINE bool AnalogNode::
is_valid() const {
return (_analog != nullptr) && _analog->is_connected();
}
/**
* Returns the number of analog controls known to the AnalogNode. This number
* may change as more controls are discovered.
*/
INLINE int AnalogNode::
get_num_controls() const {
return _analog->get_num_axes();
}
/**
* Returns the current position of indicated analog control identified by its
* index number, or 0.0 if the control is unknown. The normal range of a
* single control is -1.0 to 1.0.
*/
INLINE double AnalogNode::
get_control_state(int index) const {
return _analog->get_axis_value(index);
}
/**
* Returns true if the state of the indicated analog control is known, or
* false if we have never heard anything about this particular control.
*/
INLINE bool AnalogNode::
is_control_known(int index) const {
return _analog->is_axis_known(index);
}
/**
* Causes a particular analog control to be placed in the data graph for the
* indicated channel. Normally, a mouse uses channels 0 and 1 for the X and Y
* information, respectively; channels 0, 1, and 2 are available. If flip is
* true, the analog control value will be reversed before outputting it.
*/
INLINE void AnalogNode::
set_output(int channel, int index, bool flip) {
nassertv(channel >= 0 && channel < max_outputs);
_outputs[channel]._index = index;
_outputs[channel]._flip = flip;
}
/**
* Removes the output to the data graph associated with the indicated channel.
* See set_output().
*/
INLINE void AnalogNode::
clear_output(int channel) {
nassertv(channel >= 0 && channel < max_outputs);
_outputs[channel]._index = -1;
}
/**
* Returns the analog control index that is output to the data graph on the
* indicated channel, or -1 if no control is output on that channel. See
* set_output().
*/
INLINE int AnalogNode::
get_output(int channel) const {
nassertr(channel >= 0 && channel < max_outputs, -1);
return _outputs[channel]._index;
}
/**
* Returns true if the analog control index that is output to the data graph
* on the indicated channel is flipped. See set_output().
*/
INLINE bool AnalogNode::
is_output_flipped(int channel) const {
nassertr(channel >= 0 && channel < max_outputs, false);
return _outputs[channel]._flip;
}