From 61ee8852d771cbb735366757e24130803c8d9762 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 11 Jan 2023 16:40:47 +0000 Subject: Updated input routine to use symbol shift for special chars. --- source/gui.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 20 deletions(-) (limited to 'source/gui.c') diff --git a/source/gui.c b/source/gui.c index 57acbe0..06ca16b 100644 --- a/source/gui.c +++ b/source/gui.c @@ -836,7 +836,7 @@ int GUI_InputName(const char *prompt, const char *ext, char name[], int maxlen) FB_Print(&upper, "PRESS ENTER TO ACCEPT", 0, 32, COL_BLACK, COL_TRANSPARENT); - FB_Print(&upper, "PRESS SYMBOL SHIFT TO BACKSPACE", 0, 40, + FB_Print(&upper, "PRESS CAPS SHIFT TO BACKSPACE", 0, 40, COL_BLACK, COL_TRANSPARENT); FB_Print(&upper, "PRESS SPACE/BREAK TO CANCEL", 0, 48, COL_BLACK, COL_TRANSPARENT); @@ -855,7 +855,7 @@ int GUI_InputName(const char *prompt, const char *ext, char name[], int maxlen) switch(ev.key) { - case SK_SYMBOL: + case SK_SHIFT: if (l) { name[--l] = 0; @@ -913,28 +913,57 @@ int GUI_Input(const char *prompt, char text[], int maxlen) { SoftKey key; int ascii; + int shift; } keymap[] = { - {SK_1, '1'}, {SK_2, '2'}, {SK_3, '3'}, {SK_4, '4'}, {SK_5, '5'}, - {SK_6, '6'}, {SK_7, '7'}, {SK_8, '8'}, {SK_9, '9'}, {SK_0, '0'}, - {SK_A, 'A'}, {SK_B, 'B'}, {SK_C, 'C'}, {SK_D, 'D'}, {SK_E, 'E'}, - {SK_F, 'F'}, {SK_G, 'G'}, {SK_H, 'H'}, {SK_I, 'I'}, {SK_J, 'J'}, - {SK_K, 'K'}, {SK_L, 'L'}, {SK_M, 'M'}, {SK_N, 'N'}, {SK_O, 'O'}, - {SK_P, 'P'}, {SK_Q, 'Q'}, {SK_R, 'R'}, {SK_S, 'S'}, {SK_T, 'T'}, - {SK_U, 'U'}, {SK_V, 'V'}, {SK_W, 'W'}, {SK_X, 'X'}, {SK_Y, 'Y'}, - {SK_Z, 'Z'}, {SK_SHIFT, '.'}, - {0, 0} + {SK_1, '1', '!'}, + {SK_2, '2', '@'}, + {SK_3, '3', '#'}, + {SK_4, '4', '$'}, + {SK_5, '5', '%'}, + {SK_6, '6', '&'}, + {SK_7, '7', '\''}, + {SK_8, '8', '('}, + {SK_9, '9', ')'}, + {SK_0, '0', '_'}, + {SK_A, 'A', '~'}, + {SK_B, 'B', '*'}, + {SK_C, 'C', '?'}, + {SK_D, 'D', '\\'}, + {SK_E, 'E', 0}, + {SK_F, 'F', '{'}, + {SK_G, 'G', '}'}, + {SK_H, 'H', '^'}, + {SK_I, 'I', 0}, + {SK_J, 'J', '-'}, + {SK_K, 'K', '+'}, + {SK_L, 'L', '='}, + {SK_M, 'M', '.'}, + {SK_N, 'N', ','}, + {SK_O, 'O', ';'}, + {SK_P, 'P', '"'}, + {SK_Q, 'Q', 0}, + {SK_R, 'R', '<'}, + {SK_S, 'S', '|'}, + {SK_T, 'T', '>'}, + {SK_U, 'U', ']'}, + {SK_V, 'V', '/'}, + {SK_W, 'W', 0}, + {SK_X, 'X', 0}, + {SK_Y, 'Y', '['}, + {SK_Z, 'Z', ':'}, + {0, 0, 0} }; SoftKeyEvent ev; int done = FALSE; int accept = FALSE; + int shifted; Framebuffer upper; text[0] = 0; - + shifted = SK_KeyPressed(SK_SYMBOL); SK_SetSticky(SK_SHIFT, FALSE); - SK_SetSticky(SK_SYMBOL, FALSE); while(!done) { @@ -949,17 +978,27 @@ int GUI_Input(const char *prompt, char text[], int maxlen) FB_Print(&upper, "PRESS ENTER TO ACCEPT", 0, 32, COL_BLACK, COL_TRANSPARENT); - FB_Print(&upper, "PRESS SYMBOL SHIFT TO BACKSPACE", 0, 40, + FB_Print(&upper, "PRESS CAPS SHIFT TO BACKSPACE", 0, 40, COL_BLACK, COL_TRANSPARENT); - FB_Print(&upper, "PRESS CAPS SHIFT FOR PERIOD", 0, 48, - COL_BLACK, COL_TRANSPARENT); - FB_Print(&upper, "PRESS SPACE/BREAK TO CANCEL", 0, 56, + FB_Print(&upper, "PRESS SPACE/BREAK TO CANCEL", 0, 48, COL_BLACK, COL_TRANSPARENT); FB_EndFrame(); while(SK_GetBareEvent(&ev)) { + if (ev.pressed) + { + switch(ev.key) + { + case SK_SYMBOL: + shifted = TRUE; + break; + default: + break; + } + } + if (!ev.pressed) { size_t l; @@ -970,13 +1009,17 @@ int GUI_Input(const char *prompt, char text[], int maxlen) switch(ev.key) { - case SK_SYMBOL: + case SK_SHIFT: if (l) { text[--l] = 0; } break; + case SK_SYMBOL: + shifted = FALSE; + break; + case SK_SPACE: done = TRUE; accept = FALSE; @@ -997,7 +1040,14 @@ int GUI_Input(const char *prompt, char text[], int maxlen) { if (ev.key == keymap[f].key) { - ascii = keymap[f].ascii; + if (shifted) + { + ascii = keymap[f].shift; + } + else + { + ascii = keymap[f].ascii; + } } f++; @@ -1016,7 +1066,6 @@ int GUI_Input(const char *prompt, char text[], int maxlen) } SK_SetSticky(SK_SHIFT,DSSPEC_Config[DSSPEC_STICKY_SHIFT]); - SK_SetSticky(SK_SYMBOL,DSSPEC_Config[DSSPEC_STICKY_SHIFT]); return accept; } -- cgit v1.2.3