summaryrefslogtreecommitdiff
path: root/src/nes/controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nes/controller.cc')
-rw-r--r--src/nes/controller.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nes/controller.cc b/src/nes/controller.cc
index e73f8e5..87842e2 100644
--- a/src/nes/controller.cc
+++ b/src/nes/controller.cc
@@ -4,12 +4,15 @@ namespace nes
{
auto controller::read() -> std::uint8_t
{
- // TODO
- return 0x0;
+ auto const res = index_ < 8 ? (pressed_.get_raw_value() >> index_) & 1 : 0;
+ index_ += 1;
+ if (strobing_) { index_ = 0; }
+ return res;
}
- auto controller::write(std::uint8_t) -> void
+ auto controller::write(std::uint8_t const value) -> void
{
- // TODO
+ strobing_ = value & 1;
+ if (strobing_) { index_ = 0; }
}
} // namespace nes \ No newline at end of file