mirror of
1
0
Fork 0
ped/src/tty.c

32 lines
616 B
C
Raw Normal View History

2020-05-05 21:23:21 +02:00
#include<termios.h>
struct termios oldSettings;
void startTTY()
2020-05-05 21:23:21 +02:00
{
/* First create a struct */
struct termios termy;
/* Get current attributes */
tcgetattr(0, &termy);
/* Save current tty settings for restoral later */
oldSettings = termy;
2020-05-05 21:23:21 +02:00
/* Set the tty input modes */
//tcflag_t inputFlags = 0;
termy.c_iflag = termy.c_iflag | IGNBRK;
termy.c_lflag = termy.c_lflag & ~ISIG;
termy.c_lflag = termy.c_lflag & ~ECHO;
cfmakeraw(&termy);
/* Set the tty to raw mode */
tcsetattr(0, 0, &termy);
}
2020-05-05 21:23:21 +02:00
void stopTTY()
{
/* Restore the tty settings back to the original */
tcsetattr(0, 0, &oldSettings);
2020-05-05 21:23:21 +02:00
}