mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-26 17:32:40 +00:00
Slight refactoring of key handling
* Adds a mapping from common ASCII to internal scancodes * Renaming for consistency
This commit is contained in:
parent
e0dbcf4afc
commit
4fb69a3196
34
src/keys.c
34
src/keys.c
@ -133,10 +133,42 @@ static int apple_iie_keymap_shift_ctrl[MAP_SIZE] =
|
||||
|
||||
static char key_pressed[ 256 ] = { 0 };
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
convert ascii character to scancode
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
static int scode_map[MAP_SIZE] =
|
||||
{ -1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */
|
||||
SCODE_BS, SCODE_TAB, -1, -1, -1, SCODE_RET, -1, -1, /* 08-15 */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, /* 16-23 */
|
||||
-1, -1, -1, SCODE_ESC, -1, -1, -1, -1, /* 24-31 */
|
||||
/* */57, /*!*/2 , /*"*/40, /*#*/4 , /*$*/5 , /*%*/6 , /*&*/8 , /*'*/40, /* 32-39 */
|
||||
/*(*/10, /*)*/11, /***/9 , /*+*/13, /*,*/51, /*-*/12, /*.*/52, /*/*/53, /* 40-47 */
|
||||
/*0*/11, /*1*/2 , /*2*/3 , /*3*/4 , /*4*/5 , /*5*/6 , /*6*/7 , /*7*/8 , /* 48-55 */
|
||||
/*8*/9 , /*9*/10, /*:*/39, /*;*/39, /*<*/51, /*=*/13, /*>*/52, /*?*/53, /* 56-63 */
|
||||
/*@*/3 , /*A*/30, /*B*/48, /*C*/46, /*D*/32, /*E*/18, /*F*/33, /*G*/34, /* 64-71 */
|
||||
/*H*/35, /*I*/23, /*J*/36, /*K*/37, /*L*/38, /*M*/50, /*N*/49, /*O*/24, /* 72-79 */
|
||||
/*P*/25, /*Q*/16, /*R*/19, /*S*/31, /*T*/20, /*U*/22, /*V*/47, /*W*/17, /* 80-87 */
|
||||
/*X*/45, /*Y*/21, /*Z*/44, /*[*/26, /*\*/43, /*]*/27, /*^*/7 , /*_*/12, /* 88-95 */
|
||||
/*`*/41, /*a*/30, /*b*/48, /*c*/46, /*d*/32, /*e*/18, /*f*/33, /*g*/34, /* 96-103 */
|
||||
/*h*/35, /*i*/23, /*j*/36, /*k*/37, /*l*/38, /*m*/50, /*n*/49, /*o*/24, /* 104-111 */
|
||||
/*p*/25, /*q*/16, /*r*/19, /*s*/31, /*t*/20, /*u*/22, /*v*/47, /*w*/17, /* 112-119 */
|
||||
/*x*/45, /*y*/21, /*z*/44, /*{*/26, /*|*/43, /*}*/27, /*~*/41, SCODE_DEL }; /* 120-127 */
|
||||
|
||||
int c_keys_ascii_to_scancode(int c)
|
||||
{
|
||||
return scode_map[c&0x7f];
|
||||
}
|
||||
|
||||
int c_keys_is_shifted()
|
||||
{
|
||||
return key_pressed[SCODE_L_SHIFT] || key_pressed[SCODE_R_SHIFT];
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
void c_handle_input() : Handle input : keys and joystick.
|
||||
------------------------------------------------------------------------- */
|
||||
void c_handle_input(int scancode, int pressed)
|
||||
void c_keys_handle_input(int scancode, int pressed)
|
||||
{
|
||||
int *keymap = NULL;
|
||||
|
||||
|
@ -152,5 +152,8 @@ int c_mygetch(int block);
|
||||
int c_rawkey();
|
||||
void c_keys_set_key(int key);
|
||||
bool c_keys_is_interface_key(int key);
|
||||
int c_keys_is_shifted();
|
||||
int c_keys_ascii_to_scancode(int ch);
|
||||
void c_keys_handle_input(int scancode, int pressed);
|
||||
|
||||
#endif
|
||||
|
@ -603,7 +603,7 @@ void video_sync(int block) {
|
||||
break;
|
||||
}
|
||||
|
||||
c_handle_input(scancode, pressed);
|
||||
c_keys_handle_input(scancode, pressed);
|
||||
|
||||
} while (keyevent);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user