summaryrefslogtreecommitdiff
path: root/source/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/keyboard.c')
-rw-r--r--source/keyboard.c108
1 files changed, 71 insertions, 37 deletions
diff --git a/source/keyboard.c b/source/keyboard.c
index 8db8d34..04ae120 100644
--- a/source/keyboard.c
+++ b/source/keyboard.c
@@ -61,11 +61,11 @@ static SoftKey pad_select_key = NUM_SOFT_KEYS;
} \
} while(0)
-#define CHECK_STATE(KEYS,BIT,CODE,SHORTCUT) \
+#define CHECK_STATE(KEYS,BIT,CODE,SHORTCUT,USE_SHORTCUT) \
do \
{ \
key_state[CODE].new_state = (KEYS & BIT); \
- if (SHORTCUT != NUM_SOFT_KEYS && \
+ if (USE_SHORTCUT && SHORTCUT != NUM_SOFT_KEYS && \
!key_state[SHORTCUT].handled && (KEYS & BIT)) \
{ \
key_state[SHORTCUT].new_state = TRUE; \
@@ -73,6 +73,33 @@ static SoftKey pad_select_key = NUM_SOFT_KEYS;
} while(0)
+static const char *keynames[]=
+{
+ "1", "2", "3", "4", "5",
+ "6", "7", "8", "9", "0",
+ "Q", "W", "E", "R", "T",
+ "Y", "U", "I", "O", "P",
+ "A", "S", "D", "F", "G",
+ "H", "J", "K", "L", "NEWLINE",
+ "SHIFT", "Z", "X", "C", "V",
+ "B", "N", "M", "PERIOD", "SPACE",
+
+ "ABOUT",
+ "CONFIG",
+ "JOYPAD UP",
+ "JOYPAD DOWN",
+ "JOYPAD LEFT",
+ "JOYPAD RIGHT",
+ "A BUTTON",
+ "B BUTTON",
+ "X BUTTON",
+ "Y BUTTON",
+ "RIGHT SHOULDER BUTTON",
+ "LEFT SHOULDER BUTTON",
+ "START BUTTON",
+ "SELECT BUTTON"
+};
+
/* ---------------------------------------- PRIVATE INTERFACES
*/
static SoftKey LocatePress(const touchPosition *p)
@@ -99,19 +126,7 @@ static SoftKey LocatePress(const touchPosition *p)
}
-/* ---------------------------------------- PUBLIC INTERFACES
-*/
-void SK_DisplayKeyboard(uint16 *vram)
-{
- sImage img;
-
- loadPCX(keyb_bin,&img);
- image8to16(&img);
- dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
-}
-
-
-int SK_GetEvent(SoftKeyEvent *ev)
+static int GetEvent(SoftKeyEvent *ev, int map)
{
static SoftKey last = NUM_SOFT_KEYS;
static int poll_index = -1;
@@ -187,18 +202,18 @@ int SK_GetEvent(SoftKeyEvent *ev)
/* Check non soft-keyboard controls
*/
- CHECK_STATE(keys, KEY_A, SK_PAD_A, pad_A_key);
- CHECK_STATE(keys, KEY_B, SK_PAD_B, pad_B_key);
- CHECK_STATE(keys, KEY_X, SK_PAD_X, pad_X_key);
- CHECK_STATE(keys, KEY_Y, SK_PAD_Y, pad_Y_key);
- CHECK_STATE(keys, KEY_R, SK_PAD_R, pad_R_key);
- CHECK_STATE(keys, KEY_L, SK_PAD_L, pad_L_key);
- CHECK_STATE(keys, KEY_START, SK_PAD_START, pad_start_key);
- CHECK_STATE(keys, KEY_SELECT, SK_PAD_SELECT, pad_select_key);
- CHECK_STATE(keys, KEY_UP, SK_PAD_UP, pad_up_key);
- CHECK_STATE(keys, KEY_DOWN, SK_PAD_DOWN, pad_down_key);
- CHECK_STATE(keys, KEY_LEFT, SK_PAD_LEFT, pad_left_key);
- CHECK_STATE(keys, KEY_RIGHT, SK_PAD_RIGHT, pad_right_key);
+ CHECK_STATE(keys, KEY_A, SK_PAD_A, pad_A_key, map);
+ CHECK_STATE(keys, KEY_B, SK_PAD_B, pad_B_key, map);
+ CHECK_STATE(keys, KEY_X, SK_PAD_X, pad_X_key, map);
+ CHECK_STATE(keys, KEY_Y, SK_PAD_Y, pad_Y_key, map);
+ CHECK_STATE(keys, KEY_R, SK_PAD_R, pad_R_key, map);
+ CHECK_STATE(keys, KEY_L, SK_PAD_L, pad_L_key, map);
+ CHECK_STATE(keys, KEY_START, SK_PAD_START, pad_start_key, map);
+ CHECK_STATE(keys, KEY_SELECT, SK_PAD_SELECT, pad_select_key, map);
+ CHECK_STATE(keys, KEY_UP, SK_PAD_UP, pad_up_key, map);
+ CHECK_STATE(keys, KEY_DOWN, SK_PAD_DOWN, pad_down_key, map);
+ CHECK_STATE(keys, KEY_LEFT, SK_PAD_LEFT, pad_left_key, map);
+ CHECK_STATE(keys, KEY_RIGHT, SK_PAD_RIGHT, pad_right_key, map);
/* Reset key event poll index
*/
@@ -243,24 +258,37 @@ int SK_GetEvent(SoftKeyEvent *ev)
}
-void SK_SetSticky(SoftKey key, int is_sticky)
+/* ---------------------------------------- PUBLIC INTERFACES
+*/
+void SK_DisplayKeyboard(uint16 *vram)
{
- key_state[key].is_sticky = is_sticky;
+ sImage img;
- if (!is_sticky)
- {
- key_state[key].new_state = FALSE;
- }
+ loadPCX(keyb_bin,&img);
+ image8to16(&img);
+ dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
}
-void SK_ClearKeys(void)
+int SK_GetEvent(SoftKeyEvent *ev)
+{
+ return GetEvent(ev,TRUE);
+}
+
+
+int SK_GetBareEvent(SoftKeyEvent *ev)
{
- int f;
+ return GetEvent(ev,FALSE);
+}
- for(f=0; f < NUM_SOFT_KEYS; f++)
+
+void SK_SetSticky(SoftKey key, int is_sticky)
+{
+ key_state[key].is_sticky = is_sticky;
+
+ if (!is_sticky)
{
- key_state[f].state = FALSE;
+ key_state[key].new_state = FALSE;
}
}
@@ -311,3 +339,9 @@ void SK_DefinePad(SoftKey pad, SoftKey key)
}
+const char *SK_KeyName(SoftKey k)
+{
+ return keynames[k];
+}
+
+