Linux ioctl?
Posted: Mon Oct 20, 2003 5:07 pm
I have this C code which compiles under Linux and allows me to manipulate the buffering so I can read one key at a time from the keyboard (w/ no automatic echo). It allows me to get inkey() type functionality. Is there any way I can convert it to PBLinux?
Thanks,
Phil
#include <termio.h>
struct termio savetty; struct termio newtty;
#define gtty(fd,arg) (ioctl(fd, TCGETA, arg))
#define stty(fd,arg) (ioctl(fd, TCSETAF, arg))
cbmode()
{
if (gtty(0, &savetty) == -1) {
printf("ioctl failed: it's not a terminal\n");
exit(-1);
}
newtty = savetty;
newtty.c_lflag &= ~ICANON; newtty.c_lflag &= ~ECHO;
newtty.c_cc[VMIN] = 1;
newtty.c_cc[VTIME] = 1;
if (stty(0, &newtty) == -1) {
printf("terminal won't go into cbreak mode\n");
exit();
}
}
reset() { stty(0, &savetty); }
Thanks,
Phil
#include <termio.h>
struct termio savetty; struct termio newtty;
#define gtty(fd,arg) (ioctl(fd, TCGETA, arg))
#define stty(fd,arg) (ioctl(fd, TCSETAF, arg))
cbmode()
{
if (gtty(0, &savetty) == -1) {
printf("ioctl failed: it's not a terminal\n");
exit(-1);
}
newtty = savetty;
newtty.c_lflag &= ~ICANON; newtty.c_lflag &= ~ECHO;
newtty.c_cc[VMIN] = 1;
newtty.c_cc[VTIME] = 1;
if (stty(0, &newtty) == -1) {
printf("terminal won't go into cbreak mode\n");
exit();
}
}
reset() { stty(0, &savetty); }