diff --git a/openrtx/include/core/input.h b/openrtx/include/core/input.h index f68a5084..d29bcf65 100644 --- a/openrtx/include/core/input.h +++ b/openrtx/include/core/input.h @@ -26,19 +26,15 @@ static const uint16_t input_longPressTimeout = 700; * For a keyboard event we use 1 bit to signal a short or long press * And the remaining 29 bits to communicate currently pressed keys. */ -typedef union -{ - struct - { - uint32_t long_press : 1, - keys : 29, - _padding : 2; +typedef union { + struct { + uint32_t long_press : 1; + uint32_t keys : 29; + uint32_t _padding : 2; }; uint32_t value; -} -kbd_msg_t; - +} kbd_msg_t; /** * Scan all the keyboard buttons to detect possible keypresses filling a diff --git a/openrtx/src/core/input.c b/openrtx/src/core/input.c index ea3d86a7..f3db1b65 100644 --- a/openrtx/src/core/input.c +++ b/openrtx/src/core/input.c @@ -9,31 +9,28 @@ #include #include "core/input.h" -static long long keyTs[KBD_NUM_KEYS]; // Timestamp of each keypress -static uint32_t longPressSent; // Flags to manage long-press events -static keyboard_t prevKeys = 0; // Previous keyboard status +static long long keyTs[KBD_NUM_KEYS]; // Timestamp of each keypress +static uint32_t longPressSent; // Flags to manage long-press events +static keyboard_t prevKeys = 0; // Previous keyboard status bool input_scanKeyboard(kbd_msg_t *msg) { - msg->value = 0; + msg->value = 0; bool kbd_event = false; keyboard_t keys = kbd_getKeys(); - long long now = getTick(); + long long now = getTick(); // The key status has changed - if(keys != prevKeys) - { + if (keys != prevKeys) { // Find newly pressed keys keyboard_t newKeys = (keys ^ prevKeys) & keys; // Save timestamp - for(uint8_t k = 0; k < KBD_NUM_KEYS; k++) - { + for (uint8_t k = 0; k < KBD_NUM_KEYS; k++) { keyboard_t mask = 1 << k; - if((newKeys & mask) != 0) - { - keyTs[k] = now; + if ((newKeys & mask) != 0) { + keyTs[k] = now; longPressSent &= ~mask; } } @@ -43,22 +40,18 @@ bool input_scanKeyboard(kbd_msg_t *msg) kbd_event = true; } // Some key is kept pressed - else if(keys != 0) - { + else if (keys != 0) { // Check for saved timestamp to trigger long-presses - for(uint8_t k = 0; k < KBD_NUM_KEYS; k++) - { + for (uint8_t k = 0; k < KBD_NUM_KEYS; k++) { keyboard_t mask = 1 << k; // The key is pressed and its long-press timer is over - if(((keys & mask) != 0) && - ((longPressSent & mask) == 0) && - ((now - keyTs[k]) >= input_longPressTimeout)) - { + if (((keys & mask) != 0) && ((longPressSent & mask) == 0) + && ((now - keyTs[k]) >= input_longPressTimeout)) { msg->long_press = 1; - msg->keys = keys; - kbd_event = true; - longPressSent |= mask; + msg->keys = keys; + kbd_event = true; + longPressSent |= mask; } } } diff --git a/scripts/clang_format.sh b/scripts/clang_format.sh index 44834068..73be8da4 100755 --- a/scripts/clang_format.sh +++ b/scripts/clang_format.sh @@ -44,6 +44,7 @@ openrtx/include/core/crc.h openrtx/include/core/dsp.h openrtx/include/core/data_conversion.h openrtx/include/core/datatypes.h +openrtx/include/core/input.h openrtx/include/core/memory_profiling.h openrtx/include/core/nvmem_access.h openrtx/include/core/nvmem_device.h @@ -68,6 +69,7 @@ openrtx/include/ui/utils.h openrtx/src/core/crc.c openrtx/src/core/dsp.cpp openrtx/src/core/audio_codec.c +openrtx/src/core/input.c openrtx/src/core/nvmem_access.c openrtx/src/core/memory_profiling.cpp openrtx/src/protocols/M17/Callsign.cpp