mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
[console] Centralise handling of key modifiers
Handle Ctrl and CapsLock key modifiers within key_remap(), to provide consistent behaviour across different console types. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -71,6 +71,9 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
||||
} else if ( keycode <= USBKBD_KEY_Z ) {
|
||||
/* Alphabetic keys */
|
||||
key = ( keycode - USBKBD_KEY_A + 'a' );
|
||||
if ( modifiers & USBKBD_SHIFT ) {
|
||||
key -= ( 'a' - 'A' );
|
||||
}
|
||||
} else if ( keycode <= USBKBD_KEY_0 ) {
|
||||
/* Numeric key row */
|
||||
if ( modifiers & USBKBD_SHIFT ) {
|
||||
@@ -125,17 +128,15 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
||||
/* Remap key if applicable */
|
||||
if ( ( keycode < USBKBD_KEY_CAPS_LOCK ) ||
|
||||
( keycode == USBKBD_KEY_NON_US ) ) {
|
||||
key = key_remap ( key );
|
||||
}
|
||||
|
||||
/* Handle upper/lower case and Ctrl-<key> */
|
||||
if ( islower ( key ) ) {
|
||||
if ( modifiers & USBKBD_CTRL ) {
|
||||
key -= ( 'a' - CTRL_A );
|
||||
} else if ( ( modifiers & USBKBD_SHIFT ) ||
|
||||
( leds & USBKBD_LED_CAPS_LOCK ) ) {
|
||||
key -= ( 'a' - 'A' );
|
||||
}
|
||||
/* Apply modifiers */
|
||||
if ( modifiers & USBKBD_CTRL )
|
||||
key |= KEYMAP_CTRL;
|
||||
if ( leds & USBKBD_LED_CAPS_LOCK )
|
||||
key |= KEYMAP_CAPSLOCK;
|
||||
|
||||
/* Remap key */
|
||||
key = key_remap ( key );
|
||||
}
|
||||
|
||||
return key;
|
||||
|
||||
Reference in New Issue
Block a user