Page 1 of 1

Linux ioctl?

Posted: Mon Oct 20, 2003 5:07 pm
by pthien
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); }

ioctl

Posted: Sat Nov 08, 2003 12:07 pm
by pbdep
Hiya,

IO routines can be managed trough the use of Lib calls.
I.e. you can Call the curses (n)curses lib directly, works pritty nice...

Regards, pbdep.

Posted: Sat Nov 08, 2003 2:03 pm
by pthien
Can you give me an example of the syntax to call the curses code? Is there some documentation someone has written on doing this?

Thanks!
Phil

Re: ioctl

Posted: Sat Nov 08, 2003 5:39 pm
by pbdep
Yes i have some Curses code, ill search and post it for ya ;-)
(if i can find it...)

Regards,
Pbdep.

Posted: Sat Nov 08, 2003 5:47 pm
by pbdep
have a look at "man curses" there you will get all the C calls which can
then we called also by PB after opening the Curses Lib.

The Curses lib is the best way of controlling IO on linux but it's very lowlevel
which by meens results in RE_writing console IO for the use in PB, which I
personaly dont like because its a lot of work (still small though)..

I hope fred will release the basic Ncurses calls in a PB lib in his next
release of PB..

Regards, Pbdep