/** * Updates the state of the digital data vector. * * @note Digital is on when key is held down. * When key is release, digital goes to off state. */ void SimDigital::updateData() { //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimDigital::updateData()\n"<< vprDEBUG_FLUSH; std::vector<DigitalData> digital_data_sample(mSimKeys.size()); // The digital data that makes up the sample // -- Update digital data --- // for (unsigned int i = 0; i < mSimKeys.size(); i++) { // Set the time for the digital data to the KeyboardMouse timestamp digital_data_sample[i].setTime(mKeyboardMouse->getTimeStamp()); if(checkKeyPair(mSimKeys[i])) // If keys pressed { digital_data_sample[i] = 1; } else { digital_data_sample[i] = 0; } } // Add a sample addDigitalSample(digital_data_sample); swapDigitalBuffers(); }
/** * Updates to the sampled data. * * @pre None. * @post Most recent value is copied over to temp area. */ void TrackdController::updateData() { vprASSERT(mTrackdController != NULL && "Make sure that trackd controller has been initialized"); vprASSERT((unsigned)mTrackdController->numButtons() <= mCurButtons.size()); vprASSERT((unsigned)mTrackdController->numValuators() <= mCurValuators.size() ); for (int i=0;i<mTrackdController->numButtons();i++) { mCurButtons[i] = static_cast<DigitalState::State>(mTrackdController->getButton(i)); mCurButtons[i].setTime(); } for (int j=0;j<mTrackdController->numValuators();j++) { mCurValuators[j] = mTrackdController->getValuator(j); mCurValuators[j].setTime(); } addDigitalSample(mCurButtons); swapDigitalBuffers(); addAnalogSample(mCurValuators); swapAnalogBuffers(); }
/** * Updates to the sampled data. * * @pre None. * @post Most recent value is copied over to temp area. */ void TrackdController::updateData() { vprASSERT(mTrackdController != NULL && "Make sure that trackd controller has been initialized"); vprASSERT((unsigned)mTrackdController->numButtons() <= mCurButtons.size()); vprASSERT((unsigned)mTrackdController->numValuators() <= mCurValuators.size() ); for (int i=0;i<mTrackdController->numButtons();i++) { mCurButtons[i] = mTrackdController->getButton(i); mCurButtons[i].setTime(); } for (int j=0;j<mTrackdController->numValuators();j++) { // TrackdController doesn't have a sample, so we do // normalization here... float f; this->normalizeMinToMax (mTrackdController->getValuator(j), f); mCurValuators[j] = f; mCurValuators[j].setTime(); } addDigitalSample(mCurButtons); swapDigitalBuffers(); addAnalogSample(mCurValuators); swapAnalogBuffers(); }
void ButtonDevice::updateData() { if ( mRunning ) { swapDigitalBuffers(); } }
void SdlJoystick::updateData() { if (mInitialized) { swapAnalogBuffers(); swapDigitalBuffers(); } }
void IntersenseAPI::updateData() { if (isActive()) { swapDigitalBuffers(); swapAnalogBuffers(); swapPositionBuffers(); } }
void DTrack::updateData() { // swap buffered data: if(thrRunning){ swapPositionBuffers(); swapDigitalBuffers(); swapAnalogBuffers(); } }
void Vrpn::updateData() { // Sample the data from the device. // NOTE: This is done here because the readLoop is asyncronous and // if we place it there we get very large buffer sizes. sample(); // Swap it swapPositionBuffers(); swapDigitalBuffers(); swapAnalogBuffers(); }
bool P5GloveWrapper::sample() { P5GloveStandalone::Record rec; bool sample_read = mGlove->readRecordsFromHardware(rec); if ( sample_read ) { // Furst, we set the flexion of the gloves mAnalogP5[0] = rec.thumb; // Thumb (0.0 - 1.0) mAnalogP5[1] = rec.index; // Index mAnalogP5[2] = rec.middle; // Middle mAnalogP5[3] = rec.ring; // Ring mAnalogP5[4] = rec.pinky; // Pinky addAnalogSample(mAnalogP5); swapAnalogBuffers(); // Then, we define the buttons of the glove mDigitalP5[0] = static_cast<DigitalState::State>(rec.buttonA); mDigitalP5[1] = static_cast<DigitalState::State>(rec.buttonB); mDigitalP5[2] = static_cast<DigitalState::State>(rec.buttonC); addDigitalSample(mDigitalP5); swapDigitalBuffers(); // Finally, we set the position of the glove ... const gmtl::AxisAnglef rotation(rec.rotationAngle, rec.rotationAxis[0], rec.rotationAxis[1], rec.rotationAxis[2]); const gmtl::Vec3f translation(static_cast<float>(rec.position[0]), static_cast<float>(rec.position[1]), static_cast<float>(rec.position[2])); gmtl::Matrix44f position = gmtl::makeTrans<gmtl::Matrix44f>(translation); position = position * gmtl::make<gmtl::Matrix44f>(rotation); mPositionP5[0].setValue(position); addPositionSample(mPositionP5); swapPositionBuffers(); } return true; }
// Updates to the sampled data. void DirectXJoystick::updateData() { if ( mInputDrv.poll() ) { // Get button values. We cannot use mCurButtons.size() here because that // value includes any axis buttons that were configured. for ( unsigned int i = 0; i < mInputDrv.getNumButtons(); ++i ) { mCurButtons[i].setValue( mInputDrv.getButtonValue(i) ? gadget::DigitalState::ON : gadget::DigitalState::OFF ); mCurButtons[i].setTime(); } for ( unsigned int i = 0; i < mCurAxes.size(); ++i ) { mCurAxes[i].setTime(); const LONG cur_value(mInputDrv.getAxisValue(i)); mCurAxes[i].setValue(cur_value); // Check for axis buttons. If we have a mapping for axis #i, then we // map the value of the analog axis to two buttons (high and low). If // the analog value is greater than 0.5, then we map the high button // to 1 and the low button to 0. If the analog value is less than // 0.5, then we map the high button to 0 and the low button to 0. // Otherwise, both buttons are 0. if ( mAxisToButtonIndexLookup[i] != -1 ) { const unsigned int low_btn_index = mAxisToButtonIndexLookup[i]; const unsigned int high_btn_index = low_btn_index + 1; vprASSERT(high_btn_index < mCurButtons.size() && "Virtual high button index out of range"); vprASSERT(low_btn_index < mCurButtons.size() && "Virtual low button index out of range"); // Get a normalized form of cur_value for axis button handling. const float norm_value(normalize(cur_value)); // Record the high button as pressed and the low button as not // pressed. if ( norm_value > 0.5f ) { mCurButtons[low_btn_index] = gadget::DigitalState::OFF; mCurButtons[high_btn_index] = gadget::DigitalState::ON; } // Record the high button as not pressed and the low button as // pressed. else if ( norm_value < 0.5f ) { mCurButtons[low_btn_index] = gadget::DigitalState::ON; mCurButtons[high_btn_index] = gadget::DigitalState::OFF; } // Record both buttons as not pressed. else { mCurButtons[low_btn_index] = gadget::DigitalState::OFF; mCurButtons[high_btn_index] = gadget::DigitalState::OFF; } mCurButtons[low_btn_index].setTime(); mCurButtons[high_btn_index].setTime(); } } addDigitalSample(mCurButtons); swapDigitalBuffers(); addAnalogSample(mCurAxes); swapAnalogBuffers(); } }
void P5GloveWrapper::updateData() { swapAnalogBuffers(); swapDigitalBuffers(); swapPositionBuffers(); }