- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I searching for an implementation of kbhit() from <conio.h> in C. I want to use this function for the Terminal in the eclipse IDE. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif Thx a lot for your helpLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure if i understand you correctly but take a look at the "Board Diagnostics"-Template in Nios II IDE. There is a function called getchar() used for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi cece,
Thx for your answere. But getchart don't solve my problem, because its a blocking function. This means, if no key is pressed, the function getchar blocks until a key is pressed. With kbhit it is possible just to test, if an key was pressed(without blocking). -> with the help of <termios.h> it should be possible to programm a kbhit function, but the functions : - tcgetatt - tcsetattr from termios.h doesnt't work ??? Any other solutions are welcome Here the code : int getch() { static int ch = -1, fd = 0; struct termios neu, alt; fd = fileno(stdin); tcgetattr(fd, &alt); neu = alt; neu.c_lflag &= ~(ICANON|ECHO); tcsetattr(fd, TCSANOW, &neu); ch = getchar(); tcsetattr(fd, TCSANOW, &alt); return ch; } int kbhit(void) { struct termios term, oterm; int fd = 0; int c = 0; tcgetattr(fd, &oterm); memcpy(&term, &oterm, sizeof(term)); }
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page