コード例 #1
0
    // 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
    }
コード例 #2
0
ファイル: Myo.cs プロジェクト: kaivan29/MyoHero
        internal Myo(Hub hub, IntPtr handle)
        {
            Debug.Assert(handle != IntPtr.Zero, "Cannot construct Myo instance with null pointer.");

            _hub = hub;
            _handle = handle;
        }
コード例 #3
0
ファイル: Myo.cs プロジェクト: Ozhogi/WearablePack-Myo
        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);
        }
コード例 #4
0
ファイル: ThalmicHub.cs プロジェクト: nicksahler/MyoBender
 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);
 }
コード例 #5
0
ファイル: ThalmicHub.cs プロジェクト: kaivan29/MyoHero
    // 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();
    }
コード例 #6
0
ファイル: ThalmicHub.cs プロジェクト: cchestnut/myo-unity-1
    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);
    }
コード例 #7
0
ファイル: ThalmicHub.cs プロジェクト: st3veV/myo-unity
    // 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
    }
コード例 #8
0
ファイル: Program.cs プロジェクト: kdedakia/MyoPhysio
        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();
        }
コード例 #9
0
 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);
 }
コード例 #10
0
ファイル: ThalmicHub.cs プロジェクト: adam-bratin/Space-Story
 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;
 }
コード例 #11
0
 void OnApplicationQuit()
 {
     if (_hub != null) {
         _hub.Dispose ();
         _hub = null;
     }
 }
コード例 #12
0
    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;
    }
コード例 #13
0
 void OnApplicationQuit()
 {
     if (_hub != null) {
     #if UNITY_EDITOR || !UNITY_IOS
         _hub.Dispose ();
         _hub = null;
     #endif
     }
 }