linux input port done
This commit is contained in:
@@ -2,29 +2,28 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <threads.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
int counter = 0;
|
||||
int main (int argc, char *argv[]) {
|
||||
char t = ' ';
|
||||
while(t != 'q') {
|
||||
std::cout << "input a char" << ftell(stdin) <<" [";
|
||||
fseek(stdin, 0, SEEK_END);
|
||||
if(ftell(stdin) > 0) {
|
||||
t = term_getche();
|
||||
rewind(stdin);
|
||||
std::cout << t;
|
||||
std::cout << "]\n\r ";
|
||||
return 0;
|
||||
}else {
|
||||
std::cout << "eof";
|
||||
std::cout << "]\r ";
|
||||
}
|
||||
#include <termios.h>
|
||||
|
||||
struct timespec b;
|
||||
b.tv_sec = 1;
|
||||
thrd_sleep(&b, NULL); // sleep 1 sec
|
||||
char* bbuf;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int n;
|
||||
int counter = 0;
|
||||
struct termios te;
|
||||
term_disable_cursor();
|
||||
term_threaded_input_init();
|
||||
bbuf = term_tinputb();
|
||||
while(bbuf[0] != 'q') {
|
||||
|
||||
std::cout << counter++ << '[';
|
||||
for (int i = 0; i < 8; i++) {
|
||||
std::cout << bbuf[i] << ',';
|
||||
}
|
||||
std::cout << "] \r";
|
||||
}
|
||||
std::cout << '\n';
|
||||
term_threaded_input_stop();
|
||||
term_enable_cursor();
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user