Ejemplo n.º 1
0
        public void OnReceiveData(ref DualShockState state)
        {
            if (IsPlaying && !IsPaused)
            {
                // Recording
                if (IsRecording)
                {
                    Sequence.Add(state);
                }
                // Playing
                else
                {
                    DualShockState newState = Sequence[CurrentTick];
                    DualShockState oldState = state;

                    if (newState != null)
                    {
                        // Update the state
                        state = newState;
                        // Replace battery status
                        state.Battery    = oldState.Battery;
                        state.IsCharging = oldState.IsCharging;
                    }
                }

                // Increment tick
                CurrentTick++;

                // Reset tick if out of bounds
                if (CurrentTick >= Sequence.Count)
                {
                    CurrentTick = 0;

                    // Raise LapEnter event
                    LapEnter?.Invoke(this);
                }
            }
        }
Ejemplo n.º 2
0
        public void OnReceiveData(ref DualShockState state)
        {
            // Record shortcut trigger
            if (RecordShortcut)
            {
                // Down
                if (state.TouchButton)
                {
                    if (!m_RecordShortcutDown)
                    {
                        m_RecordShortcutDown = true;
                    }
                }
                // Up
                else
                {
                    if (m_RecordShortcutDown)
                    {
                        m_RecordShortcutDown = false;

                        // Auto play
                        if (!IsPlaying || IsPaused)
                        {
                            Play();
                        }

                        // Record
                        Record();
                    }
                }

                // Override real value
                state.TouchButton = false;
                state.Touch1      = null;
                state.Touch2      = null;
            }

            // Playback
            if (IsPlaying && !IsPaused)
            {
                // Recording
                if (IsRecording)
                {
                    Sequence.Add(state);
                }
                // Playing
                else
                {
                    DualShockState newState = Sequence[CurrentTick];
                    DualShockState oldState = state;

                    if (newState != null)
                    {
                        // Update the state
                        state = newState;
                        // Replace battery status
                        state.Battery    = oldState.Battery;
                        state.IsCharging = oldState.IsCharging;
                    }
                }

                // Increment tick
                CurrentTick++;

                // Reset tick if out of bounds
                if (CurrentTick >= Sequence.Count)
                {
                    CurrentTick = 0;

                    // Raise LapEnter event
                    LapEnter?.Invoke(this);

                    // Stop if looping is disabled
                    if (!Loop && !IsRecording)
                    {
                        Stop();
                    }
                }

                // Emulation delay compensation
                if (Program.Settings.EmulateController)
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
        }