| | |
| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <functional> |
| | #include <span> |
| | #include <boost/serialization/vector.hpp> |
| | #include "common/common_types.h" |
| |
|
| | namespace Service { |
| | namespace HID { |
| | struct AccelerometerDataEntry; |
| | struct GyroscopeDataEntry; |
| | struct PadState; |
| | struct TouchDataEntry; |
| | } |
| | namespace IR { |
| | struct ExtraHIDResponse; |
| | union PadState; |
| | } |
| | } |
| |
|
| | namespace Core { |
| |
|
| | class System; |
| | struct CTMHeader; |
| | struct ControllerState; |
| |
|
| | class Movie { |
| | public: |
| | enum class PlayMode : u32 { |
| | None, |
| | Recording, |
| | Playing, |
| | MovieFinished, |
| | }; |
| |
|
| | enum class ValidationResult : u32 { |
| | OK, |
| | RevisionDismatch, |
| | InputCountDismatch, |
| | Invalid, |
| | }; |
| |
|
| | explicit Movie(const Core::System& system); |
| | ~Movie(); |
| |
|
| | void SetPlaybackCompletionCallback(std::function<void()> completion_callback); |
| | void StartPlayback(const std::string& movie_file); |
| | void StartRecording(const std::string& movie_file, const std::string& author); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | void SetReadOnly(bool read_only); |
| |
|
| | |
| | void PrepareForPlayback(const std::string& movie_file); |
| |
|
| | |
| | void PrepareForRecording(); |
| |
|
| | ValidationResult ValidateMovie(const std::string& movie_file) const; |
| |
|
| | |
| | u64 GetOverrideInitTime() const; |
| |
|
| | |
| | s64 GetOverrideBaseTicks() const; |
| |
|
| | struct MovieMetadata { |
| | u64 program_id; |
| | std::string author; |
| | u32 rerecord_count; |
| | u64 input_count; |
| | }; |
| | MovieMetadata GetMovieMetadata(const std::string& movie_file) const; |
| |
|
| | |
| | u64 GetCurrentMovieID() const { |
| | return id; |
| | } |
| |
|
| | void Shutdown(); |
| |
|
| | |
| | |
| | |
| | |
| | void HandlePadAndCircleStatus(Service::HID::PadState& pad_state, s16& circle_pad_x, |
| | s16& circle_pad_y); |
| |
|
| | |
| | |
| | |
| | |
| | void HandleTouchStatus(Service::HID::TouchDataEntry& touch_data); |
| |
|
| | |
| | |
| | |
| | |
| | void HandleAccelerometerStatus(Service::HID::AccelerometerDataEntry& accelerometer_data); |
| |
|
| | |
| | |
| | |
| | |
| | void HandleGyroscopeStatus(Service::HID::GyroscopeDataEntry& gyroscope_data); |
| |
|
| | |
| | |
| | |
| | |
| | void HandleIrRst(Service::IR::PadState& pad_state, s16& c_stick_x, s16& c_stick_y); |
| |
|
| | |
| | |
| | |
| | |
| | void HandleExtraHidResponse(Service::IR::ExtraHIDResponse& extra_hid_response); |
| | PlayMode GetPlayMode() const; |
| |
|
| | u64 GetCurrentInputIndex() const; |
| | u64 GetTotalInputCount() const; |
| |
|
| | |
| | |
| | |
| | |
| | void SaveMovie(); |
| |
|
| | private: |
| | void CheckInputEnd(); |
| |
|
| | template <typename... Targs> |
| | void Handle(Targs&... Fargs); |
| |
|
| | void Play(Service::HID::PadState& pad_state, s16& circle_pad_x, s16& circle_pad_y); |
| | void Play(Service::HID::TouchDataEntry& touch_data); |
| | void Play(Service::HID::AccelerometerDataEntry& accelerometer_data); |
| | void Play(Service::HID::GyroscopeDataEntry& gyroscope_data); |
| | void Play(Service::IR::PadState& pad_state, s16& c_stick_x, s16& c_stick_y); |
| | void Play(Service::IR::ExtraHIDResponse& extra_hid_response); |
| |
|
| | void Record(const ControllerState& controller_state); |
| | void Record(const Service::HID::PadState& pad_state, const s16& circle_pad_x, |
| | const s16& circle_pad_y); |
| | void Record(const Service::HID::TouchDataEntry& touch_data); |
| | void Record(const Service::HID::AccelerometerDataEntry& accelerometer_data); |
| | void Record(const Service::HID::GyroscopeDataEntry& gyroscope_data); |
| | void Record(const Service::IR::PadState& pad_state, const s16& c_stick_x, const s16& c_stick_y); |
| | void Record(const Service::IR::ExtraHIDResponse& extra_hid_response); |
| |
|
| | ValidationResult ValidateHeader(const CTMHeader& header) const; |
| | ValidationResult ValidateInput(std::span<const u8> input, u64 expected_count) const; |
| |
|
| | private: |
| | const Core::System& system; |
| | PlayMode play_mode; |
| |
|
| | std::string record_movie_file; |
| | std::string record_movie_author; |
| |
|
| | u64 init_time; |
| | s64 base_ticks = -1; |
| |
|
| | std::vector<u8> recorded_input; |
| | std::size_t current_byte = 0; |
| | u64 current_input = 0; |
| | |
| | u64 total_input = 0; |
| |
|
| | u64 id = 0; |
| | u64 program_id = 0; |
| | u32 rerecord_count = 1; |
| | bool read_only = true; |
| |
|
| | std::function<void()> playback_completion_callback = [] {}; |
| |
|
| | template <class Archive> |
| | void serialize(Archive& ar, const unsigned int file_version); |
| | friend class boost::serialization::access; |
| | }; |
| | } |
| |
|
| | BOOST_CLASS_VERSION(Core::Movie, 1) |
| |
|