A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add shift lock to KeyboardEntryActivity (#513)

## Summary

* **What is the goal of this PR?** (e.g., Implements the new feature for
file uploading.)
Add shift lock to KeyboardEntryActivity


https://github.com/user-attachments/assets/00973866-6b87-4d5b-a3bf-6f4f85a5e0a6

(Apologies for the graininess of the video - I was struggling to get it
below 10mb)

* **What changes are included?**
* Relax shift disable criteria to include any character
* Add third shift option `LOCK` which is not disabled on character
entry.


## Additional Context

* Add any other information that might be helpful for the reviewer
(e.g., performance implications, potential risks,
specific areas to focus on).

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_

authored by

James Whyte and committed by
GitHub
20c5d8cc d35bda80

+13 -9
+11 -8
src/activities/util/KeyboardEntryActivity.cpp
··· 14 14 const char* const KeyboardEntryActivity::keyboardShift[NUM_ROWS] = {"~!@#$%^&*()_+", "QWERTYUIOP{}|", "ASDFGHJKL:\"", 15 15 "ZXCVBNM<>?", "SPECIAL ROW"}; 16 16 17 + // Shift state strings 18 + const char* const KeyboardEntryActivity::shiftString[3] = {"shift", "SHIFT", "LOCK"}; 19 + 17 20 void KeyboardEntryActivity::taskTrampoline(void* param) { 18 21 auto* self = static_cast<KeyboardEntryActivity*>(param); 19 22 self->displayTaskLoop(); ··· 81 84 } 82 85 83 86 char KeyboardEntryActivity::getSelectedChar() const { 84 - const char* const* layout = shiftActive ? keyboardShift : keyboard; 87 + const char* const* layout = shiftState ? keyboardShift : keyboard; 85 88 86 89 if (selectedRow < 0 || selectedRow >= NUM_ROWS) return '\0'; 87 90 if (selectedCol < 0 || selectedCol >= getRowLength(selectedRow)) return '\0'; ··· 93 96 // Handle special row (bottom row with shift, space, backspace, done) 94 97 if (selectedRow == SPECIAL_ROW) { 95 98 if (selectedCol >= SHIFT_COL && selectedCol < SPACE_COL) { 96 - // Shift toggle 97 - shiftActive = !shiftActive; 99 + // Shift toggle (0 = lower case, 1 = upper case, 2 = shift lock) 100 + shiftState = (shiftState + 1) % 3; 98 101 return; 99 102 } 100 103 ··· 131 134 132 135 if (maxLength == 0 || text.length() < maxLength) { 133 136 text += c; 134 - // Auto-disable shift after typing a letter 135 - if (shiftActive && ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))) { 136 - shiftActive = false; 137 + // Auto-disable shift after typing a character in non-lock mode 138 + if (shiftState == 1) { 139 + shiftState = 0; 137 140 } 138 141 } 139 142 } ··· 298 301 constexpr int keyHeight = 18; 299 302 constexpr int keySpacing = 3; 300 303 301 - const char* const* layout = shiftActive ? keyboardShift : keyboard; 304 + const char* const* layout = shiftState ? keyboardShift : keyboard; 302 305 303 306 // Calculate left margin to center the longest row (13 keys) 304 307 constexpr int maxRowWidth = KEYS_PER_ROW * (keyWidth + keySpacing); ··· 319 322 320 323 // SHIFT key (logical col 0, spans 2 key widths) 321 324 const bool shiftSelected = (selectedRow == 4 && selectedCol >= SHIFT_COL && selectedCol < SPACE_COL); 322 - renderItemWithSelector(currentX + 2, rowY, shiftActive ? "SHIFT" : "shift", shiftSelected); 325 + renderItemWithSelector(currentX + 2, rowY, shiftString[shiftState], shiftSelected); 323 326 currentX += 2 * (keyWidth + keySpacing); 324 327 325 328 // Space bar (logical cols 2-6, spans 5 key widths)
+2 -1
src/activities/util/KeyboardEntryActivity.h
··· 70 70 // Keyboard state 71 71 int selectedRow = 0; 72 72 int selectedCol = 0; 73 - bool shiftActive = false; 73 + int shiftState = 0; // 0 = lower case, 1 = upper case, 2 = shift lock) 74 74 75 75 // Callbacks 76 76 OnCompleteCallback onComplete; ··· 81 81 static constexpr int KEYS_PER_ROW = 13; // Max keys per row (rows 0 and 1 have 13 keys) 82 82 static const char* const keyboard[NUM_ROWS]; 83 83 static const char* const keyboardShift[NUM_ROWS]; 84 + static const char* const shiftString[3]; 84 85 85 86 // Special key positions (bottom row) 86 87 static constexpr int SPECIAL_ROW = 4;