mirror of https://github.com/ipxe/ipxe.git
[usb] Handle upper/lower case and Ctrl-<key> after applying remapping
Some keyboard layouts (e.g. "fr") swap letter and punctuation keys. Apply the logic for upper and lower case and for Ctrl-<key> only after applying remapping, in order to handle these layouts correctly. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/576/head
parent
468980db2b
commit
eb92ba0a4f
|
@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ipxe/console.h>
|
#include <ipxe/console.h>
|
||||||
|
@ -70,12 +71,6 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
||||||
} else if ( keycode <= USBKBD_KEY_Z ) {
|
} else if ( keycode <= USBKBD_KEY_Z ) {
|
||||||
/* Alphabetic keys */
|
/* Alphabetic keys */
|
||||||
key = ( keycode - USBKBD_KEY_A + 'a' );
|
key = ( keycode - USBKBD_KEY_A + 'a' );
|
||||||
if ( modifiers & USBKBD_CTRL ) {
|
|
||||||
key -= ( 'a' - CTRL_A );
|
|
||||||
} else if ( ( modifiers & USBKBD_SHIFT ) ||
|
|
||||||
( leds & USBKBD_LED_CAPS_LOCK ) ) {
|
|
||||||
key -= ( 'a' - 'A' );
|
|
||||||
}
|
|
||||||
} else if ( keycode <= USBKBD_KEY_0 ) {
|
} else if ( keycode <= USBKBD_KEY_0 ) {
|
||||||
/* Numeric key row */
|
/* Numeric key row */
|
||||||
if ( modifiers & USBKBD_SHIFT ) {
|
if ( modifiers & USBKBD_SHIFT ) {
|
||||||
|
@ -127,6 +122,16 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
||||||
if ( keycode < USBKBD_KEY_CAPS_LOCK )
|
if ( keycode < USBKBD_KEY_CAPS_LOCK )
|
||||||
key = key_remap ( key );
|
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' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue