Hi vVv
Thanks for the function you posted earlier on keypresses. It does, however only work once in my program, the rest of the function calls are just ignored. D'you know how to fix that ('cause I'm lost).
Thanks in advance
Skarr
Hi vVv
Thanks for the function you posted earlier on keypresses. It does, however only work once in my program, the rest of the function calls are just ignored. D'you know how to fix that ('cause I'm lost).
Thanks in advance
Skarr
I like traffic lights. I like traffic lights. I like traffic lights, but only when they're green.
Hey,
can you post how you are using it in your code? Note that some special characters, such as the arrow keys, fx, etc are being received with scancode mumbo jumbo.
I just tested it in a program like:
#include <stdio.h>
char inchar(void);
// The function here
int main(void) {
printf("%c\n", inchar());
printf("%c\n", inchar());
return 0;
}
And it only works the first time, the second is just skipped.
since you did not post the code for inchar(), i can only assume you expect a personal answer from vVv, which makes this thread useless to everyone else.
#include <termios.h>
char inchar()
{
char c;
static struct termios o, n;
tcgetattr( STDIN_FILENO, &o );
cfmakeraw( &n );
tcsetattr( STDIN_FILENO, TCSANOW, &n );
c = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &o );
ungetc( c, stdin );
return c;
}
Here ya go.
Oh, and btw vVv, I'm not trying to scan for arrow keys, just normal letters.
I like traffic lights. I like traffic lights. I like traffic lights, but only when they're green.
Either remove the ungetc(), or read the data from stdin after calling ``inchar()''.
Code:printf( "%c\n", inchar() ); getchar(); printf( "%c\n", inchar() );
Yeah, but that takes out the meaning of the whole function, doesn't it?