- don't swallow keystrokes

- switch back and forth between the 2 modes.
This commit is contained in:
Thomas Göttgens 2022-09-20 14:28:42 +02:00
parent ab342ce904
commit d0ad5dd4cf
2 changed files with 9 additions and 7 deletions

View File

@ -15,14 +15,14 @@ int32_t KbI2cBase::runOnce()
// Input device is not detected. // Input device is not detected.
return INT32_MAX; return INT32_MAX;
} }
InputEvent e;
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.source = this->_originName;
Wire.requestFrom(CARDKB_ADDR, 1); Wire.requestFrom(CARDKB_ADDR, 1);
while (Wire.available()) { while (Wire.available()) {
char c = Wire.read(); char c = Wire.read();
InputEvent e;
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.source = this->_originName;
switch (c) { switch (c) {
case 0x1b: // ESC case 0x1b: // ESC
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
@ -56,10 +56,10 @@ int32_t KbI2cBase::runOnce()
e.kbchar = c; e.kbchar = c;
break; break;
} }
}
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_NONE) { if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
this->notifyObservers(&e); this->notifyObservers(&e);
} }
}
return 500; return 500;
} }

View File

@ -141,7 +141,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
if (event->inputEvent == static_cast<char>(ANYKEY)) { if (event->inputEvent == static_cast<char>(ANYKEY)) {
DEBUG_MSG("Canned message event any key pressed\n"); DEBUG_MSG("Canned message event any key pressed\n");
// when inactive, this will switch to the freetext mode // when inactive, this will switch to the freetext mode
if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) {
this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT; this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
} }
// pass the pressed key // pass the pressed key
@ -218,10 +218,12 @@ int32_t CannedMessageModule::runOnce()
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE; this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) { } else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) {
this->currentMessageIndex = getPrevIndex(); this->currentMessageIndex = getPrevIndex();
this->freetext = ""; // clear freetext
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE; this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
DEBUG_MSG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage()); DEBUG_MSG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) { } else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) {
this->currentMessageIndex = this->getNextIndex(); this->currentMessageIndex = this->getNextIndex();
this->freetext = ""; // clear freetext
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE; this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
DEBUG_MSG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage()); DEBUG_MSG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { } else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {