mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-30 06:31:01 +00:00
Freetext Input with CardKB Take 1 - Also removes FacesKB support, this thing is ancient.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
#include "Observer.h"
|
||||
|
||||
#define ANYKEY 0xFF
|
||||
|
||||
typedef struct _InputEvent {
|
||||
const char* source;
|
||||
char inputEvent;
|
||||
char kbchar;
|
||||
} InputEvent;
|
||||
class InputBroker :
|
||||
public Observable<const InputEvent *>
|
||||
|
||||
@@ -16,6 +16,5 @@ void CardKbI2cImpl::init()
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_MSG("registerSource\n");
|
||||
inputBroker->registerSource(this);
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "facesKbI2cImpl.h"
|
||||
#include "InputBroker.h"
|
||||
|
||||
FacesKbI2cImpl *facesKbI2cImpl;
|
||||
|
||||
FacesKbI2cImpl::FacesKbI2cImpl() :
|
||||
KbI2cBase("facesKB")
|
||||
{
|
||||
}
|
||||
|
||||
void FacesKbI2cImpl::init()
|
||||
{
|
||||
if (faceskb_found != FACESKB_ADDR)
|
||||
{
|
||||
// Input device is not detected.
|
||||
return;
|
||||
}
|
||||
|
||||
inputBroker->registerSource(this);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include "kbI2cBase.h"
|
||||
#include "main.h"
|
||||
|
||||
/**
|
||||
* @brief The idea behind this class to have static methods for the event handlers.
|
||||
* Check attachInterrupt() at RotaryEncoderInteruptBase.cpp
|
||||
* Technically you can have as many rotary encoders hardver attached
|
||||
* to your device as you wish, but you always need to have separate event
|
||||
* handlers, thus you need to have a RotaryEncoderInterrupt implementation.
|
||||
*/
|
||||
class FacesKbI2cImpl :
|
||||
public KbI2cBase
|
||||
{
|
||||
public:
|
||||
FacesKbI2cImpl();
|
||||
void init();
|
||||
};
|
||||
|
||||
extern FacesKbI2cImpl *facesKbI2cImpl;
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Wire.h>
|
||||
|
||||
extern uint8_t cardkb_found;
|
||||
extern uint8_t faceskb_found;
|
||||
|
||||
KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
|
||||
{
|
||||
@@ -12,7 +11,7 @@ KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
|
||||
|
||||
int32_t KbI2cBase::runOnce()
|
||||
{
|
||||
if ((cardkb_found != CARDKB_ADDR) && (faceskb_found != CARDKB_ADDR)){
|
||||
if (cardkb_found != CARDKB_ADDR){
|
||||
// Input device is not detected.
|
||||
return INT32_MAX;
|
||||
}
|
||||
@@ -30,6 +29,7 @@ int32_t KbI2cBase::runOnce()
|
||||
break;
|
||||
case 0x08: // Back
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
|
||||
e.kbchar = c;
|
||||
break;
|
||||
case 0xb5: // Up
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||
@@ -39,13 +39,22 @@ int32_t KbI2cBase::runOnce()
|
||||
break;
|
||||
case 0xb4: // Left
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
|
||||
e.kbchar = c;
|
||||
break;
|
||||
case 0xb7: // Right
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||
e.kbchar = c;
|
||||
break;
|
||||
case 0x0d: // Enter
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||
break;
|
||||
case 0x00: //nopress
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
break;
|
||||
default: // all other keys
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user