Example #1
0
        /// <summary>
        /// Processes the data
        /// </summary>
        public void Process(JToken data)
        {
            JSONObject json = new JSONObject(data.ToString());

            foreach (string key in json.keys)
            {
                JSONObject j = json[key];

                string type = j["type"].str;

                if (type == "tap-button" || type == "hold-button")
                {
                    GetKeyObject(key).HandleData(j);
                }
                else if (type == "vector")
                {
                    string lKey = key.ToLower();
                    if (!Axis.ContainsKey(lKey))
                    {
                        Axis.Add(lKey, VectorFromJSON(j["value"]));
                    }
                    else
                    {
                        Axis[lKey] = VectorFromJSON(j["value"]);
                    }
                }
                else if (type == "gyro")
                {
                    Orientation.HandleData(j["value"]);
                    Motion.HandleData(j["value"]);
                }
                else if (type == "swipe")
                {
                    Swipe.HandleData(j);
                }
                else if (type == "pan")
                {
                    Pan.HandleData(j);
                }
            }
        }