#include #include #include #include "JSystem/JKeypress.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test key board pressings (class JSYSTEM::JKeypress). * \author mdejong */ int main(int argc, char* argv[]) { using namespace std; bool echo; int timeout_us; try { JParser<> zap("Example program to test key board pressings."); zap['c'] = make_field(echo); zap['t'] = make_field(timeout_us) = 1000; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; if (true) { cout << "> " << flush; int c = JKeypress(echo).get(); cout << endl << "return <" << (char) c << ">" << endl; } if (true) { JKeypress keypress(false); int c = (int) '?'; for (int i = 0; i != 10000; ++i) { cout << setw(5) << i << flush << '\r'; if (keypress.timeout(timeout_us)) { c = keypress.get(); break; } } cout << endl << "return <" << (char) c << ">" << endl; } }