diff options
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; +} |
