diff options
Diffstat (limited to 'apps/recorder/keyboard.c')
-rw-r--r-- | apps/recorder/keyboard.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 736e9738c8..26ac6c1ae7 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c | |||
@@ -951,8 +951,8 @@ static void kbd_draw_picker(struct keyboard_parameters *pm, | |||
951 | #ifdef HAVE_MORSE_INPUT | 951 | #ifdef HAVE_MORSE_INPUT |
952 | if (state->morse_mode) | 952 | if (state->morse_mode) |
953 | { | 953 | { |
954 | const int w = 6, h = 8; /* sysfixed font width, height */ | 954 | const int w = 6, h = 9; /* sysfixed font width, height */ |
955 | int i, j, x, y; | 955 | int i, iNext, j, x, y; |
956 | int sc_w = vp->width, sc_h = vp->height;//pm->main_y - pm->keyboard_margin - 1; | 956 | int sc_w = vp->width, sc_h = vp->height;//pm->main_y - pm->keyboard_margin - 1; |
957 | 957 | ||
958 | /* Draw morse code screen with sysfont */ | 958 | /* Draw morse code screen with sysfont */ |
@@ -960,37 +960,47 @@ static void kbd_draw_picker(struct keyboard_parameters *pm, | |||
960 | x = 0; | 960 | x = 0; |
961 | y = 0; | 961 | y = 0; |
962 | outline[1] = '\0'; | 962 | outline[1] = '\0'; |
963 | 963 | ||
964 | /* Draw morse code table with code descriptions. */ | 964 | /* Draw morse code table with code descriptions. */ |
965 | for (i = 0; morse_alphabets[i] != '\0'; i++) | 965 | for (i = 0; morse_alphabets[i] != '\0'; i++) { |
966 | { | ||
967 | int morse_code; | 966 | int morse_code; |
968 | |||
969 | outline[0] = morse_alphabets[i]; | 967 | outline[0] = morse_alphabets[i]; |
970 | sc->putsxy(x, y, outline); | 968 | sc->putsxy(x, y, outline); |
971 | |||
972 | morse_code = morse_codes[i]; | 969 | morse_code = morse_codes[i]; |
973 | for (j = 0; morse_code > 0x01; morse_code >>= 1) | 970 | for (j = 0; morse_code > 0x01; morse_code >>= 1) { |
974 | j++; | 971 | j++; |
975 | 972 | } | |
976 | x += w + 3 + j*4; | 973 | x += w + 3 + j * 4; |
977 | morse_code = morse_codes[i]; | 974 | morse_code = morse_codes[i]; |
978 | for (; morse_code > 0x01; morse_code >>= 1) | 975 | for (; morse_code > 0x01; morse_code >>= 1) { |
979 | { | ||
980 | x -= 4; | 976 | x -= 4; |
981 | if (morse_code & 0x01) | 977 | if (morse_code & 0x01) { |
982 | sc->fillrect(x, y + 2, 3, 4); | 978 | sc->fillrect(x, y + 2, 3, 4); |
983 | else | 979 | } else { |
984 | sc->fillrect(x, y + 3, 1, 2); | 980 | sc->fillrect(x, y + 3, 1, 2); |
981 | } | ||
985 | } | 982 | } |
986 | 983 | x += j * 4; | |
987 | x += w*5 - 3; | 984 | iNext = i + 1; |
988 | if (x + w*6 >= sc_w) | 985 | if (morse_alphabets[iNext] == '\0') { |
989 | { | 986 | break; |
987 | } | ||
988 | morse_code = morse_codes[iNext]; | ||
989 | for (j = 0; morse_code > 0x01; morse_code >>= 1) { | ||
990 | j++; | ||
991 | } | ||
992 | // If the next one will go out of line | ||
993 | bool needNewLine = x + w + 3 + j * 4 + w >= sc_w; | ||
994 | if (needNewLine) { | ||
995 | if (y + h >= sc_h) { | ||
996 | // No more height space | ||
997 | break; | ||
998 | } | ||
990 | x = 0; | 999 | x = 0; |
991 | y += h; | 1000 | y += h; |
992 | if (y + h >= sc_h) | 1001 | } else { |
993 | break; | 1002 | // Some pixels for spacing in the same line |
1003 | x += w; | ||
994 | } | 1004 | } |
995 | } | 1005 | } |
996 | } | 1006 | } |