-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb70d62
commit 0fc3ebe
Showing
13 changed files
with
912 additions
and
617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#if !defined(WINCOMPAT_INCLUDED) && !defined(PLATFORM_WINDOWS) && !defined(WIN32) && !defined(WINDOWS) && !defined(__WIN32__) | ||
#define WINCOMPAT_INCLUDED | ||
|
||
/** | ||
* | ||
* Author: Magnus Naeslund (mag@fbab.net, mag@bahnhof.se) | ||
* (c) 2000 Magnus Naeslund, all rights reserved | ||
* | ||
*/ | ||
|
||
#include <sys/time.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
#include <termios.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#ifndef TRUE | ||
#define TRUE 1 | ||
#endif | ||
#ifndef FALSE | ||
#define FALSE 0 | ||
#endif | ||
|
||
#define _kbhit kbhit | ||
#define stricmp strcasecmp | ||
#define strnicmp strncasecmp | ||
|
||
#define Sleep(x) usleep((x)*1000) | ||
|
||
static int inited=0; | ||
static struct termios ori; | ||
|
||
static void tcatexit(){ | ||
tcsetattr(0,0,&ori); | ||
} | ||
|
||
static void init_terminal(){ | ||
struct termios t; | ||
tcgetattr(0,&t); | ||
tcgetattr(0,&ori); | ||
t.c_lflag &= ~(ICANON); | ||
tcsetattr(0,0,&t); | ||
atexit(tcatexit); | ||
} | ||
|
||
static inline int kbhit(){ | ||
fd_set rfds; | ||
struct timeval tv; | ||
|
||
if (!inited){ | ||
inited=1; | ||
init_terminal(); | ||
} | ||
|
||
FD_ZERO(&rfds); | ||
FD_SET(0, &rfds); | ||
tv.tv_sec = 0; | ||
tv.tv_usec = 10*1000; | ||
return select(1, &rfds, NULL, NULL, &tv)>0; | ||
} | ||
|
||
static inline int getch(){ | ||
fd_set rfds; | ||
|
||
if (!inited){ | ||
inited=1; | ||
init_terminal(); | ||
} | ||
|
||
FD_ZERO(&rfds); | ||
FD_SET(0, &rfds); | ||
if (select(1, &rfds, NULL, NULL, NULL)>0) | ||
return getchar(); | ||
else{ | ||
printf("wincompat.h: select() on fd 0 failed\n"); | ||
return 0xDeadBeef; | ||
} | ||
} | ||
|
||
#endif |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.