summaryrefslogtreecommitdiff
path: root/lib/nes/controller.hh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nes/controller.hh')
-rw-r--r--lib/nes/controller.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/nes/controller.hh b/lib/nes/controller.hh
new file mode 100644
index 0000000..fa16859
--- /dev/null
+++ b/lib/nes/controller.hh
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "nes/util/button-mask.hh"
+
+namespace nes
+{
+ class controller
+ {
+ button_mask pressed_;
+ unsigned index_{ 0 };
+ bool strobing_{ false };
+
+ public:
+ explicit controller() = default;
+
+ controller(controller const&) = delete;
+ controller(controller&&) = delete;
+ auto operator=(controller const&) -> controller& = delete;
+ auto operator=(controller&&) -> controller& = delete;
+
+ auto get_pressed() const -> button_mask { return pressed_;}
+ auto get_pressed() -> button_mask& { return pressed_; }
+ auto set_pressed(button_mask const value) -> void { pressed_ = value; }
+
+ // IO register
+
+ auto read() -> std::uint8_t;
+ auto write(std::uint8_t) -> void;
+ };
+} // namespace nes \ No newline at end of file