mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
feat: hold confirm/select for caps
This commit is contained in:
parent
21277e03eb
commit
3937e949bf
@ -13,6 +13,10 @@ const char* const KeyboardEntryActivity::keyboard[NUM_ROWS] = {
|
||||
const char* const KeyboardEntryActivity::keyboardShift[NUM_ROWS] = {"~!@#$%^&*()_+", "QWERTYUIOP{}|", "ASDFGHJKL:\"",
|
||||
"ZXCVBNM<>?", "SPECIAL ROW"};
|
||||
|
||||
namespace {
|
||||
constexpr unsigned long capsMs = 1000;
|
||||
}
|
||||
|
||||
void KeyboardEntryActivity::taskTrampoline(void* param) {
|
||||
auto* self = static_cast<KeyboardEntryActivity*>(param);
|
||||
self->displayTaskLoop();
|
||||
@ -221,7 +225,12 @@ void KeyboardEntryActivity::loop() {
|
||||
}
|
||||
|
||||
// Selection
|
||||
if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) {
|
||||
if (mappedInput.isPressed(MappedInputManager::Button::Confirm) && mappedInput.getHeldTime() >= capsMs) {
|
||||
onCapsHeld();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mappedInput.wasPressed(MappedInputManager::Button::Confirm) && mappedInput.getHeldTime() < capsMs) {
|
||||
handleKeyPress();
|
||||
updateRequired = true;
|
||||
}
|
||||
@ -348,3 +357,12 @@ void KeyboardEntryActivity::renderItemWithSelector(const int x, const int y, con
|
||||
}
|
||||
renderer.drawText(UI_10_FONT_ID, x, y, item);
|
||||
}
|
||||
|
||||
void KeyboardEntryActivity::onCapsHeld() {
|
||||
waitForCapsRelease();
|
||||
shiftActive = !shiftActive;
|
||||
}
|
||||
|
||||
void KeyboardEntryActivity::waitForCapsRelease() {
|
||||
while (mappedInput.isPressed(MappedInputManager::Button::Confirm)) delay(50);
|
||||
}
|
||||
|
||||
@ -96,4 +96,7 @@ class KeyboardEntryActivity : public Activity {
|
||||
int getRowLength(int row) const;
|
||||
void render() const;
|
||||
void renderItemWithSelector(int x, int y, const char* item, bool isSelected) const;
|
||||
|
||||
void onCapsHeld();
|
||||
void waitForCapsRelease();
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user