Pose::Pose(const myo::Pose& pose) { switch (pose.type()) { case myo::Pose::rest: type_ = rest; break; case myo::Pose::fist: type_ = fist; break; case myo::Pose::waveIn: type_ = waveIn; break; case myo::Pose::waveOut: type_ = waveOut; break; case myo::Pose::fingersSpread: type_ = fingersSpread; break; case myo::Pose::doubleTap: type_ = doubleTap; break; default: type_ = unknown; break; } }
jobject getJavaPose(JNIEnv * env, myo::Pose pose) { std::string poseString; switch(pose.type()) { case myo::Pose::rest: poseString = "Rest"; break; case myo::Pose::fist: poseString = "Fist"; break; case myo::Pose::waveIn: poseString = "WaveIn"; break; case myo::Pose::waveOut: poseString = "WaveOut"; break; case myo::Pose::fingersSpread: poseString = "FingersSpread"; break; case myo::Pose::doubleTap: poseString = "DoubleTap"; break; case myo::Pose::unknown: default: poseString = "Unknown"; break; }; jclass poseClass = env->FindClass("net/johnluetke/myojni/jni/Pose"); jfieldID poseFieldID = env->GetStaticFieldID(poseClass, poseString.c_str(), "Lnet/johnluetke/myojni/jni/Pose;"); jobject javaPoseObject = env->GetStaticObjectField(poseClass, poseFieldID); return javaPoseObject; }
void vrpn_Tracker_ThalmicLabsMyo::onPose(myo::Myo* myo, uint64_t timestamp, myo::Pose pose) { if (myo != _myo) return; vrpn_gettimeofday(&_timestamp, NULL); double dt = vrpn_TimevalDurationSeconds(_timestamp, vrpn_Button::timestamp); vrpn_Button::timestamp = _timestamp; // std::cout << "Myo switched to pose " << pose.toString() << "." << std::endl; buttons[0] = _locked; // reset all buttons to 0. Maybe we should only do this if rest is on ? for (int i = 1; i < libmyo_num_poses + 1; ++i) buttons[i] = 0; buttons[pose.type() + 1] = 1; vrpn_Button::report_changes(); }
void myouse::MyouseListener::onPose(myo::Myo * myo, uint64_t timestamp, myo::Pose pose) { std::cout << "Pose: " << pose << std::endl; switch (pose.type()) { case myo::Pose::rest: unclickLeft(); unclickRight(); unclickMiddle(); isScrolling = false; break; case myo::Pose::fist: clickLeft(); break; case myo::Pose::waveIn: clickMiddle(); break; case myo::Pose::waveOut: isScrolling = true; break; case myo::Pose::fingersSpread: clickRight(); break; case myo::Pose::thumbToPinky: isEnabled = !isEnabled; myo->vibrate(myo::Myo::vibrationMedium); if (isEnabled) { std::cout << "Myouse enabled." << std::endl; rollOffset = rawRoll; pitchOffset = rawPitch; yawOffset = rawYaw; } else { std::cout << "Myouse disabled." << std::endl; } break; default: break; } }