// Reset the hub. This function is typically used if initialization failed to attempt to initialize again (e.g. // after asking the user to ensure that Myo Connect is running). public bool ResetHub() { if (_hub != null) { #if UNITY_EDITOR || !UNITY_IPHONE _hub.Dispose (); _hub = null; #endif foreach (ThalmicMyo myo in _myos) { myo.internalMyo = null; myo.identifier = null; } } #if UNITY_ANDROID && !UNITY_EDITOR AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var unityActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); // The Hub needs to be initialized on the Android UI thread. unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() => { createHub(); })); return true; // Return true assuming the hub constructor will succeed. Debug.Log if it fails. #else return createHub(); #endif }
internal Myo(Hub hub, IntPtr handle) { Debug.Assert(handle != IntPtr.Zero, "Cannot construct Myo instance with null pointer."); _hub = hub; _handle = handle; }
internal Myo(Hub hub, IntPtr handle) { Debug.Assert(handle != IntPtr.Zero, "Cannot construct Myo instance with null pointer."); _hub = hub; _handle = handle; _trained = (libmyo.training_load_profile(_handle, null, IntPtr.Zero) == libmyo.Result.Success); }
private bool createHub() { try { _hub = new Thalmic.Myo.Hub(applicationIdentifier, hub_MyoPaired); } catch (System.Exception) { Debug.Log("ThalmicHub failed to initialize."); return(false); } return(true); }
// Reset the hub. This function is typically used if initialization failed to attempt to initialize again (e.g. // after asking the user to ensure that Myo Connect is running). public bool ResetHub() { if (_hub != null) { _hub.Dispose (); _hub = null; foreach (ThalmicMyo myo in _myos) { myo.internalMyo = null; } } return createHub(); }
private bool createHub() { #if UNITY_EDITOR || !UNITY_IPHONE try { _hub = new Thalmic.Myo.Hub(applicationIdentifier, hub_MyoPaired); _hub.SetLockingPolicy(lockingPolicy); } catch (System.Exception e) { Debug.Log("ThalmicHub failed to initialize." + e.ToString()); return(false); } #endif return(true); }
// Reset the hub. This function is typically used if initialization failed to attempt to initialize again (e.g. // after asking the user to ensure that Myo Connect is running). public bool ResetHub() { if (_hub != null) { _hub.Dispose (); _hub = null; foreach (ThalmicMyo myo in _myos) { myo.internalMyo = null; } } #if UNITY_ANDROID && !UNITY_EDITOR return true; #else return createHub(); #endif }
static void Main(string[] args) { //Step 1: Create all the things Hub hub = new Hub(); SimpleDeviceListener deviceListener = new SimpleDeviceListener(); SimpleDeviceListener motionDataListener = new SimpleDeviceListener(); motionDataListener.PoseStart += (object sender, PoseEventArgs e) => { Motion deviceMotion = hub.DefaultDevice.Motion; Double angularVelocity = angularVelocityMagnitude(deviceMotion.AngularVelocity.X, deviceMotion.AngularVelocity.X, deviceMotion.AngularVelocity.Z); Quaternion quat = deviceMotion.Orientation; if (quat.Pitch.Degrees >= 88.0 && quat.Pitch.Degrees <= 92.0) { startHold(); } //quat. }; //Step 2: Hook up the handers for the events you care about deviceListener.PoseStart += (object sender, PoseEventArgs e) => { if (e.Pose.Type == PoseType.Fist) { Console.WriteLine("HADO"); } }; deviceListener.PoseFinish += (object sender, PoseEventArgs e) => { if (e.Pose.Type == PoseType.Fist) { Console.WriteLine("UKEN"); } }; //Step 3: Add the listener to the default device hub.DefaultDevice.AddListener(deviceListener); hub.DefaultDevice.AddListener(motionDataListener); Console.WriteLine("Round 1: FIGHT"); Console.WriteLine("Press enter to Quit"); Console.ReadLine(); }
private bool createHubAndPair() { try { _hub = new Thalmic.Myo.Hub(); } catch (System.Exception) { Debug.Log("ThalmicHub failed to initialize."); return(false); } _hub.Paired += hub_MyoPaired; if (pairingMethod == PairingMethod.Any) { _hub.PairWithAnyMyos((uint)_myos.Count); } else if (pairingMethod == PairingMethod.Adjacent) { _hub.PairWithAdjacentMyos((uint)_myos.Count); } else if (pairingMethod == PairingMethod.ByMacAddress) { _hub.PairByMacAddress(Thalmic.Myo.libmyo.string_to_mac_address(pairingMacAddress)); } return(true); }
private bool createHub () { try { _hub = new Thalmic.Myo.Hub (applicationIdentifier, hub_MyoPaired); } catch (System.Exception) { Debug.Log ("ThalmicHub failed to initialize."); return false; } return true; }
void OnApplicationQuit() { if (_hub != null) { _hub.Dispose (); _hub = null; } }
private bool createHub () { //#if UNITY_EDITOR || !UNITY_IPHONE #if UNITY_EDITOR try { _hub = new Thalmic.Myo.Hub (applicationIdentifier, hub_MyoPaired); _hub.SetLockingPolicy (lockingPolicy); } catch (System.Exception e) { Debug.Log ("ThalmicHub failed to initialize." + e.ToString()); return false; } #endif return true; }
void OnApplicationQuit() { if (_hub != null) { #if UNITY_EDITOR || !UNITY_IOS _hub.Dispose (); _hub = null; #endif } }