[console] Generalise bios_keymap() as key_remap()

Allow the keyboard remapping functionality to be exposed to consoles
other than the BIOS console.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2022-02-09 15:54:39 +00:00
parent 64113751c3
commit f51a62bc3f
3 changed files with 55 additions and 17 deletions

View File

@@ -339,22 +339,6 @@ static const char * bios_ansi_seq ( unsigned int scancode ) {
return NULL;
}
/**
* Map a key
*
* @v character Character read from console
* @ret character Mapped character
*/
static int bios_keymap ( unsigned int character ) {
struct key_mapping *mapping;
for_each_table_entry ( mapping, KEYMAP ) {
if ( mapping->from == character )
return mapping->to;
}
return character;
}
/**
* Get character from BIOS console
*
@@ -387,7 +371,7 @@ static int bios_getchar ( void ) {
/* If it's a normal character, just map and return it */
if ( character && ( character < 0x80 ) )
return bios_keymap ( character );
return key_remap ( character );
/* Otherwise, check for a special key that we know about */
if ( ( ansi_seq = bios_ansi_seq ( keypress >> 8 ) ) ) {