44 #include <vrpn_Analog.h>
45 #include <boost/lexical_cast.hpp>
46 #include <boost/any.hpp>
47 #include <boost/variant/get.hpp>
48 #include <json/value.h>
49 #include <json/reader.h>
61 boost::optional<int> sensor,
62 common::InterfaceList &ifaces)
63 : m_remote(
new vrpn_Analog_Remote(src, conn.get())),
64 m_internals(ifaces), m_all(!sensor.is_initialized()) {
65 m_remote->register_change_handler(
this, &VRPNAnalogHandler::handle);
66 OSVR_DEV_VERBOSE(
"Constructed an AnalogHandler for " << src);
68 if (sensor.is_initialized()) {
69 m_sensors.setValue(*sensor);
73 m_remote->unregister_change_handler(
this,
74 &VRPNAnalogHandler::handle);
77 static void VRPN_CALLBACK handle(
void *userdata, vrpn_ANALOGCB info) {
81 virtual void update() { m_remote->mainloop(); }
84 void m_handle(vrpn_ANALOGCB
const &info) {
86 m_all ? info.num_channel - 1 : m_sensors.getValue();
87 if (m_sensors.isValue() && (maxChannel < m_sensors.getValue())) {
96 if (m_sensors.empty()) {
97 m_sensors.setRangeMaxMin(maxChannel);
99 m_sensors.extendRangeToMax(maxChannel);
102 for (
auto sensor : m_sensors.getIntersection(
103 RangeType::RangeZeroTo(maxChannel))) {
111 unique_ptr<vrpn_Analog_Remote> m_remote;
117 AnalogRemoteFactory::AnalogRemoteFactory(
125 shared_ptr<RemoteHandler> ret;
127 if (source.hasTransform()) {
129 "Ignoring transform found on route for Analog data!");
132 auto const &devElt = source.getDeviceElement();
136 devElt.getFullDeviceName().c_str(),
137 source.getSensorNumber(), ifaces));
The result of resolving a tree node to a device: either an original source to connect to...
int32_t sensor
Identifies the sensor/channel that the report comes from.
Header including PathTree.h and all additional headers needed to define related types.
Header to bring unique_ptr into the osvr namespace.
OSVR_AnalogState state
The analog state.
void setStateAndTriggerCallbacks(const OSVR_TimeValue ×tamp, ReportType const &report)
Set state and call callbacks for a report type.
void osvrStructTimevalToTimeValue(OSVR_TimeValue *dest, const struct timeval *src)
Converts from a TimeValue struct to your system's struct timeval.
Internal, configured header file for verbosity macros.
Header for interoperation between the Eigen math library, the internal mini math library, and VRPN's quatlib.
shared_ptr< RemoteHandler > operator()(common::OriginalSource const &source, common::InterfaceList &ifaces, common::ClientContext &ctx)
Report type for a callback on an analog interface.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Base class for remote device handler classes.
Class holding shared implementation between the various handlers. Primarily used to avoid the need fo...