Example #1
0
        void m_handle(vrpn_BUTTONSTATESCB const &info) {
            auto maxChannel =
                m_all ? info.num_buttons - 1 : m_sensors.getValue();
            if (!m_all &&
                m_sensors.getIntersection(RangeType::RangeZeroTo(maxChannel))
                    .empty()) {
                // early out if we're looking for just a single channel number
                // that isn't in this report.
                return;
            }
            if (m_all) {
                if (m_sensors.empty()) {
                    m_sensors.setRangeMaxMin(maxChannel);
                } else {
                    m_sensors.extendRangeToMax(maxChannel);
                }
            }
            OSVR_TimeValue timestamp;
            osvrStructTimevalToTimeValue(&timestamp, &(info.msg_time));

            for (auto sensor : m_sensors.getIntersection(
                     RangeType::RangeZeroTo(maxChannel))) {
                m_report(timestamp, sensor, info.states[sensor]);
            }
        }
        void m_handle(vrpn_ANALOGCB const &info) {
            auto maxChannel = m_all ? info.num_channel - 1 : m_sensors.getValue();
            if (m_sensors.isValue() && (maxChannel < m_sensors.getValue())) {
                // early out if we're looking for just a single channel number
                // that isn't in this report.
                return;
            }
            OSVR_TimeValue timestamp;
            osvrStructTimevalToTimeValue(&timestamp, &(info.msg_time));

            if (m_all) {
                if (m_sensors.empty()) {
                    m_sensors.setRangeMaxMin(maxChannel);
                } else {
                    m_sensors.extendRangeToMax(maxChannel);
                }
            }
            for (auto sensor : m_sensors.getIntersection(
                     RangeType::RangeZeroTo(maxChannel))) {
                OSVR_AnalogReport report;
                report.sensor = sensor;
                /// @todo handle transform?
                report.state = info.channel[report.sensor];
                for (auto &iface : m_interfaces) {
                    iface->triggerCallbacks(timestamp, report);
                }
            }
        }
Example #3
0
        void m_handle(vrpn_BUTTONCB const &info) {
            if (!m_all && !m_sensors.contains(info.button)) {
                return;
            }

            OSVR_TimeValue timestamp;
            osvrStructTimevalToTimeValue(&timestamp, &(info.msg_time));

            m_report(timestamp, info.button, info.state);
        }