From 969fefd0aa09687c72995e056af81e57630d88f5 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 1 Dec 2019 01:18:59 -0700 Subject: [PATCH] simplified the input thread's internal loop --- src/sysinput.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/sysinput.c b/src/sysinput.c index 8f45b37..c45d6f7 100644 --- a/src/sysinput.c +++ b/src/sysinput.c @@ -13,7 +13,7 @@ static int last_bstate = 0; static void *input_thread(void *arg) { - int st, tmp, mask; + int st, down, up, mask; uintptr_t attr; while (running) @@ -22,19 +22,16 @@ static void *input_thread(void *arg) st = Gpio_read_buttons(); if (st != last_bstate) { - tmp = last_bstate & ~st; + up = last_bstate & ~st; + down = st & ~last_bstate; for (attr = 1, mask = 1; attr <= 4; attr++, mask <<= 1) { - if (tmp & mask) + if (up & mask) { Log(LDEBUG, "posting WM_HWBUTTONUP(%d)", (int)attr); MqPost1(Sys_Queue, 0, WM_HWBUTTONUP, attr); } - } - tmp = st & ~last_bstate; - for (attr = 1, mask = 1; attr <= 4; attr++, mask <<= 1) - { - if (tmp & mask) + else if (down & mask) { Log(LDEBUG, "posting WM_HWBUTTONDOWN(%d)", (int)attr); MqPost1(Sys_Queue, 0, WM_HWBUTTONDOWN, attr);