diff options
| author | Hannes Schulze <hannes.hs.schulze@fau.de> | 2025-05-02 12:50:57 +0200 |
|---|---|---|
| committer | Hannes Schulze <hannes.hs.schulze@fau.de> | 2025-05-02 12:50:57 +0200 |
| commit | 24c521f5a4b9f2e1a98668e9d9f7b19b4c9a9bd7 (patch) | |
| tree | a48ca9a718c719b30dae19a78b709874ca9b2bc5 /app/controller/main.cc | |
| parent | def315971fccfe6a1a1743b3de62addd5f0527dc (diff) | |
add controller test program
Diffstat (limited to 'app/controller/main.cc')
| -rw-r--r-- | app/controller/main.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/controller/main.cc b/app/controller/main.cc new file mode 100644 index 0000000..a9ea5bd --- /dev/null +++ b/app/controller/main.cc @@ -0,0 +1,33 @@ +#include <iostream> +#include <cstdlib> +#include <thread> +#include "serial-controller.hh" + +int main(int argc, char** argv) +{ + if (argc != 2) + { + std::cerr << "Usage:\n"; + std::cerr << " " << argv[0] << " <controller-path>" << std::endl; + return EXIT_FAILURE; + } + + auto const path = argv[1]; + auto controller = nes::app::test::serial_controller{ path }; + if (!controller.is_reliable()) + { + return EXIT_FAILURE; + } + + while (true) + { + auto const buttons = controller.read_buttons(); + if (!buttons.is_empty()) + { + std::cout << "Buttons: " << buttons.get_raw_value() << std::endl; + } + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } + + return EXIT_SUCCESS; +} |
