Exemple #1
0
        public override void UpdateFirst()
        {
            base.UpdateFirst();

            AxisLeft.Enabled       = Enabled;
            AxisRight.Enabled      = Enabled;
            AxisDPad.Enabled       = Enabled;
            Up.Enabled             = Enabled;
            Down.Enabled           = Enabled;
            Left.Enabled           = Enabled;
            Right.Enabled          = Enabled;
            A.Enabled              = Enabled;
            B.Enabled              = Enabled;
            X.Enabled              = Enabled;
            Y.Enabled              = Enabled;
            R1.Enabled             = Enabled;
            R2.Enabled             = Enabled;
            L1.Enabled             = Enabled;
            L2.Enabled             = Enabled;
            Start.Enabled          = Enabled;
            Select.Enabled         = Enabled;
            Home.Enabled           = Enabled;
            AxisLeftClick.Enabled  = Enabled;
            AxisRightClick.Enabled = Enabled;

            Up.UpdateFirst();
            Down.UpdateFirst();
            Left.UpdateFirst();
            Right.UpdateFirst();
            A.UpdateFirst();
            B.UpdateFirst();
            X.UpdateFirst();
            Y.UpdateFirst();
            R1.UpdateFirst();
            R2.UpdateFirst();
            L1.UpdateFirst();
            L2.UpdateFirst();
            Start.UpdateFirst();
            Select.UpdateFirst();
            Home.UpdateFirst();
            AxisLeftClick.UpdateFirst();
            AxisRightClick.UpdateFirst();
            AxisLeft.UpdateFirst();
            AxisRight.UpdateFirst();
            AxisDPad.UpdateFirst();

            // The recording and playback code is pretty ugly, sorry :I
            if (Recording)
            {
                foreach (var b in buttonNames)
                {
                    if (b.Value.Pressed || b.Value.Released)
                    {
                        if (!recordedButtonData.ContainsKey(recordingTimer))
                        {
                            recordedButtonData.Add(recordingTimer, new Dictionary <string, int>());
                        }
                    }
                    if (b.Value.Pressed)
                    {
                        recordedButtonData[recordingTimer].Add(b.Key, 1);
                    }
                    if (b.Value.Released)
                    {
                        recordedButtonData[recordingTimer].Add(b.Key, 0);
                    }
                }

                if (RecordAxes)
                {
                    if (AxisLeft.HasInput && (AxisLeft.X != AxisLeft.LastX || AxisLeft.Y != AxisLeft.LastY))
                    {
                        recordedAxisData[0].Add(recordingTimer, new AxisData {
                            X = AxisLeft.X, Y = AxisLeft.Y
                        });
                        //Console.WriteLine("Time: " + recordingTimer + " X: " + AxisLeft.X + " Y: " + AxisLeft.Y);
                    }

                    if (AxisRight.HasInput && (AxisRight.X != AxisRight.LastX || AxisRight.Y != AxisRight.LastY))
                    {
                        recordedAxisData[1].Add(recordingTimer, new AxisData {
                            X = AxisRight.X, Y = AxisRight.Y
                        });
                    }

                    if (AxisDPad.HasInput && (AxisDPad.X != AxisDPad.LastX || AxisDPad.Y != AxisDPad.LastY))
                    {
                        recordedAxisData[2].Add(recordingTimer, new AxisData {
                            X = AxisDPad.X, Y = AxisDPad.Y
                        });
                    }

                    if (AxisTriggers.HasInput && (AxisTriggers.X != AxisTriggers.LastX || AxisTriggers.LastY != 0))
                    {
                        recordedAxisData[3].Add(recordingTimer, new AxisData {
                            X = AxisTriggers.X, Y = AxisTriggers.Y
                        });
                    }
                }

                recordingTimer++;
            }
            if (Playing)
            {
                if (playingTimer > playbackMax)
                {
                    Stop();
                }

                if (playbackButtonData.ContainsKey(playingTimer))
                {
                    foreach (var act in playbackButtonData[playingTimer])
                    {
                        if (act.Value == 0)
                        {
                            buttonNames[act.Key].ForceState(false);
                            //Util.Log("Time: " + playingTimer + " " + act.Key + " Released");
                        }
                        else
                        {
                            buttonNames[act.Key].ForceState(true);
                            //Util.Log("Time: " + playingTimer + " " + act.Key + " Pressed");
                        }
                    }
                }

                var i = 0;
                foreach (var a in axes)
                {
                    if (playbackAxisData[i].ContainsKey(playingTimer))
                    {
                        a.ForceState(playbackAxisData[i][playingTimer].X, playbackAxisData[i][playingTimer].Y);
                        //Util.Log("Time: " + playingTimer + " X: " + playbackAxisData[i][playingTimer].X + " Y: " + playbackAxisData[i][playingTimer].Y);
                    }
                    i++;
                }

                playingTimer++;
            }
        }