Skip to content

Commit

Permalink
fc: serialize controller state
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeUsher committed Oct 17, 2023
1 parent 5deec7e commit 401df96
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions ares/fc/controller/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct Controller {

virtual auto data() -> n3 { return 0b000; }
virtual auto latch(n1 data) -> void {}
virtual auto serialize(serializer&) -> void {}
};

#include "port.hpp"
Expand Down
13 changes: 13 additions & 0 deletions ares/fc/controller/gamepad/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ auto Gamepad::latch(n1 data) -> void {
}
}
}

auto Gamepad::serialize(serializer& s) -> void {
s(latched);
s(counter);

s(yHold);
s(upLatch);
s(downLatch);
s(xHold);
s(leftLatch);
s(rightLatch);
}

1 change: 1 addition & 0 deletions ares/fc/controller/gamepad/gamepad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct Gamepad : Controller {
Gamepad(Node::Port);
auto data() -> n3 override;
auto latch(n1 data) -> void override;
auto serialize(serializer&) -> void override;

private:
bool latched = 0;
Expand Down
1 change: 1 addition & 0 deletions ares/fc/controller/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ auto ControllerPort::allocate(string name) -> Node::Peripheral {
}

auto ControllerPort::serialize(serializer& s) -> void {
if(device) device->serialize(s);
}
2 changes: 1 addition & 1 deletion ares/fc/system/serialization.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const string SerializerVersion = "v131";
static const string SerializerVersion = "v132";

auto System::serialize(bool synchronize) -> serializer {
if(synchronize) scheduler.enter(Scheduler::Mode::Synchronize);
Expand Down

0 comments on commit 401df96

Please sign in to comment.