Compilation fix

This commit is contained in:
Bertrand Songis
2019-10-05 08:21:06 +02:00
parent 701e48772b
commit 3c5cfce3b4
2 changed files with 23 additions and 12 deletions
+22 -12
View File
@@ -58,25 +58,33 @@ const uint8_t * const LBM_SPECIAL_KEYS[] = {
LBM_KEY_NUMBERS, LBM_KEY_NUMBERS,
}; };
#define KEYBOARD_SPACE "\t"
#define KEYBOARD_ENTER "\n"
#define KEYBOARD_BACKSPACE "\200"
#define KEYBOARD_SET_UPPERCASE "\201"
#define KEYBOARD_SET_LOWERCASE "\202"
#define KEYBOARD_SET_LETTERS "\203"
#define KEYBOARD_SET_NUMBERS "\204"
const char * const KEYBOARD_LOWERCASE[] = { const char * const KEYBOARD_LOWERCASE[] = {
"qwertyuiop", "qwertyuiop",
" asdfghjkl", " asdfghjkl",
"\201zxcvbnm\200", KEYBOARD_SET_UPPERCASE "zxcvbnm" KEYBOARD_BACKSPACE,
"\204\t\n" KEYBOARD_SET_NUMBERS KEYBOARD_SPACE KEYBOARD_ENTER
}; };
const char * const KEYBOARD_UPPERCASE[] = { const char * const KEYBOARD_UPPERCASE[] = {
"QWERTYUIOP", "QWERTYUIOP",
" ASDFGHJKL", " ASDFGHJKL",
"\202ZXCVBNM\200", KEYBOARD_SET_LOWERCASE "ZXCVBNM" KEYBOARD_BACKSPACE,
"\204\t\n" KEYBOARD_SET_NUMBERS KEYBOARD_SPACE KEYBOARD_ENTER
}; };
const char * const KEYBOARD_NUMBERS[] = { const char * const KEYBOARD_NUMBERS[] = {
"1234567890", "1234567890",
"_-", "_-",
" \200", " " KEYBOARD_BACKSPACE,
"\203\t\n" KEYBOARD_SET_LETTERS KEYBOARD_SPACE KEYBOARD_ENTER
}; };
const char * const * const KEYBOARD_LAYOUTS[] = { const char * const * const KEYBOARD_LAYOUTS[] = {
@@ -127,16 +135,16 @@ void TextKeyboard::paint(BitmapBuffer * dc)
coord_t y = 15 + i * 40; coord_t y = 15 + i * 40;
coord_t x = 15; coord_t x = 15;
const char * c = layout[i]; const char * c = layout[i];
while(*c) { while (*c) {
if (*c == ' ') { if (*c == ' ') {
x += 15; x += 15;
} }
else if (*c == '\t') { else if (*c == KEYBOARD_SPACE[0]) {
// spacebar // spacebar
dc->drawBitmapPattern(x, y, LBM_KEY_SPACEBAR, DEFAULT_COLOR); dc->drawBitmapPattern(x, y, LBM_KEY_SPACEBAR, DEFAULT_COLOR);
x += 135; x += 135;
} }
else if (*c == '\n') { else if (*c == KEYBOARD_ENTER[0]) {
// enter // enter
dc->drawSolidFilledRect(x, y-2, 80, 25, TEXT_DISABLE_COLOR); dc->drawSolidFilledRect(x, y-2, 80, 25, TEXT_DISABLE_COLOR);
dc->drawText(x+40, y, "ENTER", CENTERED); dc->drawText(x+40, y, "ENTER", CENTERED);
@@ -160,6 +168,8 @@ bool TextKeyboard::onTouchEnd(coord_t x, coord_t y)
if (!field) if (!field)
return false; return false;
onKeyPress();
uint8_t size = field->getMaxLength(); uint8_t size = field->getMaxLength();
char * data = field->getData(); char * data = field->getData();
@@ -167,18 +177,18 @@ bool TextKeyboard::onTouchEnd(coord_t x, coord_t y)
uint8_t row = max<coord_t>(0, y - 5) / 40; uint8_t row = max<coord_t>(0, y - 5) / 40;
const char * key = layout[row]; const char * key = layout[row];
while(*key) { while (*key) {
if (*key == ' ') { if (*key == ' ') {
x -= 15; x -= 15;
} }
else if (*key == '\t') { else if (*key == KEYBOARD_SPACE[0]) {
if (x <= 135) { if (x <= 135) {
c = ' '; c = ' ';
break; break;
} }
x -= 135; x -= 135;
} }
else if (*key == '\n') { else if (*key == KEYBOARD_ENTER[0]) {
if (x <= 80) { if (x <= 80) {
// enter // enter
disable(true); disable(true);
+1
View File
@@ -23,6 +23,7 @@
#include "keyboard_text.h" #include "keyboard_text.h"
#include "keyboard_curve.h" #include "keyboard_curve.h"
#include "theme.h" #include "theme.h"
#include "opentx.h"
PageHeader::PageHeader(Page * parent, uint8_t icon): PageHeader::PageHeader(Page * parent, uint8_t icon):
Window(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE), Window(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE),