26AnalogNode(
ClientBase *client,
const std::string &device_name) :
29 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
30 _xy =
new EventStoreVec2(LPoint2(0));
32 nassertv(client !=
nullptr);
34 client->
get_device(ClientAnalogDevice::get_class_type(), device_name);
36 if (device ==
nullptr) {
38 <<
"Unable to open analog device " << device_name <<
"\n";
42 if (!device->is_of_type(ClientAnalogDevice::get_class_type())) {
44 <<
"Inappropriate device type " << device->get_type()
45 <<
" created; expected a ClientAnalogDevice.\n";
60 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
61 _xy =
new EventStoreVec2(LPoint2(0));
63 nassertv(device !=
nullptr);
80write(std::ostream &out,
int indent_level)
const {
81 DataNode::write(out, indent_level);
83 if (_analog !=
nullptr) {
84 _analog->write_axes(out, indent_level + 2);
102 LPoint2 out(0.0f, 0.0f);
103 for (
int i = 0; i < max_outputs; i++) {
104 if (_outputs[i]._index >= 0) {
105 InputDevice::AxisState state = _analog->get_axis(_outputs[i]._index);
107 if (_outputs[i]._flip) {
108 out[i] = -state.value;
110 out[i] = state.value;
116 output.set_data(_xy_output, EventParameter(_xy));
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_valid() const
Returns true if the AnalogNode is valid and connected to a server, false otherwise.
An abstract base class for a family of client device interfaces–including trackers,...
PointerTo< ClientDevice > get_device(TypeHandle device_type, const std::string &device_name)
Returns a ClientDevice pointer that corresponds to the named device of the indicated device type.
Any of a number of different devices that might be attached to a ClientBase, including trackers,...
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
Encapsulates the data generated from (or sent into) any particular DataNode.
The fundamental type of node for the data graph.
void output(std::ostream &out) const
Outputs the Namable.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.