5 #include "json_helpers.h"
9 static struct termios saved_term;
11 static void stdin_cb(EV_P_ ev_io *w, int revents)
15 read(w->fd, &ch, sizeof(ch));
21 keys_json_print(pipefd, ch);
24 keys_json_print(pipefd, ch + 'A' - 'a');
27 strcpy(uid, "?ABC0123456789");
29 rfid_json_print(pipefd, 42, 32, uid, (strlen(uid)+1)/2);
34 int mt_sim_init(struct ev_loop *loop, int fd)
38 if (!isatty(STDIN_FILENO)) {
39 fprintf(stderr, "stdin is not a terminal\n");
44 tcgetattr(STDIN_FILENO, &term);
46 term.c_lflag &= ~ICANON;
47 tcsetattr(STDIN_FILENO, TCSADRAIN, &term);
49 ev_io_init(&w, stdin_cb, STDIN_FILENO, EV_READ);
50 ev_io_start(loop, &w);
55 void mt_sim_deinit(void)
57 tcsetattr(STDIN_FILENO, TCSADRAIN, &saved_term);