~ubuntu-branches/debian/stretch/assaultcube-data/stretch

« back to all changes in this revision

Viewing changes to source/include/wincompat.h

  • Committer: Bazaar Package Importer
  • Author(s): Gonéri Le Bouder, Ansgar Burchardt, Gonéri Le Bouder
  • Date: 2010-04-02 23:37:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100402233755-kf74fxwlu634o6vg
Tags: 1.0.4+repack1-1
[ Ansgar Burchardt ]
* debian/control: fix typo in short description

[ Gonéri Le Bouder ]
* Upgrade to 1.0.4
* bump standards-version to 3.8.4
* Add Depends: ${misc:Depends} just to avoid a lintian warning
* Add a debian/source/format file for the same reason

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if !defined(WINCOMPAT_INCLUDED) && !defined(PLATFORM_WINDOWS) && !defined(WIN32) && !defined(WINDOWS) && !defined(__WIN32__)
 
2
#define WINCOMPAT_INCLUDED
 
3
 
 
4
/**
 
5
 * 
 
6
 * Author: Magnus Naeslund (mag@fbab.net, mag@bahnhof.se)
 
7
 * (c) 2000 Magnus Naeslund, all rights reserved
 
8
 * 
 
9
 */
 
10
 
 
11
#include <sys/time.h>
 
12
#include <sys/types.h>
 
13
#include <unistd.h>
 
14
#include <termios.h>
 
15
#include <stdio.h>
 
16
#include <stdlib.h>
 
17
 
 
18
#ifndef TRUE
 
19
  #define TRUE 1
 
20
#endif
 
21
#ifndef FALSE
 
22
  #define FALSE 0
 
23
#endif
 
24
 
 
25
#define _kbhit kbhit
 
26
#define stricmp strcasecmp
 
27
#define strnicmp strncasecmp
 
28
 
 
29
#define Sleep(x) usleep((x)*1000)
 
30
 
 
31
static int            inited=0;
 
32
static struct termios ori;
 
33
 
 
34
static void tcatexit(){
 
35
   tcsetattr(0,0,&ori);
 
36
}
 
37
 
 
38
static void init_terminal(){
 
39
   struct termios t;
 
40
   tcgetattr(0,&t);
 
41
   tcgetattr(0,&ori);
 
42
   t.c_lflag &= ~(ICANON);
 
43
   tcsetattr(0,0,&t);
 
44
   atexit(tcatexit);
 
45
}
 
46
 
 
47
static inline int kbhit(){
 
48
  fd_set rfds;
 
49
  struct timeval tv;
 
50
 
 
51
   if (!inited){
 
52
          inited=1;
 
53
          init_terminal();
 
54
   }
 
55
   
 
56
   FD_ZERO(&rfds);
 
57
   FD_SET(0, &rfds);
 
58
   tv.tv_sec = 0;
 
59
   tv.tv_usec = 10*1000;
 
60
   return select(1, &rfds, NULL, NULL, &tv)>0;
 
61
}
 
62
 
 
63
static inline int getch(){
 
64
   fd_set rfds;
 
65
   
 
66
   if (!inited){
 
67
          inited=1;
 
68
          init_terminal();
 
69
   }
 
70
   
 
71
   FD_ZERO(&rfds);
 
72
   FD_SET(0, &rfds);
 
73
   if (select(1, &rfds, NULL, NULL, NULL)>0)
 
74
         return getchar();
 
75
   else{
 
76
          printf("wincompat.h: select() on fd 0 failed\n");
 
77
          return 0xDeadBeef;
 
78
   }     
 
79
}
 
80
 
 
81
#endif