summaryrefslogtreecommitdiff
path: root/lib/nes/app/input/input-device-controller.hh
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-01-30 16:43:06 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-01-31 00:02:26 +0100
commit307e07d6513f9524b7fcab5134494bd175465cd1 (patch)
treece025db2ea998bdcd8980a0ed443083f0daf8d35 /lib/nes/app/input/input-device-controller.hh
parent5959349f341a2380c0c3f41ec40a1e8e0d969d00 (diff)
handle input devices in the c++ application
Diffstat (limited to 'lib/nes/app/input/input-device-controller.hh')
-rw-r--r--lib/nes/app/input/input-device-controller.hh38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/nes/app/input/input-device-controller.hh b/lib/nes/app/input/input-device-controller.hh
new file mode 100644
index 0000000..6adb79c
--- /dev/null
+++ b/lib/nes/app/input/input-device-controller.hh
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "nes/app/input/input-device.hh"
+#include "nes/common/list.hh"
+#include <string_view>
+
+namespace nes
+{
+ /// A game controller input device.
+ class input_device_controller : public input_device, public list<input_device_controller>::node
+ {
+ public:
+ enum class index
+ {
+ unused = -1,
+ player_1 = 0,
+ player_2 = 1,
+ };
+
+ /// Indicates whether the controller can be trusted to actually exist.
+ ///
+ /// If this returns false, the controller is not automatically selected on startup if there is no other
+ /// controller already selected.
+ virtual auto is_reliable() const -> bool = 0;
+
+ /// Human-readable name for the controller.
+ virtual auto get_name() const -> std::string_view = 0;
+
+ /// Get the (persistent) player index for the controller, if already set before.
+ virtual auto get_index() const -> index = 0;
+
+ /// Set the (persistent) player index for the controller.
+ virtual auto set_index(index) -> void = 0;
+
+ protected:
+ explicit input_device_controller() = default;
+ };
+} // namespace nes \ No newline at end of file