示例#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 == "button")
                {
                    GetKeyObject(key).Pressed(int.Parse(j["value"].str != null ? j["value"].str : "0"));
                }
                else if (type == "vector")
                {
                    string lKey = key.ToLower();
                    if (!Axis.ContainsKey(lKey))
                    {
                        Axis.Add(lKey, VectorFromJSON(j["value"]));
                    }
                    else
                    {
                        Axis[lKey] = VectorFromJSON(j["value"]);
                    }
                }
            }
        }
示例#2
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);
                }
            }
        }
示例#3
0
        public LinuxJoyStick()
        {
            Process calibratejoy = Process.Start("/usr/bin/jscal", "-s 5,1,1,136,137,14127751,13765501,1,1,129,130,14127751,14127751,1,1,137,138,13094013,15789839,1,0,128,128,2147483647,2147483647,1,1,132,133,14509582,15789839 /dev/input/js0");

//			calibratejoy.StartInfo.RedirectStandardError = true;
//			calibratejoy.StartInfo.RedirectStandardOutput = true;
//			calibratejoy.StartInfo.RedirectStandardInput = true;
//			calibratejoy.StartInfo.UseShellExecute = true;
            //	Console.WriteLine (calibratejoy.StandardOutput.ReadToEnd () + calibratejoy.StandardError.ReadToEnd ());

            calibratejoy.Start();

            calibratejoy.WaitForExit();

            Open("/dev/input/js0");
            bgworker.RunWorkerAsync();
            for (int i = 0; i < 8; i++)
            {
                Axis.Add(0);
            }
        }