What is -DOS_$(OS) in the rawhid_test makefile?

Status
Not open for further replies.
It's used a couple places in the C code. For example:

Code:
#if defined(OS_LINUX) || defined(OS_MACOSX)
#include <sys/ioctl.h>
#include <termios.h>
#elif defined(OS_WINDOWS)
#include <conio.h>
#endif

and also near the end:

Code:
#if defined(OS_LINUX) || defined(OS_MACOSX)
// Linux (POSIX) implementation of _kbhit().
// Morgan McGuire, morgan@cs.brown.edu
static int _kbhit() {
        static const int STDIN = 0;
        static int initialized = 0;
        int bytesWaiting;

        if (!initialized) {
                // Use termios to turn off line buffering
                struct termios term;
                tcgetattr(STDIN, &term);
                term.c_lflag &= ~ICANON;
                tcsetattr(STDIN, TCSANOW, &term);
                setbuf(stdin, NULL);
                initialized = 1;
        }
        ioctl(STDIN, FIONREAD, &bytesWaiting);
        return bytesWaiting;
}
static char _getch(void) {
        char c;
        if (fread(&c, 1, 1, stdin) < 1) return 0;
        return c;
}
#endif
 
Status
Not open for further replies.
Back
Top