Linux does have a getch() function in the curses library, but it doesn't work like it does on DOS. So this does the same thing, with out the need of the curses library.
| 34 | // work like it does on DOS. So this does the same thing, with out the need |
| 35 | // of the curses library. |
| 36 | int getch() |
| 37 | { |
| 38 | struct termios oldt, newt; |
| 39 | int ch; |
| 40 | |
| 41 | tcgetattr(STDIN_FILENO, &oldt); |
| 42 | newt = oldt; |
| 43 | newt.c_lflag &= ~( ICANON | ECHO ); |
| 44 | tcsetattr( STDIN_FILENO, TCSANOW, &newt ); |
| 45 | |
| 46 | ch = getchar(); |
| 47 | |
| 48 | tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); |
| 49 | return ch; |
| 50 | } |
| 51 | |
| 52 | #endif |
| 53 |