simplified the input thread's internal loop

This commit is contained in:
Amy G. Bowersox 2019-12-01 01:18:59 -07:00
parent 0a20f315d5
commit 969fefd0aa

View File

@ -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);