Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/input/HackadayCommunicatorKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ static unsigned char HackadayCommunicatorTapMap[_TCA8418_NUM_KEYS][2] = {{},
{}};

HackadayCommunicatorKeyboard::HackadayCommunicatorKeyboard()
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(-1), next_key(-1),
last_tap(0L), char_idx(0), tap_interval(0)
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(UINT8_MAX),
next_key(UINT8_MAX), last_tap(0L), char_idx(0), tap_interval(0)
{
reset();
}
Expand Down Expand Up @@ -147,7 +147,6 @@ void HackadayCommunicatorKeyboard::pressed(uint8_t key)
modifierFlag = 0;
}

uint8_t next_key = 0;
int row = (key - 1) / 10;
int col = (key - 1) % 10;
if (row >= _TCA8418_ROWS || col >= _TCA8418_COLS) {
Expand Down Expand Up @@ -187,8 +186,8 @@ void HackadayCommunicatorKeyboard::released()
return;
}

if (last_key < 0 || last_key >= _TCA8418_NUM_KEYS) {
last_key = -1;
if (last_key >= _TCA8418_NUM_KEYS) {
last_key = UINT8_MAX;
state = Idle;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/input/HackadayCommunicatorKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class HackadayCommunicatorKeyboard : public TCA8418KeyboardBase
private:
uint8_t modifierFlag; // Flag to indicate if a modifier key is pressed
uint32_t last_modifier_time; // Timestamp of the last modifier key press
int8_t last_key;
int8_t next_key;
uint8_t last_key;
uint8_t next_key;
uint32_t last_tap;
uint8_t char_idx;
int32_t tap_interval;
Expand Down
6 changes: 3 additions & 3 deletions src/input/MPR121Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MPR121Keyboard::MPR121Keyboard() : m_wire(nullptr), m_addr(0), readCallback(null
{
// LOG_DEBUG("MPR121 @ %02x", m_addr);
state = Init;
last_key = -1;
last_key = UINT8_MAX;
last_tap = 0L;
char_idx = 0;
queue = "";
Expand Down Expand Up @@ -359,8 +359,8 @@ void MPR121Keyboard::released()
return;
}
// would clear longpress callback... later.
if (last_key < 0 || last_key > _NUM_KEYS) { // reset to idle if last_key out of bounds
last_key = -1;
if (last_key >= _NUM_KEYS) { // reset to idle if last_key out of bounds
last_key = UINT8_MAX;
state = Idle;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/input/MPR121Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MPR121Keyboard

MPR121States state;

int8_t last_key;
uint8_t last_key;
uint32_t last_tap;
uint8_t char_idx;

Expand Down
10 changes: 5 additions & 5 deletions src/input/TCA8418Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ static unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
};

TCA8418Keyboard::TCA8418Keyboard()
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), last_key(-1), next_key(-1), last_tap(0L), char_idx(0), tap_interval(0),
should_backspace(false)
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), last_key(UINT8_MAX), next_key(UINT8_MAX), last_tap(0L), char_idx(0),
tap_interval(0), should_backspace(false)
{
}

Expand All @@ -71,7 +71,7 @@ void TCA8418Keyboard::pressed(uint8_t key)
}

// Compute key index based on dynamic row/column
next_key = (int8_t)(row * _TCA8418_COLS + col);
next_key = (uint8_t)(row * _TCA8418_COLS + col);

// LOG_DEBUG("TCA8418: Key %u -> Next Key %u", key, next_key);

Expand Down Expand Up @@ -105,8 +105,8 @@ void TCA8418Keyboard::released()
return;
}

if (last_key < 0 || last_key > _TCA8418_NUM_KEYS) { // reset to idle if last_key out of bounds
last_key = -1;
if (last_key >= _TCA8418_NUM_KEYS) { // reset to idle if last_key out of bounds
last_key = UINT8_MAX;
state = Idle;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/input/TCA8418Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class TCA8418Keyboard : public TCA8418KeyboardBase
void pressed(uint8_t key) override;
void released(void) override;

int8_t last_key;
int8_t next_key;
uint8_t last_key;
uint8_t next_key;
uint32_t last_tap;
uint8_t char_idx;
int32_t tap_interval;
Expand Down
9 changes: 4 additions & 5 deletions src/input/TDeckProKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ static unsigned char TDeckProTapMap[_TCA8418_NUM_KEYS][5] = {
};

TDeckProKeyboard::TDeckProKeyboard()
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(-1), next_key(-1),
last_tap(0L), char_idx(0), tap_interval(0)
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(UINT8_MAX),
next_key(UINT8_MAX), last_tap(0L), char_idx(0), tap_interval(0)
{
}

Expand Down Expand Up @@ -101,7 +101,6 @@ void TDeckProKeyboard::pressed(uint8_t key)
modifierFlag = 0;
}

uint8_t next_key = 0;
int row = (key - 1) / 10;
int col = (key - 1) % 10;

Expand Down Expand Up @@ -142,8 +141,8 @@ void TDeckProKeyboard::released()
return;
}

if (last_key < 0 || last_key >= _TCA8418_NUM_KEYS) {
last_key = -1;
if (last_key >= _TCA8418_NUM_KEYS) {
last_key = UINT8_MAX;
state = Idle;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/input/TDeckProKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class TDeckProKeyboard : public TCA8418KeyboardBase
private:
uint8_t modifierFlag; // Flag to indicate if a modifier key is pressed
uint32_t last_modifier_time; // Timestamp of the last modifier key press
int8_t last_key;
int8_t next_key;
uint8_t last_key;
uint8_t next_key;
uint32_t last_tap;
uint8_t char_idx;
int32_t tap_interval;
Expand Down
9 changes: 4 additions & 5 deletions src/input/TLoraPagerKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static unsigned char TLoraPagerTapMap[_TCA8418_NUM_KEYS][3] = {{'q', 'Q', '1'},
{' ', 0x00, Key::BL_TOGGLE}};

TLoraPagerKeyboard::TLoraPagerKeyboard()
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(-1), next_key(-1),
last_tap(0L), char_idx(0), tap_interval(0)
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(UINT8_MAX),
next_key(UINT8_MAX), last_tap(0L), char_idx(0), tap_interval(0)
{
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
ledcAttach(KB_BL_PIN, LEDC_BACKLIGHT_FREQ, LEDC_BACKLIGHT_BIT_WIDTH);
Expand Down Expand Up @@ -129,7 +129,6 @@ void TLoraPagerKeyboard::pressed(uint8_t key)
modifierFlag = 0;
}

uint8_t next_key = 0;
int row = (key - 1) / 10;
int col = (key - 1) % 10;

Expand Down Expand Up @@ -170,8 +169,8 @@ void TLoraPagerKeyboard::released()
return;
}

if (last_key < 0 || last_key >= _TCA8418_NUM_KEYS) {
last_key = -1;
if (last_key >= _TCA8418_NUM_KEYS) {
last_key = UINT8_MAX;
state = Idle;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/input/TLoraPagerKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class TLoraPagerKeyboard : public TCA8418KeyboardBase
private:
uint8_t modifierFlag; // Flag to indicate if a modifier key is pressed
uint32_t last_modifier_time; // Timestamp of the last modifier key press
int8_t last_key;
int8_t next_key;
uint8_t last_key;
uint8_t next_key;
uint32_t last_tap;
uint8_t char_idx;
int32_t tap_interval;
Expand Down
Loading