Trunk fmt
This commit is contained in:
@@ -21,14 +21,13 @@ unsigned char KeyMap[3][4][10]= {{{'.','a','d','g','j','m','p','t','w',' '},
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name)
|
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name)
|
||||||
{
|
{
|
||||||
this->_originName = name;
|
this->_originName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SerialKeyboard::erase()
|
||||||
void SerialKeyboard::erase(){
|
{
|
||||||
InputEvent e;
|
InputEvent e;
|
||||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
|
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
|
||||||
e.kbchar = 0x08;
|
e.kbchar = 0x08;
|
||||||
@@ -36,7 +35,6 @@ void SerialKeyboard::erase(){
|
|||||||
this->notifyObservers(&e);
|
this->notifyObservers(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t SerialKeyboard::runOnce()
|
int32_t SerialKeyboard::runOnce()
|
||||||
{
|
{
|
||||||
if (!INPUTBROKER_SERIAL_TYPE) {
|
if (!INPUTBROKER_SERIAL_TYPE) {
|
||||||
@@ -79,54 +77,43 @@ int32_t SerialKeyboard::runOnce()
|
|||||||
quickPress = 0;
|
quickPress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys < prevKeys) { // a new key has been pressed (and not released), doesn't works for multiple presses at once but shouldn't be a limitation
|
if (keys < prevKeys) { // a new key has been pressed (and not released), doesn't works for multiple presses at once but
|
||||||
|
// shouldn't be a limitation
|
||||||
InputEvent e;
|
InputEvent e;
|
||||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
e.source = this->_originName;
|
e.source = this->_originName;
|
||||||
// SELECT OR SEND OR CANCEL EVENT
|
// SELECT OR SEND OR CANCEL EVENT
|
||||||
if (!(shiftRegister2 & (1 << 3))) {
|
if (!(shiftRegister2 & (1 << 3))) {
|
||||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||||
}
|
} else if (!(shiftRegister2 & (1 << 2))) {
|
||||||
else if (!(shiftRegister2 & (1 << 2))) {
|
|
||||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||||
e.kbchar = 0xb7;
|
e.kbchar = 0xb7;
|
||||||
}
|
} else if (!(shiftRegister2 & (1 << 1))) {
|
||||||
else if (!(shiftRegister2 & (1 << 1))) {
|
|
||||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||||
}
|
} else if (!(shiftRegister2 & (1 << 0))) {
|
||||||
else if (!(shiftRegister2 & (1 << 0))) {
|
|
||||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
|
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEXT INPUT EVENT
|
// TEXT INPUT EVENT
|
||||||
else if (!(shiftRegister1 & (1 << 4))) {
|
else if (!(shiftRegister1 & (1 << 4))) {
|
||||||
keyPressed = 0;
|
keyPressed = 0;
|
||||||
}
|
} else if (!(shiftRegister1 & (1 << 3))) {
|
||||||
else if (!(shiftRegister1 & (1 << 3))) {
|
|
||||||
keyPressed = 1;
|
keyPressed = 1;
|
||||||
}
|
} else if (!(shiftRegister2 & (1 << 4))) {
|
||||||
else if (!(shiftRegister2 & (1 << 4))) {
|
|
||||||
keyPressed = 2;
|
keyPressed = 2;
|
||||||
}
|
} else if (!(shiftRegister1 & (1 << 5))) {
|
||||||
else if (!(shiftRegister1 & (1 << 5))) {
|
|
||||||
keyPressed = 3;
|
keyPressed = 3;
|
||||||
}
|
} else if (!(shiftRegister1 & (1 << 2))) {
|
||||||
else if (!(shiftRegister1 & (1 << 2))) {
|
|
||||||
keyPressed = 4;
|
keyPressed = 4;
|
||||||
}
|
} else if (!(shiftRegister2 & (1 << 5))) {
|
||||||
else if (!(shiftRegister2 & (1 << 5))) {
|
|
||||||
keyPressed = 5;
|
keyPressed = 5;
|
||||||
}
|
} else if (!(shiftRegister1 & (1 << 6))) {
|
||||||
else if (!(shiftRegister1 & (1 << 6))) {
|
|
||||||
keyPressed = 6;
|
keyPressed = 6;
|
||||||
}
|
} else if (!(shiftRegister1 & (1 << 1))) {
|
||||||
else if (!(shiftRegister1 & (1 << 1))) {
|
|
||||||
keyPressed = 7;
|
keyPressed = 7;
|
||||||
}
|
} else if (!(shiftRegister2 & (1 << 6))) {
|
||||||
else if (!(shiftRegister2 & (1 << 6))) {
|
|
||||||
keyPressed = 8;
|
keyPressed = 8;
|
||||||
}
|
} else if (!(shiftRegister1 & (1 << 0))) {
|
||||||
else if (!(shiftRegister1 & (1 << 0))) {
|
|
||||||
keyPressed = 9;
|
keyPressed = 9;
|
||||||
}
|
}
|
||||||
// BACKSPACE or TAB
|
// BACKSPACE or TAB
|
||||||
@@ -144,7 +131,6 @@ int32_t SerialKeyboard::runOnce()
|
|||||||
keyPressed = 10;
|
keyPressed = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (keyPressed < 11) {
|
if (keyPressed < 11) {
|
||||||
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
|
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
|
||||||
quickPress += 1;
|
quickPress += 1;
|
||||||
@@ -161,8 +147,7 @@ int32_t SerialKeyboard::runOnce()
|
|||||||
}
|
}
|
||||||
e.inputEvent = ANYKEY;
|
e.inputEvent = ANYKEY;
|
||||||
e.kbchar = char(KeyMap[shift][quickPress][keyPressed]);
|
e.kbchar = char(KeyMap[shift][quickPress][keyPressed]);
|
||||||
}
|
} else { // then it's shift
|
||||||
else { //then it's shift
|
|
||||||
shift += 1;
|
shift += 1;
|
||||||
if (shift > 2) {
|
if (shift > 2) {
|
||||||
shift = 0;
|
shift = 0;
|
||||||
@@ -178,10 +163,8 @@ int32_t SerialKeyboard::runOnce()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevKeys = keys;
|
prevKeys = keys;
|
||||||
|
|
||||||
}
|
}
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // INPUTBROKER_SERIAL_TYPE
|
#endif // INPUTBROKER_SERIAL_TYPE
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "configuration.h"
|
|
||||||
#include "InputBroker.h"
|
|
||||||
#include "SerialKeyboardImpl.h"
|
#include "SerialKeyboardImpl.h"
|
||||||
|
#include "InputBroker.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
#ifdef INPUTBROKER_SERIAL_TYPE
|
#ifdef INPUTBROKER_SERIAL_TYPE
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||||
#include "input/InputBroker.h"
|
#include "input/InputBroker.h"
|
||||||
#include "input/RotaryEncoderInterruptImpl1.h"
|
#include "input/RotaryEncoderInterruptImpl1.h"
|
||||||
|
#include "input/SerialKeyboardImpl.h"
|
||||||
#include "input/TrackballInterruptImpl1.h"
|
#include "input/TrackballInterruptImpl1.h"
|
||||||
#include "input/UpDownInterruptImpl1.h"
|
#include "input/UpDownInterruptImpl1.h"
|
||||||
#include "input/cardKbI2cImpl.h"
|
#include "input/cardKbI2cImpl.h"
|
||||||
#include "input/kbMatrixImpl.h"
|
#include "input/kbMatrixImpl.h"
|
||||||
#include "input/SerialKeyboardImpl.h"
|
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_ADMIN
|
#if !MESHTASTIC_EXCLUDE_ADMIN
|
||||||
#include "modules/AdminModule.h"
|
#include "modules/AdminModule.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user