예제 #1
0
        internal void updateAccelerometer(AccelState accelState)
        {
            JToken key = this.jsonObj.GetValue("AccelX");
            if (key != null)
            {
                string handle = key.ToString().ToLower();

                if (handle.Length > 4 && handle.Substring(0, 4).Equals("360."))
                {
                    this.xinputUpdateAnalog(handle.Substring(4), accelState.Values.X * -0.5 + 0.5);
                }
            }

            key = this.jsonObj.GetValue("AccelY");
            if (key != null)
            {
                string handle = key.ToString().ToLower();

                if (handle.Length > 4 && handle.Substring(0, 4).Equals("360."))
                {
                    this.xinputUpdateAnalog(handle.Substring(4), accelState.Values.Y * -0.5 + 0.5);
                }
            }

            key = this.jsonObj.GetValue("AccelZ");
            if (key != null)
            {
                string handle = key.ToString().ToLower();

                if (handle.Length > 4 && handle.Substring(0, 4).Equals("360."))
                {
                    this.xinputUpdateAnalog(handle.Substring(4), accelState.Values.Z * -0.5 + 0.5);
                }
            }
        }
예제 #2
0
        public void updateAccelerometer(AccelState accelState)
        {
            KeymapOutConfig outConfig;
            if (this.config.TryGetValue("AccelX+", out outConfig))
            {
                if (accelState.Values.X > 0)
                {
                    updateStickHandlers(outConfig, accelState.Values.X);
                }
                else if (accelState.Values.X == 0)
                {
                    updateStickHandlers(outConfig, 0);
                }

                if (accelState.Values.X * 2 > outConfig.Threshold && !PressedButtons["AccelX+"])
                {
                    PressedButtons["AccelX+"] = true;
                    this.executeButtonDown("AccelX+");
                }
                else if (accelState.Values.X * 2 < outConfig.Threshold && PressedButtons["AccelX+"])
                {
                    PressedButtons["AccelX+"] = false;
                    this.executeButtonUp("AccelX+");
                }
            }
            if (this.config.TryGetValue("AccelX-", out outConfig))
            {
                if (accelState.Values.X < 0)
                {
                    updateStickHandlers(outConfig, accelState.Values.X * -1);
                }
                else if (accelState.Values.X == 0)
                {
                    updateStickHandlers(outConfig, 0);
                }

                if (accelState.Values.X * -2 > outConfig.Threshold && !PressedButtons["AccelX-"])
                {
                    PressedButtons["AccelX-"] = true;
                    this.executeButtonDown("AccelX-");
                }
                else if (accelState.Values.X * -2 < outConfig.Threshold && PressedButtons["AccelX-"])
                {
                    PressedButtons["AccelX-"] = false;
                    this.executeButtonUp("AccelX-");
                }
            }
            if (this.config.TryGetValue("AccelY+", out outConfig))
            {
                if (accelState.Values.Y > 0)
                {
                    updateStickHandlers(outConfig, accelState.Values.Y);
                }
                else if (accelState.Values.Y == 0)
                {
                    updateStickHandlers(outConfig, 0);
                }

                if (accelState.Values.Y * 2 > outConfig.Threshold && !PressedButtons["AccelY+"])
                {
                    PressedButtons["AccelY+"] = true;
                    this.executeButtonDown("AccelY+");
                }
                else if (accelState.Values.Y * 2 < outConfig.Threshold && PressedButtons["AccelY+"])
                {
                    PressedButtons["AccelY+"] = false;
                    this.executeButtonUp("AccelY+");
                }
            }
            if (this.config.TryGetValue("AccelY-", out outConfig))
            {
                if (accelState.Values.Y < 0)
                {
                    updateStickHandlers(outConfig, accelState.Values.Y * -1);
                }
                else if (accelState.Values.Y == 0)
                {
                    updateStickHandlers(outConfig, 0);
                }

                if (accelState.Values.Y * -2 > outConfig.Threshold && !PressedButtons["AccelY-"])
                {
                    PressedButtons["AccelY-"] = true;
                    this.executeButtonDown("AccelY-");
                }
                else if (accelState.Values.Y * -2 < outConfig.Threshold && PressedButtons["AccelY-"])
                {
                    PressedButtons["AccelY-"] = false;
                    this.executeButtonUp("AccelY-");
                }
            }
            if (this.config.TryGetValue("AccelZ+", out outConfig))
            {
                if (accelState.Values.Z > 0)
                {
                    updateStickHandlers(outConfig, accelState.Values.Z);
                }
                else if (accelState.Values.Z == 0)
                {
                    updateStickHandlers(outConfig, 0);
                }

                if (accelState.Values.Z * 2 > outConfig.Threshold && !PressedButtons["AccelZ+"])
                {
                    PressedButtons["AccelZ+"] = true;
                    this.executeButtonDown("AccelZ+");
                }
                else if (accelState.Values.Z * 2 < outConfig.Threshold && PressedButtons["AccelZ+"])
                {
                    PressedButtons["AccelZ+"] = false;
                    this.executeButtonUp("AccelZ+");
                }
            }
            if (this.config.TryGetValue("AccelZ-", out outConfig))
            {
                if (accelState.Values.Z < 0)
                {
                    updateStickHandlers(outConfig, accelState.Values.Z * -1);
                }
                else if (accelState.Values.Z == 0)
                {
                    updateStickHandlers(outConfig, 0);
                }

                if (accelState.Values.Z * -2 > outConfig.Threshold && !PressedButtons["AccelZ-"])
                {
                    PressedButtons["AccelZ-"] = true;
                    this.executeButtonDown("AccelZ-");
                }
                else if (accelState.Values.Z * -2 < outConfig.Threshold && PressedButtons["AccelZ-"])
                {
                    PressedButtons["AccelZ-"] = false;
                    this.executeButtonUp("AccelZ-");
                }
            }
        }