From c303b1abb41ed4467646de04a6ea963ecc87f72d Mon Sep 17 00:00:00 2001 From: Andrew Brooks Date: Sat, 27 Jan 2018 14:27:57 -0600 Subject: [PATCH] Slight corrections to input event handling to prevent double-keypress events. --- barcode_service/barcode_service.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/barcode_service/barcode_service.c b/barcode_service/barcode_service.c index 25f0433..3b6a186 100644 --- a/barcode_service/barcode_service.c +++ b/barcode_service/barcode_service.c @@ -102,13 +102,14 @@ decode_next_event(int fd) ssize_t n_read = read(fd, &event, sizeof(struct input_event)); if (n_read != sizeof(struct input_event)) { fprintf(stderr, "Read interrupted!\n"); - exit(1); + continue; } /* * If we received a keypress event, decode the keycode responsible. + * (Event value 1 = key depressed) */ - if (event.type == EV_KEY) { + if (event.type == EV_KEY && event.value == 1) { switch (event.code) { #define DECODE_KEY(key_name, decode_char) case (KEY_##key_name): return decode_char DECODE_KEY(ENTER, '\n');