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 memset(uid, 0, sizeof(uid));
28 for (int i = 0; i < 14; i++)
31 rfid_json_print(pipefd, 42, 32, uid, (strlen(uid)+1)/2);
36 int mt_sim_init(struct ev_loop *loop, int fd)
40 if (!isatty(STDIN_FILENO)) {
41 fprintf(stderr, "stdin is not a terminal\n");
46 tcgetattr(STDIN_FILENO, &term);
48 term.c_lflag &= ~ICANON;
49 tcsetattr(STDIN_FILENO, TCSADRAIN, &term);
51 ev_io_init(&w, stdin_cb, STDIN_FILENO, EV_READ);
52 ev_io_start(loop, &w);
57 void mt_sim_deinit(void)
59 tcsetattr(STDIN_FILENO, TCSADRAIN, &saved_term);