Design Pattern Examples
Overview of object-oriented design patterns
checkforkey.cpp
Go to the documentation of this file.
1
5
6#ifdef _MSC_VER
7#include <conio.h>
8#else
9#include <unistd.h>
10#include <sys/time.h>
11#endif
12
13#include "checkforkey.h"
14
15#ifndef _MSC_VER
16namespace // Anonymous
17{
18 int kbhit(void)
19 {
20 struct timeval tv;
21 fd_set rdfs;
22
23 tv.tv_sec = 0;
24 tv.tv_usec = 0;
25
26 FD_ZERO(&rdfs);
27 FD_SET(STDIN_FILENO, &rdfs);
28
29 select(STDIN_FILENO + 1, &rdfs, NULL, NULL, &tv);
30 return FD_ISSET(STDIN_FILENO, &rdfs);
31 }
32} // end Anonymous namespace
33#endif
34
38namespace Helpers
39{
40
47 {
48#ifdef _MSC_VER
49 return _kbhit() != 0;
50#else
51 return kbhit() != 0;
52#endif
53 }
54
55} // end namespace
int kbhit(void)
Definition: checkforkey.c:16
Declaration of the checkforkey() function for determining if a key has been pressed.
The namespace containing all the "helper" functions in the C++ code.
bool checkforkey()
Determine if a key has been pressed.
Definition: checkforkey.cpp:46