Serialize HID service

This commit is contained in:
Hamish Milne 2019-12-30 14:46:35 +00:00 committed by zhupengfei
parent 30494c06a4
commit 74361fa3fb
7 changed files with 50 additions and 2 deletions

2
TODO
View file

@ -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

View file

@ -4,6 +4,7 @@
#include <algorithm>
#include <cmath>
#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 <class Archive>
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;

View file

@ -294,7 +294,7 @@ public:
*/
void GetGyroscopeLowCalibrateParam(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> hid;
};
@ -342,9 +342,16 @@ private:
std::unique_ptr<Input::AnalogDevice> circle_pad;
std::unique_ptr<Input::MotionDevice> motion_device;
std::unique_ptr<Input::TouchDevice> touch_device;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
std::shared_ptr<Module> GetModule(Core::System& system);
void InstallInterfaces(Core::System& system);
} // namespace Service::HID
SERVICE_CONSTRUCT(Service::HID::Module)
BOOST_CLASS_EXPORT_KEY(Service::HID::Module)

View file

@ -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<Module> hid) : Module::Interface(std::move(hid), "hid:SPVR", 6) {

View file

@ -11,6 +11,11 @@ namespace Service::HID {
class Spvr final : public Module::Interface {
public:
explicit Spvr(std::shared_ptr<Module> hid);
private:
SERVICE_SERIALIZATION(Spvr, hid, Module)
};
} // namespace Service::HID
BOOST_CLASS_EXPORT_KEY(Service::HID::Spvr)
BOOST_SERIALIZATION_CONSTRUCT(Service::HID::Spvr)

View file

@ -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<Module> hid) : Module::Interface(std::move(hid), "hid:USER", 6) {

View file

@ -14,6 +14,11 @@ namespace Service::HID {
class User final : public Module::Interface {
public:
explicit User(std::shared_ptr<Module> hid);
private:
SERVICE_SERIALIZATION(User, hid, Module)
};
} // namespace Service::HID
BOOST_CLASS_EXPORT_KEY(Service::HID::User)
BOOST_SERIALIZATION_CONSTRUCT(Service::HID::User)