Reading from /dev/con1 without pressing <RETURN> or stalling

If I have a thread that reads from /dev/con1

waiting for

char buf[80];
int fd1 = open( “/dev/con1”, O_RDWR );

for(;:wink: {
int sz = read( fd1, buf, 1 );
printf( “%d, %c”, sz, buf[0] );
}

This will never work, it simply stall everything

if I do a select(), I can’t read chars unless I push return
for instance, I won’t get anything like an kbhit() statement.

I look through termios stuff,
but I can’t figure out a way of reading chars
without pressing return.

How can I do it, to have something like QUAKE/DOOM behavior.
Upon a key unblock, read and do something in CONSOLE mode.

I know it’s possible to program Controls keys without termios,
at least it seems to be, but how do I get something like Doom ?

= void fire()
= strafe_right()
= go_left()

etc.

I mean in Doom, you don’t press enter, enter, etc.
It wouldn’t make sense, right?

I tried:
readcond( fd, buf, 80, 0, 0, 0 );
didn’t work

Anybody has an idea or trick ???

Thank you very much,

Fred.

Fred a écrit :

If I have a thread that reads from /dev/con1

waiting for

char buf[80];
int fd1 = open( “/dev/con1”, O_RDWR );

for(;:wink: {
int sz = read( fd1, buf, 1 );
printf( “%d, %c”, sz, buf[0] );
}

This will never work, it simply stall everything

if I do a select(), I can’t read chars unless I push return
for instance, I won’t get anything like an kbhit() statement.

I look through termios stuff,
but I can’t figure out a way of reading chars
without pressing return.

How can I do it, to have something like QUAKE/DOOM behavior.
Upon a key unblock, read and do something in CONSOLE mode.

I know it’s possible to program Controls keys without termios,
at least it seems to be, but how do I get something like Doom ?

space> = void fire()
j> = strafe_right()
left> = go_left()

etc.

I mean in Doom, you don’t press enter, enter, etc.
It wouldn’t make sense, right?

I tried:
readcond( fd, buf, 80, 0, 0, 0 );
didn’t work

Anybody has an idea or trick ???

Thank you very much,

Fred.

You have to program the console in raw mode. Look at ‘getchar() problem’
thread in qdn.public.qnxrtp.devtools forum.

Alain.

Alain Bonnefoy wrote in message <3A923AC6.A826ECA3@icbt.com>…

Fred a écrit :

If I have a thread that reads from /dev/con1

waiting for

char buf[80];
int fd1 = open( “/dev/con1”, O_RDWR );

for(;:wink: {
int sz = read( fd1, buf, 1 );
printf( “%d, %c”, sz, buf[0] );
}

This will never work, it simply stall everything

if I do a select(), I can’t read chars unless I push return
for instance, I won’t get anything like an kbhit() statement.

I look through termios stuff,
but I can’t figure out a way of reading chars
without pressing return.

How can I do it, to have something like QUAKE/DOOM behavior.
Upon a key unblock, read and do something in CONSOLE mode.

I know it’s possible to program Controls keys without termios,
at least it seems to be, but how do I get something like Doom ?

space> = void fire()
j> = strafe_right()
left> = go_left()

etc.

I mean in Doom, you don’t press enter, enter, etc.
It wouldn’t make sense, right?

I tried:
readcond( fd, buf, 80, 0, 0, 0 );
didn’t work

Anybody has an idea or trick ???

Thank you very much,

Fred.

You have to program the console in raw mode. Look at ‘getchar() problem’
thread in qdn.public.qnxrtp.devtools forum.

Alain.

I already tried in RAW mode and it doesn’t work neither !
Worst, the entire computer STALL if I go in Raw console mode.

I will try to find that article
With the following code:

int dev_raw (int fd)
{
struct termios termios_p;

if (tcgetattr (fd, &termios_p))
return (-1);

termios_p.c_cc[VMIN] = 1;
termios_p.c_cc[VTIME] = 0;
termios_p.c_lflag &= ~(ECHO | ICANON | ISIG |
ECHOE | ECHOK | ECHONL);
termios_p.c_oflag &= ~(OPOST);
return (tcsetattr (fd, TCSANOW, &termios_p));
}

int dev_unraw (int fd)
{
struct termios termios_p;

if (tcgetattr (fd, &termios_p))
return (-1);

termios_p.c_lflag |= (ECHO | ICANON | ISIG |
ECHOE | ECHOK | ECHONL);
termios_p.c_oflag |= (OPOST);
return (tcsetattr (fd, TCSAFLUSH, &termios_p));
}