Linux ioctl?

Linux specific forum
pthien
Enthusiast
Enthusiast
Posts: 150
Joined: Sun Jun 29, 2003 9:39 pm

Linux ioctl?

Post 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); }
pbdep
User
User
Posts: 68
Joined: Fri Apr 25, 2003 5:18 pm
Location: Netherlands

ioctl

Post 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.
pthien
Enthusiast
Enthusiast
Posts: 150
Joined: Sun Jun 29, 2003 9:39 pm

Post 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
pbdep
User
User
Posts: 68
Joined: Fri Apr 25, 2003 5:18 pm
Location: Netherlands

Re: ioctl

Post by pbdep »

Yes i have some Curses code, ill search and post it for ya ;-)
(if i can find it...)

Regards,
Pbdep.
pbdep
User
User
Posts: 68
Joined: Fri Apr 25, 2003 5:18 pm
Location: Netherlands

Post 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
Post Reply