From 3d117efae11ff358ce31154dbdf11e63918e5546 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 6 Jun 2016 19:08:46 +0200 Subject: [PATCH] [Horus] Crash when renaming model category --- radio/src/gui/horus/menu_model.cpp | 40 ++++++++++++------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/radio/src/gui/horus/menu_model.cpp b/radio/src/gui/horus/menu_model.cpp index 3a2678a6a..3f6ed94dc 100644 --- a/radio/src/gui/horus/menu_model.cpp +++ b/radio/src/gui/horus/menu_model.cpp @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" extern uint8_t s_curveChan; @@ -64,16 +64,14 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint if (active) { if (s_editMode > 0) { int8_t c = name[editNameCursorPos]; + if (!(flags & ZCHAR)) { + c = char2idx(c); + } int8_t v = c; if (event==EVT_ROTARY_RIGHT || event==EVT_ROTARY_LEFT) { - if (flags & ZCHAR) { - v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0); - if (c <= 0) v = -v; - } - else { - v = checkIncDec(event, abs(v), '0', 'z', 0); - } + v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0); + if (c <= 0) v = -v; } switch (event) { @@ -97,7 +95,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint break; case EVT_KEY_LONG(KEY_ENTER): - if (v == ((flags & ZCHAR) ? 0 : ' ')) { + if (v == 0) { s_editMode = 0; killEvents(event); break; @@ -106,25 +104,19 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint case EVT_KEY_LONG(KEY_LEFT): case EVT_KEY_LONG(KEY_RIGHT): - if (flags & ZCHAR) { - if (v>=-26 && v<=26) { - v = -v; // toggle case - if (event==EVT_KEY_LONG(KEY_LEFT)) - killEvents(KEY_LEFT); - } - } - else { - if (v>='A' && v<='Z') { - v = 'a'+v-'A'; // toggle case - } - else if (v>='a' && v<='z') { - v = 'A'+v-'a'; // toggle case - } + if (v>=-26 && v<=26) { + v = -v; // toggle case + if (event==EVT_KEY_LONG(KEY_LEFT)) + killEvents(KEY_LEFT); } break; } if (c != v) { + if (!(flags & ZCHAR)) { + if (v != '\0' || name[editNameCursorPos+1] != '\0') + v = idx2char(v); + } name[editNameCursorPos] = v; storageDirty(menuVerticalPositions[0] == 0 ? EE_MODEL : EE_GENERAL); }