Jpp
15.0.2
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JSystem
JKeypress.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JSystem/JKeypress.hh
"
6
#include "
Jeep/JParser.hh
"
7
#include "
Jeep/JMessage.hh
"
8
9
10
/**
11
* \file
12
*
13
* Example program to test key board pressings (class JSYSTEM::JKeypress).
14
* \author mdejong
15
*/
16
int
main
(
int
argc,
char
* argv[])
17
{
18
using namespace
std;
19
20
bool
echo
;
21
int
timeout_us;
22
23
try
{
24
25
JParser<>
zap(
"Example program to test key board pressings."
);
26
27
zap[
'c'
] =
make_field
(
echo
);
28
zap[
't'
] =
make_field
(timeout_us) = 1000;
29
30
zap(argc, argv);
31
}
32
catch
(
const
exception &error) {
33
FATAL
(error.what() << endl);
34
}
35
36
37
using namespace
JPP;
38
39
if
(
true
) {
40
41
cout <<
"> "
<< flush;
42
43
int
c = JKeypress(
echo
).get();
44
45
cout << endl <<
"return <"
<< (char) c <<
">"
<< endl;
46
}
47
48
if
(
true
) {
49
50
JKeypress keypress(
false
);
51
52
int
c = (int)
'?'
;
53
54
for
(
int
i = 0; i != 10000; ++i) {
55
56
cout << setw(5) << i << flush <<
'\r'
;
57
58
if
(keypress.timeout(timeout_us)) {
59
c = keypress.get();
60
break
;
61
}
62
}
63
64
cout << endl <<
"return <"
<< (char) c <<
">"
<< endl;
65
}
66
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
echo
then echo
Definition:
JDOMDAQDriver.sh:56
JKeypress.hh
Keyboard settings for unbuffered input.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
Generated by
1.8.5