mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-29 07:36:46 +00:00
T-Lora Pager, T-Deck Pro: One modifier to next key
- Restore behavior of single modifier keypress influencing next keypress - Holding modifier and clicking other keys/modifiers still combines them as you would expect from a real keyboard - But for ease of use, can press just one modifier on its own to make it apply to the next keypress
This commit is contained in:
parent
63468df93f
commit
f6d5e1bdb6
@ -62,7 +62,7 @@ static const uint8_t TDeckProTapMap[_TCA8418_NUM_KEYS][5] = {
|
||||
static bool TDeckProHeldMap[_TCA8418_NUM_KEYS] = {};
|
||||
|
||||
TDeckProKeyboard::TDeckProKeyboard()
|
||||
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0)
|
||||
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), pressedKeysCount(0), onlyOneModifierPressed(false), persistedPreviousModifier(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -98,7 +98,15 @@ void TDeckProKeyboard::pressed(uint8_t key)
|
||||
}
|
||||
|
||||
TDeckProHeldMap[key_index] = true;
|
||||
modifierFlag |= keyToModifierFlag(key_index);
|
||||
pressedKeysCount++;
|
||||
|
||||
uint8_t key_modifier = keyToModifierFlag(key_index);
|
||||
if (key_modifier && pressedKeysCount == 1) {
|
||||
onlyOneModifierPressed = true;
|
||||
} else {
|
||||
onlyOneModifierPressed = false;
|
||||
}
|
||||
modifierFlag |= key_modifier;
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::released(uint8_t key)
|
||||
@ -111,15 +119,27 @@ void TDeckProKeyboard::released(uint8_t key)
|
||||
return;
|
||||
}
|
||||
|
||||
TDeckProHeldMap[key_index] = false;
|
||||
modifierFlag &= ~keyToModifierFlag(key_index);
|
||||
|
||||
if (TDeckProTapMap[key_index][modifierFlag % TDeckProTapMod[key_index]] == Key::BL_TOGGLE) {
|
||||
toggleBacklight();
|
||||
return;
|
||||
} else {
|
||||
queueEvent(TDeckProTapMap[key_index][modifierFlag % TDeckProTapMod[key_index]]);
|
||||
}
|
||||
|
||||
queueEvent(TDeckProTapMap[key_index][modifierFlag % TDeckProTapMod[key_index]]);
|
||||
TDeckProHeldMap[key_index] = false;
|
||||
pressedKeysCount--;
|
||||
|
||||
if (onlyOneModifierPressed) {
|
||||
onlyOneModifierPressed = false;
|
||||
if (persistedPreviousModifier) {
|
||||
modifierFlag = 0;
|
||||
}
|
||||
persistedPreviousModifier = !persistedPreviousModifier;
|
||||
} else if (persistedPreviousModifier && pressedKeysCount == 0) {
|
||||
modifierFlag = 0;
|
||||
persistedPreviousModifier = false;
|
||||
} else {
|
||||
modifierFlag &= ~keyToModifierFlag(key_index);
|
||||
}
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::setBacklight(bool on)
|
||||
|
||||
@ -18,4 +18,7 @@ class TDeckProKeyboard : public TCA8418KeyboardBase
|
||||
|
||||
private:
|
||||
uint8_t modifierFlag; // Flag to indicate if a modifier key is pressed
|
||||
uint8_t pressedKeysCount;
|
||||
bool onlyOneModifierPressed;
|
||||
bool persistedPreviousModifier;
|
||||
};
|
||||
|
||||
@ -67,7 +67,7 @@ static const uint8_t TLoraPagerTapMap[_TCA8418_NUM_KEYS][3] = {
|
||||
static bool TLoraPagerHeldMap[_TCA8418_NUM_KEYS] = {};
|
||||
|
||||
TLoraPagerKeyboard::TLoraPagerKeyboard()
|
||||
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0)
|
||||
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), pressedKeysCount(0), onlyOneModifierPressed(false), persistedPreviousModifier(false)
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
ledcAttach(KB_BL_PIN, LEDC_BACKLIGHT_FREQ, LEDC_BACKLIGHT_BIT_WIDTH);
|
||||
@ -121,7 +121,15 @@ void TLoraPagerKeyboard::pressed(uint8_t key)
|
||||
}
|
||||
|
||||
TLoraPagerHeldMap[key_index] = true;
|
||||
modifierFlag |= keyToModifierFlag(key_index);
|
||||
pressedKeysCount++;
|
||||
|
||||
uint8_t key_modifier = keyToModifierFlag(key_index);
|
||||
if (key_modifier && pressedKeysCount == 1) {
|
||||
onlyOneModifierPressed = true;
|
||||
} else {
|
||||
onlyOneModifierPressed = false;
|
||||
}
|
||||
modifierFlag |= key_modifier;
|
||||
}
|
||||
|
||||
void TLoraPagerKeyboard::released(uint8_t key)
|
||||
@ -134,15 +142,27 @@ void TLoraPagerKeyboard::released(uint8_t key)
|
||||
return;
|
||||
}
|
||||
|
||||
TLoraPagerHeldMap[key_index] = false;
|
||||
modifierFlag &= ~keyToModifierFlag(key_index);
|
||||
|
||||
if (TLoraPagerTapMap[key_index][modifierFlag % TLoraPagerTapMod[key_index]] == Key::BL_TOGGLE) {
|
||||
toggleBacklight();
|
||||
return;
|
||||
} else {
|
||||
queueEvent(TLoraPagerTapMap[key_index][modifierFlag % TLoraPagerTapMod[key_index]]);
|
||||
}
|
||||
|
||||
queueEvent(TLoraPagerTapMap[key_index][modifierFlag % TLoraPagerTapMod[key_index]]);
|
||||
TLoraPagerHeldMap[key_index] = false;
|
||||
pressedKeysCount--;
|
||||
|
||||
if (onlyOneModifierPressed) {
|
||||
onlyOneModifierPressed = false;
|
||||
if (persistedPreviousModifier) {
|
||||
modifierFlag = 0;
|
||||
}
|
||||
persistedPreviousModifier = !persistedPreviousModifier;
|
||||
} else if (persistedPreviousModifier && pressedKeysCount == 0) {
|
||||
modifierFlag = 0;
|
||||
persistedPreviousModifier = false;
|
||||
} else {
|
||||
modifierFlag &= ~keyToModifierFlag(key_index);
|
||||
}
|
||||
}
|
||||
|
||||
void TLoraPagerKeyboard::hapticFeedback()
|
||||
|
||||
@ -20,4 +20,7 @@ class TLoraPagerKeyboard : public TCA8418KeyboardBase
|
||||
|
||||
private:
|
||||
uint8_t modifierFlag; // Flag to indicate if a modifier key is pressed
|
||||
uint8_t pressedKeysCount;
|
||||
bool onlyOneModifierPressed;
|
||||
bool persistedPreviousModifier;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user