diff --git a/TODO b/TODO index fa627b214..51cbc627c 100644 --- a/TODO +++ b/TODO @@ -83,7 +83,7 @@ ✔ FS @done(19-12-27 11:46) ✔ GSP @done(19-12-30 12:45) ☐ Fix the global weak_ptr to gsp - ☐ HID + ✔ HID @done(19-12-30 14:46) ☐ HTTP ☐ IR ☐ LDR_RO diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index ded1809b1..f20cebca7 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -4,6 +4,7 @@ #include #include +#include "common/archives.h" #include "common/logging/log.h" #include "core/3ds.h" #include "core/core.h" @@ -20,8 +21,32 @@ #include "core/movie.h" #include "video_core/video_core.h" +SERVICE_CONSTRUCT_IMPL(Service::HID::Module) +SERIALIZE_EXPORT_IMPL(Service::HID::Module) + namespace Service::HID { +template +void Module::serialize(Archive& ar, const unsigned int) { + ar& shared_mem; + ar& event_pad_or_touch_1; + ar& event_pad_or_touch_2; + ar& event_accelerometer; + ar& event_gyroscope; + ar& event_debug_pad; + ar& next_pad_index; + ar& next_touch_index; + ar& next_accelerometer_index; + ar& next_gyroscope_index; + ar& enable_accelerometer_count; + ar& enable_gyroscope_count; + ReloadInputDevices(); + // Pad state not needed as it's always updated + // Update events are set in the constructor + // Devices are set from the implementation (and are stateless afaik) +} +SERIALIZE_IMPL(Module) + // Updating period for each HID device. These empirical values are measured from a 11.2 3DS. constexpr u64 pad_update_ticks = BASE_CLOCK_RATE_ARM11 / 234; constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE_ARM11 / 104; diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 8d217f835..e34c1186a 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -294,7 +294,7 @@ public: */ void GetGyroscopeLowCalibrateParam(Kernel::HLERequestContext& ctx); - private: + protected: std::shared_ptr hid; }; @@ -342,9 +342,16 @@ private: std::unique_ptr circle_pad; std::unique_ptr motion_device; std::unique_ptr touch_device; + + template + void serialize(Archive& ar, const unsigned int); + friend class boost::serialization::access; }; std::shared_ptr GetModule(Core::System& system); void InstallInterfaces(Core::System& system); } // namespace Service::HID + +SERVICE_CONSTRUCT(Service::HID::Module) +BOOST_CLASS_EXPORT_KEY(Service::HID::Module) diff --git a/src/core/hle/service/hid/hid_spvr.cpp b/src/core/hle/service/hid/hid_spvr.cpp index 8371a6169..87791f073 100644 --- a/src/core/hle/service/hid/hid_spvr.cpp +++ b/src/core/hle/service/hid/hid_spvr.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/service/hid/hid_spvr.h" +SERIALIZE_EXPORT_IMPL(Service::HID::Spvr) + namespace Service::HID { Spvr::Spvr(std::shared_ptr hid) : Module::Interface(std::move(hid), "hid:SPVR", 6) { diff --git a/src/core/hle/service/hid/hid_spvr.h b/src/core/hle/service/hid/hid_spvr.h index e2346dda5..a49101dc3 100644 --- a/src/core/hle/service/hid/hid_spvr.h +++ b/src/core/hle/service/hid/hid_spvr.h @@ -11,6 +11,11 @@ namespace Service::HID { class Spvr final : public Module::Interface { public: explicit Spvr(std::shared_ptr hid); +private: + SERVICE_SERIALIZATION(Spvr, hid, Module) }; } // namespace Service::HID + +BOOST_CLASS_EXPORT_KEY(Service::HID::Spvr) +BOOST_SERIALIZATION_CONSTRUCT(Service::HID::Spvr) diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp index 129b3fd02..97ce8f111 100644 --- a/src/core/hle/service/hid/hid_user.cpp +++ b/src/core/hle/service/hid/hid_user.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/service/hid/hid_user.h" +SERIALIZE_EXPORT_IMPL(Service::HID::User) + namespace Service::HID { User::User(std::shared_ptr hid) : Module::Interface(std::move(hid), "hid:USER", 6) { diff --git a/src/core/hle/service/hid/hid_user.h b/src/core/hle/service/hid/hid_user.h index 813f09504..6fd9803c6 100644 --- a/src/core/hle/service/hid/hid_user.h +++ b/src/core/hle/service/hid/hid_user.h @@ -14,6 +14,11 @@ namespace Service::HID { class User final : public Module::Interface { public: explicit User(std::shared_ptr hid); +private: + SERVICE_SERIALIZATION(User, hid, Module) }; } // namespace Service::HID + +BOOST_CLASS_EXPORT_KEY(Service::HID::User) +BOOST_SERIALIZATION_CONSTRUCT(Service::HID::User)