summaryrefslogtreecommitdiff
path: root/lib/nes/ref/controller.hh
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-01-23 22:10:55 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-01-23 22:10:55 +0100
commit0f24863561b7c609395b59ab73e634509d3111d8 (patch)
treeb89c6a8db88f0c1c8c55d41d733b6cfa566a08f4 /lib/nes/ref/controller.hh
parentb1d1573702f21e3104606d6ade5f5d39ec86a33a (diff)
copy reference implementation
Diffstat (limited to 'lib/nes/ref/controller.hh')
-rw-r--r--lib/nes/ref/controller.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/nes/ref/controller.hh b/lib/nes/ref/controller.hh
new file mode 100644
index 0000000..231653c
--- /dev/null
+++ b/lib/nes/ref/controller.hh
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "nes/util/button-mask.hh"
+
+namespace nes::ref
+{
+ 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::ref \ No newline at end of file