//public GameObject cube;

    // Start is called before the first frame update
    void Start()
    {
        KaiSDK.Initialise("4C4C4544-0031-3910-805A-CAC04F533332", "qwerty");
        KaiSDK.Connect();


        KaiSDK.GetConnectedKais();

        //cube.GetComponent<Transform>();

        while ((k1 = KaiSDK.GetKaiByID(0)) == null)
        {
            ;
        }

        Debug.Log("Connected...");

        Capabilities();

        Debug.Log(k1.Capabilities);

        k1.GyroscopeData += gyro;

        k1.Gesture += gestr;

        k1.PYRData += pyr;

        k1.QuaternionData += quat;

        k1.MagnetometerData += mag;

        k1.AccelerometerData += accel;

        k1.FingerPositionalData += fpd;
    }
Exemple #2
0
        private static void DecodeKaiConnected(JObject input)
        {
            var kaiID = input[Constants.KaiID].ToObject <int>();
            var hand  = input[Constants.Hand]?.ToObject <string>();           // will not be optional in future

            var defaultKai =
                input[Constants.DefaultKai]?.ToObject <bool>() ??
                input[Constants.Default]?.ToObject <bool>();
            var defaultLeftKai =
                input[Constants.DefaultLeftKai]?.ToObject <bool>() ??
                input[Constants.DefaultLeft]?.ToObject <bool>();
            var defaultRightKai =
                input[Constants.DefaultRightKai]?.ToObject <bool>() ??
                input[Constants.DefaultRight]?.ToObject <bool>();

            var kaiSerialNumber = input[Constants.KaiSerialNumber]?.ToObject <bool>();            // will not be optional in future

            //var kaiParsed = KaiObjectParsed.Parse(input);
            if (!Enum.TryParse(hand, true, out Hand handEnum))
            {
                handEnum = Hand.Left;
            }

            if (defaultKai == true)
            {
                DefaultKai.KaiID = kaiID;
                DefaultKai.Hand  = handEnum;
            }

            if (defaultLeftKai == true)
            {
                DefaultLeftKai.KaiID = kaiID;
                DefaultLeftKai.Hand  = Hand.Left;
            }

            if (defaultRightKai == true)
            {
                DefaultRightKai.KaiID = kaiID;
                DefaultRightKai.Hand  = Hand.Right;
            }

            ConnectedKais[kaiID] = new Kai
            {
                KaiID = kaiID,
                Hand  = handEnum
            };

            if (defaultKai == true || defaultLeftKai == true || defaultRightKai == true)
            {
                ResetDefaultCapabilities();
            }
        }
Exemple #3
0
        /// <summary>
        /// Unset the Kai's capabilities and subscribes to that data
        /// </summary>
        /// <param name="capabilities">The capabilities to set the Kai to</param>
        /// <param name="kai">The kai to set the capabilities to</param>
        public static void UnsetCapabilities(Kai kai, KaiCapabilities capabilities)
        {
            kai.Capabilities &= ~capabilities;             // value = value AND NOT parameter. This will unset the parameter from the value
            if (!Authenticated)
            {
                return;
            }

            var json = new JObject
            {
                [Constants.Type] = Constants.SetCapabilities
            };

            if (ReferenceEquals(kai, DefaultKai))
            {
                json.Add(Constants.KaiID, Constants.Default);
            }
            else if (ReferenceEquals(kai, DefaultLeftKai))
            {
                json.Add(Constants.KaiID, Constants.DefaultLeft);
            }
            else if (ReferenceEquals(kai, DefaultRightKai))
            {
                json.Add(Constants.KaiID, Constants.DefaultRight);
            }
            else
            {
                json.Add(Constants.KaiID, kai.KaiID);
            }

            if (capabilities.HasFlag(KaiCapabilities.GestureData))
            {
                json.Add(Constants.GestureData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.LinearFlickData))
            {
                json.Add(Constants.LinearFlickData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.FingerShortcutData))
            {
                json.Add(Constants.FingerShortcutData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.FingerPositionalData))
            {
                json.Add(Constants.FingerPositionalData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.PYRData))
            {
                json.Add(Constants.PYRData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.QuaternionData))
            {
                json.Add(Constants.QuaternionData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.AccelerometerData))
            {
                json.Add(Constants.AccelerometerData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.GyroscopeData))
            {
                json.Add(Constants.GyroscopeData, false);
            }

            if (capabilities.HasFlag(KaiCapabilities.MagnetometerData))
            {
                json.Add(Constants.MagnetometerData, false);
            }

            Send(json.ToString(Formatting.None));
        }
Exemple #4
0
        /// <summary>
        /// Set the Kai's capabilities and subscribes to that data
        /// </summary>
        /// <param name="capabilities">The capabilities to set the Kai to</param>
        /// <param name="kai">The kai to set the capabilities to</param>
        public static void SetCapabilities(Kai kai, KaiCapabilities capabilities)
        {
            kai.Capabilities |= capabilities;
            if (!Authenticated)
            {
                return;
            }

            var json = new JObject
            {
                [Constants.Type] = Constants.SetCapabilities
            };

            if (ReferenceEquals(kai, DefaultKai))
            {
                json.Add(Constants.KaiID, Constants.Default);
            }
            else if (ReferenceEquals(kai, DefaultLeftKai))
            {
                json.Add(Constants.KaiID, Constants.DefaultLeft);
            }
            else if (ReferenceEquals(kai, DefaultRightKai))
            {
                json.Add(Constants.KaiID, Constants.DefaultRight);
            }
            else
            {
                json.Add(Constants.KaiID, kai.KaiID);
            }

            if (capabilities.HasFlag(KaiCapabilities.GestureData))
            {
                json.Add(Constants.GestureData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.LinearFlickData))
            {
                json.Add(Constants.LinearFlickData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.FingerShortcutData))
            {
                json.Add(Constants.FingerShortcutData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.FingerPositionalData))
            {
                json.Add(Constants.FingerPositionalData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.PYRData))
            {
                json.Add(Constants.PYRData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.QuaternionData))
            {
                json.Add(Constants.QuaternionData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.AccelerometerData))
            {
                json.Add(Constants.AccelerometerData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.GyroscopeData))
            {
                json.Add(Constants.GyroscopeData, true);
            }

            if (capabilities.HasFlag(KaiCapabilities.MagnetometerData))
            {
                json.Add(Constants.MagnetometerData, true);
            }

            Send(json.ToString(Constants.JsonFormatting));
        }