summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2023-01-11 16:40:47 +0000
committerIan C <ianc@noddybox.co.uk>2023-01-11 16:40:47 +0000
commit61ee8852d771cbb735366757e24130803c8d9762 (patch)
tree61f9c9535cd49157f36fcab98e199ee055a3405e /source
parentc257263f3b0e22be70f537264ea33af107c8547a (diff)
Updated input routine to use symbol shift for special chars.
Diffstat (limited to 'source')
-rw-r--r--source/gui.c89
-rw-r--r--source/keyboard.c8
2 files changed, 76 insertions, 21 deletions
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;
}
diff --git a/source/keyboard.c b/source/keyboard.c
index 9562bfa..c8adbdd 100644
--- a/source/keyboard.c
+++ b/source/keyboard.c
@@ -93,7 +93,7 @@ static const char *keynames[]=
"A", "S", "D", "F", "G",
"H", "J", "K", "L", "NEWLINE",
"SHIFT", "Z", "X", "C", "V",
- "B", "N", "M", "PERIOD", "SPACE",
+ "B", "N", "M", "SYMBOL SHIFT", "SPACE",
"ABOUT",
"CONFIG",
@@ -372,6 +372,12 @@ const char *SK_KeyName(SoftKey k)
}
+int SK_KeyPressed(SoftKey key)
+{
+ return key_state[key].state;
+}
+
+
void SK_SaveSnapshot(FILE *fp)
{
int f;